Skip to contentSkip to conversation

drm/lima: Drain fence callbacks before destroying slab

PATCH In review Jiale Yao 2 participants 2 messages Oct 3 – Oct 9

Subsystems (3)
lore
Share & tools
lore

Jiale Yao

author
#0 lore raw

PATCH 1/1 drm/lima: Drain fence callbacks before destroying slab

lima_fence_release() defers freeing fences from lima_fence_slab to an RCU callback. The last lima_sched_slab_fini() can destroy the slab and clear its pointer while a release callback is still queued. Module removal can also free lima_fence_release_rcu() before that callback runs.

Drain outstanding callbacks before destroying the last fence slab.

Fixes a1d2a6339961 ("drm/lima: driver for ARM Mali4xx GPUs")
---
 drivers/gpu/drm/lima/lima_sched.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/lima/lima_sched.c +1 -0
index 9a1e6b9ecbe5..9c5ff1929d3e 100644
@@ -44,6 +44,7 @@ int lima_sched_slab_init(void)
 void lima_sched_slab_fini(void)
 {
 	if (!--lima_fence_slab_refcnt) {
+		rcu_barrier();
 		kmem_cache_destroy(lima_fence_slab);
 		lima_fence_slab = NULL;
 	}
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Jiale Yao

lima_fence_release() defers freeing fences from lima_fence_slab to an RCU callback. The last lima_sched_slab_fini() can destroy the slab and clear its pointer while a release callback is still queued. Module removal can also free lima_fence_release_rcu() before that callback runs.

Drain outstanding callbacks before destroying the last fence slab.

Fixes a1d2a6339961 ("drm/lima: driver for ARM Mali4xx GPUs")
---
 drivers/gpu/drm/lima/lima_sched.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/lima/lima_sched.c +1 -1
index 9a1e6b9ecbe5..9c5ff1929d3e 100644
@@ -44,6 +44,7 @@ int lima_sched_slab_init(void)
 void lima_sched_slab_fini(void)
 {
        if (!--lima_fence_slab_refcnt) {
+               rcu_barrier();
                kmem_cache_destroy(lima_fence_slab);
                lima_fence_slab = NULL;
        }
--

2.34.1