Message ID | 20221110201349.351294-2-dmitry.osipenko@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp355918wru; Thu, 10 Nov 2022 12:17:33 -0800 (PST) X-Google-Smtp-Source: AMsMyM7hi9Wjad3Ib+6+mGI/9jvfeRWomgjmT5aeppQ3plcDwb5byafaovfn2pQKJJkVTOcUM1Ca X-Received: by 2002:a17:906:c21a:b0:7ae:41e6:9076 with SMTP id d26-20020a170906c21a00b007ae41e69076mr3560167ejz.321.1668111453473; Thu, 10 Nov 2022 12:17:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668111453; cv=none; d=google.com; s=arc-20160816; b=a987KSj1FE5+8U3UIjF7Cjcl6OnXcZKZdJJKMDYrC+eVavOuibrKn0bu6Cuin12vRR D6mSDBz1G0E76HA58p4wymQ8aPLbYY9p04tlsxzRAEx/6u8u2aCm22xQ7vAWC+heKC5u XVGhovkvwytt3uxkZwURUfPugWVZal39sfqa8pjXgmsrICX+FOZjE29jX91x+dbMojpZ Ee7wTZ9/NfR4DU06osceA5OvxIY495+HacHl5JUtdFkIV9xmRo2wvmZNI1Lwg2U7Vwji hfSdpqD9kxMUI4U5iqJbdzNWKuaWnF+PCTT4B1spSkNKeggsPn4/+J4tcbmpEJuIpW/Z V0dA== 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=kEi0e3L8+2KPLk86MHEQEVD60tWun2s11MndgHtUsQQ=; b=KMdfUCTB/WAP4TJBgUjlig2lY8n0GfOD1yDkNNu9IGhQpTyCk2QxnIZX/rAZwaT6Xh NWphah0U06uauSp8Ip1QXPMqIUGmnJDqpsemWpd8Oe9MoTYlXqNMyAqkfxDUjDSKedxt wuHT/ZCqgkLKY/5qOB4GNk4OzcAK/ywTeCqr2/w1jpU9VmqqFn75zkO74VQBN04jz7yv /kCFOB/9N0RxCGdF5vasmbiZ3eq488cgt6MX7pzDZiHXhFHFe7YuEgwaxopqCkwxJRCf NovsY1murIqQnaS+fxuqYHGM1DqiQ2tgk3jKM+gq9D19PunqWZVmesdGu+X3VDdMaN0s dU7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Vs2Dxqer; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb36-20020a1709071ca400b007882926c090si204903ejc.773.2022.11.10.12.17.03; Thu, 10 Nov 2022 12:17:33 -0800 (PST) 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=Vs2Dxqer; 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 S231508AbiKJUO4 (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Thu, 10 Nov 2022 15:14:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231298AbiKJUOx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 10 Nov 2022 15:14:53 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90B644D5E6; Thu, 10 Nov 2022 12:14:52 -0800 (PST) Received: from dimapc.. (unknown [109.252.117.140]) (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 32EF16602A35; Thu, 10 Nov 2022 20:14:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1668111291; bh=8lPPkB/X/nAF7UCnlj4YAfVJ4CiTG60x/dmXzJUkhFQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vs2DxqerXBoYuKVokuo4qllebuVOqRgJgOpEfACXfRig5MufY62WKEHWvF/TUVx5J cLnzg7+wdeX5IipFW0IcfkQN1byMmwbt/0wlM/oGvFJEMvmAHO0WeOnQJltTIjkON9 OT56X85voHyfhssNDFiy7CAvhnjlcF+LZ0YBuOQedrYMIix/hsfgyRYJ2FaHYo2NhF eD9Qz6L32qGZXVhlY3HuwfdxozObHRKC0FCIAbvyLZVmNXmqBJ5svUDWy5tgC8fHq8 OY6cY1et+6vAWLYfCRoEJ0vs5iiKlfkc9eCn+24UrhclhzmzECbfJJlC/lvPZkrEvd GOgUuvv+yCMjg== From: Dmitry Osipenko <dmitry.osipenko@collabora.com> To: Sumit Semwal <sumit.semwal@linaro.org>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>, Benjamin Gaignard <benjamin.gaignard@collabora.com>, Liam Mark <lmark@codeaurora.org>, Brian Starkey <Brian.Starkey@arm.com>, John Stultz <jstultz@google.com>, Gerd Hoffmann <kraxel@redhat.com>, Daniel Vetter <daniel@ffwll.ch>, Jani Nikula <jani.nikula@linux.intel.com>, Joonas Lahtinen <joonas.lahtinen@linux.intel.com>, Rodrigo Vivi <rodrigo.vivi@intel.com>, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>, Thomas Zimmermann <tzimmermann@suse.de>, Tomi Valkeinen <tomba@kernel.org>, Thierry Reding <thierry.reding@gmail.com>, Tomasz Figa <tfiga@chromium.org>, Marek Szyprowski <m.szyprowski@samsung.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, Amol Maheshwari <amahesh@qti.qualcomm.com> Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-arm-msm@vger.kernel.org, kernel@collabora.com Subject: [PATCH v1 1/6] dma-buf: Move dma_buf_mmap_internal() to dynamic locking specification Date: Thu, 10 Nov 2022 23:13:44 +0300 Message-Id: <20221110201349.351294-2-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221110201349.351294-1-dmitry.osipenko@collabora.com> References: <20221110201349.351294-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749141635220215818?= X-GMAIL-MSGID: =?utf-8?q?1749141635220215818?= |
Series |
Move dma_buf_mmap_internal() to dynamic locking specification
|
|
Commit Message
Dmitry Osipenko
Nov. 10, 2022, 8:13 p.m. UTC
All dma-buf functions has been moved to dynamic locking specification
The dma_buf_mmap_internal() was missed out by accident. Take reservation
lock around file mapping operation to adhere the common locking convention.
Reported-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
---
drivers/dma-buf/dma-buf.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
Comments
Am 10.11.22 um 21:13 schrieb Dmitry Osipenko: > All dma-buf functions has been moved to dynamic locking specification > The dma_buf_mmap_internal() was missed out by accident. Take reservation > lock around file mapping operation to adhere the common locking convention. > > Reported-by: Daniel Vetter <daniel@ffwll.ch> > Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Reviewed-by: Christian König <christian.koenig@amd.com> for this patch here. Acked-by: Christian König <christian.koenig@amd.com> for the rest of the series. Regards, Christian. > --- > drivers/dma-buf/dma-buf.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c > index 13bfd2d09c56..b809513b03fe 100644 > --- a/drivers/dma-buf/dma-buf.c > +++ b/drivers/dma-buf/dma-buf.c > @@ -129,6 +129,7 @@ static struct file_system_type dma_buf_fs_type = { > static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma) > { > struct dma_buf *dmabuf; > + int ret; > > if (!is_dma_buf_file(file)) > return -EINVAL; > @@ -144,7 +145,11 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma) > dmabuf->size >> PAGE_SHIFT) > return -EINVAL; > > - 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; > } > > static loff_t dma_buf_llseek(struct file *file, loff_t offset, int whence)
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 13bfd2d09c56..b809513b03fe 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -129,6 +129,7 @@ static struct file_system_type dma_buf_fs_type = { static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma) { struct dma_buf *dmabuf; + int ret; if (!is_dma_buf_file(file)) return -EINVAL; @@ -144,7 +145,11 @@ static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma) dmabuf->size >> PAGE_SHIFT) return -EINVAL; - 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; } static loff_t dma_buf_llseek(struct file *file, loff_t offset, int whence)