Skip to content

Commit 0a9a4b6

Browse files
committed
drm/panfrost: Fix sleeping while atomic in panfrost_gem_open
We can't hold the mm_lock spinlock as panfrost_mmu_map() can sleep: BUG: sleeping function called from invalid context at kernel/locking/mutex.c:909 in_atomic(): 1, irqs_disabled(): 0, pid: 974, name: glmark2-es2-drm 1 lock held by glmark2-es2-drm/974: CPU: 5 PID: 974 Comm: glmark2-es2-drm Tainted: G W L 5.3.0-rc1+ torvalds#94 Hardware name: 96boards Rock960 (DT) Call trace: dump_backtrace+0x0/0x130 show_stack+0x14/0x20 dump_stack+0xc4/0x10c ___might_sleep+0x158/0x228 __might_sleep+0x50/0x88 __mutex_lock+0x58/0x800 mutex_lock_interruptible_nested+0x1c/0x28 drm_gem_shmem_get_pages+0x24/0xa0 drm_gem_shmem_get_pages_sgt+0x48/0xd0 panfrost_mmu_map+0x38/0xf8 [panfrost] panfrost_gem_open+0xc0/0xd8 [panfrost] drm_gem_handle_create_tail+0xe8/0x198 drm_gem_handle_create+0x3c/0x50 panfrost_gem_create_with_handle+0x70/0xa0 [panfrost] panfrost_ioctl_create_bo+0x48/0x80 [panfrost] drm_ioctl_kernel+0xb8/0x110 drm_ioctl+0x244/0x3f0 do_vfs_ioctl+0xbc/0x910 ksys_ioctl+0x78/0xa8 __arm64_sys_ioctl+0x1c/0x28 el0_svc_common.constprop.0+0x90/0x168 el0_svc_handler+0x28/0x78 el0_svc+0x8/0xc Fixes: a5efb4c ("drm/panfrost: Restructure the GEM object creation") Cc: Tomeu Vizoso <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Reviewed-by: Steven Price <[email protected]> Signed-off-by: Rob Herring <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 528a25d commit 0a9a4b6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: drivers/gpu/drm/panfrost/panfrost_gem.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,18 @@ static int panfrost_gem_open(struct drm_gem_object *obj, struct drm_file *file_p
6565
spin_lock(&priv->mm_lock);
6666
ret = drm_mm_insert_node_generic(&priv->mm, &bo->node,
6767
size >> PAGE_SHIFT, align, color, 0);
68+
spin_unlock(&priv->mm_lock);
6869
if (ret)
69-
goto out;
70+
return ret;
7071

7172
if (!bo->is_heap) {
7273
ret = panfrost_mmu_map(bo);
73-
if (ret)
74+
if (ret) {
75+
spin_lock(&priv->mm_lock);
7476
drm_mm_remove_node(&bo->node);
77+
spin_unlock(&priv->mm_lock);
78+
}
7579
}
76-
out:
77-
spin_unlock(&priv->mm_lock);
7880
return ret;
7981
}
8082

0 commit comments

Comments
 (0)