diff options
author | Christian König <christian.koenig@amd.com> | 2013-04-08 06:41:28 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2013-04-09 10:31:33 -0400 |
commit | 4474f3a91f95e3fcc62d97e36f1e8e3392c96ee0 (patch) | |
tree | 88e320164b4cd3fb2ac94b8e15f9ccf37277bd22 | |
parent | 574490401d8fd553ac4baa33ea22fa315a2b4294 (diff) |
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: Christian König <christian.koenig@amd.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_cs.c | 49 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_object.c | 8 |
3 files changed, 35 insertions, 27 deletions
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 730d3359af60..3db6b02c4263 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -358,8 +358,9 @@ struct radeon_bo_list { | |||
358 | struct ttm_validate_buffer tv; | 358 | struct ttm_validate_buffer tv; |
359 | struct radeon_bo *bo; | 359 | struct radeon_bo *bo; |
360 | uint64_t gpu_offset; | 360 | uint64_t gpu_offset; |
361 | unsigned rdomain; | 361 | bool written; |
362 | unsigned wdomain; | 362 | unsigned domain; |
363 | unsigned alt_domain; | ||
363 | u32 tiling_flags; | 364 | u32 tiling_flags; |
364 | }; | 365 | }; |
365 | 366 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index a3dd04d038fe..c9ee4c02522a 100644 --- a/drivers/gpu/drm/radeon/radeon_cs.c +++ b/drivers/gpu/drm/radeon/radeon_cs.c | |||
@@ -53,6 +53,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) | |||
53 | } | 53 | } |
54 | for (i = 0; i < p->nrelocs; i++) { | 54 | for (i = 0; i < p->nrelocs; i++) { |
55 | struct drm_radeon_cs_reloc *r; | 55 | struct drm_radeon_cs_reloc *r; |
56 | uint32_t domain; | ||
56 | 57 | ||
57 | duplicate = false; | 58 | duplicate = false; |
58 | r = (struct drm_radeon_cs_reloc *)&chunk->kdata[i*4]; | 59 | 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 | break; | 64 | break; |
64 | } | 65 | } |
65 | } | 66 | } |
66 | if (!duplicate) { | 67 | if (duplicate) { |
67 | p->relocs[i].gobj = drm_gem_object_lookup(ddev, | ||
68 | p->filp, | ||
69 | r->handle); | ||
70 | if (p->relocs[i].gobj == NULL) { | ||
71 | DRM_ERROR("gem object lookup failed 0x%x\n", | ||
72 | r->handle); | ||
73 | return -ENOENT; | ||
74 | } | ||
75 | p->relocs_ptr[i] = &p->relocs[i]; | ||
76 | p->relocs[i].robj = gem_to_radeon_bo(p->relocs[i].gobj); | ||
77 | p->relocs[i].lobj.bo = p->relocs[i].robj; | ||
78 | p->relocs[i].lobj.wdomain = r->write_domain; | ||
79 | p->relocs[i].lobj.rdomain = r->read_domains; | ||
80 | p->relocs[i].lobj.tv.bo = &p->relocs[i].robj->tbo; | ||
81 | p->relocs[i].handle = r->handle; | ||
82 | p->relocs[i].flags = r->flags; | ||
83 | radeon_bo_list_add_object(&p->relocs[i].lobj, | ||
84 | &p->validated); | ||
85 | |||
86 | } else | ||
87 | p->relocs[i].handle = 0; | 68 | p->relocs[i].handle = 0; |
69 | continue; | ||
70 | } | ||
71 | |||
72 | p->relocs[i].gobj = drm_gem_object_lookup(ddev, p->filp, | ||
73 | r->handle); | ||
74 | if (p->relocs[i].gobj == NULL) { | ||
75 | DRM_ERROR("gem object lookup failed 0x%x\n", | ||
76 | r->handle); | ||
77 | return -ENOENT; | ||
78 | } | ||
79 | p->relocs_ptr[i] = &p->relocs[i]; | ||
80 | p->relocs[i].robj = gem_to_radeon_bo(p->relocs[i].gobj); | ||
81 | p->relocs[i].lobj.bo = p->relocs[i].robj; | ||
82 | p->relocs[i].lobj.written = !!r->write_domain; | ||
83 | |||
84 | domain = r->write_domain ? r->write_domain : r->read_domains; | ||
85 | p->relocs[i].lobj.domain = domain; | ||
86 | if (domain == RADEON_GEM_DOMAIN_VRAM) | ||
87 | domain |= RADEON_GEM_DOMAIN_GTT; | ||
88 | p->relocs[i].lobj.alt_domain = domain; | ||
89 | |||
90 | p->relocs[i].lobj.tv.bo = &p->relocs[i].robj->tbo; | ||
91 | p->relocs[i].handle = r->handle; | ||
92 | |||
93 | radeon_bo_list_add_object(&p->relocs[i].lobj, | ||
94 | &p->validated); | ||
88 | } | 95 | } |
89 | return radeon_bo_list_validate(&p->validated); | 96 | return radeon_bo_list_validate(&p->validated); |
90 | } | 97 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 58e026afec17..4466477f1e7b 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c | |||
@@ -341,7 +341,7 @@ void radeon_bo_fini(struct radeon_device *rdev) | |||
341 | void radeon_bo_list_add_object(struct radeon_bo_list *lobj, | 341 | void radeon_bo_list_add_object(struct radeon_bo_list *lobj, |
342 | struct list_head *head) | 342 | struct list_head *head) |
343 | { | 343 | { |
344 | if (lobj->wdomain) { | 344 | if (lobj->written) { |
345 | list_add(&lobj->tv.head, head); | 345 | list_add(&lobj->tv.head, head); |
346 | } else { | 346 | } else { |
347 | list_add_tail(&lobj->tv.head, head); | 347 | list_add_tail(&lobj->tv.head, head); |
@@ -362,15 +362,15 @@ int radeon_bo_list_validate(struct list_head *head) | |||
362 | list_for_each_entry(lobj, head, tv.head) { | 362 | list_for_each_entry(lobj, head, tv.head) { |
363 | bo = lobj->bo; | 363 | bo = lobj->bo; |
364 | if (!bo->pin_count) { | 364 | if (!bo->pin_count) { |
365 | domain = lobj->wdomain ? lobj->wdomain : lobj->rdomain; | 365 | domain = lobj->domain; |
366 | 366 | ||
367 | retry: | 367 | retry: |
368 | radeon_ttm_placement_from_domain(bo, domain); | 368 | radeon_ttm_placement_from_domain(bo, domain); |
369 | r = ttm_bo_validate(&bo->tbo, &bo->placement, | 369 | r = ttm_bo_validate(&bo->tbo, &bo->placement, |
370 | true, false); | 370 | true, false); |
371 | if (unlikely(r)) { | 371 | if (unlikely(r)) { |
372 | if (r != -ERESTARTSYS && domain == RADEON_GEM_DOMAIN_VRAM) { | 372 | if (r != -ERESTARTSYS && domain != lobj->alt_domain) { |
373 | domain |= RADEON_GEM_DOMAIN_GTT; | 373 | domain = lobj->alt_domain; |
374 | goto retry; | 374 | goto retry; |
375 | } | 375 | } |
376 | return r; | 376 | return r; |