From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: drm/amdgpu: fix sleeping allocation under spinlock in PASID IDR Date: Tue, 31 Mar 2026 17:50:57 +1000 Message-ID: In-Reply-To: <20260328213900.19255-1-mikhail.v.gavrilov@gmail.com> References: <20260328213900.19255-1-mikhail.v.gavrilov@gmail.com> <20260328213900.19255-1-mikhail.v.gavrilov@gmail.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review **Analysis of the bug:** Confirmed by reading the current tree at `amdgpu_i= ds.c:70-73` =E2=80=94 the code currently calls `idr_alloc_cyclic()` with `G= FP_KERNEL` while holding `amdgpu_pasid_idr_lock` (a spinlock). This is inde= ed a sleeping-in-atomic-context bug. **Analysis of the fix:** ```c + idr_preload(GFP_KERNEL); spin_lock(&amdgpu_pasid_idr_lock); pasid =3D idr_alloc_cyclic(&amdgpu_pasid_idr, NULL, 1, - 1U << bits, GFP_KERNEL); + 1U << bits, GFP_NOWAIT); spin_unlock(&amdgpu_pasid_idr_lock); + idr_preload_end(); ``` This is textbook correct: 1. `idr_preload(GFP_KERNEL)` pre-allocates radix tree nodes (can sleep, cal= led outside spinlock) and disables preemption. 2. `GFP_NOWAIT` inside the spinlock ensures the allocator uses the preloade= d pool and never sleeps. 3. `idr_preload_end()` re-enables preemption after the spinlock is released. **One minor ordering note:** `idr_preload_end()` is called after `spin_unlo= ck()`, which is correct =E2=80=94 `idr_preload()` disables preemption, so y= ou must hold the preload context across the allocation. The unlock-before-p= reload_end ordering is the standard pattern (see e.g., `drivers/infiniband/= `, `net/core/`). **Fixes tag and Cc: stable** are both appropriate since this is a straightf= orward bugfix for a commit that introduced the regression. **No issues found.**=20 Reviewed-by recommendation: This patch is correct and follows established k= ernel patterns. --- Generated by Claude Code Patch Reviewer