From patchwork Fri Oct 15 11:57:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 77782 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1mbLzH-003Rgp-0F; Fri, 15 Oct 2021 12:06:59 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238655AbhJOMJC (ORCPT + 1 other); Fri, 15 Oct 2021 08:09:02 -0400 Received: from mblankhorst.nl ([141.105.120.124]:47938 "EHLO mblankhorst.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238651AbhJOMI6 (ORCPT ); Fri, 15 Oct 2021 08:08:58 -0400 From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Maarten Lankhorst , =?utf-8?q?Christian_?= =?utf-8?q?K=C3=B6nig?= , Daniel Vetter Subject: [PATCH 1/2] dma-buf: Fix dma_resv_wait_timeout handling of timeout = 0. Date: Fri, 15 Oct 2021 13:57:19 +0200 Message-Id: <20211015115720.79958-2-maarten.lankhorst@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211015115720.79958-1-maarten.lankhorst@linux.intel.com> References: <20211015115720.79958-1-maarten.lankhorst@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.7 (----) X-LSpam-Report: No, score=-4.7 required=5.0 tests=BAYES_00=-1.9,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no Commit ada5c48b11a3 ("dma-buf: use new iterator in dma_resv_wait_timeout") accidentally started mishandling timeout = 0, by forcing a blocking wait with timeout = 1 passed to fences. This is not intended, as timeout = 0 may be used for peeking, similar to test_signaled. Fixes: ada5c48b11a3 ("dma-buf: use new iterator in dma_resv_wait_timeout") Cc: Christian König Cc: Daniel Vetter Signed-off-by: Maarten Lankhorst --- drivers/dma-buf/dma-resv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 9eb2baa387d4..70a8082660c5 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -617,18 +617,18 @@ EXPORT_SYMBOL_GPL(dma_resv_get_fences); long dma_resv_wait_timeout(struct dma_resv *obj, bool wait_all, bool intr, unsigned long timeout) { - long ret = timeout ? timeout : 1; + long ret = timeout ?: 1; struct dma_resv_iter cursor; struct dma_fence *fence; dma_resv_iter_begin(&cursor, obj, wait_all); dma_resv_for_each_fence_unlocked(&cursor, fence) { + ret = dma_fence_wait_timeout(fence, intr, timeout); + if (ret <= 0) + break; - ret = dma_fence_wait_timeout(fence, intr, ret); - if (ret <= 0) { - dma_resv_iter_end(&cursor); - return ret; - } + if (timeout) + timeout = ret; } dma_resv_iter_end(&cursor); From patchwork Fri Oct 15 11:57:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 77783 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1mbLzH-003Rgp-UX; Fri, 15 Oct 2021 12:07:00 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238656AbhJOMJD (ORCPT + 1 other); Fri, 15 Oct 2021 08:09:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238652AbhJOMJA (ORCPT ); Fri, 15 Oct 2021 08:09:00 -0400 X-Greylist: delayed 566 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 15 Oct 2021 05:06:52 PDT Received: from mblankhorst.nl (mblankhorst.nl [IPv6:2a02:2308:0:7ec:e79c:4e97:b6c4:f0ae]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCF16C061570 for ; Fri, 15 Oct 2021 05:06:52 -0700 (PDT) From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Maarten Lankhorst , =?utf-8?q?Christian_?= =?utf-8?q?K=C3=B6nig?= , Daniel Vetter Subject: [PATCH 2/2] dma-buf: Fix dma_resv_test_signaled. Date: Fri, 15 Oct 2021 13:57:20 +0200 Message-Id: <20211015115720.79958-3-maarten.lankhorst@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211015115720.79958-1-maarten.lankhorst@linux.intel.com> References: <20211015115720.79958-1-maarten.lankhorst@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -4.7 (----) X-LSpam-Report: No, score=-4.7 required=5.0 tests=BAYES_00=-1.9,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no Commit 7fa828cb9265 ("dma-buf: use new iterator in dma_resv_test_signaled") accidentally forgot to test whether the dma-buf is actually signaled, breaking pretty much everything depending on it. Fixes: 7fa828cb9265 ("dma-buf: use new iterator in dma_resv_test_signaled") Cc: Christian König Cc: Daniel Vetter Signed-off-by: Maarten Lankhorst --- drivers/dma-buf/dma-resv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index 70a8082660c5..37ab2875e469 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -655,14 +655,16 @@ bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) { struct dma_resv_iter cursor; struct dma_fence *fence; + bool ret = true; dma_resv_iter_begin(&cursor, obj, test_all); dma_resv_for_each_fence_unlocked(&cursor, fence) { - dma_resv_iter_end(&cursor); - return false; + ret = dma_fence_is_signaled(fence); + if (!ret) + break; } dma_resv_iter_end(&cursor); - return true; + return ret; } EXPORT_SYMBOL_GPL(dma_resv_test_signaled);