Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1066162rwb; Wed, 28 Sep 2022 12:43:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4I3Zkiw4OL1ltzVfd9MZMU9oMuVBrr/XLNRlKmhdETkHOOm/SX9+b2Yx2pum6MiXgUh+BS X-Received: by 2002:a17:902:7783:b0:179:f802:4091 with SMTP id o3-20020a170902778300b00179f8024091mr1295036pll.147.1664394189951; Wed, 28 Sep 2022 12:43:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664394189; cv=none; d=google.com; s=arc-20160816; b=awXHdATtDoehjfUSxng1cTzC3nv5TSI8Sy3LUgRs5gxkZM6SIUEMJMmg0Rht14oqqJ oVNZCEaaFt/KYOIpgqm4OK/eMKwUNu/G5W6XYzJR2dTmx+XLGfAivoBNzAue902N9b/V /ouWBSzvRnicVeblQDqNl87MblOkbLi38g5UpeQBLMxgDlH7ftzN3R55Laq9GbXAVh72 L+PPWye1JogvcybovA/tDTM6/22YV89/fL8XNsWVBosQMHeRPspSNK+l/SHw+SjUkvTX tKihTGTr77gfikx8oL5t4iT7nbvuB04Mc70UKZx0KrzhoR0PV0jKoA/GvOdMSHYr8tKi XTlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y+yorA8S9Z9XZ7N3pGWIDXnK0qQxqCQ0jjyF0D9XUGI=; b=uFFDEWUw1NkC0k3yWphlEAqkTdLoOeVeAk5PLoEVVHnwM2bNI0WZoisCyO5dQPS3da rasw8r8Hy0pTfIvQSUPAP4mpzM0aJ65APaOIVsazg4oYx5a5zVdC1nKdQWdKw+fOnKH9 PTYhvX7oOynYa3eXU3AdSeANve9GoErd452oRCiE1wWW2M/cvvmdUtILZp0NP2VSWKqB dy8xxwmFyhdZC97XuO06yP6PaZDEDInfItKUxvei4qXyoJ0MP85iQxm+g9lh+0FoaFvh HQXGJdbv0sy3zev99ueO+PsnGYLjWj6v43iK4y2H0Jreo+IWMex24taOoYM1C5BtlheI mJ1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=h+pBTBtu; 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=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d12-20020a170903230c00b0017531071bffsi6863950plh.104.2022.09.28.12.42.58; Wed, 28 Sep 2022 12:43:09 -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=@collabora.com header.s=mail header.b=h+pBTBtu; 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=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234550AbiI1TT5 (ORCPT + 99 others); Wed, 28 Sep 2022 15:19:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234471AbiI1TTH (ORCPT ); Wed, 28 Sep 2022 15:19:07 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B01EFAD89; Wed, 28 Sep 2022 12:18:23 -0700 (PDT) Received: from dimapc.. (unknown [109.252.125.248]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id 4469566022A7; Wed, 28 Sep 2022 20:18:15 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664392698; bh=ApDS5ibNhTrjBBSgfcy40+nriol/IwNJG4knEZO1xBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h+pBTBtuuKVsQeNDf5FPKg4CeUsVKju4z4WLSkyTj8ki0n39Ridn/1amMP/l1Wa2r 27paCoMEh0O+8GtOV3i8NpmUDqhyK4qWcC2ShXWn6HdvrnWkyiSLvwhfRQoadhyEOX UTQPkxJXZA+S5q99lotqAp+pUHmtnoN8kQqUso2GrKsKIjtwbNNusc+O0u0tOCEF3T k45fyxR+k1a6jZsJ38C6BUtsqHiJc3Xm+93qEbVrKqRaIXHNxGGbUTKid/Pa5C5s8r MpexUjThPhx6b0IBm5Lsax7b/lPjU74gifc/SDamFu9wFrOS8C/9tBTGHvnisfnHkd ydG4zpN88amXg== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny , Gustavo Padovan , Daniel Stone , Tomeu Vizoso , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Clark , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , Thierry Reding , Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Alex Deucher , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Qiang Yu , Srinivas Kandagatla , Amol Maheshwari , Jason Gunthorpe , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Tomi Valkeinen , Russell King , Lucas Stach , Christian Gmeiner , Ruhl Michael J Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Osipenko , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, kernel@collabora.com, virtualization@lists.linux-foundation.org, linux-rdma@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v6 17/21] dma-buf: Move dma_buf_map_attachment() to dynamic locking specification Date: Wed, 28 Sep 2022 22:15:56 +0300 Message-Id: <20220928191600.5874-18-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928191600.5874-1-dmitry.osipenko@collabora.com> References: <20220928191600.5874-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 Move dma-buf attachment mapping functions to the dynamic locking specification by asserting that the reservation lock is held. Acked-by: Sumit Semwal Reviewed-by: Christian König Signed-off-by: Dmitry Osipenko --- drivers/dma-buf/dma-buf.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index d60585bbb529..bff5a70b8735 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -1038,8 +1038,7 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach, if (WARN_ON(!attach || !attach->dmabuf)) return ERR_PTR(-EINVAL); - if (dma_buf_attachment_is_dynamic(attach)) - dma_resv_assert_held(attach->dmabuf->resv); + dma_resv_assert_held(attach->dmabuf->resv); if (attach->sgt) { /* @@ -1054,7 +1053,6 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach, } if (dma_buf_is_dynamic(attach->dmabuf)) { - dma_resv_assert_held(attach->dmabuf->resv); if (!IS_ENABLED(CONFIG_DMABUF_MOVE_NOTIFY)) { r = attach->dmabuf->ops->pin(attach); if (r) @@ -1143,15 +1141,11 @@ void dma_buf_unmap_attachment(struct dma_buf_attachment *attach, if (WARN_ON(!attach || !attach->dmabuf || !sg_table)) return; - if (dma_buf_attachment_is_dynamic(attach)) - dma_resv_assert_held(attach->dmabuf->resv); + dma_resv_assert_held(attach->dmabuf->resv); if (attach->sgt == sg_table) return; - if (dma_buf_is_dynamic(attach->dmabuf)) - dma_resv_assert_held(attach->dmabuf->resv); - __unmap_dma_buf(attach, sg_table, direction); if (dma_buf_is_dynamic(attach->dmabuf) && -- 2.37.3