Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4324191rwl; Mon, 3 Apr 2023 03:22:36 -0700 (PDT) X-Google-Smtp-Source: AKy350azDc14b8FUBtaSxTGAu3H6ASpocQJ3xRORv9eO3OGrQce1N5FdbUJBP9MXwpDb9+bdiC3R X-Received: by 2002:a17:906:7e16:b0:92d:145a:6115 with SMTP id e22-20020a1709067e1600b0092d145a6115mr31881529ejr.38.1680517355906; Mon, 03 Apr 2023 03:22:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680517355; cv=none; d=google.com; s=arc-20160816; b=mJh8xvfrbu5MkL0PtJ4hCAPqBOfbbKVqoU9m7yT6IOu4kthR41f6t/bn1/q5sULxMq 7ZbbZa05R4gDnb62fGi0YB5eofgyRBRCdDJGIB4f9pAxrDaU7JSg4s2BBHOesK1YhDM1 zR5S9VnH7mZX4T/SSNPOYVDrUARO2XRQ0cJ1hLzUETnotvzgPAzOv3gDzbnLEVwxl0m6 kUQGYkGSTQ7pb4VXPOx+hxVirsykWVUR55hk0SVO5oSmJES8uWs5Jflsl/mGw2NjQT76 FMwppmb5G15wa4+fWpC+5HHplBkxxUUyLlD2VH/LaBNBFq9Ja8Z8pKBDOGx4AB/UuqwT f5sQ== 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:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=iLeRDuOEhRmy5jhLRfemJ98v0Nhe6cddfdBubgnJUKY=; b=ntgbrUY/GckMWSxWf7FFB3/SWm8C9D/vku/IZgKm2AV5Faw5J6tcWkruiR6Hn19Xwq xyXlUGFU88/HUMrn6px1P9y8vH4Bk9ZsabdeoDejDcRYnP8lbZqd5rCb+TXQjWD+pV07 48bwSZXrZubPQO8t1nGsN21G4xCRNb3g0MEm2D+CgOII2Md/Fzk9T8ByYFtJNXgCQ/4r e1pithr9Par6F0shvMZSK6QRAlg+Bnr+kYYOJIJxFTDCsARjd5cofi4/rHJ2H/8n4Ytp YnKcSqrovbOZgYMUJLsgRySGLG2PSRFP9mXpeBX8sFlcSLjJro2rc+J47INoqhYz2+bu l9xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=lULd60iy; 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=QUARANTINE sp=QUARANTINE 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 h22-20020a170906591600b0093ba70535e8si4374512ejq.767.2023.04.03.03.22.11; Mon, 03 Apr 2023 03:22:35 -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=lULd60iy; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232410AbjDCKTz (ORCPT + 99 others); Mon, 3 Apr 2023 06:19:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231961AbjDCKTT (ORCPT ); Mon, 3 Apr 2023 06:19:19 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10B2112BF3; Mon, 3 Apr 2023 03:19:07 -0700 (PDT) Received: from [192.168.2.163] (109-252-124-32.nat.spd-mgts.ru [109.252.124.32]) (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 7E3D56601F5E; Mon, 3 Apr 2023 11:19:04 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680517146; bh=oUsrnUvVWFNCO2I8SuCXiTW/AVZU2rkXoBafHs5oU3Y=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=lULd60iyGYARm3PqzyHmdn7asLZYd2d8dPWIEjvXyMF07YzyTnsdvZi2dYUGyyKAu hmW8XBPJQ6/iNKJHewWO+8Ak6W2rS3OU/OVGVuet7EP1bZyS1GNzWJz8c1D/Ip+QLK LN/UrIG7gufbNIC48TTRIRA99cicPtqUQT7ij8l6h/yE2i1Jt468aGCYN6B6ZSPq6V NB0nVByIN7hCp3ntdWTkFDGH9uP7rozub9VgUCThwJg6vLpuPNZpnl+83FFlS5pOuL 5iEzz4yl/t408u97uSNIW7ZmNXhyVTF0D6zS6/I4Rov2Y+ceq8S1Pn9+WjLchRvvIg nb8/Tklw6SA6A== Message-ID: <80cdf100-ef3c-23ae-5adf-bcf97fa85e72@collabora.com> Date: Mon, 3 Apr 2023 13:19:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v1 0/7] Move dma-buf mmap() reservation locking down to exporters Content-Language: en-US From: Dmitry Osipenko To: Sumit Semwal , =?UTF-8?Q?Christian_K=c3=b6nig?= , Benjamin Gaignard , Liam Mark , Brian Starkey , John Stultz , Gerd Hoffmann , Daniel Vetter , Jani Nikula , Arnd Bergmann , Greg Kroah-Hartman , Thomas Zimmermann , Tomi Valkeinen , Thierry Reding , Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Srinivas Kandagatla , Amol Maheshwari 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 References: <20230402164826.752842-1-dmitry.osipenko@collabora.com> In-Reply-To: <20230402164826.752842-1-dmitry.osipenko@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 4/2/23 19:48, Dmitry Osipenko wrote: > This patchset makes dma-buf exporters responisble for taking care of > the reservation lock. I also included patch that moves drm-shmem to use > reservation lock, to let CI test the whole set. I'm going to take all > the patches via the drm-misc tree, please give an ack. > > Previous policy stated that dma-buf core takes the lock around mmap() > callback. Which meant that both importers and exporters shouldn't touch > the reservation lock in the mmap() code path. This worked well until > Intel-CI found a deadlock problem in a case of self-imported dma-buf [1]. > > The problem happens when userpace mmaps a self-imported dma-buf, i.e. > mmaps the dma-buf FD. DRM core treats self-imported dma-bufs as own GEMs > [2]. There is no way to differentiate a prime GEM from a normal GEM for > drm-shmem in drm_gem_shmem_mmap(), which resulted in a deadlock problem > for drm-shmem mmap() code path once it's switched to use reservation lock. > > It was difficult to fix the drm-shmem problem without adjusting dma-buf > locking policy. In parctice not much changed from importers perspective > because previosly dma-buf was taking the lock in between of importers > and exporters. Now this lock is shifted down to exporters. > > [1] https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_114671v2/shard-snb5/igt@prime_vgem@sync@rcs0.html > [2] https://elixir.bootlin.com/linux/v6.3-rc4/source/drivers/gpu/drm/drm_prime.c#L924 > > Dmitry Osipenko (7): > Revert "media: videobuf2: Assert held reservation lock for dma-buf > mmapping" > Revert "dma-buf/heaps: Assert held reservation lock for dma-buf > mmapping" > Revert "udmabuf: Assert held reservation lock for dma-buf mmapping" > Revert "fastrpc: Assert held reservation lock for dma-buf mmapping" > Revert "drm: Assert held reservation lock for dma-buf mmapping" > dma-buf: Change locking policy for mmap() > drm/shmem-helper: Switch to reservation lock > > drivers/dma-buf/dma-buf.c | 17 +- > drivers/dma-buf/heaps/cma_heap.c | 3 - > drivers/dma-buf/heaps/system_heap.c | 3 - > drivers/dma-buf/udmabuf.c | 2 - > drivers/gpu/drm/drm_gem_shmem_helper.c | 217 ++++++++---------- > drivers/gpu/drm/drm_prime.c | 2 - > drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 2 - > drivers/gpu/drm/lima/lima_gem.c | 8 +- > drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 2 - > drivers/gpu/drm/panfrost/panfrost_drv.c | 7 +- > .../gpu/drm/panfrost/panfrost_gem_shrinker.c | 6 +- > drivers/gpu/drm/panfrost/panfrost_mmu.c | 19 +- > drivers/gpu/drm/tegra/gem.c | 2 - > .../common/videobuf2/videobuf2-dma-contig.c | 3 - > .../media/common/videobuf2/videobuf2-dma-sg.c | 3 - > .../common/videobuf2/videobuf2-vmalloc.c | 3 - > drivers/misc/fastrpc.c | 3 - > include/drm/drm_gem_shmem_helper.h | 14 +- > 18 files changed, 123 insertions(+), 193 deletions(-) > Intel's IGT passed[1] (see Tests section) with the new locking policy, which failed previously for the "drm/shmem-helper: Switch to reservation lock" patch. [1] https://patchwork.freedesktop.org/series/116000/ -- Best regards, Dmitry