aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2017-03-13 05:13:38 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-03-29 23:54:01 -0400
commitdc54d3d1744d23ed0b345fd8bc1c493b74e8df44 (patch)
tree7cbdaf7c7edfe9bd86329737fdd5014b747594fd /drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
parent663e4577a5733fab18d601128f54486d78595bc0 (diff)
drm/amdgpu: implement AMDGPU_VA_OP_CLEAR v2
A new VM operation to remove all mappings in a range. v2: limit unmapped area as noted by Jerry Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@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, 20 insertions, 7 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 0240f108f90e..b311b389bd5a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -507,14 +507,16 @@ static int amdgpu_gem_va_check(void *param, struct amdgpu_bo *bo)
507 * amdgpu_gem_va_update_vm -update the bo_va in its VM 507 * amdgpu_gem_va_update_vm -update the bo_va in its VM
508 * 508 *
509 * @adev: amdgpu_device pointer 509 * @adev: amdgpu_device pointer
510 * @vm: vm to update
510 * @bo_va: bo_va to update 511 * @bo_va: bo_va to update
511 * @list: validation list 512 * @list: validation list
512 * @operation: map or unmap 513 * @operation: map, unmap or clear
513 * 514 *
514 * Update the bo_va directly after setting its address. Errors are not 515 * Update the bo_va directly after setting its address. Errors are not
515 * vital here, so they are not reported back to userspace. 516 * vital here, so they are not reported back to userspace.
516 */ 517 */
517static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, 518static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
519 struct amdgpu_vm *vm,
518 struct amdgpu_bo_va *bo_va, 520 struct amdgpu_bo_va *bo_va,
519 struct list_head *list, 521 struct list_head *list,
520 uint32_t operation) 522 uint32_t operation)
@@ -529,16 +531,16 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
529 goto error; 531 goto error;
530 } 532 }
531 533
532 r = amdgpu_vm_validate_pt_bos(adev, bo_va->vm, amdgpu_gem_va_check, 534 r = amdgpu_vm_validate_pt_bos(adev, vm, amdgpu_gem_va_check,
533 NULL); 535 NULL);
534 if (r) 536 if (r)
535 goto error; 537 goto error;
536 538
537 r = amdgpu_vm_update_page_directory(adev, bo_va->vm); 539 r = amdgpu_vm_update_page_directory(adev, vm);
538 if (r) 540 if (r)
539 goto error; 541 goto error;
540 542
541 r = amdgpu_vm_clear_freed(adev, bo_va->vm); 543 r = amdgpu_vm_clear_freed(adev, vm);
542 if (r) 544 if (r)
543 goto error; 545 goto error;
544 546
@@ -592,6 +594,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
592 switch (args->operation) { 594 switch (args->operation) {
593 case AMDGPU_VA_OP_MAP: 595 case AMDGPU_VA_OP_MAP:
594 case AMDGPU_VA_OP_UNMAP: 596 case AMDGPU_VA_OP_UNMAP:
597 case AMDGPU_VA_OP_CLEAR:
595 break; 598 break;
596 default: 599 default:
597 dev_err(&dev->pdev->dev, "unsupported operation %d\n", 600 dev_err(&dev->pdev->dev, "unsupported operation %d\n",
@@ -600,7 +603,8 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
600 } 603 }
601 604
602 INIT_LIST_HEAD(&list); 605 INIT_LIST_HEAD(&list);
603 if (!(args->flags & AMDGPU_VM_PAGE_PRT)) { 606 if ((args->operation != AMDGPU_VA_OP_CLEAR) &&
607 !(args->flags & AMDGPU_VM_PAGE_PRT)) {
604 gobj = drm_gem_object_lookup(filp, args->handle); 608 gobj = drm_gem_object_lookup(filp, args->handle);
605 if (gobj == NULL) 609 if (gobj == NULL)
606 return -ENOENT; 610 return -ENOENT;
@@ -625,8 +629,10 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
625 r = -ENOENT; 629 r = -ENOENT;
626 goto error_backoff; 630 goto error_backoff;
627 } 631 }
628 } else { 632 } else if (args->operation != AMDGPU_VA_OP_CLEAR) {
629 bo_va = fpriv->prt_va; 633 bo_va = fpriv->prt_va;
634 } else {
635 bo_va = NULL;
630 } 636 }
631 637
632 switch (args->operation) { 638 switch (args->operation) {
@@ -644,11 +650,18 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
644 case AMDGPU_VA_OP_UNMAP: 650 case AMDGPU_VA_OP_UNMAP:
645 r = amdgpu_vm_bo_unmap(adev, bo_va, args->va_address); 651 r = amdgpu_vm_bo_unmap(adev, bo_va, args->va_address);
646 break; 652 break;
653
654 case AMDGPU_VA_OP_CLEAR:
655 r = amdgpu_vm_bo_clear_mappings(adev, &fpriv->vm,
656 args->va_address,
657 args->map_size);
658 break;
647 default: 659 default:
648 break; 660 break;
649 } 661 }
650 if (!r && !(args->flags & AMDGPU_VM_DELAY_UPDATE) && !amdgpu_vm_debug) 662 if (!r && !(args->flags & AMDGPU_VM_DELAY_UPDATE) && !amdgpu_vm_debug)
651 amdgpu_gem_va_update_vm(adev, bo_va, &list, args->operation); 663 amdgpu_gem_va_update_vm(adev, &fpriv->vm, bo_va, &list,
664 args->operation);
652 665
653error_backoff: 666error_backoff:
654 ttm_eu_backoff_reservation(&ticket, &list); 667 ttm_eu_backoff_reservation(&ticket, &list);