drm/amd/pm: Fix pp_entries_max() bios check

Commit 055a40c32f ("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: c42871ba48 ("drm/amdgpu/pm: add pp_entries_max() helper")
Reported-by: John Olender <john.olender@gmail.com>
Signed-off-by: Asad Kamal <asad.kamal@amd.com>
Reviewed-by: Yang Wang <kevinyang.wang@amd.com>
Tested-by: John Olender <john.olender@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Asad Kamal
2026-07-13 09:00:00 +05:30
committed by Alex Deucher
parent fffb5cd730
commit 262d5a7dc4

View File

@@ -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);