]> git.ipfire.org Git - thirdparty/linux.git/commit
drm/amd/pm: fix torn gpu metrics reads
authorYang Wang <kevinyang.wang@amd.com>
Thu, 23 Jul 2026 15:18:33 +0000 (23:18 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 29 Jul 2026 00:00:06 +0000 (20:00 -0400)
commit048f4541b71fb19645fb79d6e62e6e4da23a4035
tree471f4ddce41b736afcc17730daff5f4b3cf0074f
parentbb493058c35c8676e48269ab6732688ea733d23c
drm/amd/pm: fix torn gpu metrics reads

amdgpu_dpm_get_gpu_metrics() returns a pointer to the shared metrics cache
after dropping adev->pm.mutex. The sysfs path then copies from that pointer.
Another reader can refresh the cache in place during the copy and return a
snapshot containing data from two generations.

Pass caller-provided storage through the DPM interface and copy the metrics
while the mutex is held. This keeps the cache pointer private and makes each
sysfs read observe one complete sample.

Fixes: 25c933b1c4fc ("drm/amd/powerplay: add new sysfs interface for retrieving gpu metrics(V2)")
Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 862333bb48693ecafcae25af0c9d9ec31015ac77)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
drivers/gpu/drm/amd/pm/amdgpu_pm.c
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h