From 262d5a7dc441047a46d5b8aabd25fe8ddd6e8ae6 Mon Sep 17 00:00:00 2001 From: Asad Kamal Date: Mon, 13 Jul 2026 09:00:00 +0530 Subject: [PATCH] drm/amd/pm: Fix pp_entries_max() bios check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 055a40c32f3a ("drm/amd/pm: Use uploaded size for legacy custom PPTable") changed pp_dpm_set_pp_table() to kmemdup the uploaded buffer directly and set soft_pp_table_size to the uploaded size. As a result soft_pp_table now points to an allocation completely outside adev->bios, making the pp_end > bios_end check in pp_entries_max() likely true for custom PP tables — returning 0 and breaking PP table overrides via sysfs. Fixes: c42871ba4833 ("drm/amdgpu/pm: add pp_entries_max() helper") Reported-by: John Olender Signed-off-by: Asad Kamal Reviewed-by: Yang Wang Tested-by: John Olender Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h index 7ebc1344023f..e01afbc39d67 100644 --- a/drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h +++ b/drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h @@ -833,14 +833,17 @@ static inline uint32_t pp_entries_max(const struct pp_hwmgr *hwmgr, const void *sub_table, size_t hdr_size, size_t rec_size) { - struct amdgpu_device *adev = (struct amdgpu_device *)hwmgr->adev; - const char *bios_end = (const char *)adev->bios + adev->bios_size; - const char *pp_end = (const char *)hwmgr->soft_pp_table - + hwmgr->soft_pp_table_size; + const char *pp_start = hwmgr->soft_pp_table; + const char *pp_end = pp_start + hwmgr->soft_pp_table_size; const char *entries = (const char *)sub_table + hdr_size; - if (pp_end > bios_end) - return 0; + if (!hwmgr->hardcode_pp_table) { + struct amdgpu_device *adev = hwmgr->adev; + const char *bios_end = (const char *)adev->bios + adev->bios_size; + + if (pp_end > bios_end) + return 0; + } if (!rec_size || entries >= pp_end) return 0; return (uint32_t)((pp_end - entries) / rec_size);