Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1060821rwb; Wed, 28 Sep 2022 12:38:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6jQmRAUG+UfbmeHj7Wvtl2M4lEsdSPy1502TGyWj23hE6JMw9Y8dCDI/U5ADO5+zJnFrTk X-Received: by 2002:a65:6d89:0:b0:421:94bc:cb89 with SMTP id bc9-20020a656d89000000b0042194bccb89mr30196802pgb.129.1664393904058; Wed, 28 Sep 2022 12:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664393904; cv=none; d=google.com; s=arc-20160816; b=MTpCLjMZLXmftxfBetjdoWtQKKo+4LTIYkIQ/8jdDx5vsGWHDNTN+q2ANRB7lczhM2 gRuqcZroj3TJS2CO0od4PrX01dvmbArPfmTXsmPz0D9blm7oBxiUFQLbZ5ixesnMZHlL 7COyNqMOeEvPdVmej5NNefsuKwWrm+aRmi+Tp9VR+Mu8EMvxKJQEGpPvJfFjCxKbqL0J SR5VTKS5fkir7wWHo83fr9svUybzVPZrHbHAlF95Vo5g41qW2gigxXAKIBNLikFJAJaT YOuibEUhP7t5xNpaW5l92PM8Kvyy8VCGywtlG7qA6nM17Z7k9ZQH7BnA1VuxBtSAfvBB 1GWA== 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=p78qQuhkTAT0FKgiU6RlwE/5bUU/RTmjzTSdFUOt90U=; b=nvrMxskm8p0s0aVRyZ/9vN3kHlQZqzc1p4Bb8pUgbxTZgKXV8qG0EPRNdjBrfzGo+/ BTO5lT34hy+VcnT8G9l4NoTw5pUH8XK7P6eRD3auWEywH//XK2r9pqGrl35HbK5UxTcp epAXyPiko7F0WM234aGijn5Hztxun6ISZ8qhDprzHXiQwWfvdEr+hXMCitqAsZ9yu/8k Ge9mVafodOBOX/Qs37C3gXsPtdhapzqIo1bb24RcwHkI2aDmZTQX7iZcBAdcUs/fi8uF bZs+yBLybsrW5bbBW47T141TBVEVam8SUMRmlBmpBA+bnVhIvRDuASYifEt4rKwo42Vg VByA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=abP6CtWU; 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 z34-20020a634c22000000b004392e26a2f7si7089038pga.404.2022.09.28.12.38.12; Wed, 28 Sep 2022 12:38:24 -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=abP6CtWU; 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 S234663AbiI1TUB (ORCPT + 99 others); Wed, 28 Sep 2022 15:20:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234559AbiI1TTU (ORCPT ); Wed, 28 Sep 2022 15:19:20 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 623E3FB312; Wed, 28 Sep 2022 12:18:26 -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 BB23466022C4; Wed, 28 Sep 2022 20:18:18 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664392701; bh=89/65f/dDy+eASrj3PX7nWokVxmv9ZpmtoFT7wYq/aE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=abP6CtWU9WWWHjvSe2Ygdq+MLjfMh95HR0FMwBvJ7q4vJqbb8xRVkEWMRReWS2R6J CVJ6RyC/neUsRVNH/OhRlO1DPx9CZ0akB2JrW+LoIf/Ua/DbBX5OoVcGtNmKaUp28+ lp8lmmVdanhZdxDXVdw/ER6wzpik6+fcTY1MLWw3Esj0WMz3eQ88fVOl+mZSaRo0uT ozryYQt5ZZz3t9kmaL1ZCDpGk1mhhW1fuyIgxGgaBvS8jUQC2mEnnnlkH0Bw5M3xDA 4MDhaQFZ2jDwol9cncESUNyNnfByN4KukK+SR2By2AJ1NLuJc0I5l0kA9sNpXEYC22 3SptQpreSo7/w== 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 18/21] dma-buf: Move dma_buf_mmap() to dynamic locking specification Date: Wed, 28 Sep 2022 22:15:57 +0300 Message-Id: <20220928191600.5874-19-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_mmap() function to the dynamic locking specification by taking the reservation lock. Neither of the today's drivers take the reservation lock within the mmap() callback, hence it's safe to enforce the locking. Acked-by: Sumit Semwal Acked-by: Christian König Signed-off-by: Dmitry Osipenko --- drivers/dma-buf/dma-buf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index bff5a70b8735..2452b4c82584 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -1390,6 +1390,8 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_end_cpu_access, DMA_BUF); int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma, unsigned long pgoff) { + int ret; + if (WARN_ON(!dmabuf || !vma)) return -EINVAL; @@ -1410,7 +1412,11 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma, vma_set_file(vma, dmabuf->file); vma->vm_pgoff = pgoff; - return dmabuf->ops->mmap(dmabuf, vma); + dma_resv_lock(dmabuf->resv, NULL); + ret = dmabuf->ops->mmap(dmabuf, vma); + dma_resv_unlock(dmabuf->resv); + + return ret; } EXPORT_SYMBOL_NS_GPL(dma_buf_mmap, DMA_BUF); -- 2.37.3