From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: "Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Benjamin Gaignard" <benjamin.gaignard@collabora.com>,
"Brian Starkey" <Brian.Starkey@arm.com>,
"John Stultz" <jstultz@google.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Tomi Valkeinen" <tomba@kernel.org>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Tomasz Figa" <tfiga@chromium.org>,
"Marek Szyprowski" <m.szyprowski@samsung.com>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Emil Velikov" <emil.l.velikov@gmail.com>
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, kernel@collabora.com
Subject: [PATCH v4 0/6] Move dma-buf mmap() reservation locking down to exporters
Date: Tue, 30 May 2023 01:39:29 +0300 [thread overview]
Message-ID: <20230529223935.2672495-1-dmitry.osipenko@collabora.com> (raw)
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
Changelog:
v4: - Added dma_resv_assert_held() to drm_gem_shmem_get_pages(), making
assert consistent with the put() variant. Suggested by Emil Velikov.
v3: - Added r-b from Hans Verkuil to the videobuf2 patch.
- The v2 fastrpc patch was already applied, not including it anymore.
Though, the cover-letter says that I'd want to apply all the patches
via the drm-misc tree to keep the proper ordering of the changes.
- Previously Intel's CI gave a flake failure to v2, want to re-test
it again.
v2: - Added ack from Christian König to the DRM patch.
- Dropped "fixes" tag from the patches, like was requested by
Christian König. The patches don't actually need a backport
and merely improve the locking policy.
- Dropped "reverts" from the patch titles to prevent them from
auto-backporting by the stable bot based on the title.
- Added r-b from Emil Velikov and placed the drm_WARN in the
drm-shmem patch like he suggested in a comment to v1.
- Corrected drm-shmem patch dma_resv_lock(obj->resv) inconsistently
used with dma_resv_unlock(shmem->base.resv). Now shmem->base.resv
variant is used for all locks/unlocks.
Dmitry Osipenko (6):
media: videobuf2: Don't assert held reservation lock for dma-buf
mmapping
dma-buf/heaps: Don't assert held reservation lock for dma-buf mmapping
udmabuf: Don't assert held reservation lock for dma-buf mmapping
drm: Don't 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 | 210 ++++++++----------
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 -
include/drm/drm_gem_shmem_helper.h | 14 +-
17 files changed, 119 insertions(+), 187 deletions(-)
--
2.40.1
next reply other threads:[~2023-05-29 22:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-29 22:39 Dmitry Osipenko [this message]
2023-05-29 22:39 ` [PATCH v4 1/6] media: videobuf2: Don't assert held reservation lock for dma-buf mmapping Dmitry Osipenko
2023-05-29 22:39 ` [PATCH v4 2/6] dma-buf/heaps: " Dmitry Osipenko
2023-06-21 17:21 ` T.J. Mercier
2023-06-21 18:16 ` Dmitry Osipenko
2023-06-21 19:24 ` T.J. Mercier
2023-05-29 22:39 ` [PATCH v4 3/6] udmabuf: " Dmitry Osipenko
2023-05-29 22:39 ` [PATCH v4 4/6] drm: " Dmitry Osipenko
2023-05-29 22:39 ` [PATCH v4 5/6] dma-buf: Change locking policy for mmap() Dmitry Osipenko
[not found] ` <91466907-d4e1-1619-27a8-a49a01cbc8f1@collabora.com>
2023-06-20 15:58 ` Dmitry Osipenko
2023-06-21 5:42 ` Christian König
2023-06-21 18:17 ` Dmitry Osipenko
2023-05-29 22:39 ` [PATCH v4 6/6] drm/shmem-helper: Switch to reservation lock Dmitry Osipenko
2023-06-26 9:40 ` Boris Brezillon
2023-06-26 9:57 ` Boris Brezillon
2023-06-26 13:05 ` Dmitry Osipenko
2023-06-26 13:05 ` Dmitry Osipenko
2023-06-21 19:13 ` [PATCH v4 0/6] Move dma-buf mmap() reservation locking down to exporters Dmitry Osipenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230529223935.2672495-1-dmitry.osipenko@collabora.com \
--to=dmitry.osipenko@collabora.com \
--cc=Brian.Starkey@arm.com \
--cc=arnd@arndb.de \
--cc=benjamin.gaignard@collabora.com \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=jstultz@google.com \
--cc=kernel@collabora.com \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tfiga@chromium.org \
--cc=thierry.reding@gmail.com \
--cc=tomba@kernel.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).