Skip to content

Commit 62f553d

Browse files
prliangpubalexdeucher
authored andcommitted
drm/amdgpu: fix the idr allocation flags
Fix the IDR allocation flags by using atomic GFP flags in non‑sleepable contexts to avoid the __might_sleep() complaint. 268.290239] [drm] Initialized amdgpu 3.64.0 for 0000:03:00.0 on minor 0 [ 268.294900] BUG: sleeping function called from invalid context at ./include/linux/sched/mm.h:323 [ 268.295355] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1744, name: modprobe [ 268.295705] preempt_count: 1, expected: 0 [ 268.295886] RCU nest depth: 0, expected: 0 [ 268.296072] 2 locks held by modprobe/1744: [ 268.296077] #0: ffff8c3a44abd1b8 (&dev->mutex){....}-{4:4}, at: __driver_attach+0xe4/0x210 [ 268.296100] #1: ffffffffc1a6ea78 (amdgpu_pasid_idr_lock){+.+.}-{3:3}, at: amdgpu_pasid_alloc+0x26/0xe0 [amdgpu] [ 268.296494] CPU: 12 UID: 0 PID: 1744 Comm: modprobe Tainted: G U OE 6.19.0-custom #16 PREEMPT(voluntary) [ 268.296498] Tainted: [U]=USER, [O]=OOT_MODULE, [E]=UNSIGNED_MODULE [ 268.296499] Hardware name: AMD Majolica-RN/Majolica-RN, BIOS RMJ1009A 06/13/2021 [ 268.296501] Call Trace: Fixes: 8f1de51 ("drm/amdgpu: prevent immediate PASID reuse case") Tested-by: Borislav Petkov (AMD) <[email protected]> Signed-off-by: Prike Liang <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]> (cherry picked from commit ea56aa2) Cc: [email protected]
1 parent a018d18 commit 62f553d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ int amdgpu_pasid_alloc(unsigned int bits)
6868
return -EINVAL;
6969

7070
spin_lock(&amdgpu_pasid_idr_lock);
71+
/* TODO: Need to replace the idr with an xarry, and then
72+
* handle the internal locking with ATOMIC safe paths.
73+
*/
7174
pasid = idr_alloc_cyclic(&amdgpu_pasid_idr, NULL, 1,
72-
1U << bits, GFP_KERNEL);
75+
1U << bits, GFP_ATOMIC);
7376
spin_unlock(&amdgpu_pasid_idr_lock);
7477

7578
if (pasid >= 0)

0 commit comments

Comments
 (0)