drm/panthor: fix for dma-fence safe access rules
Subsystems (3)
PATCH v2 1/1 drm/panthor: fix for dma-fence safe access rules
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.
---
v2: collect R-bs and drop misleading Fixes: tag
--- drivers/gpu/drm/panthor/panthor_sched.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/panthor/panthor_sched.c +4 -0
@@ -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]);
Signature · 1 line
2.52.0.223.gf5cc29aaa4-goog
Boris Brezillon
maintainerQuoted 5 lines · On Thu, 4 Dec 2025 09:45:45 -0800 Chia-I Wu <[email protected]> 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 thatdrm_sched_fence_get_timeline_namemay race withgroup_free_queue.
Quoted 7 lines
Signed-off-by Chia-I Wu <[email protected]>Reviewed-by Boris Brezillon <[email protected]>Reviewed-by Liviu Dudau <[email protected]>Reviewed-by Steven Price <[email protected]>---
v2: collect R-bs and drop misleading Fixes: tag
Should we at least
so this gets considered for backporting?
Quoted 26 lines
--- drivers/gpu/drm/panthor/panthor_sched.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/panthor/panthor_sched.c +4
-0@@ -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]);
Quoted 14 lines · Boris Brezillon
Quoted 10 lines · On Thu, 4 Dec 2025 09:45:45 -0800 Chia-I Wu <[email protected]> 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 thatdrm_sched_fence_get_timeline_namemay race withgroup_free_queue.Signed-off-by Chia-I Wu <[email protected]>Reviewed-by Boris Brezillon <[email protected]>Reviewed-by Liviu Dudau <[email protected]>Reviewed-by Steven Price <[email protected]>
Quoted 8 lines
Quoted 2 lines
---
v2: collect R-bs and drop misleading Fixes: tagShould we at least
so this gets considered for backporting?
This can be considered a follow-up to commit 506aa8b02a8d6. I think
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.
Quoted 28 lines
Quoted 27 lines
--- drivers/gpu/drm/panthor/panthor_sched.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/panthor/panthor_sched.c +4
-0@@ -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]);
Steven Price
maintainerQuoted 28 lines · Chia-I Wu
Quoted 14 lines · Boris Brezillon
Quoted 10 lines · On Thu, 4 Dec 2025 09:45:45 -0800 Chia-I Wu <[email protected]> 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 thatdrm_sched_fence_get_timeline_namemay race withgroup_free_queue.Signed-off-by Chia-I Wu <[email protected]>Reviewed-by Boris Brezillon <[email protected]>Reviewed-by Liviu Dudau <[email protected]>Reviewed-by Steven Price <[email protected]>Quoted 8 lines
Quoted 2 lines
---
v2: collect R-bs and drop misleading Fixes: tagShould we at least
so this gets considered for backporting?
This can be considered a follow-up to commit
506aa8b02a8d6. I thinkCc [email protected] # v6.17+
Quoted 9 lines
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
506aa8b02a8d6itself 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
Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
--- drivers/gpu/drm/panthor/panthor_sched.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/panthor/panthor_sched.c +4
-0@@ -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]);