From patchwork Fri Mar 5 10:51:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 12118313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7521C433E0 for ; Fri, 5 Mar 2021 10:51:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4559E64FD3 for ; Fri, 5 Mar 2021 10:51:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4559E64FD3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=chris-wilson.co.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 93B356EB6E; Fri, 5 Mar 2021 10:51:37 +0000 (UTC) Received: from fireflyinternet.com (unknown [77.68.26.236]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1450E6E18E for ; Fri, 5 Mar 2021 10:51:35 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.69.177; Received: from build.alporthouse.com (unverified [78.156.69.177]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 24023334-1500050 for multiple; Fri, 05 Mar 2021 10:51:16 +0000 From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH] dma-buf: Fix confusion of dynamic dma-buf vs dynamic attachment Date: Fri, 5 Mar 2021 10:51:14 +0000 Message-Id: <20210305105114.26338-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , =?utf-8?q?Christian_K=C3=B6nig?= , stable@vger.kernel.org, Chris Wilson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Commit c545781e1c55 ("dma-buf: doc polish for pin/unpin") disagrees with the introduction of dynamism in commit: bb42df4662a4 ("dma-buf: add dynamic DMA-buf handling v15") resulting in warning spew on importing dma-buf. Silence the warning from the latter by only pinning the attachment if the attachment rather than the dmabuf is to be dynamic. Fixes: bb42df4662a4 ("dma-buf: add dynamic DMA-buf handling v15") Fixes: c545781e1c55 ("dma-buf: doc polish for pin/unpin") Signed-off-by: Chris Wilson Cc: Daniel Vetter Cc: Christian König Cc: # v5.7+ --- drivers/dma-buf/dma-buf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index f264b70c383e..09f5ae458515 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -758,8 +758,8 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev, dma_buf_is_dynamic(dmabuf)) { struct sg_table *sgt; - if (dma_buf_is_dynamic(attach->dmabuf)) { - dma_resv_lock(attach->dmabuf->resv, NULL); + if (dma_buf_attachment_is_dynamic(attach)) { + dma_resv_lock(dmabuf->resv, NULL); ret = dma_buf_pin(attach); if (ret) goto err_unlock; @@ -772,8 +772,9 @@ dma_buf_dynamic_attach(struct dma_buf *dmabuf, struct device *dev, ret = PTR_ERR(sgt); goto err_unpin; } - if (dma_buf_is_dynamic(attach->dmabuf)) - dma_resv_unlock(attach->dmabuf->resv); + if (dma_buf_attachment_is_dynamic(attach)) + dma_resv_unlock(dmabuf->resv); + attach->sgt = sgt; attach->dir = DMA_BIDIRECTIONAL; }