diff mbox series

[6/9] drm/qxl: stop using ttm_bo_wait

Message ID 20221125102137.1801-6-christian.koenig@amd.com (mailing list archive)
State New, archived
Headers show
Series [1/9] drm/amdgpu: generally allow over-commit during BO allocation | expand

Commit Message

Christian König Nov. 25, 2022, 10:21 a.m. UTC
TTM is just wrapping core DMA functionality here, remove the mid-layer.
No functional change.

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

Comments

Christian König Dec. 15, 2022, 2:19 p.m. UTC | #1
Am 25.11.22 um 11:21 schrieb Christian König:
> TTM is just wrapping core DMA functionality here, remove the mid-layer.
> No functional change.

Any objections to this guys?

I'm basically just following a suggestion from Daniel here and it 
already triggered a discussion about the timeout for i915.

Thanks,
Christian.

>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/qxl/qxl_cmd.c | 16 ++++++++++++++--
>   1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
> index 63aa96a69752..281edab518cd 100644
> --- a/drivers/gpu/drm/qxl/qxl_cmd.c
> +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
> @@ -579,7 +579,7 @@ void qxl_surface_evict(struct qxl_device *qdev, struct qxl_bo *surf, bool do_upd
>   
>   static int qxl_reap_surf(struct qxl_device *qdev, struct qxl_bo *surf, bool stall)
>   {
> -	int ret;
> +	long ret;
>   
>   	ret = qxl_bo_reserve(surf);
>   	if (ret)
> @@ -588,7 +588,19 @@ static int qxl_reap_surf(struct qxl_device *qdev, struct qxl_bo *surf, bool stal
>   	if (stall)
>   		mutex_unlock(&qdev->surf_evict_mutex);
>   
> -	ret = ttm_bo_wait(&surf->tbo, true, !stall);
> +	if (stall) {
> +		ret = dma_resv_wait_timeout(surf->tbo.base.resv,
> +					    DMA_RESV_USAGE_BOOKKEEP, true,
> +					    15 * HZ);
> +		if (ret > 0)
> +			ret = 0;
> +		else if (ret == 0)
> +			ret = -EBUSY;
> +	} else {
> +		ret = dma_resv_test_signaled(surf->tbo.base.resv,
> +					     DMA_RESV_USAGE_BOOKKEEP);
> +		ret = ret ? -EBUSY : 0;
> +	}
>   
>   	if (stall)
>   		mutex_lock(&qdev->surf_evict_mutex);
Dave Airlie Dec. 15, 2022, 8:09 p.m. UTC | #2
Acked-by: Dave Airlie <airlied@redhat.com>

On Fri, 16 Dec 2022 at 00:20, Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> Am 25.11.22 um 11:21 schrieb Christian König:
> > TTM is just wrapping core DMA functionality here, remove the mid-layer.
> > No functional change.
>
> Any objections to this guys?
>
> I'm basically just following a suggestion from Daniel here and it
> already triggered a discussion about the timeout for i915.
>
> Thanks,
> Christian.
>
> >
> > Signed-off-by: Christian König <christian.koenig@amd.com>
> > ---
> >   drivers/gpu/drm/qxl/qxl_cmd.c | 16 ++++++++++++++--
> >   1 file changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
> > index 63aa96a69752..281edab518cd 100644
> > --- a/drivers/gpu/drm/qxl/qxl_cmd.c
> > +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
> > @@ -579,7 +579,7 @@ void qxl_surface_evict(struct qxl_device *qdev, struct qxl_bo *surf, bool do_upd
> >
> >   static int qxl_reap_surf(struct qxl_device *qdev, struct qxl_bo *surf, bool stall)
> >   {
> > -     int ret;
> > +     long ret;
> >
> >       ret = qxl_bo_reserve(surf);
> >       if (ret)
> > @@ -588,7 +588,19 @@ static int qxl_reap_surf(struct qxl_device *qdev, struct qxl_bo *surf, bool stal
> >       if (stall)
> >               mutex_unlock(&qdev->surf_evict_mutex);
> >
> > -     ret = ttm_bo_wait(&surf->tbo, true, !stall);
> > +     if (stall) {
> > +             ret = dma_resv_wait_timeout(surf->tbo.base.resv,
> > +                                         DMA_RESV_USAGE_BOOKKEEP, true,
> > +                                         15 * HZ);
> > +             if (ret > 0)
> > +                     ret = 0;
> > +             else if (ret == 0)
> > +                     ret = -EBUSY;
> > +     } else {
> > +             ret = dma_resv_test_signaled(surf->tbo.base.resv,
> > +                                          DMA_RESV_USAGE_BOOKKEEP);
> > +             ret = ret ? -EBUSY : 0;
> > +     }
> >
> >       if (stall)
> >               mutex_lock(&qdev->surf_evict_mutex);
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
index 63aa96a69752..281edab518cd 100644
--- a/drivers/gpu/drm/qxl/qxl_cmd.c
+++ b/drivers/gpu/drm/qxl/qxl_cmd.c
@@ -579,7 +579,7 @@  void qxl_surface_evict(struct qxl_device *qdev, struct qxl_bo *surf, bool do_upd
 
 static int qxl_reap_surf(struct qxl_device *qdev, struct qxl_bo *surf, bool stall)
 {
-	int ret;
+	long ret;
 
 	ret = qxl_bo_reserve(surf);
 	if (ret)
@@ -588,7 +588,19 @@  static int qxl_reap_surf(struct qxl_device *qdev, struct qxl_bo *surf, bool stal
 	if (stall)
 		mutex_unlock(&qdev->surf_evict_mutex);
 
-	ret = ttm_bo_wait(&surf->tbo, true, !stall);
+	if (stall) {
+		ret = dma_resv_wait_timeout(surf->tbo.base.resv,
+					    DMA_RESV_USAGE_BOOKKEEP, true,
+					    15 * HZ);
+		if (ret > 0)
+			ret = 0;
+		else if (ret == 0)
+			ret = -EBUSY;
+	} else {
+		ret = dma_resv_test_signaled(surf->tbo.base.resv,
+					     DMA_RESV_USAGE_BOOKKEEP);
+		ret = ret ? -EBUSY : 0;
+	}
 
 	if (stall)
 		mutex_lock(&qdev->surf_evict_mutex);