nouveau.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org,
	Tanmay Bhushan <007047221b@gmail.com>,
	Ben Skeggs <bskeggs@redhat.com>, Daniel Vetter <daniel@ffwll.ch>
Subject: Re: [Nouveau] [PATCH v3] drm/nouveau: fix incorrect conversion to dma_resv_wait_timeout()
Date: Mon, 17 Apr 2023 07:55:43 +0200	[thread overview]
Message-ID: <7b17a825-0f76-3e0f-5e56-0e689b7d7866@amd.com> (raw)
In-Reply-To: <87edolaomt.fsf@jogness.linutronix.de>

Am 15.04.23 um 04:02 schrieb John Ogness:
> Commit 41d351f29528 ("drm/nouveau: stop using ttm_bo_wait")
> converted from ttm_bo_wait_ctx() to dma_resv_wait_timeout().
> However, dma_resv_wait_timeout() returns greater than zero on
> success as opposed to ttm_bo_wait_ctx(). As a result, relocs
> will fail and log errors even when it was a success.
>
> Change the return code handling to match that of
> nouveau_gem_ioctl_cpu_prep(), which was already using
> dma_resv_wait_timeout() correctly.
>
> Fixes: 41d351f29528 ("drm/nouveau: stop using ttm_bo_wait")
> Reported-by: Tanmay Bhushan <007047221b@gmail.com>
> Link: https://lore.kernel.org/lkml/20230119225351.71657-1-007047221b@gmail.com
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   I just realized that the nouveau driver style prefers to scope
>   variables used only in loops.
>
>   v3: Define @lret within the for-loop.
>
>   drivers/gpu/drm/nouveau/nouveau_gem.c | 18 ++++++++++++------
>   1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
> index f77e44958037..ab9062e50977 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
> @@ -645,7 +645,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
>   				struct drm_nouveau_gem_pushbuf_reloc *reloc,
>   				struct drm_nouveau_gem_pushbuf_bo *bo)
>   {
> -	long ret = 0;
> +	int ret = 0;
>   	unsigned i;
>   
>   	for (i = 0; i < req->nr_relocs; i++) {
> @@ -653,6 +653,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
>   		struct drm_nouveau_gem_pushbuf_bo *b;
>   		struct nouveau_bo *nvbo;
>   		uint32_t data;
> +		long lret;
>   
>   		if (unlikely(r->bo_index >= req->nr_buffers)) {
>   			NV_PRINTK(err, cli, "reloc bo index invalid\n");
> @@ -703,13 +704,18 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
>   				data |= r->vor;
>   		}
>   
> -		ret = dma_resv_wait_timeout(nvbo->bo.base.resv,
> -					    DMA_RESV_USAGE_BOOKKEEP,
> -					    false, 15 * HZ);
> -		if (ret == 0)
> +		lret = dma_resv_wait_timeout(nvbo->bo.base.resv,
> +					     DMA_RESV_USAGE_BOOKKEEP,
> +					     false, 15 * HZ);
> +		if (!lret)
>   			ret = -EBUSY;
> +		else if (lret > 0)
> +			ret = 0;
> +		else
> +			ret = lret;
> +
>   		if (ret) {
> -			NV_PRINTK(err, cli, "reloc wait_idle failed: %ld\n",
> +			NV_PRINTK(err, cli, "reloc wait_idle failed: %d\n",
>   				  ret);
>   			break;
>   		}
>
> base-commit: 09a9639e56c01c7a00d6c0ca63f4c7c41abe075d


  reply	other threads:[~2023-04-17  5:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-15  1:21 [Nouveau] [PATCH v2] drm/nouveau: fix incorrect conversion to dma_resv_wait_timeout() John Ogness
2023-04-15  2:02 ` [Nouveau] [PATCH v3] " John Ogness
2023-04-17  5:55   ` Christian König [this message]
2023-04-17 12:46     ` Karol Herbst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7b17a825-0f76-3e0f-5e56-0e689b7d7866@amd.com \
    --to=christian.koenig@amd.com \
    --cc=007047221b@gmail.com \
    --cc=bskeggs@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).