All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/panthor: fix for dma-fence safe access rules
@ 2025-12-04 17:45 Chia-I Wu
  2025-12-05 12:43 ` Boris Brezillon
  0 siblings, 1 reply; 4+ messages in thread
From: Chia-I Wu @ 2025-12-04 17:45 UTC (permalink / raw)
  To: Boris Brezillon, Steven Price, Liviu Dudau, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Grant Likely, Heiko Stuebner, dri-devel, linux-kernel,
	tvrtko.ursulin

Commit 506aa8b02a8d6 ("dma-fence: Add safe access helpers and document
the rules") details the dma-fence safe access rules. The most common
culprit is that drm_sched_fence_get_timeline_name may race with
group_free_queue.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Reviewed-by: Steven Price <steven.price@arm.com>

---
v2: collect R-bs and drop misleading Fixes: tag
---
 drivers/gpu/drm/panthor/panthor_sched.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
index 33b9ef537e359..a8b1347e4da71 100644
--- a/drivers/gpu/drm/panthor/panthor_sched.c
+++ b/drivers/gpu/drm/panthor/panthor_sched.c
@@ -23,6 +23,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/rcupdate.h>
 
 #include "panthor_devfreq.h"
 #include "panthor_device.h"
@@ -923,6 +924,9 @@ static void group_release_work(struct work_struct *work)
 						   release_work);
 	u32 i;
 
+	/* dma-fences may still be accessing group->queues under rcu lock. */
+	synchronize_rcu();
+
 	for (i = 0; i < group->queue_count; i++)
 		group_free_queue(group, group->queues[i]);
 
-- 
2.52.0.223.gf5cc29aaa4-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm/panthor: fix for dma-fence safe access rules
  2025-12-04 17:45 [PATCH v2] drm/panthor: fix for dma-fence safe access rules Chia-I Wu
@ 2025-12-05 12:43 ` Boris Brezillon
  2025-12-05 18:45   ` Chia-I Wu
  0 siblings, 1 reply; 4+ messages in thread
From: Boris Brezillon @ 2025-12-05 12:43 UTC (permalink / raw)
  To: Chia-I Wu
  Cc: Steven Price, Liviu Dudau, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Grant Likely,
	Heiko Stuebner, dri-devel, linux-kernel, tvrtko.ursulin

On Thu,  4 Dec 2025 09:45:45 -0800
Chia-I Wu <olvaffe@gmail.com> wrote:

> Commit 506aa8b02a8d6 ("dma-fence: Add safe access helpers and document
> the rules") details the dma-fence safe access rules. The most common
> culprit is that drm_sched_fence_get_timeline_name may race with
> group_free_queue.
> 
> Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> Reviewed-by: Steven Price <steven.price@arm.com>
> 
> ---
> v2: collect R-bs and drop misleading Fixes: tag

Should we at least

Cc: stable@vger.kernel.org

so this gets considered for backporting?

> ---
>  drivers/gpu/drm/panthor/panthor_sched.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> index 33b9ef537e359..a8b1347e4da71 100644
> --- a/drivers/gpu/drm/panthor/panthor_sched.c
> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> @@ -23,6 +23,7 @@
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/rcupdate.h>
>  
>  #include "panthor_devfreq.h"
>  #include "panthor_device.h"
> @@ -923,6 +924,9 @@ static void group_release_work(struct work_struct *work)
>  						   release_work);
>  	u32 i;
>  
> +	/* dma-fences may still be accessing group->queues under rcu lock. */
> +	synchronize_rcu();
> +
>  	for (i = 0; i < group->queue_count; i++)
>  		group_free_queue(group, group->queues[i]);
>  


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm/panthor: fix for dma-fence safe access rules
  2025-12-05 12:43 ` Boris Brezillon
@ 2025-12-05 18:45   ` Chia-I Wu
  2025-12-17 15:55     ` Steven Price
  0 siblings, 1 reply; 4+ messages in thread
From: Chia-I Wu @ 2025-12-05 18:45 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Steven Price, Liviu Dudau, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Grant Likely,
	Heiko Stuebner, dri-devel, linux-kernel, tvrtko.ursulin

