* [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time
@ 2024-05-01 6:55 Adrián Larumbe
2024-05-01 6:55 ` [PATCH v3 1/2] drm/panfrost: " Adrián Larumbe
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Adrián Larumbe @ 2024-05-01 6:55 UTC (permalink / raw)
To: Qiang Yu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter, Boris Brezillon, Rob Herring,
Steven Price, Sumit Semwal, Christian Koenig=, Dmitry Osipenko,
Zack Rusin
Cc: kernel, Adrian Larumbe, dri-devel, lima, linux-kernel,
linux-media, linaro-mm-sig
This is v3 of https://lore.kernel.org/dri-devel/20240424090429.57de7d1c@collabora.com/
The goal of this patch series is fixing a deadlock upon locking the dma reservation
of a DRM gem object when pinning it, at a prime import operation.
Changes from v2:
- Removed comment explaining reason why an already-locked
pin function replaced the locked variant inside Panfrost's
object pin callback.
- Moved already-assigned attachment warning into generic
already-locked gem object pin function
Adrián Larumbe (2):
drm/panfrost: Fix dma_resv deadlock at drm object pin time
drm/gem-shmem: Add import attachment warning to locked pin function
drivers/gpu/drm/drm_gem_shmem_helper.c | 2 ++
drivers/gpu/drm/lima/lima_gem.c | 2 +-
drivers/gpu/drm/panfrost/panfrost_gem.c | 2 +-
3 files changed, 4 insertions(+), 2 deletions(-)
base-commit: 75b68f22e39aafb22f3d8e3071e1aba73560788c
--
2.44.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 1/2] drm/panfrost: Fix dma_resv deadlock at drm object pin time
2024-05-01 6:55 [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time Adrián Larumbe
@ 2024-05-01 6:55 ` Adrián Larumbe
2024-05-02 7:09 ` Boris Brezillon
2024-05-02 11:14 ` Thomas Zimmermann
2024-05-01 6:56 ` [PATCH v3 2/2] drm/gem-shmem: Add import attachment warning to locked pin function Adrián Larumbe
2024-05-02 11:51 ` [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time Thomas Zimmermann
2 siblings, 2 replies; 12+ messages in thread
From: Adrián Larumbe @ 2024-05-01 6:55 UTC (permalink / raw)
To: Qiang Yu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter, Boris Brezillon, Rob Herring,
Steven Price, Sumit Semwal, Christian Koenig=, Dmitry Osipenko,
Zack Rusin
Cc: kernel, Adrian Larumbe, dri-devel, lima, linux-kernel,
linux-media, linaro-mm-sig
When Panfrost must pin an object that is being prepared a dma-buf
attachment for on behalf of another driver, the core drm gem object pinning
code already takes a lock on the object's dma reservation.
However, Panfrost GEM object's pinning callback would eventually try taking
the lock on the same dma reservation when delegating pinning of the object
onto the shmem subsystem, which led to a deadlock.
This can be shown by enabling CONFIG_DEBUG_WW_MUTEX_SLOWPATH, which throws
the following recursive locking situation:
weston/3440 is trying to acquire lock:
ffff000000e235a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: drm_gem_shmem_pin+0x34/0xb8 [drm_shmem_helper]
but task is already holding lock:
ffff000000e235a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: drm_gem_pin+0x2c/0x80 [drm]
Fix it by assuming the object's reservation had already been locked by the
time we reach panfrost_gem_pin.
Do the same thing for the Lima driver, as it most likely suffers from the
same issue.
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Steven Price <steven.price@arm.com>
Fixes: a78027847226 ("drm/gem: Acquire reservation lock in drm_gem_{pin/unpin}()")
Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
---
drivers/gpu/drm/lima/lima_gem.c | 2 +-
drivers/gpu/drm/panfrost/panfrost_gem.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c
index 7ea244d876ca..c4e0f9faaa47 100644
--- a/drivers/gpu/drm/lima/lima_gem.c
+++ b/drivers/gpu/drm/lima/lima_gem.c
@@ -185,7 +185,7 @@ static int lima_gem_pin(struct drm_gem_object *obj)
if (bo->heap_size)
return -EINVAL;
- return drm_gem_shmem_pin(&bo->base);
+ return drm_gem_shmem_object_pin(obj);
}
static int lima_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
index d47b40b82b0b..f268bd5c2884 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gem.c
+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
@@ -192,7 +192,7 @@ static int panfrost_gem_pin(struct drm_gem_object *obj)
if (bo->is_heap)
return -EINVAL;
- return drm_gem_shmem_pin(&bo->base);
+ return drm_gem_shmem_object_pin(obj);
}
static enum drm_gem_object_status panfrost_gem_status(struct drm_gem_object *obj)
--
2.44.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3 2/2] drm/gem-shmem: Add import attachment warning to locked pin function
2024-05-01 6:55 [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time Adrián Larumbe
2024-05-01 6:55 ` [PATCH v3 1/2] drm/panfrost: " Adrián Larumbe
@ 2024-05-01 6:56 ` Adrián Larumbe
2024-05-02 7:01 ` Boris Brezillon
2024-05-02 11:51 ` [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time Thomas Zimmermann
2 siblings, 1 reply; 12+ messages in thread
From: Adrián Larumbe @ 2024-05-01 6:56 UTC (permalink / raw)
To: Qiang Yu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter, Boris Brezillon, Rob Herring,
Steven Price, Sumit Semwal, Christian Koenig=, Dmitry Osipenko,
Zack Rusin
Cc: kernel, Adrian Larumbe, dri-devel, lima, linux-kernel,
linux-media, linaro-mm-sig
Commit ec144244a43f ("drm/gem-shmem: Acquire reservation lock in GEM
pin/unpin callbacks") moved locking DRM object's dma reservation to
drm_gem_shmem_object_pin, and made drm_gem_shmem_pin_locked public, so we
need to make sure the non-NULL check warning is also added to the latter.
Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
---
drivers/gpu/drm/drm_gem_shmem_helper.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index 177773bcdbfd..ad5d9f704e15 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -233,6 +233,8 @@ int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem)
dma_resv_assert_held(shmem->base.resv);
+ drm_WARN_ON(shmem->base.dev, shmem->base.import_attach);
+
ret = drm_gem_shmem_get_pages(shmem);
return ret;
--
2.44.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] drm/gem-shmem: Add import attachment warning to locked pin function
2024-05-01 6:56 ` [PATCH v3 2/2] drm/gem-shmem: Add import attachment warning to locked pin function Adrián Larumbe
@ 2024-05-02 7:01 ` Boris Brezillon
0 siblings, 0 replies; 12+ messages in thread
From: Boris Brezillon @ 2024-05-02 7:01 UTC (permalink / raw)
To: Adrián Larumbe
Cc: Qiang Yu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter, Rob Herring, Steven Price,
Sumit Semwal, Christian Koenig=, Dmitry Osipenko, Zack Rusin,
kernel, dri-devel, lima, linux-kernel, linux-media, linaro-mm-sig
On Wed, 1 May 2024 07:56:00 +0100
Adrián Larumbe <adrian.larumbe@collabora.com> wrote:
> Commit ec144244a43f ("drm/gem-shmem: Acquire reservation lock in GEM
> pin/unpin callbacks") moved locking DRM object's dma reservation to
> drm_gem_shmem_object_pin, and made drm_gem_shmem_pin_locked public, so we
> need to make sure the non-NULL check warning is also added to the latter.
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
> ---
> drivers/gpu/drm/drm_gem_shmem_helper.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index 177773bcdbfd..ad5d9f704e15 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -233,6 +233,8 @@ int drm_gem_shmem_pin_locked(struct drm_gem_shmem_object *shmem)
>
> dma_resv_assert_held(shmem->base.resv);
>
> + drm_WARN_ON(shmem->base.dev, shmem->base.import_attach);
If we add a WARN_ON() here, we can probably drop the one in
drm_gem_shmem_pin(), and do the same for drm_gem_shmem_unpin[_locked]()
to keep things consistent.
> +
> ret = drm_gem_shmem_get_pages(shmem);
>
> return ret;
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] drm/panfrost: Fix dma_resv deadlock at drm object pin time
2024-05-01 6:55 ` [PATCH v3 1/2] drm/panfrost: " Adrián Larumbe
@ 2024-05-02 7:09 ` Boris Brezillon
2024-05-02 11:14 ` Thomas Zimmermann
1 sibling, 0 replies; 12+ messages in thread
From: Boris Brezillon @ 2024-05-02 7:09 UTC (permalink / raw)
To: Adrián Larumbe
Cc: Qiang Yu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Daniel Vetter, Rob Herring, Steven Price,
Sumit Semwal, Christian Koenig=, Dmitry Osipenko, Zack Rusin,
kernel, dri-devel, lima, linux-kernel, linux-media, linaro-mm-sig
On Wed, 1 May 2024 07:55:59 +0100
Adrián Larumbe <adrian.larumbe@collabora.com> wrote:
> When Panfrost must pin an object that is being prepared a dma-buf
> attachment for on behalf of another driver, the core drm gem object pinning
> code already takes a lock on the object's dma reservation.
>
> However, Panfrost GEM object's pinning callback would eventually try taking
> the lock on the same dma reservation when delegating pinning of the object
> onto the shmem subsystem, which led to a deadlock.
>
> This can be shown by enabling CONFIG_DEBUG_WW_MUTEX_SLOWPATH, which throws
> the following recursive locking situation:
>
> weston/3440 is trying to acquire lock:
> ffff000000e235a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: drm_gem_shmem_pin+0x34/0xb8 [drm_shmem_helper]
> but task is already holding lock:
> ffff000000e235a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: drm_gem_pin+0x2c/0x80 [drm]
>
> Fix it by assuming the object's reservation had already been locked by the
> time we reach panfrost_gem_pin.
You should probably mention that drm_gem_shmem_object_pin() assumes the
lock to be held, thus explaining the drm_gem_shmem_pin() ->
drm_gem_shmem_object_pin() transition.
Oh, and the commit message refers explicitly to Panfrost in a few places
even though you're fixing Lima as well.
>
> Do the same thing for the Lima driver, as it most likely suffers from the
> same issue.
>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> Cc: Boris Brezillon <boris.brezillon@collabora.com>
> Cc: Steven Price <steven.price@arm.com>
> Fixes: a78027847226 ("drm/gem: Acquire reservation lock in drm_gem_{pin/unpin}()")
> Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
With the commit message adjusted as suggested,
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
> drivers/gpu/drm/lima/lima_gem.c | 2 +-
> drivers/gpu/drm/panfrost/panfrost_gem.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c
> index 7ea244d876ca..c4e0f9faaa47 100644
> --- a/drivers/gpu/drm/lima/lima_gem.c
> +++ b/drivers/gpu/drm/lima/lima_gem.c
> @@ -185,7 +185,7 @@ static int lima_gem_pin(struct drm_gem_object *obj)
> if (bo->heap_size)
> return -EINVAL;
>
> - return drm_gem_shmem_pin(&bo->base);
> + return drm_gem_shmem_object_pin(obj);
> }
>
> static int lima_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
> diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
> index d47b40b82b0b..f268bd5c2884 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_gem.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
> @@ -192,7 +192,7 @@ static int panfrost_gem_pin(struct drm_gem_object *obj)
> if (bo->is_heap)
> return -EINVAL;
>
> - return drm_gem_shmem_pin(&bo->base);
> + return drm_gem_shmem_object_pin(obj);
> }
>
> static enum drm_gem_object_status panfrost_gem_status(struct drm_gem_object *obj)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] drm/panfrost: Fix dma_resv deadlock at drm object pin time
2024-05-01 6:55 ` [PATCH v3 1/2] drm/panfrost: " Adrián Larumbe
2024-05-02 7:09 ` Boris Brezillon
@ 2024-05-02 11:14 ` Thomas Zimmermann
1 sibling, 0 replies; 12+ messages in thread
From: Thomas Zimmermann @ 2024-05-02 11:14 UTC (permalink / raw)
To: Adrián Larumbe, Qiang Yu, Maarten Lankhorst, Maxime Ripard,
David Airlie, Daniel Vetter, Boris Brezillon, Rob Herring,
Steven Price, Sumit Semwal, Christian Koenig=, Dmitry Osipenko,
Zack Rusin
Cc: kernel, dri-devel, lima, linux-kernel, linux-media, linaro-mm-sig
Hi
Am 01.05.24 um 08:55 schrieb Adrián Larumbe:
> When Panfrost must pin an object that is being prepared a dma-buf
> attachment for on behalf of another driver, the core drm gem object pinning
> code already takes a lock on the object's dma reservation.
>
> However, Panfrost GEM object's pinning callback would eventually try taking
> the lock on the same dma reservation when delegating pinning of the object
> onto the shmem subsystem, which led to a deadlock.
>
> This can be shown by enabling CONFIG_DEBUG_WW_MUTEX_SLOWPATH, which throws
> the following recursive locking situation:
>
> weston/3440 is trying to acquire lock:
> ffff000000e235a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: drm_gem_shmem_pin+0x34/0xb8 [drm_shmem_helper]
> but task is already holding lock:
> ffff000000e235a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: drm_gem_pin+0x2c/0x80 [drm]
>
> Fix it by assuming the object's reservation had already been locked by the
> time we reach panfrost_gem_pin.
Maybe say that the reservation lock has been taken in drm_gem_pin()
>
> Do the same thing for the Lima driver, as it most likely suffers from the
> same issue.
Please split this patch into one for panfrost and one for lima. To each
patch, you can add
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Best regards
Thomas
>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> Cc: Boris Brezillon <boris.brezillon@collabora.com>
> Cc: Steven Price <steven.price@arm.com>
> Fixes: a78027847226 ("drm/gem: Acquire reservation lock in drm_gem_{pin/unpin}()")
> Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
> ---
> drivers/gpu/drm/lima/lima_gem.c | 2 +-
> drivers/gpu/drm/panfrost/panfrost_gem.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c
> index 7ea244d876ca..c4e0f9faaa47 100644
> --- a/drivers/gpu/drm/lima/lima_gem.c
> +++ b/drivers/gpu/drm/lima/lima_gem.c
> @@ -185,7 +185,7 @@ static int lima_gem_pin(struct drm_gem_object *obj)
> if (bo->heap_size)
> return -EINVAL;
>
> - return drm_gem_shmem_pin(&bo->base);
> + return drm_gem_shmem_object_pin(obj);
> }
>
> static int lima_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
> diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
> index d47b40b82b0b..f268bd5c2884 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_gem.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
> @@ -192,7 +192,7 @@ static int panfrost_gem_pin(struct drm_gem_object *obj)
> if (bo->is_heap)
> return -EINVAL;
>
> - return drm_gem_shmem_pin(&bo->base);
> + return drm_gem_shmem_object_pin(obj);
> }
>
> static enum drm_gem_object_status panfrost_gem_status(struct drm_gem_object *obj)
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time
2024-05-01 6:55 [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time Adrián Larumbe
2024-05-01 6:55 ` [PATCH v3 1/2] drm/panfrost: " Adrián Larumbe
2024-05-01 6:56 ` [PATCH v3 2/2] drm/gem-shmem: Add import attachment warning to locked pin function Adrián Larumbe
@ 2024-05-02 11:51 ` Thomas Zimmermann
2024-05-02 11:59 ` Boris Brezillon
2 siblings, 1 reply; 12+ messages in thread
From: Thomas Zimmermann @ 2024-05-02 11:51 UTC (permalink / raw)
To: Adrián Larumbe, Qiang Yu, Maarten Lankhorst, Maxime Ripard,
David Airlie, Daniel Vetter, Boris Brezillon, Rob Herring,
Steven Price, Sumit Semwal, Christian Koenig=, Dmitry Osipenko,
Zack Rusin
Cc: kernel, dri-devel, lima, linux-kernel, linux-media, linaro-mm-sig
Hi,
ignoring my r-b on patch 1, I'd like to rethink the current patches in
general.
I think drm_gem_shmem_pin() should become the locked version of _pin(),
so that drm_gem_shmem_object_pin() can call it directly. The existing
_pin_unlocked() would not be needed any longer. Same for the _unpin()
functions. This change would also fix the consistency with the semantics
of the shmem _vmap() functions, which never take reservation locks.
There are only two external callers of drm_gem_shmem_pin(): the test
case and panthor. These assume that drm_gem_shmem_pin() acquires the
reservation lock. The test case should likely call drm_gem_pin()
instead. That would acquire the reservation lock and the test would
validate that shmem's pin helper integrates well into the overall GEM
framework. The way panthor uses drm_gem_shmem_pin() looks wrong to me.
For now, it could receive a wrapper that takes the lock and that's it.
Best regards
Thomas
Am 01.05.24 um 08:55 schrieb Adrián Larumbe:
> This is v3 of https://lore.kernel.org/dri-devel/20240424090429.57de7d1c@collabora.com/
>
> The goal of this patch series is fixing a deadlock upon locking the dma reservation
> of a DRM gem object when pinning it, at a prime import operation.
>
> Changes from v2:
> - Removed comment explaining reason why an already-locked
> pin function replaced the locked variant inside Panfrost's
> object pin callback.
> - Moved already-assigned attachment warning into generic
> already-locked gem object pin function
>
> Adrián Larumbe (2):
> drm/panfrost: Fix dma_resv deadlock at drm object pin time
> drm/gem-shmem: Add import attachment warning to locked pin function
>
> drivers/gpu/drm/drm_gem_shmem_helper.c | 2 ++
> drivers/gpu/drm/lima/lima_gem.c | 2 +-
> drivers/gpu/drm/panfrost/panfrost_gem.c | 2 +-
> 3 files changed, 4 insertions(+), 2 deletions(-)
>
>
> base-commit: 75b68f22e39aafb22f3d8e3071e1aba73560788c
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time
2024-05-02 11:51 ` [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time Thomas Zimmermann
@ 2024-05-02 11:59 ` Boris Brezillon
2024-05-02 12:00 ` Boris Brezillon
0 siblings, 1 reply; 12+ messages in thread
From: Boris Brezillon @ 2024-05-02 11:59 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: Adrián Larumbe, Qiang Yu, Maarten Lankhorst, Maxime Ripard,
David Airlie, Daniel Vetter, Rob Herring, Steven Price,
Sumit Semwal, Christian Koenig=, Dmitry Osipenko, Zack Rusin,
kernel, dri-devel, lima, linux-kernel, linux-media, linaro-mm-sig
Hi Thomas,
On Thu, 2 May 2024 13:51:16 +0200
Thomas Zimmermann <tzimmermann@suse.de> wrote:
> Hi,
>
> ignoring my r-b on patch 1, I'd like to rethink the current patches in
> general.
>
> I think drm_gem_shmem_pin() should become the locked version of _pin(),
> so that drm_gem_shmem_object_pin() can call it directly. The existing
> _pin_unlocked() would not be needed any longer. Same for the _unpin()
> functions. This change would also fix the consistency with the semantics
> of the shmem _vmap() functions, which never take reservation locks.
>
> There are only two external callers of drm_gem_shmem_pin(): the test
> case and panthor. These assume that drm_gem_shmem_pin() acquires the
> reservation lock. The test case should likely call drm_gem_pin()
> instead. That would acquire the reservation lock and the test would
> validate that shmem's pin helper integrates well into the overall GEM
> framework. The way panthor uses drm_gem_shmem_pin() looks wrong to me.
> For now, it could receive a wrapper that takes the lock and that's it.
I do agree that the current inconsistencies in the naming is
troublesome (sometimes _unlocked, sometimes _locked, with the version
without any suffix meaning either _locked or _unlocked depending on
what the suffixed version does), and that's the very reason I asked
Dmitry to address that in his shrinker series [1]. So, ideally I'd
prefer if patches from Dmitry's series were applied instead of
trying to fix that here (IIRC, we had an ack from Maxime).
Regards,
Boris
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time
2024-05-02 11:59 ` Boris Brezillon
@ 2024-05-02 12:00 ` Boris Brezillon
2024-05-02 12:18 ` Thomas Zimmermann
0 siblings, 1 reply; 12+ messages in thread
From: Boris Brezillon @ 2024-05-02 12:00 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: Adrián Larumbe, Qiang Yu, Maarten Lankhorst, Maxime Ripard,
David Airlie, Daniel Vetter, Rob Herring, Steven Price,
Sumit Semwal, Christian Koenig=, Dmitry Osipenko, Zack Rusin,
kernel, dri-devel, lima, linux-kernel, linux-media, linaro-mm-sig
On Thu, 2 May 2024 13:59:41 +0200
Boris Brezillon <boris.brezillon@collabora.com> wrote:
> Hi Thomas,
>
> On Thu, 2 May 2024 13:51:16 +0200
> Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> > Hi,
> >
> > ignoring my r-b on patch 1, I'd like to rethink the current patches in
> > general.
> >
> > I think drm_gem_shmem_pin() should become the locked version of _pin(),
> > so that drm_gem_shmem_object_pin() can call it directly. The existing
> > _pin_unlocked() would not be needed any longer. Same for the _unpin()
> > functions. This change would also fix the consistency with the semantics
> > of the shmem _vmap() functions, which never take reservation locks.
> >
> > There are only two external callers of drm_gem_shmem_pin(): the test
> > case and panthor. These assume that drm_gem_shmem_pin() acquires the
> > reservation lock. The test case should likely call drm_gem_pin()
> > instead. That would acquire the reservation lock and the test would
> > validate that shmem's pin helper integrates well into the overall GEM
> > framework. The way panthor uses drm_gem_shmem_pin() looks wrong to me.
> > For now, it could receive a wrapper that takes the lock and that's it.
>
> I do agree that the current inconsistencies in the naming is
> troublesome (sometimes _unlocked, sometimes _locked, with the version
> without any suffix meaning either _locked or _unlocked depending on
> what the suffixed version does), and that's the very reason I asked
> Dmitry to address that in his shrinker series [1]. So, ideally I'd
> prefer if patches from Dmitry's series were applied instead of
> trying to fix that here (IIRC, we had an ack from Maxime).
With the link this time :-).
[1]https://lore.kernel.org/lkml/20240105184624.508603-1-dmitry.osipenko@collabora.com/T/
>
> Regards,
>
> Boris
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time
2024-05-02 12:00 ` Boris Brezillon
@ 2024-05-02 12:18 ` Thomas Zimmermann
2024-05-17 18:16 ` Adrián Larumbe
0 siblings, 1 reply; 12+ messages in thread
From: Thomas Zimmermann @ 2024-05-02 12:18 UTC (permalink / raw)
To: Boris Brezillon
Cc: Adrián Larumbe, Qiang Yu, Maarten Lankhorst, Maxime Ripard,
David Airlie, Daniel Vetter, Rob Herring, Steven Price,
Sumit Semwal, Christian Koenig=, Dmitry Osipenko, Zack Rusin,
kernel, dri-devel, lima, linux-kernel, linux-media, linaro-mm-sig
Hi
Am 02.05.24 um 14:00 schrieb Boris Brezillon:
> On Thu, 2 May 2024 13:59:41 +0200
> Boris Brezillon <boris.brezillon@collabora.com> wrote:
>
>> Hi Thomas,
>>
>> On Thu, 2 May 2024 13:51:16 +0200
>> Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>
>>> Hi,
>>>
>>> ignoring my r-b on patch 1, I'd like to rethink the current patches in
>>> general.
>>>
>>> I think drm_gem_shmem_pin() should become the locked version of _pin(),
>>> so that drm_gem_shmem_object_pin() can call it directly. The existing
>>> _pin_unlocked() would not be needed any longer. Same for the _unpin()
>>> functions. This change would also fix the consistency with the semantics
>>> of the shmem _vmap() functions, which never take reservation locks.
>>>
>>> There are only two external callers of drm_gem_shmem_pin(): the test
>>> case and panthor. These assume that drm_gem_shmem_pin() acquires the
>>> reservation lock. The test case should likely call drm_gem_pin()
>>> instead. That would acquire the reservation lock and the test would
>>> validate that shmem's pin helper integrates well into the overall GEM
>>> framework. The way panthor uses drm_gem_shmem_pin() looks wrong to me.
>>> For now, it could receive a wrapper that takes the lock and that's it.
>> I do agree that the current inconsistencies in the naming is
>> troublesome (sometimes _unlocked, sometimes _locked, with the version
>> without any suffix meaning either _locked or _unlocked depending on
>> what the suffixed version does), and that's the very reason I asked
>> Dmitry to address that in his shrinker series [1]. So, ideally I'd
>> prefer if patches from Dmitry's series were applied instead of
>> trying to fix that here (IIRC, we had an ack from Maxime).
> With the link this time :-).
>
> [1]https://lore.kernel.org/lkml/20240105184624.508603-1-dmitry.osipenko@collabora.com/T/
Thanks. I remember these patches. Somehow I thought they would have been
merged already. I wasn't super happy about the naming changes in patch
5, because the names of the GEM object callbacks do no longer correspond
with their implementations. But anyway.
If we go that direction, we should here simply push drm_gem_shmem_pin()
and drm_gem_shmem_unpin() into panthor and update the shmem tests with
drm_gem_pin(). Panfrost and lima would call drm_gem_shmem_pin_locked().
IMHO we should not promote the use of drm_gem_shmem_object_*()
functions, as they are meant to be callbacks for struct
drm_gem_object_funcs. (Auto-generating them would be nice.)
Best regards
Thomas
>
>> Regards,
>>
>> Boris
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time
2024-05-02 12:18 ` Thomas Zimmermann
@ 2024-05-17 18:16 ` Adrián Larumbe
2024-05-21 16:18 ` Boris Brezillon
0 siblings, 1 reply; 12+ messages in thread
From: Adrián Larumbe @ 2024-05-17 18:16 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: Boris Brezillon, Qiang Yu, Maarten Lankhorst, Maxime Ripard,
David Airlie, Daniel Vetter, Rob Herring, Steven Price,
Sumit Semwal, Christian Koenig=, Dmitry Osipenko, Zack Rusin,
kernel, dri-devel, lima, linux-kernel, linux-media, linaro-mm-sig
Hi Boris and Thomas,
On 02.05.2024 14:18, Thomas Zimmermann wrote:
> Hi
>
> Am 02.05.24 um 14:00 schrieb Boris Brezillon:
> > On Thu, 2 May 2024 13:59:41 +0200
> > Boris Brezillon <boris.brezillon@collabora.com> wrote:
> >
> > > Hi Thomas,
> > >
> > > On Thu, 2 May 2024 13:51:16 +0200
> > > Thomas Zimmermann <tzimmermann@suse.de> wrote:
> > >
> > > > Hi,
> > > >
> > > > ignoring my r-b on patch 1, I'd like to rethink the current patches in
> > > > general.
> > > >
> > > > I think drm_gem_shmem_pin() should become the locked version of _pin(),
> > > > so that drm_gem_shmem_object_pin() can call it directly. The existing
> > > > _pin_unlocked() would not be needed any longer. Same for the _unpin()
> > > > functions. This change would also fix the consistency with the semantics
> > > > of the shmem _vmap() functions, which never take reservation locks.
> > > >
> > > > There are only two external callers of drm_gem_shmem_pin(): the test
> > > > case and panthor. These assume that drm_gem_shmem_pin() acquires the
> > > > reservation lock. The test case should likely call drm_gem_pin()
> > > > instead. That would acquire the reservation lock and the test would
> > > > validate that shmem's pin helper integrates well into the overall GEM
> > > > framework. The way panthor uses drm_gem_shmem_pin() looks wrong to me.
> > > > For now, it could receive a wrapper that takes the lock and that's it.
> > > I do agree that the current inconsistencies in the naming is
> > > troublesome (sometimes _unlocked, sometimes _locked, with the version
> > > without any suffix meaning either _locked or _unlocked depending on
> > > what the suffixed version does), and that's the very reason I asked
> > > Dmitry to address that in his shrinker series [1]. So, ideally I'd
> > > prefer if patches from Dmitry's series were applied instead of
> > > trying to fix that here (IIRC, we had an ack from Maxime).
> > With the link this time :-).
> >
> > [1]https://lore.kernel.org/lkml/20240105184624.508603-1-dmitry.osipenko@collabora.com/T/
>
> Thanks. I remember these patches. Somehow I thought they would have been
> merged already. I wasn't super happy about the naming changes in patch 5,
> because the names of the GEM object callbacks do no longer correspond with
> their implementations. But anyway.
>
> If we go that direction, we should here simply push drm_gem_shmem_pin() and
> drm_gem_shmem_unpin() into panthor and update the shmem tests with
> drm_gem_pin(). Panfrost and lima would call drm_gem_shmem_pin_locked(). IMHO
> we should not promote the use of drm_gem_shmem_object_*() functions, as they
> are meant to be callbacks for struct drm_gem_object_funcs. (Auto-generating
> them would be nice.)
I'll be doing this in the next patch series iteration, casting the pin function's
drm object parameter to an shmem object.
Also for the sake of leaving things in a consistent state, and against Boris' advice,
I think I'll leave the drm WARN statement inside drm_gem_shmem_pin_locked. I guess
even though Dmitry's working on it, rebasing his work on top of this minor change
shouldn't be an issue.
Cheers,
Adrian Larumbe
> Best regards
> Thomas
>
>
> >
> > > Regards,
> > >
> > > Boris
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time
2024-05-17 18:16 ` Adrián Larumbe
@ 2024-05-21 16:18 ` Boris Brezillon
0 siblings, 0 replies; 12+ messages in thread
From: Boris Brezillon @ 2024-05-21 16:18 UTC (permalink / raw)
To: Adrián Larumbe
Cc: Thomas Zimmermann, Qiang Yu, Maarten Lankhorst, Maxime Ripard,
David Airlie, Daniel Vetter, Rob Herring, Steven Price,
Sumit Semwal, Christian Koenig=, Dmitry Osipenko, Zack Rusin,
kernel, dri-devel, lima, linux-kernel, linux-media, linaro-mm-sig
On Fri, 17 May 2024 19:16:21 +0100
Adrián Larumbe <adrian.larumbe@collabora.com> wrote:
> Hi Boris and Thomas,
>
> On 02.05.2024 14:18, Thomas Zimmermann wrote:
> > Hi
> >
> > Am 02.05.24 um 14:00 schrieb Boris Brezillon:
> > > On Thu, 2 May 2024 13:59:41 +0200
> > > Boris Brezillon <boris.brezillon@collabora.com> wrote:
> > >
> > > > Hi Thomas,
> > > >
> > > > On Thu, 2 May 2024 13:51:16 +0200
> > > > Thomas Zimmermann <tzimmermann@suse.de> wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > ignoring my r-b on patch 1, I'd like to rethink the current patches in
> > > > > general.
> > > > >
> > > > > I think drm_gem_shmem_pin() should become the locked version of _pin(),
> > > > > so that drm_gem_shmem_object_pin() can call it directly. The existing
> > > > > _pin_unlocked() would not be needed any longer. Same for the _unpin()
> > > > > functions. This change would also fix the consistency with the semantics
> > > > > of the shmem _vmap() functions, which never take reservation locks.
> > > > >
> > > > > There are only two external callers of drm_gem_shmem_pin(): the test
> > > > > case and panthor. These assume that drm_gem_shmem_pin() acquires the
> > > > > reservation lock. The test case should likely call drm_gem_pin()
> > > > > instead. That would acquire the reservation lock and the test would
> > > > > validate that shmem's pin helper integrates well into the overall GEM
> > > > > framework. The way panthor uses drm_gem_shmem_pin() looks wrong to me.
> > > > > For now, it could receive a wrapper that takes the lock and that's it.
> > > > I do agree that the current inconsistencies in the naming is
> > > > troublesome (sometimes _unlocked, sometimes _locked, with the version
> > > > without any suffix meaning either _locked or _unlocked depending on
> > > > what the suffixed version does), and that's the very reason I asked
> > > > Dmitry to address that in his shrinker series [1]. So, ideally I'd
> > > > prefer if patches from Dmitry's series were applied instead of
> > > > trying to fix that here (IIRC, we had an ack from Maxime).
> > > With the link this time :-).
> > >
> > > [1]https://lore.kernel.org/lkml/20240105184624.508603-1-dmitry.osipenko@collabora.com/T/
> >
> > Thanks. I remember these patches. Somehow I thought they would have been
> > merged already. I wasn't super happy about the naming changes in patch 5,
> > because the names of the GEM object callbacks do no longer correspond with
> > their implementations. But anyway.
> >
> > If we go that direction, we should here simply push drm_gem_shmem_pin() and
> > drm_gem_shmem_unpin() into panthor and update the shmem tests with
> > drm_gem_pin(). Panfrost and lima would call drm_gem_shmem_pin_locked(). IMHO
> > we should not promote the use of drm_gem_shmem_object_*() functions, as they
> > are meant to be callbacks for struct drm_gem_object_funcs. (Auto-generating
> > them would be nice.)
>
> I'll be doing this in the next patch series iteration, casting the pin function's
> drm object parameter to an shmem object.
>
> Also for the sake of leaving things in a consistent state, and against Boris' advice,
> I think I'll leave the drm WARN statement inside drm_gem_shmem_pin_locked.
Sure, that's fine.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-05-21 16:18 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-01 6:55 [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time Adrián Larumbe
2024-05-01 6:55 ` [PATCH v3 1/2] drm/panfrost: " Adrián Larumbe
2024-05-02 7:09 ` Boris Brezillon
2024-05-02 11:14 ` Thomas Zimmermann
2024-05-01 6:56 ` [PATCH v3 2/2] drm/gem-shmem: Add import attachment warning to locked pin function Adrián Larumbe
2024-05-02 7:01 ` Boris Brezillon
2024-05-02 11:51 ` [PATCH v3 0/2] drm: Fix dma_resv deadlock at drm object pin time Thomas Zimmermann
2024-05-02 11:59 ` Boris Brezillon
2024-05-02 12:00 ` Boris Brezillon
2024-05-02 12:18 ` Thomas Zimmermann
2024-05-17 18:16 ` Adrián Larumbe
2024-05-21 16:18 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox