Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7026610rwn; Tue, 13 Sep 2022 12:34:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Cmo4dB1MF9HhJxX/yd3T7sEIUDmw1SMq7BFpE/Bht6DcrcxzNiJ46FzM/McqfBkUQ9n6G X-Received: by 2002:a05:6402:440c:b0:43a:1124:e56a with SMTP id y12-20020a056402440c00b0043a1124e56amr28286526eda.134.1663097691438; Tue, 13 Sep 2022 12:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663097691; cv=none; d=google.com; s=arc-20160816; b=sbAACpVEZnFfwSmtP6qAF7Zo2D95EJgvSTegI+5bR4XuPkvtetYqsoxP2i804G2IBx XFbbIy5gKupsCoubZaToCIE88kdexiGVai05tmZFqpUgx3wXTgsffb/uahhneGw6xXx6 Lz5Fw+MVvYsFKIM0xqWAoofPW1TADKyK+tFwBNE9ollvtjxJRZPS8fJ6WJAuoK+2qdmi xuyECBl9lriy6f/6CB6HHcKMZVjvi1qK7CDIXbkIWR+KvOsukoHQkuQY66s5pl8cCK6N l41yuFK4lz1o4A4sgjYmPlIfUKiDMaa1RIJ9cSGBAns8HkmQA4D9nx5nhqKJDMZRAuXB hoiw== 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=CyzCbzO/T5nw3DeYxwGNG/R9rqBZ/h0LypNBwYJGCNo=; b=0UiGWAm8x+mYnm6la+yxaK9KLCB2MIy0kFED4KIdYQXQXoswIrfOrJOXCyyunkhPd1 OqUCZawN7hJNTMm1ptG79g6W5xQYbdiNpDbZmVak/MtGn4z7HnM9oBWtiEUud5/zZAbl I0OkO6xMvMCr45D1n8aW49zCf5YtVHZGKVT3XhhM3/N0je2oxzTExFsKXKe3Q6X3zkkN p7f45Ir6ziq8CfvPbRJ+MQzvJ5oK55rowHxYus0rOkS/8M7GZg0UGpq29jq2PwvdBE4/ gXkYOuplYWiI66u7s9a4VnRw3pl8k9j+NU2DACUSlHTGY4LTCjXwIKuogObL36H3YV0c a01Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iahWG9Qh; 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 cr16-20020a170906d55000b0077fc6cbccb1si3457539ejc.963.2022.09.13.12.34.21; Tue, 13 Sep 2022 12:34:51 -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=iahWG9Qh; 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 S229665AbiIMTcB (ORCPT + 99 others); Tue, 13 Sep 2022 15:32:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbiIMTbg (ORCPT ); Tue, 13 Sep 2022 15:31:36 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 867E371719; Tue, 13 Sep 2022 12:29:50 -0700 (PDT) Received: from dimapc.. (109-252-122-187.nat.spd-mgts.ru [109.252.122.187]) (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 913356602006; Tue, 13 Sep 2022 20:29:43 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1663097388; bh=1GtKrwThZVJsniK/ptiZT5S6PL4TRRG1YKxbwpZHIhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iahWG9QhacEAl4VINBeLXiSWEkk0ZfYsZ5ZMd/mQXxBuGVP3fwGIyCDEEPkTBklVw F2IrWL/57n6JO11EaSwKt//9LJZQW/Kp3LWtAkz+7MiidjvTgCSPiPu6hfBnckFqM6 HMUILDoGsfxYprNWaR9CEbuzhEcV3N5Z/saNVT3ZKlwhtuwR3vzpnZ1mSrtMtYO5aN pU59cM86CUHdMdoE1HRBI22kpUd0rWKnUy+zMGElw8s+Iyzh6pj+QhIVfwqOcNzHem 3f5fdgBRvLE5cFN+c19ZuXluy+hc9bcmmgg4KT7LtSexT8Wgg9sPLjQbskg3QEHod/ HlVfpcq3uK5ZA== 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 v5 18/21] dma-buf: Move dma_buf_mmap() to dynamic locking specification Date: Tue, 13 Sep 2022 22:27:54 +0300 Message-Id: <20220913192757.37727-19-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913192757.37727-1-dmitry.osipenko@collabora.com> References: <20220913192757.37727-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 8873315d6edc..8821a3ad9530 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