Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp765132rwe; Wed, 24 Aug 2022 08:37:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR52TFCDZqqOIWkDcxGfqE9HjOTfzIGSq9Z8FSYE7KJVN+UGsKWEZ7DpFBxSF1rg+hZn+My4 X-Received: by 2002:a17:906:58c9:b0:73c:37bb:c4d4 with SMTP id e9-20020a17090658c900b0073c37bbc4d4mr3223496ejs.467.1661355479019; Wed, 24 Aug 2022 08:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661355479; cv=none; d=google.com; s=arc-20160816; b=WbGkaIawvxShYJbCgROSHq9kzmQShg/JlWDPh0cNpSx2NFV0o89rFvnzCAGnmE6iBg JmrKzqgEjmCus9ZC8NweAqfhSPLUrc8w5mJrPAjIvMh7dsO3s6durxeTqTL94D2DtvTa qf3nHkH3CuxkfQuNOLQf6dJo4NKtbvv3xrYid0k0A/aFRzNN5d46xRvwDqMtjtj3hubz ouINbZjSIjuf0PMGRC3DfKeZ0JEZ33yOKnL4KvZvOfbbUedY0oqkLAajvwN98jbWAsP7 c/x9J5xAeTB+8SOhAnz2I6kq78mMr9+Hj9S6idOkv4FVhNMF4/nmAlaPmzA0eOkNokVj g6GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Pgn98FwgSeT+EWGgobng+h/q3s7ltAmi/kmJN7zE3nY=; b=0bzJOKGPZPJU4L3YS57LL4OxAOYdhsW+3rIl7ueCB6AAD8IxZfEYWOfnl9LTHKCJjW Gl6n5xt9YTBbyl+sRxqwzBhYmSLpPHHagViJJLPTIul/T/Qz8bN2S2RocGMS4Eyq96nf TW/ybdyfWsEut94hKirnsPsBiY7FVBO4EFxndCQ9NE/+MS4FStRpkA6LyGEC/QMgQBiE XlQUzMVFHaTCgaoFG5k5hyY3PqdKfY1/NRKPnJy7IU78lZwqGSywsKAzz3cM6kUtQ7zI RbjUQoQotDKWk7jSe7zKwufBj+EMV0TDO3VO7g3G3E0JOM+Gn9nYL6KLh3wDBwXq3wVa xGZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=oAR0YvOO; 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 n3-20020a17090695c300b0072ab5d0fc33si1954842ejy.863.2022.08.24.08.37.31; Wed, 24 Aug 2022 08:37:58 -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=oAR0YvOO; 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 S238841AbiHXPDz (ORCPT + 99 others); Wed, 24 Aug 2022 11:03:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237612AbiHXPDy (ORCPT ); Wed, 24 Aug 2022 11:03:54 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3C3898A5D; Wed, 24 Aug 2022 08:03:48 -0700 (PDT) Received: from [192.168.2.145] (109-252-119-13.nat.spd-mgts.ru [109.252.119.13]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 7B8806601E8F; Wed, 24 Aug 2022 16:03:44 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1661353426; bh=ss7Re+WGJ6gPDf+07fuRLgmV2oF07ngUyzhkLngogMo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=oAR0YvOOYSafNUGMl1oNd0JDpIq3FDAHC3HSFM85TQLAtdUKWV9S7/KMulX1yzdJU ynpYz4YtIeU371JqvKb8/c29/d8CPVp3PGsQrb8kJYYp7JpoSNHveANuXdDGoXqRHL p9edkNfznNFe0vL1B7KsPf3EQ1iqD0q15Jh9BVqB7qaGinbAx23HtsmgAfze7Sezsa 5eCHp4KjFs2i46CRc/qn7EZjWd/w/c9qg+8YOKS0kgwlBEA5uFkOiS4rzy8gfpu2eT /NbO6kk31WXQ6hWLjRcZaGob2toZeqNH+aU5AQGrgKbdtAC0glWaondyOLmCNSr5lf VJAAXcJe1ilqw== Message-ID: <4af793fd-eccc-ad70-65c3-de78dced71f0@collabora.com> Date: Wed, 24 Aug 2022 18:03:42 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH v3 6/9] dma-buf: Move dma-buf attachment to dynamic locking specification Content-Language: en-US To: =?UTF-8?Q?Christian_K=c3=b6nig?= , 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 , "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_Hellstr=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 References: <20220824102248.91964-1-dmitry.osipenko@collabora.com> <20220824102248.91964-7-dmitry.osipenko@collabora.com> <17181951-1b40-cd39-48df-58b43cad117d@amd.com> From: Dmitry Osipenko In-Reply-To: <17181951-1b40-cd39-48df-58b43cad117d@amd.com> 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,NICE_REPLY_A,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 On 8/24/22 17:08, Christian König wrote: > Am 24.08.22 um 12:22 schrieb Dmitry Osipenko: >> Move dma-buf attachment API functions to the dynamic locking >> specification. >> The strict locking convention prevents deadlock situations for dma-buf >> importers and exporters. >> >> Previously, the "unlocked" versions of the attachment API functions >> weren't taking the reservation lock and this patch makes them to take >> the lock. > > Didn't we concluded that we need to keep the attach and detach callbacks > without the lock and only move the map/unmap callbacks over? > > Otherwise it won't be possible for drivers to lock multiple buffers if > they have to shuffle things around for a specific attachment. We did conclude that. The attach/detach dma-buf ops are unlocked, but the map_dma_buf/unmap_dma_buf must be invoked under lock and dma_buf_dynamic_attach_unlocked() maps dma-buf if either importer or exporter can't handle the dynamic mapping [1]. [1] https://elixir.bootlin.com/linux/v6.0-rc2/source/drivers/dma-buf/dma-buf.c#L869 Hence I re-arranged the dma_resv_lock() in dma_buf_dynamic_attach_unlocked() to move both pinning and mapping under the held lock. -- Best regards, Dmitry