* [PATCH 1/3] drm/amdgpu: clear in_runpm when runtime suspend fails in prepare
@ 2026-12-01 14:14 James Zhu
2026-12-01 14:14 ` [PATCH 2/3] drm/amdkfd: rebuild CWSR TBA/TMA in VRAM after system resume James Zhu
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: James Zhu @ 2026-12-01 14:14 UTC (permalink / raw)
To: amd-gfx
Cc: alexander.deucher, philip.yang, Harish.Kasiviswanathan,
vladimir.indic, jamesz, Heng.Zhou
amdgpu_pmops_runtime_suspend() sets in_runpm and, on BOCO, mp1_state
before it calls amdgpu_device_prepare(). When prepare fails it returns
without undoing either, unlike the amdgpu_device_suspend() failure just
below. The device stays active with in_runpm set, so later checks of
in_runpm, including the ones made during system suspend and resume, take
the runtime PM path. The next patch relies on in_runpm to tell a system
resume from a runtime resume.
Handle both failures the same way.
Fixes: 5095d5418193 ("drm/amd: Evict resources during PM ops prepare() callback")
Signed-off-by: James Zhu <James.Zhu@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 2a8614269984..7418c8588e18 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2917,9 +2917,8 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
adev->mp1_state = PP_MP1_STATE_UNLOAD;
ret = amdgpu_device_prepare(drm_dev);
- if (ret)
- return ret;
- ret = amdgpu_device_suspend(drm_dev, false);
+ if (!ret)
+ ret = amdgpu_device_suspend(drm_dev, false);
if (ret) {
adev->in_runpm = false;
if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/3] drm/amdkfd: rebuild CWSR TBA/TMA in VRAM after system resume 2026-12-01 14:14 [PATCH 1/3] drm/amdgpu: clear in_runpm when runtime suspend fails in prepare James Zhu @ 2026-12-01 14:14 ` James Zhu 2026-12-01 14:15 ` [PATCH 3/3] Revert "drm/amdkfd: move TBA/TMA back to system memory" James Zhu 2026-12-01 14:28 ` [PATCH 1/3] drm/amdgpu: clear in_runpm when runtime suspend fails in prepare sashiko-bot 2 siblings, 0 replies; 5+ messages in thread From: James Zhu @ 2026-12-01 14:14 UTC (permalink / raw) To: amd-gfx Cc: alexander.deucher, philip.yang, Harish.Kasiviswanathan, vladimir.indic, jamesz, Heng.Zhou The CWSR TBA/TMA buffer is pinned, so it is not evicted on suspend. When it lives in VRAM its contents are lost once the GPU loses power, and nothing writes them again on resume. The first context switch after resume then runs a garbage trap handler and hangs the GPU. Only the kernel writes this buffer: the CWSR trap handler, the second-level TBA/TMA addresses and the debug trap flag. Keep a copy of the three TMA values and rebuild the whole buffer from kgd2kfd_resume() on system resume, before the queue manager is started, and flush HDP so that the GPU sees it. This is done once per kfd_dev, for the pdds of all its nodes. Until now the ioctls that write the buffer ran under p->mutex. The rebuild cannot take p->mutex: it walks the process table under kfd_processes_mutex, and p->mutex is already taken outside of kfd_processes_mutex. User space is frozen on system resume, but not when vga_switcheroo powers the GPU off and on, and there the rebuild would race with the set trap handler and debug trap ioctls. Add a per pdd cwsr_lock for the buffer, its mapping and the saved values. It is a leaf lock, nothing is taken under it. Runtime suspend would lose the contents the same way, so hold a runtime PM reference from the time a CWSR buffer is placed in VRAM until the pdd is destroyed, instead of rebuilding there. Fixes: fe5966d4fdcb ("drm/amdkfd: move TBA/TMA from system to device memory") Signed-off-by: James Zhu <James.Zhu@amd.com> --- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 11 +++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 16 ++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 100 +++++++++++++++++++++-- 3 files changed, 120 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c index 2200f5c7c38d..8dc48a1eb5aa 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c @@ -1134,6 +1134,17 @@ int kgd2kfd_resume(struct kfd_dev *kfd, bool resume_proc) if (!kfd->init_complete) return 0; + /* + * A CWSR buffer pinned in VRAM is not saved across suspend, so rewrite + * it before any queue can be mapped. This also runs when vga_switcheroo + * powers the GPU back on, and in the unwind of a failed suspend, where + * it is merely redundant. Runtime resume is skipped: a pdd with such a + * buffer holds a runtime PM reference, so the device was never runtime + * suspended. + */ + if (kfd->adev->in_suspend && !kfd->adev->in_runpm) + kfd_process_restore_cwsr(kfd); + for (i = 0; i < kfd->num_nodes; i++) { ret = kfd_resume(kfd->nodes[i]); if (ret) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 8eac086aa108..c5cfd2d848fd 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -733,6 +733,21 @@ struct qcm_process_device { uint64_t cwsr_base; uint64_t tba_addr; uint64_t tma_addr; + /* + * cwsr_lock protects cwsr_map and tba2_addr, tma2_addr and + * trap_debug_flag, which mirror what the kernel wrote into the + * first-level TMA so that it can be rebuilt. + * The ioctls that write them hold p->mutex, but that does not cover + * kfd_process_restore_cwsr(): it walks the process table under + * kfd_processes_mutex, where p->mutex cannot be taken (the Arcturus + * debug trap callback suspends and resumes KFD with p->mutex held), + * and it can run with user space not frozen (vga_switcheroo). + * Nothing is taken under this lock. + */ + struct mutex cwsr_lock; + uint64_t tba2_addr; + uint64_t tma2_addr; + bool trap_debug_flag; /* IB memory */ struct kgd_mem *ib_mem; @@ -1141,6 +1156,7 @@ int kfd_process_restore_queues(struct kfd_process *p); void kfd_suspend_all_processes(void); void kfd_process_wait_gpu_reset_complete(struct kfd_process *p); int kfd_resume_all_processes(void); +void kfd_process_restore_cwsr(struct kfd_dev *kfd); struct kfd_process_device *kfd_process_device_data_by_id(struct kfd_process *process, uint32_t gpu_id); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index 5dc657f32d38..7118ad38957f 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -1294,6 +1294,7 @@ static void kfd_process_destroy_pdds(struct kfd_process *p) mutex_destroy(&pdd->doorbell_mutex); kfree(pdd->vm_fault_exc_data); + mutex_destroy(&pdd->qpd.cwsr_lock); kfree(pdd); p->pdds[i] = NULL; } @@ -1582,6 +1583,65 @@ void kfd_cleanup_processes(void) mmu_notifier_synchronize(); } +/* + * Write the CWSR trap handler and the TMA fields. Only the kernel writes this + * buffer, so this also rebuilds it after VRAM lost its contents. + */ +static void kfd_process_device_fill_cwsr(struct kfd_process_device *pdd) +{ + struct qcm_process_device *qpd = &pdd->qpd; + struct kfd_dev *kfd = pdd->dev->kfd; + + lockdep_assert_held(&qpd->cwsr_lock); + + iosys_map_memset(&qpd->cwsr_map, 0, 0, KFD_CWSR_TBA_TMA_SIZE); + iosys_map_memcpy_to(&qpd->cwsr_map, 0, kfd->cwsr_isa, + kfd->cwsr_isa_size); + iosys_map_wr(&qpd->cwsr_map, KFD_CWSR_TMA_OFFSET, + uint64_t, qpd->tba2_addr); + iosys_map_wr(&qpd->cwsr_map, KFD_CWSR_TMA_OFFSET + sizeof(uint64_t), + uint64_t, qpd->tma2_addr); + iosys_map_wr(&qpd->cwsr_map, KFD_CWSR_TMA_OFFSET + 2 * sizeof(uint64_t), + uint64_t, qpd->trap_debug_flag); +} + +/* + * Rebuild the CWSR buffers that the nodes of this kfd_dev keep pinned in + * VRAM. kfd_processes_mutex keeps the processes in the table from being torn + * down. See cwsr_lock for why p->mutex is not used here. + */ +void kfd_process_restore_cwsr(struct kfd_dev *kfd) +{ + struct kfd_process *p; + bool rebuilt = false; + unsigned int temp; + int i, idx; + + mutex_lock(&kfd_processes_mutex); + idx = srcu_read_lock(&kfd_processes_srcu); + hash_for_each_rcu(kfd_processes_table, temp, p, kfd_processes) { + for (i = 0; i < p->n_pdds; i++) { + struct kfd_process_device *pdd = p->pdds[i]; + + if (pdd->dev->kfd != kfd) + continue; + + mutex_lock(&pdd->qpd.cwsr_lock); + if (pdd->qpd.cwsr_map.is_iomem) { + kfd_process_device_fill_cwsr(pdd); + rebuilt = true; + } + mutex_unlock(&pdd->qpd.cwsr_lock); + } + } + srcu_read_unlock(&kfd_processes_srcu, idx); + mutex_unlock(&kfd_processes_mutex); + + /* The GPU must see the CPU writes to VRAM before queues are mapped */ + if (rebuilt) + amdgpu_device_flush_hdp(kfd->adev, NULL); +} + static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd) { struct kfd_node *dev = pdd->dev; @@ -1605,6 +1665,17 @@ static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd) else flags |= KFD_IOC_ALLOC_MEM_FLAGS_GTT; + /* + * The buffer is pinned, so it is not evicted and its contents are lost + * when VRAM loses power. Keep the device out of runtime suspend from + * here until the pdd is destroyed; system resume rebuilds the buffer. + */ + if (flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM) { + ret = kfd_process_device_runtime_get(pdd); + if (ret) + return ret; + } + /* Allocate CWSR TBA/TMA buffers */ ret = kfd_process_alloc_gpuvm(pdd, qpd->cwsr_base, KFD_CWSR_TBA_TMA_SIZE, flags, &mem, &kaddr); @@ -1613,20 +1684,20 @@ static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd) qpd->cwsr_mem = mem; + mutex_lock(&qpd->cwsr_lock); + /* Set up iosys_map based on whether memory is MMIO or system memory */ if (mem->bo->kmap.bo_kmap_type & TTM_BO_MAP_IOMEM_MASK) iosys_map_set_vaddr_iomem(&qpd->cwsr_map, kaddr); else iosys_map_set_vaddr(&qpd->cwsr_map, kaddr); - qpd->tba_addr = qpd->cwsr_base; + qpd->trap_debug_flag = pdd->process->debug_trap_enabled; + kfd_process_device_fill_cwsr(pdd); - /* Copy CWSR ISA to buffer using appropriate accessor */ - iosys_map_memcpy_to(&qpd->cwsr_map, 0, dev->kfd->cwsr_isa, - dev->kfd->cwsr_isa_size); + mutex_unlock(&qpd->cwsr_lock); - kfd_process_set_trap_debug_flag(&pdd->qpd, - pdd->process->debug_trap_enabled); + qpd->tba_addr = qpd->cwsr_base; qpd->tma_addr = qpd->tba_addr + KFD_CWSR_TMA_OFFSET; pr_debug("set tba :0x%llx, tma:0x%llx, cwsr_map:%s at %p for pqm.\n", @@ -1642,21 +1713,31 @@ static void kfd_process_device_destroy_cwsr_dgpu(struct kfd_process_device *pdd) { struct kfd_node *dev = pdd->dev; struct qcm_process_device *qpd = &pdd->qpd; + struct iosys_map map; if (!dev->kfd->cwsr_enabled || iosys_map_is_null(&qpd->cwsr_map) || !qpd->cwsr_base) return; - kfd_process_free_gpuvm_map(qpd->cwsr_mem, pdd, &qpd->cwsr_map); + /* Hide the mapping from kfd_process_restore_cwsr() before it goes */ + mutex_lock(&qpd->cwsr_lock); + map = qpd->cwsr_map; + iosys_map_clear(&qpd->cwsr_map); + mutex_unlock(&qpd->cwsr_lock); + + kfd_process_free_gpuvm_map(qpd->cwsr_mem, pdd, &map); } void kfd_process_set_trap_handler(struct qcm_process_device *qpd, uint64_t tba_addr, uint64_t tma_addr) { + mutex_lock(&qpd->cwsr_lock); if (!iosys_map_is_null(&qpd->cwsr_map)) { /* KFD trap handler is bound, record as second-level TBA/TMA * in first-level TMA. First-level trap will jump to second. */ + qpd->tba2_addr = tba_addr; + qpd->tma2_addr = tma_addr; iosys_map_wr(&qpd->cwsr_map, KFD_CWSR_TMA_OFFSET, uint64_t, tba_addr); iosys_map_wr(&qpd->cwsr_map, KFD_CWSR_TMA_OFFSET + sizeof(uint64_t), @@ -1666,6 +1747,7 @@ void kfd_process_set_trap_handler(struct qcm_process_device *qpd, qpd->tba_addr = tba_addr; qpd->tma_addr = tma_addr; } + mutex_unlock(&qpd->cwsr_lock); } bool kfd_process_xnack_mode(struct kfd_process *p, bool supported) @@ -1726,11 +1808,14 @@ bool kfd_process_xnack_mode(struct kfd_process *p, bool supported) void kfd_process_set_trap_debug_flag(struct qcm_process_device *qpd, bool enabled) { + mutex_lock(&qpd->cwsr_lock); if (!iosys_map_is_null(&qpd->cwsr_map)) { + qpd->trap_debug_flag = enabled; iosys_map_wr(&qpd->cwsr_map, KFD_CWSR_TMA_OFFSET + 2 * sizeof(uint64_t), uint64_t, enabled); } + mutex_unlock(&qpd->cwsr_lock); } /* @@ -1915,6 +2000,7 @@ struct kfd_process_device *kfd_create_process_device_data(struct kfd_node *dev, pdd->bound = PDD_UNBOUND; pdd->already_dequeued = false; pdd->runtime_inuse = false; + mutex_init(&pdd->qpd.cwsr_lock); atomic64_set(&pdd->vram_usage, 0); pdd->sdma_past_activity_counter = 0; pdd->user_gpu_id = dev->id; -- 2.56.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] Revert "drm/amdkfd: move TBA/TMA back to system memory" 2026-12-01 14:14 [PATCH 1/3] drm/amdgpu: clear in_runpm when runtime suspend fails in prepare James Zhu 2026-12-01 14:14 ` [PATCH 2/3] drm/amdkfd: rebuild CWSR TBA/TMA in VRAM after system resume James Zhu @ 2026-12-01 14:15 ` James Zhu 2026-12-01 14:37 ` sashiko-bot 2026-12-01 14:28 ` [PATCH 1/3] drm/amdgpu: clear in_runpm when runtime suspend fails in prepare sashiko-bot 2 siblings, 1 reply; 5+ messages in thread From: James Zhu @ 2026-12-01 14:15 UTC (permalink / raw) To: amd-gfx Cc: alexander.deucher, philip.yang, Harish.Kasiviswanathan, vladimir.indic, jamesz, Heng.Zhou This reverts commit e5e12a10e817. That commit moved TBA/TMA back to system memory on most parts to work around GPU hangs after suspend, at a performance cost. The buffer is now rebuilt on system resume, so keep it in VRAM again for GFX 9.4.2 and above, unless apu_prefer_gtt is set. Link: https://gitlab.freedesktop.org/drm/amd/-/work_items/6116 Signed-off-by: James Zhu <James.Zhu@amd.com> --- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index 7118ad38957f..81fabc0edc34 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -1655,12 +1655,7 @@ static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd) if (!dev->kfd->cwsr_enabled || !iosys_map_is_null(&qpd->cwsr_map) || !qpd->cwsr_base) return 0; - if ((KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) || - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 3) || - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 4) || - KFD_GC_VERSION(dev) == IP_VERSION(9, 5, 0) || - KFD_GC_VERSION(dev) == IP_VERSION(12, 1, 0)) && - !dev->adev->apu_prefer_gtt) + if (KFD_GC_VERSION(dev) >= IP_VERSION(9, 4, 2) && !dev->adev->apu_prefer_gtt) flags |= KFD_IOC_ALLOC_MEM_FLAGS_VRAM; else flags |= KFD_IOC_ALLOC_MEM_FLAGS_GTT; -- 2.56.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] Revert "drm/amdkfd: move TBA/TMA back to system memory" 2026-12-01 14:15 ` [PATCH 3/3] Revert "drm/amdkfd: move TBA/TMA back to system memory" James Zhu @ 2026-12-01 14:37 ` sashiko-bot 0 siblings, 0 replies; 5+ messages in thread From: sashiko-bot @ 2026-12-01 14:37 UTC (permalink / raw) To: James Zhu, amd-gfx Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] drm/amdkfd: stale GPUVM PTEs and SDMA race in kfd_process_device_init_cwsr_dgpu() - [High] drm/amdkfd: missing HDP flush after VRAM CWSR writes in kfd_process.c -- commit 38f74754f766d51b400ed1883826540572c8a9ac Author: James Zhu <James.Zhu@amd.com> Revert "drm/amdkfd: move TBA/TMA back to system memory" This commit reverts moving the CWSR TBA/TMA buffer to system memory, placing it back in VRAM for all GFX 9.4.2 and newer GPUs unless apu_prefer_gtt is set. Link: https://gitlab.freedesktop.org/drm/amd/-/work_items/6116 > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c > index 4508fbd5626c0..ebae27e75575c 100644 > --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c > @@ -1657,12 +1657,7 @@ static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd) > if (!dev->kfd->cwsr_enabled || !iosys_map_is_null(&qpd->cwsr_map) || !qpd->cwsr_base) > return 0; > > - if ((KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 2) || > - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 3) || > - KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 4) || > - KFD_GC_VERSION(dev) == IP_VERSION(9, 5, 0) || > - KFD_GC_VERSION(dev) == IP_VERSION(12, 1, 0)) && > - !dev->adev->apu_prefer_gtt) > + if (KFD_GC_VERSION(dev) >= IP_VERSION(9, 4, 2) && !dev->adev->apu_prefer_gtt) > flags |= KFD_IOC_ALLOC_MEM_FLAGS_VRAM; > else > flags |= KFD_IOC_ALLOC_MEM_FLAGS_GTT; [Severity: High] Can this leave the GPUVM PTEs for qpd->cwsr_base pointing to freed invisible VRAM on GFX10, GFX11, or GFX12.0 dGPUs running with a small BAR? kfd_process_device_init_cwsr_dgpu() sets KFD_IOC_ALLOC_MEM_FLAGS_VRAM without KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC. In kfd_process_alloc_gpuvm(), amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu() creates the BO without AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, so TTM places it top-down in CPU-invisible VRAM (above visible_pfn), and amdgpu_amdkfd_gpuvm_map_memory_to_gpu() programs the process GPUVM PTEs with that invisible-VRAM address. Immediately after, kfd_process_alloc_gpuvm() calls amdgpu_amdkfd_gpuvm_map_bo_to_kernel() -> amdgpu_bo_pin(): drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:amdgpu_bo_pin() { ... /* force to pin into visible video ram */ if (!(bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)) bo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; amdgpu_bo_placement_from_domain(bo, domain); ... r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx); } ttm_bo_validate() migrates the BO to visible VRAM via an asynchronous SDMA blit and frees the invisible-VRAM blocks, but nothing updates the GPUVM PTEs afterward or waits for the move fence before kfd_process_device_fill_cwsr() writes the trap handler via MMIO. The CPU writes can race with the SDMA move, and wave preemption or trap execution will fetch TBA/TMA from the stale invisible-VRAM address, causing VM faults or GPU hangs. Passing KFD_IOC_ALLOC_MEM_FLAGS_PUBLIC when allocating in VRAM would place the BO in visible VRAM from the start. [Severity: High] Should CPU writes to qpd->cwsr_map flush HDP when the CWSR buffer is in VRAM? In kfd_process_restore_cwsr(), the driver flushes HDP after kfd_process_device_fill_cwsr() so the GPU sees the CPU MMIO writes to VRAM. However, kfd_process_device_init_cwsr_dgpu(), kfd_process_set_trap_handler(), and kfd_process_set_trap_debug_flag() write the trap handler ISA and first-level TMA fields through qpd->cwsr_map without calling amdgpu_device_flush_hdp(). On GFX10, GFX11, and GFX12.0 dGPUs (which this patch switches from GTT to VRAM), MQDs live in GTT rather than VRAM, so queue creation and debugger attach/detach do not flush HDP either, allowing the SQ to read stale or uninitialized TBA/TMA contents from VRAM. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261201141500.3346608-1-James.Zhu@amd.com?part=3 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] drm/amdgpu: clear in_runpm when runtime suspend fails in prepare 2026-12-01 14:14 [PATCH 1/3] drm/amdgpu: clear in_runpm when runtime suspend fails in prepare James Zhu 2026-12-01 14:14 ` [PATCH 2/3] drm/amdkfd: rebuild CWSR TBA/TMA in VRAM after system resume James Zhu 2026-12-01 14:15 ` [PATCH 3/3] Revert "drm/amdkfd: move TBA/TMA back to system memory" James Zhu @ 2026-12-01 14:28 ` sashiko-bot 2 siblings, 0 replies; 5+ messages in thread From: sashiko-bot @ 2026-12-01 14:28 UTC (permalink / raw) To: James Zhu, amd-gfx Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] drm/amdgpu: uncleaned runpm state in amdgpu_pmops_runtime_suspend() [1] -- commit 3c42fe64301c37b90df126008a21b7d19c71b9fc Author: James Zhu <James.Zhu@amd.com> drm/amdgpu: clear in_runpm when runtime suspend fails in prepare This commit routes amdgpu_device_prepare() failures in amdgpu_pmops_runtime_suspend() through the error cleanup block so that adev->in_runpm and adev->mp1_state are reset on failure. > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > index d2db20c172c69..7bd53054ef6e7 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > @@ -2907,9 +2907,8 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev) > adev->mp1_state = PP_MP1_STATE_UNLOAD; > > ret = amdgpu_device_prepare(drm_dev); > - if (ret) > - return ret; > - ret = amdgpu_device_suspend(drm_dev, false); > + if (!ret) > + ret = amdgpu_device_suspend(drm_dev, false); > if (ret) { > adev->in_runpm = false; > if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO) [Severity: High] This problem wasn't introduced by this patch, but on AMDGPU_RUNPM_PX systems does this error path [1] leave drm_dev->switch_power_state stuck at DRM_SWITCH_POWER_CHANGING when amdgpu_device_prepare() or amdgpu_device_suspend() fails? Earlier in amdgpu_pmops_runtime_suspend(): drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c:amdgpu_pmops_runtime_suspend() { ... adev->in_runpm = true; if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX) drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; ... } Because the failure cleanup does not restore drm_dev->switch_power_state to DRM_SWITCH_POWER_ON, drm_open_helper() will reject all subsequent DRM device opens with -EINVAL while the device remains active. [1] https://sashiko.dev/#/bug/linux-c9ddb109-ab18-4c50-8882-a9a764aa1bd4 -- Sashiko AI review · https://sashiko.dev/#/patchset/20261201141500.3346608-1-James.Zhu@amd.com?part=1 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-01 14:37 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-01 14:14 [PATCH 1/3] drm/amdgpu: clear in_runpm when runtime suspend fails in prepare James Zhu 2026-12-01 14:14 ` [PATCH 2/3] drm/amdkfd: rebuild CWSR TBA/TMA in VRAM after system resume James Zhu 2026-12-01 14:15 ` [PATCH 3/3] Revert "drm/amdkfd: move TBA/TMA back to system memory" James Zhu 2026-12-01 14:37 ` sashiko-bot 2026-12-01 14:28 ` [PATCH 1/3] drm/amdgpu: clear in_runpm when runtime suspend fails in prepare sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox