Commit 4474f3a9 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/radeon: rework fallback handling v2

Let the CS module decide if we can fall back to VRAM or not.

v2: remove unintended change
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarJerome Glisse <jglisse@redhat.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 57449040
...@@ -358,8 +358,9 @@ struct radeon_bo_list { ...@@ -358,8 +358,9 @@ struct radeon_bo_list {
struct ttm_validate_buffer tv; struct ttm_validate_buffer tv;
struct radeon_bo *bo; struct radeon_bo *bo;
uint64_t gpu_offset; uint64_t gpu_offset;
unsigned rdomain; bool written;
unsigned wdomain; unsigned domain;
unsigned alt_domain;
u32 tiling_flags; u32 tiling_flags;
}; };
......
...@@ -53,6 +53,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) ...@@ -53,6 +53,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
} }
for (i = 0; i < p->nrelocs; i++) { for (i = 0; i < p->nrelocs; i++) {
struct drm_radeon_cs_reloc *r; struct drm_radeon_cs_reloc *r;
uint32_t domain;
duplicate = false; duplicate = false;
r = (struct drm_radeon_cs_reloc *)&chunk->kdata[i*4]; r = (struct drm_radeon_cs_reloc *)&chunk->kdata[i*4];
...@@ -63,28 +64,34 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) ...@@ -63,28 +64,34 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
break; break;
} }
} }
if (!duplicate) { if (duplicate) {
p->relocs[i].gobj = drm_gem_object_lookup(ddev,
p->filp,
r->handle);
if (p->relocs[i].gobj == NULL) {
DRM_ERROR("gem object lookup failed 0x%x\n",
r->handle);
return -ENOENT;
}
p->relocs_ptr[i] = &p->relocs[i];
p->relocs[i].robj = gem_to_radeon_bo(p->relocs[i].gobj);
p->relocs[i].lobj.bo = p->relocs[i].robj;
p->relocs[i].lobj.wdomain = r->write_domain;
p->relocs[i].lobj.rdomain = r->read_domains;
p->relocs[i].lobj.tv.bo = &p->relocs[i].robj->tbo;
p->relocs[i].handle = r->handle;
p->relocs[i].flags = r->flags;
radeon_bo_list_add_object(&p->relocs[i].lobj,
&p->validated);
} else
p->relocs[i].handle = 0; p->relocs[i].handle = 0;
continue;
}
p->relocs[i].gobj = drm_gem_object_lookup(ddev, p->filp,
r->handle);
if (p->relocs[i].gobj == NULL) {
DRM_ERROR("gem object lookup failed 0x%x\n",
r->handle);
return -ENOENT;
}
p->relocs_ptr[i] = &p->relocs[i];
p->relocs[i].robj = gem_to_radeon_bo(p->relocs[i].gobj);
p->relocs[i].lobj.bo = p->relocs[i].robj;
p->relocs[i].lobj.written = !!r->write_domain;
domain = r->write_domain ? r->write_domain : r->read_domains;
p->relocs[i].lobj.domain = domain;
if (domain == RADEON_GEM_DOMAIN_VRAM)
domain |= RADEON_GEM_DOMAIN_GTT;
p->relocs[i].lobj.alt_domain = domain;
p->relocs[i].lobj.tv.bo = &p->relocs[i].robj->tbo;
p->relocs[i].handle = r->handle;
radeon_bo_list_add_object(&p->relocs[i].lobj,
&p->validated);
} }
return radeon_bo_list_validate(&p->validated); return radeon_bo_list_validate(&p->validated);
} }
......
...@@ -341,7 +341,7 @@ void radeon_bo_fini(struct radeon_device *rdev) ...@@ -341,7 +341,7 @@ void radeon_bo_fini(struct radeon_device *rdev)
void radeon_bo_list_add_object(struct radeon_bo_list *lobj, void radeon_bo_list_add_object(struct radeon_bo_list *lobj,
struct list_head *head) struct list_head *head)
{ {
if (lobj->wdomain) { if (lobj->written) {
list_add(&lobj->tv.head, head); list_add(&lobj->tv.head, head);
} else { } else {
list_add_tail(&lobj->tv.head, head); list_add_tail(&lobj->tv.head, head);
...@@ -362,15 +362,15 @@ int radeon_bo_list_validate(struct list_head *head) ...@@ -362,15 +362,15 @@ int radeon_bo_list_validate(struct list_head *head)
list_for_each_entry(lobj, head, tv.head) { list_for_each_entry(lobj, head, tv.head) {
bo = lobj->bo; bo = lobj->bo;
if (!bo->pin_count) { if (!bo->pin_count) {
domain = lobj->wdomain ? lobj->wdomain : lobj->rdomain; domain = lobj->domain;
retry: retry:
radeon_ttm_placement_from_domain(bo, domain); radeon_ttm_placement_from_domain(bo, domain);
r = ttm_bo_validate(&bo->tbo, &bo->placement, r = ttm_bo_validate(&bo->tbo, &bo->placement,
true, false); true, false);
if (unlikely(r)) { if (unlikely(r)) {
if (r != -ERESTARTSYS && domain == RADEON_GEM_DOMAIN_VRAM) { if (r != -ERESTARTSYS && domain != lobj->alt_domain) {
domain |= RADEON_GEM_DOMAIN_GTT; domain = lobj->alt_domain;
goto retry; goto retry;
} }
return r; return r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment