diff options
author | Christian König <christian.koenig@amd.com> | 2017-04-12 08:24:39 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-12-06 12:48:01 -0500 |
commit | 19be5570107108fba772bc2e3a1eb22ec32fb021 (patch) | |
tree | 86b971706ea8fce92b58cac4ea73e8799564a6ef /drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |
parent | 750a25037cac56afeb48ab807ce80fa2cd518b8d (diff) |
drm/ttm: add operation ctx to ttm_bo_validate v2
Give moving a BO into place an operation context to work with.
v2: rebased
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 743875ad4404..faab662ce680 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -343,6 +343,7 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, | |||
343 | struct amdgpu_bo *bo) | 343 | struct amdgpu_bo *bo) |
344 | { | 344 | { |
345 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); | 345 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); |
346 | struct ttm_operation_ctx ctx = { true, false }; | ||
346 | u64 initial_bytes_moved, bytes_moved; | 347 | u64 initial_bytes_moved, bytes_moved; |
347 | uint32_t domain; | 348 | uint32_t domain; |
348 | int r; | 349 | int r; |
@@ -374,7 +375,7 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, | |||
374 | retry: | 375 | retry: |
375 | amdgpu_ttm_placement_from_domain(bo, domain); | 376 | amdgpu_ttm_placement_from_domain(bo, domain); |
376 | initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); | 377 | initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); |
377 | r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); | 378 | r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx); |
378 | bytes_moved = atomic64_read(&adev->num_bytes_moved) - | 379 | bytes_moved = atomic64_read(&adev->num_bytes_moved) - |
379 | initial_bytes_moved; | 380 | initial_bytes_moved; |
380 | p->bytes_moved += bytes_moved; | 381 | p->bytes_moved += bytes_moved; |
@@ -396,6 +397,7 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p, | |||
396 | struct amdgpu_bo *validated) | 397 | struct amdgpu_bo *validated) |
397 | { | 398 | { |
398 | uint32_t domain = validated->allowed_domains; | 399 | uint32_t domain = validated->allowed_domains; |
400 | struct ttm_operation_ctx ctx = { true, false }; | ||
399 | int r; | 401 | int r; |
400 | 402 | ||
401 | if (!p->evictable) | 403 | if (!p->evictable) |
@@ -437,7 +439,7 @@ static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p, | |||
437 | bo->tbo.mem.mem_type == TTM_PL_VRAM && | 439 | bo->tbo.mem.mem_type == TTM_PL_VRAM && |
438 | bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT; | 440 | bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT; |
439 | initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); | 441 | initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); |
440 | r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); | 442 | r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx); |
441 | bytes_moved = atomic64_read(&adev->num_bytes_moved) - | 443 | bytes_moved = atomic64_read(&adev->num_bytes_moved) - |
442 | initial_bytes_moved; | 444 | initial_bytes_moved; |
443 | p->bytes_moved += bytes_moved; | 445 | p->bytes_moved += bytes_moved; |
@@ -476,6 +478,7 @@ static int amdgpu_cs_validate(void *param, struct amdgpu_bo *bo) | |||
476 | static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p, | 478 | static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p, |
477 | struct list_head *validated) | 479 | struct list_head *validated) |
478 | { | 480 | { |
481 | struct ttm_operation_ctx ctx = { true, false }; | ||
479 | struct amdgpu_bo_list_entry *lobj; | 482 | struct amdgpu_bo_list_entry *lobj; |
480 | int r; | 483 | int r; |
481 | 484 | ||
@@ -493,8 +496,7 @@ static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p, | |||
493 | lobj->user_pages) { | 496 | lobj->user_pages) { |
494 | amdgpu_ttm_placement_from_domain(bo, | 497 | amdgpu_ttm_placement_from_domain(bo, |
495 | AMDGPU_GEM_DOMAIN_CPU); | 498 | AMDGPU_GEM_DOMAIN_CPU); |
496 | r = ttm_bo_validate(&bo->tbo, &bo->placement, true, | 499 | r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx); |
497 | false); | ||
498 | if (r) | 500 | if (r) |
499 | return r; | 501 | return r; |
500 | amdgpu_ttm_tt_set_user_pages(bo->tbo.ttm, | 502 | amdgpu_ttm_tt_set_user_pages(bo->tbo.ttm, |
@@ -1575,6 +1577,7 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, | |||
1575 | struct amdgpu_bo_va_mapping **map) | 1577 | struct amdgpu_bo_va_mapping **map) |
1576 | { | 1578 | { |
1577 | struct amdgpu_fpriv *fpriv = parser->filp->driver_priv; | 1579 | struct amdgpu_fpriv *fpriv = parser->filp->driver_priv; |
1580 | struct ttm_operation_ctx ctx = { false, false }; | ||
1578 | struct amdgpu_vm *vm = &fpriv->vm; | 1581 | struct amdgpu_vm *vm = &fpriv->vm; |
1579 | struct amdgpu_bo_va_mapping *mapping; | 1582 | struct amdgpu_bo_va_mapping *mapping; |
1580 | int r; | 1583 | int r; |
@@ -1595,8 +1598,7 @@ int amdgpu_cs_find_mapping(struct amdgpu_cs_parser *parser, | |||
1595 | if (!((*bo)->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)) { | 1598 | if (!((*bo)->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)) { |
1596 | (*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS; | 1599 | (*bo)->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS; |
1597 | amdgpu_ttm_placement_from_domain(*bo, (*bo)->allowed_domains); | 1600 | amdgpu_ttm_placement_from_domain(*bo, (*bo)->allowed_domains); |
1598 | r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, false, | 1601 | r = ttm_bo_validate(&(*bo)->tbo, &(*bo)->placement, &ctx); |
1599 | false); | ||
1600 | if (r) | 1602 | if (r) |
1601 | return r; | 1603 | return r; |
1602 | } | 1604 | } |