]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
accel/amdxdna: Fix race condition when checking rpm_on
authorLizhi Hou <lizhi.hou@amd.com>
Mon, 8 Dec 2025 16:53:56 +0000 (08:53 -0800)
committerLizhi Hou <lizhi.hou@amd.com>
Tue, 9 Dec 2025 19:51:03 +0000 (11:51 -0800)
commit00ffe45ece80160aef446d74ded906352f21dd72
tree9ed74c53ddfa2bdeeb903b51c3ca912877834725
parent0823bd894278e4c0f1acb8f3a8a3c67745e6d1f6
accel/amdxdna: Fix race condition when checking rpm_on

When autosuspend is triggered, driver rpm_on flag is set to indicate that
a suspend/resume is already in progress. However, when a userspace
application submits a command during this narrow window,
amdxdna_pm_resume_get() may incorrectly skip the resume operation because
the rpm_on flag is still set. This results in commands being submitted
while the device has not actually resumed, causing unexpected behavior.

The set_dpm() is called by suspend/resume, it relied on rpm_on flag to
avoid calling into rpm suspend/resume recursivly. So to fix this, remove
the use of the rpm_on flag entirely. Instead, introduce aie2_pm_set_dpm()
which explicitly resumes the device before invoking set_dpm(). With this
change, set_dpm() is called directly inside the suspend or resume execution
path. Otherwise, aie2_pm_set_dpm() is called.

Fixes: 063db451832b ("accel/amdxdna: Enhance runtime power management")
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Reviewed-by: Maciej Falkowski <maciej.falkowski@linux.intel.com>
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://patch.msgid.link/20251208165356.1549237-1-lizhi.hou@amd.com
drivers/accel/amdxdna/aie2_message.c
drivers/accel/amdxdna/aie2_pci.c
drivers/accel/amdxdna/aie2_pci.h
drivers/accel/amdxdna/aie2_pm.c
drivers/accel/amdxdna/aie2_smu.c
drivers/accel/amdxdna/amdxdna_pci_drv.h
drivers/accel/amdxdna/amdxdna_pm.c