Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp426212rwe; Wed, 24 Aug 2022 03:31:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR7v9Mt1Rdw8uM9S53sIAyQx//8joPQJnEs0fO18JJigg9tOAW1HYVmGPPsoyWuOmXjfeVfC X-Received: by 2002:a17:907:7612:b0:73d:5b08:68be with SMTP id jx18-20020a170907761200b0073d5b0868bemr2529026ejc.430.1661337113449; Wed, 24 Aug 2022 03:31:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661337113; cv=none; d=google.com; s=arc-20160816; b=R32igPzSm1yltL0OlffwuTzPTChrwJuv/LOccQyzYX5c70TEo+R04IpbLHFSgu1WCn k3xSDkflruPOWyz10SMWLylmYHYv/OEGcSjRHFjdrRv7vMPE3qnQL/7LOQcs0Q7JWEzG TGiMY+kC2AgYUKY7ReTT9T+h2owFSoiYq/izKyNk5irv89EHJA13LPlqCMnaFf/5SWTa 0UPa2QEoQSbFS80wXG+5oFNrFZTSqy3VqxG9lUWKQ/rfynB9z2gHD9JMjwtk9QUYpZIR U677JEPIBV3KKefbKt8PrfXVuhImd+GwUA/4eSjqVGWD4htnB8t34spGOzXWj0kyazzg BDsw== 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=AqsYhWFriJe5bQhBgwh43//Dj0cRPE8cClyyxNpUkMg=; b=AuE1LDE5+4jxhUp834+YNakp6f1BXjZ86hXT0xjctFEwa06mr9yRaaiS8gkMRUqHUU MyOBfA4nmmUFwfAZRiU6ON+mO4pX/hnZQi+AGPOdBC6KnwvmBmFbDaUMyhjXs3Q1mFwO sYrSegBlGZcRwcTre2tL004WqTKYvoGbkndZ4rwG8xs7WujCBOt3A3PzTu1qqzEUWyh1 d8EZQnr6Z1jO2Jl8VqFzHoQWy9dm8vlWIUg6Z77/nk/jhjlnHvIEhaDqSR6HaErX6t3c FkpCvC7yY0B5TJJMkhgrmEdwbV2QwYzz1N/RJGSZyQYdyt/x9YJcMRutx/DleeKFFeJS K+wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DLs9UpYo; 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 f6-20020a05640214c600b0043be0095146si3082347edx.601.2022.08.24.03.31.27; Wed, 24 Aug 2022 03:31:53 -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=DLs9UpYo; 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 S236994AbiHXKZB (ORCPT + 99 others); Wed, 24 Aug 2022 06:25:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236984AbiHXKYa (ORCPT ); Wed, 24 Aug 2022 06:24:30 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51B577A526; Wed, 24 Aug 2022 03:24:03 -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 48F6C6601E89; Wed, 24 Aug 2022 11:23:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1661336641; bh=L+nOt3PDFpJyCENPQKDfuFe80wgZT5z7cwxh3RrG5qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DLs9UpYoldhNB6W+XPnQ5M5X6LsDHvoxl56Aa4f5Z8BPbry3DgtbDbuSVPYX5CN6b 9H903JpaoZPjWxj4kemRlSF4DdmLiUglE0l7R7elEnUUbTexAJh9YoyF6hYUsYUqBf JccDgnSOnojfUk6MebhOdV5teSTdEmesjcILXFQi8yAggjFAK1Wyvw58PKLl29oIDe RuP3g0rlhDtkP6mhUPAvqowpA96GxS4pGdLdWGmCENPWB1xeHy6Sfgmk2jL2WdcQBy xquZBumyfM12n4i4ybYyKD5Vv8QSDIRF+UFnQ1eo/eVSWiVXtyMpXpvd5FzOFBnncv gE4R0ob1619oQ== 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 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, lima@lists.freedesktop.org Subject: [PATCH v3 9/9] dma-buf: Remove internal lock Date: Wed, 24 Aug 2022 13:22:48 +0300 Message-Id: <20220824102248.91964-10-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220824102248.91964-1-dmitry.osipenko@collabora.com> References: <20220824102248.91964-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, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 The internal dma-buf lock isn't needed anymore because the updated locking specification claims that dma-buf reservation must be locked by importers, and thus, the internal data is already protected by the reservation lock. Remove the obsoleted internal lock. Signed-off-by: Dmitry Osipenko --- drivers/dma-buf/dma-buf.c | 14 ++++---------- include/linux/dma-buf.h | 9 --------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 696d132b02f4..a0406254f0ae 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -656,7 +656,6 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info) dmabuf->file = file; - mutex_init(&dmabuf->lock); INIT_LIST_HEAD(&dmabuf->attachments); mutex_lock(&db_list.lock); @@ -1503,7 +1502,7 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_mmap_unlocked, DMA_BUF); int dma_buf_vmap(struct dma_buf *dmabuf, struct iosys_map *map) { struct iosys_map ptr; - int ret = 0; + int ret; iosys_map_clear(map); @@ -1515,28 +1514,25 @@ int dma_buf_vmap(struct dma_buf *dmabuf, struct iosys_map *map) if (!dmabuf->ops->vmap) return -EINVAL; - mutex_lock(&dmabuf->lock); if (dmabuf->vmapping_counter) { dmabuf->vmapping_counter++; BUG_ON(iosys_map_is_null(&dmabuf->vmap_ptr)); *map = dmabuf->vmap_ptr; - goto out_unlock; + return 0; } BUG_ON(iosys_map_is_set(&dmabuf->vmap_ptr)); ret = dmabuf->ops->vmap(dmabuf, &ptr); if (WARN_ON_ONCE(ret)) - goto out_unlock; + return ret; dmabuf->vmap_ptr = ptr; dmabuf->vmapping_counter = 1; *map = dmabuf->vmap_ptr; -out_unlock: - mutex_unlock(&dmabuf->lock); - return ret; + return 0; } EXPORT_SYMBOL_NS_GPL(dma_buf_vmap, DMA_BUF); @@ -1578,13 +1574,11 @@ void dma_buf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map) BUG_ON(dmabuf->vmapping_counter == 0); BUG_ON(!iosys_map_is_equal(&dmabuf->vmap_ptr, map)); - mutex_lock(&dmabuf->lock); if (--dmabuf->vmapping_counter == 0) { if (dmabuf->ops->vunmap) dmabuf->ops->vunmap(dmabuf, map); iosys_map_clear(&dmabuf->vmap_ptr); } - mutex_unlock(&dmabuf->lock); } EXPORT_SYMBOL_NS_GPL(dma_buf_vunmap, DMA_BUF); diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index d48d534dc55c..aed6695bbb50 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -326,15 +326,6 @@ struct dma_buf { /** @ops: dma_buf_ops associated with this buffer object. */ const struct dma_buf_ops *ops; - /** - * @lock: - * - * Used internally to serialize list manipulation, attach/detach and - * vmap/unmap. Note that in many cases this is superseeded by - * dma_resv_lock() on @resv. - */ - struct mutex lock; - /** * @vmapping_counter: * -- 2.37.2