diff mbox series

[1/5] drm/ttm: move SG flag check into ttm_bo_vm_reserve

Message ID 20200925145540.1214-1-christian.koenig@amd.com (mailing list archive)
State New, archived
Headers show
Series [1/5] drm/ttm: move SG flag check into ttm_bo_vm_reserve | expand

Commit Message

Christian König Sept. 25, 2020, 2:55 p.m. UTC
Just check earlier if a BO can be page faulted in the first place.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Dave Airlie Sept. 28, 2020, 5:28 a.m. UTC | #1
On Sat, 26 Sep 2020 at 00:55, Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> Just check earlier if a BO can be page faulted in the first place.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>

Nice work,

For the series

Reviewed-by: Dave Airlie <airlied@redhat.com>

> ---
>  drivers/gpu/drm/ttm/ttm_bo_vm.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index 98a006fc30a5..991ef132e108 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -157,6 +157,15 @@ vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,
>                         return VM_FAULT_NOPAGE;
>         }
>
> +       /*
> +        * Refuse to fault imported pages. This should be handled
> +        * (if at all) by redirecting mmap to the exporter.
> +        */
> +       if (bo->ttm && (bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) {
> +               dma_resv_unlock(bo->base.resv);
> +               return VM_FAULT_SIGBUS;
> +       }
> +
>         return 0;
>  }
>  EXPORT_SYMBOL(ttm_bo_vm_reserve);
> @@ -281,13 +290,6 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
>         vm_fault_t ret = VM_FAULT_NOPAGE;
>         unsigned long address = vmf->address;
>
> -       /*
> -        * Refuse to fault imported pages. This should be handled
> -        * (if at all) by redirecting mmap to the exporter.
> -        */
> -       if (bo->ttm && (bo->ttm->page_flags & TTM_PAGE_FLAG_SG))
> -               return VM_FAULT_SIGBUS;
> -
>         if (bdev->driver->fault_reserve_notify) {
>                 struct dma_fence *moving = dma_fence_get(bo->moving);
>
> --
> 2.17.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 98a006fc30a5..991ef132e108 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -157,6 +157,15 @@  vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo,
 			return VM_FAULT_NOPAGE;
 	}
 
+	/*
+	 * Refuse to fault imported pages. This should be handled
+	 * (if at all) by redirecting mmap to the exporter.
+	 */
+	if (bo->ttm && (bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) {
+		dma_resv_unlock(bo->base.resv);
+		return VM_FAULT_SIGBUS;
+	}
+
 	return 0;
 }
 EXPORT_SYMBOL(ttm_bo_vm_reserve);
@@ -281,13 +290,6 @@  vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 	vm_fault_t ret = VM_FAULT_NOPAGE;
 	unsigned long address = vmf->address;
 
-	/*
-	 * Refuse to fault imported pages. This should be handled
-	 * (if at all) by redirecting mmap to the exporter.
-	 */
-	if (bo->ttm && (bo->ttm->page_flags & TTM_PAGE_FLAG_SG))
-		return VM_FAULT_SIGBUS;
-
 	if (bdev->driver->fault_reserve_notify) {
 		struct dma_fence *moving = dma_fence_get(bo->moving);