Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp652649rwe; Wed, 31 Aug 2022 08:44:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR7hyqJhGGIZp7mui3u4ppvYjyU1ndGFSV7VS7B4feEOdEV3YpbNtsAHIHTTKwde26fDPO3s X-Received: by 2002:a05:6402:cbc:b0:448:95be:397 with SMTP id cn28-20020a0564020cbc00b0044895be0397mr10419339edb.417.1661960679936; Wed, 31 Aug 2022 08:44:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661960679; cv=none; d=google.com; s=arc-20160816; b=UutJPC0Ye4UMxJJaHT3c+1uT7IdW2jvqwiVAqEAqvPTrmhAv/aIlJntZqd+8k/d9Ju OaKf43DhY0RQYrDBkPmSqBjqZ9nJQ8fIiJkKRkg81ghrGb2J+c5R/Wqh2NSjXXHjeN8N pAaYGrsZtxdwGLq/ZlHhwmT4cNPlXtar/1jf4wckVdSBtNKxDbQft5K+f++i0Oo7oqeZ S0m9wvsCLO9Pwp51r2aEiNgUIkNkz5Uud2o1uzRZxE3sUSDnr4sqLuA/WcPKFN60Bi22 kseekw8tI1IpFTADldHgeSoxbUTDlT17PyWMqLymY1OshjuEXH9y1nOfIIPzJ48Mq8SK /VhQ== 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=53aNAs6yNO7Z7/EhhS1b+PC37ART9V7vA7F/HXngCFs=; b=faSEUBZvafzcg6C2e/9C/sgYaBFZap1BYYnyVMXTJhZy+5ztfqqRAO1iSGK5TaKRDS 7AY1pO0UDy23LFYzoiai6HC+qy+yVpGKnvtkoNlDGvroI5Pj5GCn1afzNzOYbg/trMSU UJ8CpyzEsfurBai0cjrobUJrEsp/9d1WbvQ5eXIwreBz8M1DABQWG9SqIbBZk23dhAiz 1BQV3ylolsFsKdPILOmlcZNWmh4Z1zYimS7oA4WMuw79df4jNm6D6ta7Bx1C6pAUE8Od fvJSyHFKw8daQBMFDDZ4C5j/VrvRYOF6JAqZp+TNgPTJHKojnoV4LLQ4cxwK+7hskdmy 7kgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dnGv0uxh; 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 eh23-20020a0564020f9700b00447a70e89e2si10548502edb.195.2022.08.31.08.43.58; Wed, 31 Aug 2022 08:44:39 -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=dnGv0uxh; 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 S229591AbiHaPly (ORCPT + 99 others); Wed, 31 Aug 2022 11:41:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231416AbiHaPlE (ORCPT ); Wed, 31 Aug 2022 11:41:04 -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 A685765563; Wed, 31 Aug 2022 08:40:18 -0700 (PDT) Received: from dimapc.. (109-252-119-13.nat.spd-mgts.ru [109.252.119.13]) (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 1817B6601F08; Wed, 31 Aug 2022 16:40:08 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1661960411; bh=wM9CtxO7g+I2MDvrzT3LZe35Eb7d1xKXFtly+o9W8Ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dnGv0uxhtNMBxsdvy3hH+pPM5/F2s6xH4ZhZcnNjO08lYkNBDqZm4iMB3nemHgWFB xB/nRvHipZ2WOZ5Kqpkf56IU/2D3DvGF8Ukp4zZCKoG7ndRQ+r8cINug8sgCQnMTH7 saMR0YeItwmYev/7tzwNgcXa1oRjErFEjeAAZMZPlax5q8kI+a/wG7coEm1oVYHaeI Kw0kAckg2QNpLnwZqNiSOQmKc+EGEjXs1gswAZIvlxq/ggU62BRAwq838pQ6IwjI/9 FK9xl6sHtEO4DnPpF7PMp4LzNmCD4DaNMXlGCvkAiyNSG8GlqH5e+cf1vhxAdtfnJB cCB0V24HbPT+A== 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 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 v4 18/21] dma-buf: Move dma_buf_mmap() to dynamic locking specification Date: Wed, 31 Aug 2022 18:37:54 +0300 Message-Id: <20220831153757.97381-19-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220831153757.97381-1-dmitry.osipenko@collabora.com> References: <20220831153757.97381-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, T_SCC_BODY_TEXT_LINE 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: 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 8e928fe6e8df..d9130486cb8f 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -1389,6 +1389,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; @@ -1409,7 +1411,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.2