mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
drm/amd/pm: Use uploaded size for legacy custom PPTable
The legacy powerplay path used to allocate hardcode_pp_table from the original VBIOS PPTable size, copy only the uploaded bytes into it, and keep soft_pp_table_size unchanged. If a custom PPTable is shorter than the original table, later code can still treat the stale tail as valid table data. Treat the uploaded buffer as the complete custom PPTable: duplicate the uploaded buffer directly, replace hardcode_pp_table atomically, and set soft_pp_table_size to the uploaded size. Signed-off-by: Yang Wang <kevinyang.wang@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
a17e79d01f
commit
055a40c32f
|
|
@ -660,25 +660,20 @@ static int amd_powerplay_reset(void *handle)
|
||||||
static int pp_dpm_set_pp_table(void *handle, const char *buf, size_t size)
|
static int pp_dpm_set_pp_table(void *handle, const char *buf, size_t size)
|
||||||
{
|
{
|
||||||
struct pp_hwmgr *hwmgr = handle;
|
struct pp_hwmgr *hwmgr = handle;
|
||||||
|
void *hardcode_pp_table;
|
||||||
int ret = -ENOMEM;
|
int ret = -ENOMEM;
|
||||||
|
|
||||||
if (!hwmgr || !hwmgr->pm_en)
|
if (!hwmgr || !hwmgr->pm_en || !buf || !size || size > U32_MAX)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (size > hwmgr->soft_pp_table_size)
|
hardcode_pp_table = kmemdup(buf, size, GFP_KERNEL);
|
||||||
return -EINVAL;
|
if (!hardcode_pp_table)
|
||||||
|
|
||||||
if (!hwmgr->hardcode_pp_table) {
|
|
||||||
hwmgr->hardcode_pp_table = kmemdup(hwmgr->soft_pp_table,
|
|
||||||
hwmgr->soft_pp_table_size,
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!hwmgr->hardcode_pp_table)
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(hwmgr->hardcode_pp_table, buf, size);
|
|
||||||
|
|
||||||
|
kfree(hwmgr->hardcode_pp_table);
|
||||||
|
hwmgr->hardcode_pp_table = hardcode_pp_table;
|
||||||
hwmgr->soft_pp_table = hwmgr->hardcode_pp_table;
|
hwmgr->soft_pp_table = hwmgr->hardcode_pp_table;
|
||||||
|
hwmgr->soft_pp_table_size = size;
|
||||||
|
|
||||||
ret = amd_powerplay_reset(handle);
|
ret = amd_powerplay_reset(handle);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user