From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: "Daniel Almeida" <daniel.almeida@collabora.com>,
dri-devel@lists.freedesktop.org,
virtualization@lists.linux-foundation.org,
"Gerd Hoffmann" <kraxel@redhat.com>,
kernel@collabora.com, "David Airlie" <airlied@gmail.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Rob Herring" <robh@kernel.org>,
"Daniel Stone" <daniel@fooishbar.org>,
"Steven Price" <steven.price@arm.com>,
"Gustavo Padovan" <gustavo.padovan@collabora.com>,
"Alyssa Rosenzweig" <alyssa.rosenzweig@collabora.com>,
"Chia-I Wu" <olvaffe@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
intel-gfx@lists.freedesktop.org,
"Maxime Ripard" <mripard@kernel.org>,
"Gurchetan Singh" <gurchetansingh@chromium.org>,
linux-kernel@vger.kernel.org, "Qiang Yu" <yuq825@gmail.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Christian König" <christian.koenig@amd.com>
Subject: Re: [Intel-gfx] [PATCH v13 01/10] drm/shmem-helper: Switch to reservation lock
Date: Sun, 26 Mar 2023 11:19:26 +0200 [thread overview]
Message-ID: <2631edac-a57e-638d-226c-08ea3d9b6b8d@gmail.com> (raw)
In-Reply-To: <20c88807-8513-a816-aed9-5cd67eb5c1ed@collabora.com>
Am 25.03.23 um 15:58 schrieb Dmitry Osipenko:
> On 3/15/23 16:46, Dmitry Osipenko wrote:
>> On 3/14/23 05:26, Dmitry Osipenko wrote:
>>> @@ -633,7 +605,10 @@ int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct
>>> return ret;
>>> }
>>>
>>> + dma_resv_lock(shmem->base.resv, NULL);
>>> ret = drm_gem_shmem_get_pages(shmem);
>>> + dma_resv_unlock(shmem->base.resv);
>> Intel CI reported locking problem [1] here. It actually was also
>> reported for v12, but I missed that report because of the other noisy
>> reports.
>>
>> [1]
>> https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_114671v2/shard-snb5/igt@prime_vgem@sync@rcs0.html
>>
>> The test does the following:
>>
>> 1. creates vgem
>> 2. export it do dmabuf
>> 3. mmaps dmabuf
>>
>> There is an obvious deadlock there. The DRM code assumes that mmap() is
>> unlocked, while for dma-buf it's locked. I'll see how to fix it for v14.
>>
> Christian, there is a deadlock problem in drm_gem_shmem_mmap() once we
> move drm-shmem to use resv lock. The current dma-buf locking policy
> claims that importer holds the lock for mmap(), but DRM code assumes
> that obj->mmap() handles the locking itself and then the same
> obj->mmap() code path is used by both dma-buf DRM and a usual DRM object
> paths. Hence importer -> dma_buf_mmap_internal()[takes the lock] ->
> exporter -> drm_gem_shmem_mmap()[takes the lock] deadlocks.
>
> I was looking at how to fix it and to me the best option is to change
> the dma-buf locking policy, making exporter responsible for handling the
> resv lock. Changing DRM code mmap lockings might be possible too [moving
> locking to drm_gem_mmap_obj()], but will be very messy and doesn't feel
> intuitive.
>
> Want to get yours thoughts on this before sending out the dma-buf mmap()
> policy-change patch. Does the new mmap() locking policy sound good to
> you? Thanks!
IIRC we tried that before and ran into problems.
dma_buf_mmap() needs to swap the backing file of the VMA and for this
calls fput() on the old file.
This fput() in turn could (in theory) grab the resv lock as well and
there isn't anything we could do about that.
Just information from the back of my memory, probably best if you double
check that.
Regards,
Christian.
next prev parent reply other threads:[~2023-03-26 9:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-14 2:26 [Intel-gfx] [PATCH v13 00/10] Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers Dmitry Osipenko
2023-03-14 2:26 ` [Intel-gfx] [PATCH v13 01/10] drm/shmem-helper: Switch to reservation lock Dmitry Osipenko
2023-03-15 13:46 ` Dmitry Osipenko
2023-03-25 14:58 ` Dmitry Osipenko
2023-03-26 9:19 ` Christian König [this message]
2023-04-02 14:54 ` Dmitry Osipenko
2023-03-14 2:26 ` [Intel-gfx] [PATCH v13 02/10] drm/shmem-helper: Factor out pages alloc/release from drm_gem_shmem_get/put_pages() Dmitry Osipenko
2023-03-14 2:26 ` [Intel-gfx] [PATCH v13 03/10] drm/shmem-helper: Add pages_pin_count field Dmitry Osipenko
2023-06-26 15:04 ` Boris Brezillon
2023-06-26 15:21 ` Boris Brezillon
2023-06-26 15:32 ` Dmitry Osipenko
2023-03-14 2:26 ` [Intel-gfx] [PATCH v13 04/10] drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin Dmitry Osipenko
2023-03-14 2:26 ` [Intel-gfx] [PATCH v13 05/10] drm/shmem-helper: Factor out unpinning part from drm_gem_shmem_purge() Dmitry Osipenko
2023-03-14 2:26 ` [Intel-gfx] [PATCH v13 06/10] drm/shmem-helper: Add memory shrinker Dmitry Osipenko
2023-03-14 2:26 ` [Intel-gfx] [PATCH v13 07/10] drm/shmem-helper: Remove obsoleted is_iomem test Dmitry Osipenko
2023-03-14 2:26 ` [Intel-gfx] [PATCH v13 08/10] drm/shmem-helper: Export drm_gem_shmem_get_pages_sgt_locked() Dmitry Osipenko
2023-03-14 2:26 ` [Intel-gfx] [PATCH v13 09/10] drm/virtio: Support memory shrinking Dmitry Osipenko
2023-03-14 2:26 ` [Intel-gfx] [PATCH v13 10/10] drm/panfrost: Switch to generic memory shrinker Dmitry Osipenko
2023-03-14 2:49 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for Add generic memory shrinker to VirtIO-GPU and Panfrost DRM drivers (rev2) Patchwork
2023-03-14 3:08 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-03-15 7:44 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
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=2631edac-a57e-638d-226c-08ea3d9b6b8d@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=airlied@gmail.com \
--cc=alyssa.rosenzweig@collabora.com \
--cc=christian.koenig@amd.com \
--cc=daniel.almeida@collabora.com \
--cc=daniel@ffwll.ch \
--cc=daniel@fooishbar.org \
--cc=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gurchetansingh@chromium.org \
--cc=gustavo.padovan@collabora.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=kernel@collabora.com \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@kernel.org \
--cc=olvaffe@gmail.com \
--cc=robh@kernel.org \
--cc=steven.price@arm.com \
--cc=sumit.semwal@linaro.org \
--cc=tzimmermann@suse.de \
--cc=virtualization@lists.linux-foundation.org \
--cc=yuq825@gmail.com \
/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