Skip to content

Commit 7363d6b

Browse files
jognesskarolherbst
authored andcommitted
drm/nouveau: fix incorrect conversion to dma_resv_wait_timeout()
Commit 41d351f ("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: 41d351f ("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> Reviewed-by: Karol Herbst <kherbst@redhat.com> Signed-off-by: Karol Herbst <kherbst@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/87edolaomt.fsf@jogness.linutronix.de
1 parent afa965a commit 7363d6b

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

drivers/gpu/drm/nouveau/nouveau_gem.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,14 +645,15 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
645645
struct drm_nouveau_gem_pushbuf_reloc *reloc,
646646
struct drm_nouveau_gem_pushbuf_bo *bo)
647647
{
648-
long ret = 0;
648+
int ret = 0;
649649
unsigned i;
650650

651651
for (i = 0; i < req->nr_relocs; i++) {
652652
struct drm_nouveau_gem_pushbuf_reloc *r = &reloc[i];
653653
struct drm_nouveau_gem_pushbuf_bo *b;
654654
struct nouveau_bo *nvbo;
655655
uint32_t data;
656+
long lret;
656657

657658
if (unlikely(r->bo_index >= req->nr_buffers)) {
658659
NV_PRINTK(err, cli, "reloc bo index invalid\n");
@@ -703,13 +704,18 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
703704
data |= r->vor;
704705
}
705706

706-
ret = dma_resv_wait_timeout(nvbo->bo.base.resv,
707-
DMA_RESV_USAGE_BOOKKEEP,
708-
false, 15 * HZ);
709-
if (ret == 0)
707+
lret = dma_resv_wait_timeout(nvbo->bo.base.resv,
708+
DMA_RESV_USAGE_BOOKKEEP,
709+
false, 15 * HZ);
710+
if (!lret)
710711
ret = -EBUSY;
712+
else if (lret > 0)
713+
ret = 0;
714+
else
715+
ret = lret;
716+
711717
if (ret) {
712-
NV_PRINTK(err, cli, "reloc wait_idle failed: %ld\n",
718+
NV_PRINTK(err, cli, "reloc wait_idle failed: %d\n",
713719
ret);
714720
break;
715721
}

0 commit comments

Comments
 (0)