On Fri, Dec 5, 2025 at 4:43 AM Boris Brezillon
<boris.brezillon@collabora.com> wrote:
>
> On Thu,  4 Dec 2025 09:45:45 -0800
> Chia-I Wu <olvaffe@gmail.com> wrote:
>
> > Commit 506aa8b02a8d6 ("dma-fence: Add safe access helpers and document
> > the rules") details the dma-fence safe access rules. The most common
> > culprit is that drm_sched_fence_get_timeline_name may race with
> > group_free_queue.
> >
> > Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
> > Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
> > Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> > Reviewed-by: Steven Price <steven.price@arm.com>
> >
> > ---
> > v2: collect R-bs and drop misleading Fixes: tag
>
> Should we at least
>
> Cc: stable@vger.kernel.org
>
> so this gets considered for backporting?
This can be considered a follow-up to commit 506aa8b02a8d6. I think

  Cc: stable@vger.kernel.org # v6.17+

is appropriate. (Not sure if I should send v3 or leave it to
maintainers, because I was once told to never add the line and always
leave it to maintainers).

To help make the decision, commit 506aa8b02a8d6 itself narrowed the
race window greatly. This follow-up closes the remaining case where
panthor signals the fence and destroys the group while the consumer
holds the rcu read lock.


>
> > ---
> >  drivers/gpu/drm/panthor/panthor_sched.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> > index 33b9ef537e359..a8b1347e4da71 100644
> > --- a/drivers/gpu/drm/panthor/panthor_sched.c
> > +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> > @@ -23,6 +23,7 @@
> >  #include <linux/module.h>
> >  #include <linux/platform_device.h>
> >  #include <linux/pm_runtime.h>
> > +#include <linux/rcupdate.h>
> >
> >  #include "panthor_devfreq.h"
> >  #include "panthor_device.h"
> > @@ -923,6 +924,9 @@ static void group_release_work(struct work_struct *work)
> >                                                  release_work);
> >       u32 i;
> >
> > +     /* dma-fences may still be accessing group->queues under rcu lock. */
> > +     synchronize_rcu();
> > +
> >       for (i = 0; i < group->queue_count; i++)
> >               group_free_queue(group, group->queues[i]);
> >
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] drm/panthor: fix for dma-fence safe access rules
  2025-12-05 18:45   ` Chia-I Wu
@ 2025-12-17 15:55     ` Steven Price
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Price @ 2025-12-17 15:55 UTC (permalink / raw)
  To: Chia-I Wu, Boris Brezillon
  Cc: Liviu Dudau, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, Grant Likely, Heiko Stuebner,
	dri-devel, linux-kernel, tvrtko.ursulin

On 05/12/2025 18:45, Chia-I Wu wrote:
> On Fri, Dec 5, 2025 at 4:43 AM Boris Brezillon
> <boris.brezillon@collabora.com> wrote:
>>
>> On Thu,  4 Dec 2025 09:45:45 -0800
>> Chia-I Wu <olvaffe@gmail.com> wrote:
>>
>>> Commit 506aa8b02a8d6 ("dma-fence: Add safe access helpers and document
>>> the rules") details the dma-fence safe access rules. The most common
>>> culprit is that drm_sched_fence_get_timeline_name may race with
>>> group_free_queue.
>>>
>>> Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
>>> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
>>> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
>>> Reviewed-by: Steven Price <steven.price@arm.com>
>>>
>>> ---
>>> v2: collect R-bs and drop misleading Fixes: tag
>>
>> Should we at least
>>
>> Cc: stable@vger.kernel.org
>>
>> so this gets considered for backporting?
> This can be considered a follow-up to commit 506aa8b02a8d6. I think
> 
>   Cc: stable@vger.kernel.org # v6.17+
> 
> is appropriate. (Not sure if I should send v3 or leave it to
> maintainers, because I was once told to never add the line and always
> leave it to maintainers).
> 
> To help make the decision, commit 506aa8b02a8d6 itself narrowed the
> race window greatly. This follow-up closes the remaining case where
> panthor signals the fence and destroys the group while the consumer
> holds the rcu read lock.
> 

I've pushed this to drm-misc-next with the Cc tag.

Thanks,
Steve

>>
>>> ---
>>>  drivers/gpu/drm/panthor/panthor_sched.c | 4 ++++
>>>  1 file changed, 4 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
>>> index 33b9ef537e359..a8b1347e4da71 100644
>>> --- a/drivers/gpu/drm/panthor/panthor_sched.c
>>> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
>>> @@ -23,6 +23,7 @@
>>>  #include <linux/module.h>
>>>  #include <linux/platform_device.h>
>>>  #include <linux/pm_runtime.h>
>>> +#include <linux/rcupdate.h>
>>>
>>>  #include "panthor_devfreq.h"
>>>  #include "panthor_device.h"
>>> @@ -923,6 +924,9 @@ static void group_release_work(struct work_struct *work)
>>>                                                  release_work);
>>>       u32 i;
>>>
>>> +     /* dma-fences may still be accessing group->queues under rcu lock. */
>>> +     synchronize_rcu();
>>> +
>>>       for (i = 0; i < group->queue_count; i++)
>>>               group_free_queue(group, group->queues[i]);
>>>
>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-12-17 15:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-04 17:45 [PATCH v2] drm/panthor: fix for dma-fence safe access rules Chia-I Wu
2025-12-05 12:43 ` Boris Brezillon
2025-12-05 18:45   ` Chia-I Wu
2025-12-17 15:55     ` Steven Price

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.