aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2016-09-28 06:03:04 -0400
committerAlex Deucher <alexander.deucher@amd.com>2016-10-25 14:38:27 -0400
commitf7da30d979d4c6af4b7f4fe3094e581d8c5812d7 (patch)
tree146e1d60ebd94ec4be945449a6a399b4f5543b01 /drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
parenta7d64de659946e852cd8f2a9691a21ddbb4ebc86 (diff)
drm/amdgpu: move PT validation back into VM code v2
Saves a bunch of CPU cycles when swapping things back in and allows us to split the VM headers into a separate file. v2: rename parameters Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index d4fce326502b..5dc0158b12db 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -469,6 +469,16 @@ out:
469 return r; 469 return r;
470} 470}
471 471
472static int amdgpu_gem_va_check(void *param, struct amdgpu_bo *bo)
473{
474 unsigned domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
475
476 /* if anything is swapped out don't swap it in here,
477 just abort and wait for the next CS */
478
479 return domain == AMDGPU_GEM_DOMAIN_CPU ? -ERESTARTSYS : 0;
480}
481
472/** 482/**
473 * amdgpu_gem_va_update_vm -update the bo_va in its VM 483 * amdgpu_gem_va_update_vm -update the bo_va in its VM
474 * 484 *
@@ -479,7 +489,8 @@ out:
479 * vital here, so they are not reported back to userspace. 489 * vital here, so they are not reported back to userspace.
480 */ 490 */
481static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, 491static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
482 struct amdgpu_bo_va *bo_va, uint32_t operation) 492 struct amdgpu_bo_va *bo_va,
493 uint32_t operation)
483{ 494{
484 struct ttm_validate_buffer tv, *entry; 495 struct ttm_validate_buffer tv, *entry;
485 struct amdgpu_bo_list_entry vm_pd; 496 struct amdgpu_bo_list_entry vm_pd;
@@ -502,7 +513,6 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
502 if (r) 513 if (r)
503 goto error_print; 514 goto error_print;
504 515
505 amdgpu_vm_get_pt_bos(adev, bo_va->vm, &duplicates);
506 list_for_each_entry(entry, &list, head) { 516 list_for_each_entry(entry, &list, head) {
507 domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); 517 domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type);
508 /* if anything is swapped out don't swap it in here, 518 /* if anything is swapped out don't swap it in here,
@@ -510,13 +520,10 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
510 if (domain == AMDGPU_GEM_DOMAIN_CPU) 520 if (domain == AMDGPU_GEM_DOMAIN_CPU)
511 goto error_unreserve; 521 goto error_unreserve;
512 } 522 }
513 list_for_each_entry(entry, &duplicates, head) { 523 r = amdgpu_vm_validate_pt_bos(adev, bo_va->vm, amdgpu_gem_va_check,
514 domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); 524 NULL);
515 /* if anything is swapped out don't swap it in here, 525 if (r)
516 just abort and wait for the next CS */ 526 goto error_unreserve;
517 if (domain == AMDGPU_GEM_DOMAIN_CPU)
518 goto error_unreserve;
519 }
520 527
521 r = amdgpu_vm_update_page_directory(adev, bo_va->vm); 528 r = amdgpu_vm_update_page_directory(adev, bo_va->vm);
522 if (r) 529 if (r)
@@ -537,8 +544,6 @@ error_print:
537 DRM_ERROR("Couldn't update BO_VA (%d)\n", r); 544 DRM_ERROR("Couldn't update BO_VA (%d)\n", r);
538} 545}
539 546
540
541
542int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, 547int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
543 struct drm_file *filp) 548 struct drm_file *filp)
544{ 549{