From patchwork Sat Apr 15 02:02:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 83635 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp777815vqo; Fri, 14 Apr 2023 19:06:27 -0700 (PDT) X-Google-Smtp-Source: AKy350aUnOg6AbFzwpPXfIhjxnbsIgz7zyc6Oadp7C/icuurTIB9OJPvoMWBetER7I5eYonoYxhr X-Received: by 2002:a17:903:1252:b0:1a2:7d:8a8d with SMTP id u18-20020a170903125200b001a2007d8a8dmr5424018plh.57.1681524386765; Fri, 14 Apr 2023 19:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681524386; cv=none; d=google.com; s=arc-20160816; b=ZzkeBTlprPgc6yOIc4UkgEne5XKpT3qWGE9dl1is4dOmf3fYDEIRt8viQVG65B9l8v GZwzKd28XFNdJGcZ8ITxzGae679R4w1kST9DuOWNqytfdI++FG405v8VMfxFWPyfm7B9 HaVtldbC0RyaKdIBrp6jPDqXyq7E3BmSCqziSJ39KkUSW6cWLc9zMVicJavr5Ea6C/LS WSBGPisxjd2V8V5NS5QvzEi5UayoyljW+HRD+ZNhmXtyg8u+hwfnpkW6CJ/Grfgl1P0m 0nEBsTRrL/VunBaYosmXM8xraDm554odZ5UaCzoAIFpuATvL7F/L49GJsfAlPpYQVMGz dSmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=QvcA5HnArT0juQcF/pl/UzocaIDN3s8qO05ZD9AHBzE=; b=C9nxeuAfJBBxcctahO6duh25DIYwCAm40U1sxH9TXw2k2DIY9k2uiREjRSf3auXp2S sxBJoh5I/U/0K0bosakG6lj6mIEIJcSfdwlN2yUtlCedpwBpcdQdhUBBMOp2/DMCwfHE C6/Jm9WnypQiemTx6KiCH7mYNaTkg49vm/4ozgMzVq2iCCZtq3If+6llfztuboQbbR1/ 1q4AqV5dWuqTMg/NERWTJF6+xbWW33N+antYnFklUoKrZDoDYCOZQUPMPmv1tIvM1e8Y KQlYQ8tWAMo2FBWE7vSLUnohoSY3klYpBImdU5B03QSq6T8847dEMiCEAv/kV7W57/mF 7iHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WAdGjtoj; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u10-20020a17090341ca00b001a66bec3ceesi6587687ple.256.2023.04.14.19.06.14; Fri, 14 Apr 2023 19:06:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WAdGjtoj; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230161AbjDOCEx (ORCPT + 99 others); Fri, 14 Apr 2023 22:04:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbjDOCEu (ORCPT ); Fri, 14 Apr 2023 22:04:50 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D8244C39 for ; Fri, 14 Apr 2023 19:04:47 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1681524285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QvcA5HnArT0juQcF/pl/UzocaIDN3s8qO05ZD9AHBzE=; b=WAdGjtojvZtiEi0uFTGSkIhurdv40v6CO9/2ElIZENNMe/XpJb6QqRTo7lK+AVvZ/QSaGu SPGx0ndC+0A0mVsTL5HcIh77lBq3+ojEHj/h2i1mdbQwHu5g5UQonlvrLc3bzGwj/iF8Hw LZAU4Yl5o+nGNAQHinyQRG/Xo7Arffk53TSjXUxrl95YRoifE4rCEgk9k6PbW/RCxbK3lg liSjFPsFw/KfoepDZKW8S4GVazp/pNLxibZntNctNFHBpdRExSRd8LLAIr6uNSys3ETss5 bfw+YjOoIq+xe3QCyRsDSlzi5w7Nn3SJS2plz21OPFI94G/6w4U2OgU/zVbZdQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1681524285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QvcA5HnArT0juQcF/pl/UzocaIDN3s8qO05ZD9AHBzE=; b=CwlW0QiZiaCRp7T+kaLraqtWcuxFmF7F3Nw4r2zMdjo8BTw+gg7+DNlx4B/zx+6AeXqakD jLgy4BY6abTjgwBQ== To: =?utf-8?q?Christian_K=C3=B6nig?= Cc: linux-kernel@vger.kernel.org, Ben Skeggs , Karol Herbst , Lyude Paul , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, Tanmay Bhushan <007047221b@gmail.com> Subject: [PATCH v3] drm/nouveau: fix incorrect conversion to dma_resv_wait_timeout() In-Reply-To: <20230415012137.615305-1-john.ogness@linutronix.de> References: <20230415012137.615305-1-john.ogness@linutronix.de> Date: Sat, 15 Apr 2023 04:08:50 +0206 Message-ID: <87edolaomt.fsf@jogness.linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763203956144021011?= X-GMAIL-MSGID: =?utf-8?q?1763206114976470362?= 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 Reviewed-by: Christian König Reviewed-by: Karol Herbst --- 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(-) base-commit: 09a9639e56c01c7a00d6c0ca63f4c7c41abe075d 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; }