diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 21 |
2 files changed, 14 insertions, 9 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index d0fee29ebeba..eaff96afe540 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -1261,6 +1261,8 @@ struct amdgpu_cs_parser { | |||
1261 | struct amdgpu_bo_list_entry vm_pd; | 1261 | struct amdgpu_bo_list_entry vm_pd; |
1262 | struct list_head validated; | 1262 | struct list_head validated; |
1263 | struct fence *fence; | 1263 | struct fence *fence; |
1264 | uint64_t bytes_moved_threshold; | ||
1265 | uint64_t bytes_moved; | ||
1264 | 1266 | ||
1265 | struct amdgpu_ib *ibs; | 1267 | struct amdgpu_ib *ibs; |
1266 | uint32_t num_ibs; | 1268 | uint32_t num_ibs; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index b882e8175615..2f80da016d57 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -336,14 +336,14 @@ static u64 amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev) | |||
336 | return max(bytes_moved_threshold, 1024*1024ull); | 336 | return max(bytes_moved_threshold, 1024*1024ull); |
337 | } | 337 | } |
338 | 338 | ||
339 | int amdgpu_cs_list_validate(struct amdgpu_device *adev, | 339 | int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p, |
340 | struct amdgpu_vm *vm, | ||
341 | struct list_head *validated) | 340 | struct list_head *validated) |
342 | { | 341 | { |
342 | struct amdgpu_fpriv *fpriv = p->filp->driver_priv; | ||
343 | struct amdgpu_vm *vm = &fpriv->vm; | ||
343 | struct amdgpu_bo_list_entry *lobj; | 344 | struct amdgpu_bo_list_entry *lobj; |
344 | struct amdgpu_bo *bo; | 345 | struct amdgpu_bo *bo; |
345 | u64 bytes_moved = 0, initial_bytes_moved; | 346 | u64 initial_bytes_moved; |
346 | u64 bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(adev); | ||
347 | int r; | 347 | int r; |
348 | 348 | ||
349 | list_for_each_entry(lobj, validated, tv.head) { | 349 | list_for_each_entry(lobj, validated, tv.head) { |
@@ -363,16 +363,16 @@ int amdgpu_cs_list_validate(struct amdgpu_device *adev, | |||
363 | */ | 363 | */ |
364 | if ((lobj->allowed_domains & current_domain) != 0 && | 364 | if ((lobj->allowed_domains & current_domain) != 0 && |
365 | (domain & current_domain) == 0 && /* will be moved */ | 365 | (domain & current_domain) == 0 && /* will be moved */ |
366 | bytes_moved > bytes_moved_threshold) { | 366 | p->bytes_moved > p->bytes_moved_threshold) { |
367 | /* don't move it */ | 367 | /* don't move it */ |
368 | domain = current_domain; | 368 | domain = current_domain; |
369 | } | 369 | } |
370 | 370 | ||
371 | retry: | 371 | retry: |
372 | amdgpu_ttm_placement_from_domain(bo, domain); | 372 | amdgpu_ttm_placement_from_domain(bo, domain); |
373 | initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); | 373 | initial_bytes_moved = atomic64_read(&bo->adev->num_bytes_moved); |
374 | r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); | 374 | r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); |
375 | bytes_moved += atomic64_read(&adev->num_bytes_moved) - | 375 | p->bytes_moved += atomic64_read(&bo->adev->num_bytes_moved) - |
376 | initial_bytes_moved; | 376 | initial_bytes_moved; |
377 | 377 | ||
378 | if (unlikely(r)) { | 378 | if (unlikely(r)) { |
@@ -421,11 +421,14 @@ static int amdgpu_cs_parser_relocs(struct amdgpu_cs_parser *p) | |||
421 | 421 | ||
422 | amdgpu_vm_get_pt_bos(&fpriv->vm, &duplicates); | 422 | amdgpu_vm_get_pt_bos(&fpriv->vm, &duplicates); |
423 | 423 | ||
424 | r = amdgpu_cs_list_validate(p->adev, &fpriv->vm, &duplicates); | 424 | p->bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(p->adev); |
425 | p->bytes_moved = 0; | ||
426 | |||
427 | r = amdgpu_cs_list_validate(p, &duplicates); | ||
425 | if (r) | 428 | if (r) |
426 | goto error_validate; | 429 | goto error_validate; |
427 | 430 | ||
428 | r = amdgpu_cs_list_validate(p->adev, &fpriv->vm, &p->validated); | 431 | r = amdgpu_cs_list_validate(p, &p->validated); |
429 | 432 | ||
430 | error_validate: | 433 | error_validate: |
431 | if (r) { | 434 | if (r) { |