* [PATCH v3 0/4] drm/amd/pm: overdrive support for smu8 (Carrizo/Stoney)
@ 2026-12-06 4:52 ` Joshua Horne via B4 Relay
0 siblings, 0 replies; 13+ messages in thread
From: Joshua Horne @ 2026-12-06 4:52 UTC (permalink / raw)
To: Alex Deucher, Kenneth Feng
Cc: Christian König, David Airlie, Simona Vetter,
Timur Kristóf, Lijo Lazar, amd-gfx, dri-devel, linux-kernel,
Joshua Horne
This series implements pp_od_clk_voltage for the smu8 backend, so the
graphics DPM levels of Carrizo and Stoney can be underclocked and
undervolted, or overclocked where the VBIOS declares an overdrive
limit. It uses the smu7 format and stays behind PP_OVERDRIVE_MASK.
The voltage is GfxVid, which drives the separate VDDGFX rail; the NB
rail is not touched. The allowed range is the GfxVid range of the
enabled VBIOS levels, so nothing goes above the highest stock graphics
voltage. Earlier APU overdrive support is clock-only; I can send a
clock-only version if that is preferred. Patch 4 documents in the
kernel-doc that a committed level takes effect the next time the GPU
enters it.
The series is meant to go in after "drm/amd/pm: keep smu8 sclk level
lookups within the table" [1], which was patch 1 of v1 and v2 and is
now sent on its own. The series applies and builds without it, but with
the highest level underclocked below the display's minimum engine
clock, the SclkHardMin lookup returns an index past the end of the
table, and that fix selects the highest level instead.
Known limitation: DCE 11 reads the sclk levels only once, so after a
large underclock its bandwidth calculations still assume the VBIOS
clocks. smu7 and vega10 overdrive have the same issue on DCE 11.2 and
DCE 12; the fix belongs in DC.
Tested on an A10-8700P (ASUS X555DA): underclocking, undervolting,
invalid input and S3. This VBIOS has no overdrive limit, so
overclocking is untested. Stoney is untested as well; Tested-by from
Stoney owners would be welcome, or the series can be limited to
CHIP_CARRIZO.
Changes in v3:
- Sent the lookup fix (v2 1/5) on its own [1]
- 3/4: removed two redundant comments
- Rebased onto amd-staging-drm-next
Changes in v2 (only 4/5 was resent [2], after the Sashiko review):
- 4/5: resend SclkHardMin after a commit
- 4/5: keep the exact clock for a level's VBIOS clock and the OD_RANGE
limits
I used an AI coding assistant (Claude Code) for this series. It wrote
the code, the changelogs and a draft of this letter, and wrote and ran
the build checks and test scripts. I reviewed the series, ran the tests
on my hardware, and I am responsible for it.
[1] https://lore.kernel.org/amd-gfx/20261205-smu8-sclk-lookup-fix-v1-1-e16f35ce434c@etsu.edu/
[2] https://lore.kernel.org/amd-gfx/179481705669.12281.9149615824591242380@etsu.edu/
v1: https://lore.kernel.org/amd-gfx/20261113-smu8-overdrive-v1-0-763f07bdfca9@etsu.edu/
---
Joshua Horne (4):
drm/amd/pm: move smu8_populate_umdpstate_clocks() up
drm/amd/pm: show the smu8 overdrive sclk table
drm/amd/pm: allow editing the smu8 overdrive sclk table
drm/amd/pm: stop disabling overdrive on Carrizo and Stoney
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 6 +
drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c | 1 -
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 325 ++++++++++++++++++++-
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h | 8 +
4 files changed, 326 insertions(+), 14 deletions(-)
---
base-commit: 910fd45c4364d29810d0d10e848f8f7ef4e7b3ef
change-id: 20261113-smu8-overdrive-4208a3756d57
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 0/4] drm/amd/pm: overdrive support for smu8 (Carrizo/Stoney)
@ 2026-12-06 4:52 ` Joshua Horne via B4 Relay
0 siblings, 0 replies; 13+ messages in thread
From: Joshua Horne via B4 Relay @ 2026-12-06 4:52 UTC (permalink / raw)
To: Alex Deucher, Kenneth Feng
Cc: Christian König, David Airlie, Simona Vetter,
Timur Kristóf, Lijo Lazar, amd-gfx, dri-devel, linux-kernel,
Joshua Horne
This series implements pp_od_clk_voltage for the smu8 backend, so the
graphics DPM levels of Carrizo and Stoney can be underclocked and
undervolted, or overclocked where the VBIOS declares an overdrive
limit. It uses the smu7 format and stays behind PP_OVERDRIVE_MASK.
The voltage is GfxVid, which drives the separate VDDGFX rail; the NB
rail is not touched. The allowed range is the GfxVid range of the
enabled VBIOS levels, so nothing goes above the highest stock graphics
voltage. Earlier APU overdrive support is clock-only; I can send a
clock-only version if that is preferred. Patch 4 documents in the
kernel-doc that a committed level takes effect the next time the GPU
enters it.
The series is meant to go in after "drm/amd/pm: keep smu8 sclk level
lookups within the table" [1], which was patch 1 of v1 and v2 and is
now sent on its own. The series applies and builds without it, but with
the highest level underclocked below the display's minimum engine
clock, the SclkHardMin lookup returns an index past the end of the
table, and that fix selects the highest level instead.
Known limitation: DCE 11 reads the sclk levels only once, so after a
large underclock its bandwidth calculations still assume the VBIOS
clocks. smu7 and vega10 overdrive have the same issue on DCE 11.2 and
DCE 12; the fix belongs in DC.
Tested on an A10-8700P (ASUS X555DA): underclocking, undervolting,
invalid input and S3. This VBIOS has no overdrive limit, so
overclocking is untested. Stoney is untested as well; Tested-by from
Stoney owners would be welcome, or the series can be limited to
CHIP_CARRIZO.
Changes in v3:
- Sent the lookup fix (v2 1/5) on its own [1]
- 3/4: removed two redundant comments
- Rebased onto amd-staging-drm-next
Changes in v2 (only 4/5 was resent [2], after the Sashiko review):
- 4/5: resend SclkHardMin after a commit
- 4/5: keep the exact clock for a level's VBIOS clock and the OD_RANGE
limits
I used an AI coding assistant (Claude Code) for this series. It wrote
the code, the changelogs and a draft of this letter, and wrote and ran
the build checks and test scripts. I reviewed the series, ran the tests
on my hardware, and I am responsible for it.
[1] https://lore.kernel.org/amd-gfx/20261205-smu8-sclk-lookup-fix-v1-1-e16f35ce434c@etsu.edu/
[2] https://lore.kernel.org/amd-gfx/179481705669.12281.9149615824591242380@etsu.edu/
v1: https://lore.kernel.org/amd-gfx/20261113-smu8-overdrive-v1-0-763f07bdfca9@etsu.edu/
---
Joshua Horne (4):
drm/amd/pm: move smu8_populate_umdpstate_clocks() up
drm/amd/pm: show the smu8 overdrive sclk table
drm/amd/pm: allow editing the smu8 overdrive sclk table
drm/amd/pm: stop disabling overdrive on Carrizo and Stoney
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 6 +
drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c | 1 -
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 325 ++++++++++++++++++++-
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h | 8 +
4 files changed, 326 insertions(+), 14 deletions(-)
---
base-commit: 910fd45c4364d29810d0d10e848f8f7ef4e7b3ef
change-id: 20261113-smu8-overdrive-4208a3756d57
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 1/4] drm/amd/pm: move smu8_populate_umdpstate_clocks() up
2026-12-06 4:52 ` Joshua Horne via B4 Relay
@ 2026-12-06 4:52 ` Joshua Horne via B4 Relay
-1 siblings, 0 replies; 13+ messages in thread
From: Joshua Horne @ 2026-12-06 4:52 UTC (permalink / raw)
To: Alex Deucher, Kenneth Feng
Cc: Christian König, David Airlie, Simona Vetter,
Timur Kristóf, Lijo Lazar, amd-gfx, dri-devel, linux-kernel,
Joshua Horne
The overdrive support added next updates the UMD pstate clocks from a
new helper placed before smu8_set_power_state_tasks(). Move the function
above it, so that no forward declaration is needed.
No functional change.
Signed-off-by: Joshua Horne <hornejd@etsu.edu>
---
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 24 +++++++++++-----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
index 5a3f697a37a2..a19f7a258c67 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
@@ -846,6 +846,18 @@ static int smu8_update_low_mem_pstate(struct pp_hwmgr *hwmgr, const void *input)
return 0;
}
+static void smu8_populate_umdpstate_clocks(struct pp_hwmgr *hwmgr)
+{
+ struct phm_clock_voltage_dependency_table *table =
+ hwmgr->dyn_state.vddc_dependency_on_sclk;
+
+ hwmgr->pstate_sclk = table->entries[0].clk / 100;
+ hwmgr->pstate_mclk = 0;
+
+ hwmgr->pstate_sclk_peak = table->entries[table->count - 1].clk / 100;
+ hwmgr->pstate_mclk_peak = 0;
+}
+
static int smu8_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *input)
{
int ret = 0;
@@ -986,18 +998,6 @@ static void smu8_reset_acp_boot_level(struct pp_hwmgr *hwmgr)
data->acp_boot_level = 0xff;
}
-static void smu8_populate_umdpstate_clocks(struct pp_hwmgr *hwmgr)
-{
- struct phm_clock_voltage_dependency_table *table =
- hwmgr->dyn_state.vddc_dependency_on_sclk;
-
- hwmgr->pstate_sclk = table->entries[0].clk / 100;
- hwmgr->pstate_mclk = 0;
-
- hwmgr->pstate_sclk_peak = table->entries[table->count - 1].clk / 100;
- hwmgr->pstate_mclk_peak = 0;
-}
-
static int smu8_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
{
smu8_program_voting_clients(hwmgr);
--
2.56.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 1/4] drm/amd/pm: move smu8_populate_umdpstate_clocks() up
@ 2026-12-06 4:52 ` Joshua Horne via B4 Relay
0 siblings, 0 replies; 13+ messages in thread
From: Joshua Horne via B4 Relay @ 2026-12-06 4:52 UTC (permalink / raw)
To: Alex Deucher, Kenneth Feng
Cc: Christian König, David Airlie, Simona Vetter,
Timur Kristóf, Lijo Lazar, amd-gfx, dri-devel, linux-kernel,
Joshua Horne
From: Joshua Horne <hornejd@etsu.edu>
The overdrive support added next updates the UMD pstate clocks from a
new helper placed before smu8_set_power_state_tasks(). Move the function
above it, so that no forward declaration is needed.
No functional change.
Signed-off-by: Joshua Horne <hornejd@etsu.edu>
---
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 24 +++++++++++-----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
index 5a3f697a37a2..a19f7a258c67 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
@@ -846,6 +846,18 @@ static int smu8_update_low_mem_pstate(struct pp_hwmgr *hwmgr, const void *input)
return 0;
}
+static void smu8_populate_umdpstate_clocks(struct pp_hwmgr *hwmgr)
+{
+ struct phm_clock_voltage_dependency_table *table =
+ hwmgr->dyn_state.vddc_dependency_on_sclk;
+
+ hwmgr->pstate_sclk = table->entries[0].clk / 100;
+ hwmgr->pstate_mclk = 0;
+
+ hwmgr->pstate_sclk_peak = table->entries[table->count - 1].clk / 100;
+ hwmgr->pstate_mclk_peak = 0;
+}
+
static int smu8_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *input)
{
int ret = 0;
@@ -986,18 +998,6 @@ static void smu8_reset_acp_boot_level(struct pp_hwmgr *hwmgr)
data->acp_boot_level = 0xff;
}
-static void smu8_populate_umdpstate_clocks(struct pp_hwmgr *hwmgr)
-{
- struct phm_clock_voltage_dependency_table *table =
- hwmgr->dyn_state.vddc_dependency_on_sclk;
-
- hwmgr->pstate_sclk = table->entries[0].clk / 100;
- hwmgr->pstate_mclk = 0;
-
- hwmgr->pstate_sclk_peak = table->entries[table->count - 1].clk / 100;
- hwmgr->pstate_mclk_peak = 0;
-}
-
static int smu8_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
{
smu8_program_voting_clients(hwmgr);
--
2.56.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 2/4] drm/amd/pm: show the smu8 overdrive sclk table
2026-12-06 4:52 ` Joshua Horne via B4 Relay
@ 2026-12-06 4:52 ` Joshua Horne via B4 Relay
-1 siblings, 0 replies; 13+ messages in thread
From: Joshua Horne @ 2026-12-06 4:52 UTC (permalink / raw)
To: Alex Deucher, Kenneth Feng
Cc: Christian König, David Airlie, Simona Vetter,
Timur Kristóf, Lijo Lazar, amd-gfx, dri-devel, linux-kernel,
Joshua Horne
Carrizo and Stoney upload up to eight graphics DPM levels to the SMU,
each with an engine clock, a VDDGFX voltage (GfxVid) and an NB voltage
(GnbVid) from the VBIOS dependency tables.
Prepare overdrive support for them in the pp_od_clk_voltage format of
smu7: keep the VBIOS levels and the user's edits in struct
phm_odn_clock_levels as smu7 does, and print the edits as OD_SCLK and
the allowed ranges as OD_RANGE. Only the levels that the SMU enables
(PPSMC_MSG_GetMaxSclkLevel) are used, as the VBIOS table can list
levels above the fused maximum of the part.
The engine clock may range from the lowest level up to the overdrive
limit of the VBIOS. Without a limit, the highest enabled level is used,
so only underclocking is possible, as smu7 and vega10 do since
commit 46defdd6fff7 ("drm/amd/pp: Allow underclocking when od table is
empty in vbios"). The voltage is limited to the range the VBIOS uses
for these levels and kept in mV as on smu7 and vega10, converted from
the VID with convert_to_vddc().
Overdrive stays disabled on these APUs until a later patch.
Signed-off-by: Joshua Horne <hornejd@etsu.edu>
---
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 75 +++++++++++++++++++++-
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h | 7 ++
2 files changed, 81 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
index a19f7a258c67..0bfb9ef72151 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
@@ -1078,6 +1078,54 @@ static int smu8_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,
return 0;
}
+static void smu8_init_od_settings(struct pp_hwmgr *hwmgr)
+{
+ struct smu8_hwmgr *data = hwmgr->backend;
+ struct phm_clock_voltage_dependency_table *vddc_table =
+ hwmgr->dyn_state.vddc_dependency_on_sclk;
+ struct phm_clock_voltage_dependency_table *vdd_gfx_table =
+ hwmgr->dyn_state.vdd_gfx_dependency_on_sclk;
+ struct phm_odn_clock_levels *od = &data->od_default_sclk;
+ struct amdgpu_device *adev = hwmgr->adev;
+ uint32_t i, mv;
+
+ if (!vddc_table || !vdd_gfx_table || !vddc_table->count ||
+ vddc_table->count > ARRAY_SIZE(od->entries) ||
+ vdd_gfx_table->count != vddc_table->count) {
+ dev_info(adev->dev,
+ "OverDrive not supported by the sclk tables\n");
+ hwmgr->od_enabled = false;
+ return;
+ }
+
+ /*
+ * Only expose the levels that the SMU enables: the VBIOS table can
+ * list levels above the fused maximum of the part.
+ */
+ od->num_of_pl = min(vddc_table->count, smu8_get_max_sclk_level(hwmgr));
+ data->od_min_vddc = U32_MAX;
+ data->od_max_vddc = 0;
+ for (i = 0; i < od->num_of_pl; i++) {
+ mv = convert_to_vddc((uint8_t)vdd_gfx_table->entries[i].v);
+ od->entries[i].clock = vddc_table->entries[i].clk;
+ od->entries[i].vddc = mv;
+ od->entries[i].enabled = true;
+ data->od_min_vddc = min(data->od_min_vddc, mv);
+ data->od_max_vddc = max(data->od_max_vddc, mv);
+ }
+
+ /*
+ * Without an overdrive limit in the VBIOS only allow underclocking,
+ * as smu7 and vega10 do. The voltages are limited to the range that
+ * the VBIOS uses for these levels.
+ */
+ if (!hwmgr->platform_descriptor.overdriveLimit.engineClock)
+ hwmgr->platform_descriptor.overdriveLimit.engineClock =
+ od->entries[od->num_of_pl - 1].clock;
+
+ data->od_edit_sclk = *od;
+}
+
static int smu8_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
{
int result = 0;
@@ -1105,6 +1153,9 @@ static int smu8_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
hwmgr->platform_descriptor.hardwareActivityPerformanceLevels = SMU8_MAX_HARDWARE_POWERLEVELS;
+ if (hwmgr->od_enabled)
+ smu8_init_od_settings(hwmgr);
+
return result;
}
@@ -1518,7 +1569,8 @@ static int smu8_emit_clock_levels(struct pp_hwmgr *hwmgr,
struct smu8_hwmgr *data = hwmgr->backend;
struct phm_clock_voltage_dependency_table *sclk_table =
hwmgr->dyn_state.vddc_dependency_on_sclk;
- uint32_t i, now;
+ const struct phm_odn_clock_levels *od = &data->od_edit_sclk;
+ uint32_t i, now, clk;
int size = *offset;
switch (type) {
@@ -1549,6 +1601,27 @@ static int smu8_emit_clock_levels(struct pp_hwmgr *hwmgr,
(SMU8_NUM_NBPMEMORYCLOCK - i == now) ? "*" :
"");
break;
+ case OD_SCLK:
+ if (!hwmgr->od_enabled)
+ break;
+ size += sysfs_emit_at(buf, size, "%s:\n", "OD_SCLK");
+ for (i = 0; i < od->num_of_pl; i++)
+ size += sysfs_emit_at(buf, size, "%u: %10uMHz %10umV\n",
+ i, od->entries[i].clock / 100,
+ od->entries[i].vddc);
+ break;
+ case OD_RANGE:
+ if (!hwmgr->od_enabled)
+ break;
+ size += sysfs_emit_at(buf, size, "%s:\n", "OD_RANGE");
+ clk = data->od_default_sclk.entries[0].clock;
+ size += sysfs_emit_at(buf, size, "SCLK: %7uMHz", clk / 100);
+ clk = hwmgr->platform_descriptor.overdriveLimit.engineClock;
+ size += sysfs_emit_at(buf, size, " %10uMHz\n", clk / 100);
+ /* VDDC is the graphics (VDDGFX) rail of these APUs */
+ size += sysfs_emit_at(buf, size, "VDDC: %7umV %11umV\n",
+ data->od_min_vddc, data->od_max_vddc);
+ break;
default:
break;
}
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h
index 05a06083e1b8..490fcc352a8f 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h
@@ -25,6 +25,7 @@
#define _SMU8_HWMGR_H_
#include "cgs_common.h"
+#include "hardwaremanager.h"
#include "ppatomctrl.h"
#define SMU8_NUM_NBPSTATES 4
@@ -306,6 +307,12 @@ struct smu8_hwmgr {
uint32_t max_sclk_level;
uint32_t num_of_clk_entries;
+
+ /* overdrive: the VBIOS levels, the user's edits, the VDDGFX range */
+ struct phm_odn_clock_levels od_default_sclk;
+ struct phm_odn_clock_levels od_edit_sclk;
+ uint32_t od_min_vddc; /* in mV */
+ uint32_t od_max_vddc; /* in mV */
};
#endif /* _SMU8_HWMGR_H_ */
--
2.56.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 2/4] drm/amd/pm: show the smu8 overdrive sclk table
@ 2026-12-06 4:52 ` Joshua Horne via B4 Relay
0 siblings, 0 replies; 13+ messages in thread
From: Joshua Horne via B4 Relay @ 2026-12-06 4:52 UTC (permalink / raw)
To: Alex Deucher, Kenneth Feng
Cc: Christian König, David Airlie, Simona Vetter,
Timur Kristóf, Lijo Lazar, amd-gfx, dri-devel, linux-kernel,
Joshua Horne
From: Joshua Horne <hornejd@etsu.edu>
Carrizo and Stoney upload up to eight graphics DPM levels to the SMU,
each with an engine clock, a VDDGFX voltage (GfxVid) and an NB voltage
(GnbVid) from the VBIOS dependency tables.
Prepare overdrive support for them in the pp_od_clk_voltage format of
smu7: keep the VBIOS levels and the user's edits in struct
phm_odn_clock_levels as smu7 does, and print the edits as OD_SCLK and
the allowed ranges as OD_RANGE. Only the levels that the SMU enables
(PPSMC_MSG_GetMaxSclkLevel) are used, as the VBIOS table can list
levels above the fused maximum of the part.
The engine clock may range from the lowest level up to the overdrive
limit of the VBIOS. Without a limit, the highest enabled level is used,
so only underclocking is possible, as smu7 and vega10 do since
commit 46defdd6fff7 ("drm/amd/pp: Allow underclocking when od table is
empty in vbios"). The voltage is limited to the range the VBIOS uses
for these levels and kept in mV as on smu7 and vega10, converted from
the VID with convert_to_vddc().
Overdrive stays disabled on these APUs until a later patch.
Signed-off-by: Joshua Horne <hornejd@etsu.edu>
---
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 75 +++++++++++++++++++++-
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h | 7 ++
2 files changed, 81 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
index a19f7a258c67..0bfb9ef72151 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
@@ -1078,6 +1078,54 @@ static int smu8_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,
return 0;
}
+static void smu8_init_od_settings(struct pp_hwmgr *hwmgr)
+{
+ struct smu8_hwmgr *data = hwmgr->backend;
+ struct phm_clock_voltage_dependency_table *vddc_table =
+ hwmgr->dyn_state.vddc_dependency_on_sclk;
+ struct phm_clock_voltage_dependency_table *vdd_gfx_table =
+ hwmgr->dyn_state.vdd_gfx_dependency_on_sclk;
+ struct phm_odn_clock_levels *od = &data->od_default_sclk;
+ struct amdgpu_device *adev = hwmgr->adev;
+ uint32_t i, mv;
+
+ if (!vddc_table || !vdd_gfx_table || !vddc_table->count ||
+ vddc_table->count > ARRAY_SIZE(od->entries) ||
+ vdd_gfx_table->count != vddc_table->count) {
+ dev_info(adev->dev,
+ "OverDrive not supported by the sclk tables\n");
+ hwmgr->od_enabled = false;
+ return;
+ }
+
+ /*
+ * Only expose the levels that the SMU enables: the VBIOS table can
+ * list levels above the fused maximum of the part.
+ */
+ od->num_of_pl = min(vddc_table->count, smu8_get_max_sclk_level(hwmgr));
+ data->od_min_vddc = U32_MAX;
+ data->od_max_vddc = 0;
+ for (i = 0; i < od->num_of_pl; i++) {
+ mv = convert_to_vddc((uint8_t)vdd_gfx_table->entries[i].v);
+ od->entries[i].clock = vddc_table->entries[i].clk;
+ od->entries[i].vddc = mv;
+ od->entries[i].enabled = true;
+ data->od_min_vddc = min(data->od_min_vddc, mv);
+ data->od_max_vddc = max(data->od_max_vddc, mv);
+ }
+
+ /*
+ * Without an overdrive limit in the VBIOS only allow underclocking,
+ * as smu7 and vega10 do. The voltages are limited to the range that
+ * the VBIOS uses for these levels.
+ */
+ if (!hwmgr->platform_descriptor.overdriveLimit.engineClock)
+ hwmgr->platform_descriptor.overdriveLimit.engineClock =
+ od->entries[od->num_of_pl - 1].clock;
+
+ data->od_edit_sclk = *od;
+}
+
static int smu8_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
{
int result = 0;
@@ -1105,6 +1153,9 @@ static int smu8_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
hwmgr->platform_descriptor.hardwareActivityPerformanceLevels = SMU8_MAX_HARDWARE_POWERLEVELS;
+ if (hwmgr->od_enabled)
+ smu8_init_od_settings(hwmgr);
+
return result;
}
@@ -1518,7 +1569,8 @@ static int smu8_emit_clock_levels(struct pp_hwmgr *hwmgr,
struct smu8_hwmgr *data = hwmgr->backend;
struct phm_clock_voltage_dependency_table *sclk_table =
hwmgr->dyn_state.vddc_dependency_on_sclk;
- uint32_t i, now;
+ const struct phm_odn_clock_levels *od = &data->od_edit_sclk;
+ uint32_t i, now, clk;
int size = *offset;
switch (type) {
@@ -1549,6 +1601,27 @@ static int smu8_emit_clock_levels(struct pp_hwmgr *hwmgr,
(SMU8_NUM_NBPMEMORYCLOCK - i == now) ? "*" :
"");
break;
+ case OD_SCLK:
+ if (!hwmgr->od_enabled)
+ break;
+ size += sysfs_emit_at(buf, size, "%s:\n", "OD_SCLK");
+ for (i = 0; i < od->num_of_pl; i++)
+ size += sysfs_emit_at(buf, size, "%u: %10uMHz %10umV\n",
+ i, od->entries[i].clock / 100,
+ od->entries[i].vddc);
+ break;
+ case OD_RANGE:
+ if (!hwmgr->od_enabled)
+ break;
+ size += sysfs_emit_at(buf, size, "%s:\n", "OD_RANGE");
+ clk = data->od_default_sclk.entries[0].clock;
+ size += sysfs_emit_at(buf, size, "SCLK: %7uMHz", clk / 100);
+ clk = hwmgr->platform_descriptor.overdriveLimit.engineClock;
+ size += sysfs_emit_at(buf, size, " %10uMHz\n", clk / 100);
+ /* VDDC is the graphics (VDDGFX) rail of these APUs */
+ size += sysfs_emit_at(buf, size, "VDDC: %7umV %11umV\n",
+ data->od_min_vddc, data->od_max_vddc);
+ break;
default:
break;
}
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h
index 05a06083e1b8..490fcc352a8f 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h
@@ -25,6 +25,7 @@
#define _SMU8_HWMGR_H_
#include "cgs_common.h"
+#include "hardwaremanager.h"
#include "ppatomctrl.h"
#define SMU8_NUM_NBPSTATES 4
@@ -306,6 +307,12 @@ struct smu8_hwmgr {
uint32_t max_sclk_level;
uint32_t num_of_clk_entries;
+
+ /* overdrive: the VBIOS levels, the user's edits, the VDDGFX range */
+ struct phm_odn_clock_levels od_default_sclk;
+ struct phm_odn_clock_levels od_edit_sclk;
+ uint32_t od_min_vddc; /* in mV */
+ uint32_t od_max_vddc; /* in mV */
};
#endif /* _SMU8_HWMGR_H_ */
--
2.56.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 3/4] drm/amd/pm: allow editing the smu8 overdrive sclk table
2026-12-06 4:52 ` Joshua Horne via B4 Relay
@ 2026-12-06 4:52 ` Joshua Horne via B4 Relay
-1 siblings, 0 replies; 13+ messages in thread
From: Joshua Horne @ 2026-12-06 4:52 UTC (permalink / raw)
To: Alex Deucher, Kenneth Feng
Cc: Christian König, David Airlie, Simona Vetter,
Timur Kristóf, Lijo Lazar, amd-gfx, dri-devel, linux-kernel,
Joshua Horne
Implement the "s <level> <MHz> <mV>", "r" and "c" commands of
pp_od_clk_voltage for Carrizo and Stoney.
The levels given in one write are checked against OD_RANGE and applied
all or none. A new clock is rounded to the one the engine PLL produces,
as reported by the ComputeMemoryEnginePLL table. OD_SCLK and OD_RANGE
show whole MHz, so a level written back with the clock OD_SCLK shows or
with its VBIOS clock keeps that exact clock, and the OD_RANGE maximum
stands for the exact limit. A voltage between two VID steps is rounded
up by convert_to_vid(). A commit is refused unless the clocks increase
from level to level over the whole table, in which the levels that the
SMU does not enable keep their VBIOS clocks.
As on smu7 and vega10, a commit only marks the table as pending. The
power state readjustment that follows it writes the clocks and VDDGFX
voltages into the dependency tables and uploads them through
smu8_upload_pptable_to_smu(), the path used at init and resume, so the
settings also survive suspend. The NB voltages (GnbVid) are not
changed. The power states refer to the levels by clock and are read by
amdgpu_dpm_get_sclk(), so update them as well, like
vega10_odn_update_power_state() does.
smu8_update_sclk_limit() sends the display's minimum engine clock to
the SMU as a level index, but only when that clock changes. The upload
clears the cached clock, so the minimum is looked up again in the new
table.
The SMU accepts the new table at runtime and switches to the new clock
and voltage of a level the next time it enters that level. No
powerplay backend forces a level change after a commit, so this one
does not either.
Signed-off-by: Joshua Horne <hornejd@etsu.edu>
---
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 226 +++++++++++++++++++++
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h | 1 +
2 files changed, 227 insertions(+)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
index 0bfb9ef72151..17c720d04728 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
@@ -858,10 +858,92 @@ static void smu8_populate_umdpstate_clocks(struct pp_hwmgr *hwmgr)
hwmgr->pstate_mclk_peak = 0;
}
+static void smu8_od_update_power_state(struct pp_hwmgr *hwmgr,
+ struct pp_power_state *ps)
+{
+ struct smu8_hwmgr *data = hwmgr->backend;
+ const struct phm_odn_clock_levels *od = &data->od_edit_sclk;
+ const struct phm_clock_voltage_dependency_table *old =
+ hwmgr->dyn_state.vddc_dependency_on_sclk;
+ struct smu8_power_state *smu8_ps;
+ struct smu8_power_level *level;
+ uint32_t i, j;
+
+ if (!ps)
+ return;
+
+ smu8_ps = cast_smu8_power_state(&ps->hardware);
+ if (!smu8_ps)
+ return;
+
+ for (i = 0; i < smu8_ps->level; i++) {
+ level = &smu8_ps->levels[i];
+ for (j = 0; j < od->num_of_pl; j++) {
+ if (level->engineClock == old->entries[j].clk) {
+ level->engineClock = od->entries[j].clock;
+ break;
+ }
+ }
+ }
+}
+
+static int smu8_od_upload_sclk_table(struct pp_hwmgr *hwmgr)
+{
+ struct smu8_hwmgr *data = hwmgr->backend;
+ const struct phm_odn_clock_levels *od = &data->od_edit_sclk;
+ struct phm_clock_voltage_dependency_table *vddc_table =
+ hwmgr->dyn_state.vddc_dependency_on_sclk;
+ struct phm_clock_voltage_dependency_table *vdd_gfx_table =
+ hwmgr->dyn_state.vdd_gfx_dependency_on_sclk;
+ struct pp_power_state *ps;
+ uint32_t i;
+
+ data->od_update_pending = false;
+
+ /* the power states refer to the levels by clock, update them first */
+ ps = hwmgr->ps;
+ for (i = 0; i < hwmgr->num_ps; i++) {
+ smu8_od_update_power_state(hwmgr, ps);
+ ps = (struct pp_power_state *)
+ ((unsigned long)ps + hwmgr->ps_size);
+ }
+ smu8_od_update_power_state(hwmgr, hwmgr->current_ps);
+ smu8_od_update_power_state(hwmgr, hwmgr->request_ps);
+
+ /* the NB voltages (GnbVid) of the levels are left untouched */
+ for (i = 0; i < od->num_of_pl; i++) {
+ vddc_table->entries[i].clk = od->entries[i].clock;
+ vdd_gfx_table->entries[i].clk = od->entries[i].clock;
+ vdd_gfx_table->entries[i].v =
+ convert_to_vid(od->entries[i].vddc);
+ }
+
+ smu8_populate_umdpstate_clocks(hwmgr);
+
+ /*
+ * The SMU gets the display minimum as a level index, which may differ
+ * in the new table: make smu8_update_sclk_limit() send it again.
+ */
+ data->sclk_dpm.hard_min_clk = 0;
+
+ /*
+ * The SMU switches to the new clock and voltage of a level the next
+ * time it enters that level.
+ */
+ return smu8_upload_pptable_to_smu(hwmgr);
+}
+
static int smu8_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *input)
{
+ struct smu8_hwmgr *data = hwmgr->backend;
int ret = 0;
+ if (data->od_update_pending) {
+ ret = smu8_od_upload_sclk_table(hwmgr);
+ if (ret)
+ return ret;
+ }
+
smu8_update_sclk_limit(hwmgr);
smu8_set_deep_sleep_sclk_threshold(hwmgr);
smu8_set_watermark_threshold(hwmgr);
@@ -2065,6 +2147,149 @@ static void smu8_dpm_powergate_vce(struct pp_hwmgr *hwmgr, bool bgate)
}
}
+static uint32_t smu8_od_real_sclk(struct pp_hwmgr *hwmgr, uint32_t clk)
+{
+ pp_atomctrl_clock_dividers_kong dividers;
+
+ if (atomctrl_get_engine_pll_dividers_kong(hwmgr, clk, ÷rs) ||
+ !dividers.real_clock)
+ return clk;
+
+ return dividers.real_clock;
+}
+
+static int smu8_od_edit_sclk_level(struct pp_hwmgr *hwmgr,
+ struct phm_odn_clock_levels *od,
+ long level, long mhz, long mv)
+{
+ struct smu8_hwmgr *data = hwmgr->backend;
+ struct amdgpu_device *adev = hwmgr->adev;
+ uint32_t min_clk, max_clk, clk;
+
+ min_clk = data->od_default_sclk.entries[0].clock;
+ max_clk = hwmgr->platform_descriptor.overdriveLimit.engineClock;
+
+ if (level < 0 || level >= od->num_of_pl) {
+ dev_info(adev->dev,
+ "OD sclk level %ld is out of range [0 - %u]\n",
+ level, od->num_of_pl - 1);
+ return -EINVAL;
+ }
+
+ if (mhz < min_clk / 100 || mhz > max_clk / 100) {
+ dev_info(adev->dev,
+ "OD engine clock is out of range [%u - %u] MHz\n",
+ min_clk / 100, max_clk / 100);
+ return -EINVAL;
+ }
+
+ if (mv < data->od_min_vddc || mv > data->od_max_vddc) {
+ dev_info(adev->dev, "OD voltage is out of range [%u - %u] mV\n",
+ data->od_min_vddc, data->od_max_vddc);
+ return -EINVAL;
+ }
+
+ /*
+ * OD_SCLK and OD_RANGE show whole MHz. A level written back unchanged
+ * or with its VBIOS clock keeps that exact clock, and the OD_RANGE
+ * maximum stands for the exact limit. Otherwise use the clock the PLL
+ * produces.
+ */
+ clk = mhz * 100;
+ if (clk == od->entries[level].clock / 100 * 100)
+ clk = od->entries[level].clock;
+ else if (clk == data->od_default_sclk.entries[level].clock / 100 * 100)
+ clk = data->od_default_sclk.entries[level].clock;
+ else if (clk == max_clk / 100 * 100)
+ clk = smu8_od_real_sclk(hwmgr, max_clk);
+ else
+ clk = smu8_od_real_sclk(hwmgr, clk);
+
+ if (clk < min_clk || clk > max_clk) {
+ dev_info(adev->dev,
+ "OD engine clock %u.%02u MHz is out of range\n",
+ clk / 100, clk % 100);
+ return -EINVAL;
+ }
+
+ od->entries[level].clock = clk;
+ /* a voltage between two VID steps is rounded up */
+ od->entries[level].vddc = convert_to_vddc(convert_to_vid(mv));
+
+ return 0;
+}
+
+static int smu8_od_commit_sclk_table(struct pp_hwmgr *hwmgr)
+{
+ struct smu8_hwmgr *data = hwmgr->backend;
+ struct phm_odn_clock_levels *od = &data->od_edit_sclk;
+ struct phm_clock_voltage_dependency_table *table =
+ hwmgr->dyn_state.vddc_dependency_on_sclk;
+ struct amdgpu_device *adev = hwmgr->adev;
+ uint32_t i, clk, prev = 0;
+
+ /* the levels that the SMU does not enable keep their clocks */
+ for (i = 0; i < table->count; i++) {
+ clk = i < od->num_of_pl ? od->entries[i].clock :
+ table->entries[i].clk;
+ if (clk <= prev) {
+ dev_info(adev->dev, "OD sclk levels must increase\n");
+ return -EINVAL;
+ }
+ prev = clk;
+ }
+
+ /* uploaded by the power state readjustment that follows a commit */
+ data->od_update_pending = true;
+
+ return 0;
+}
+
+static int smu8_odn_edit_dpm_table(struct pp_hwmgr *hwmgr,
+ enum PP_OD_DPM_TABLE_COMMAND type,
+ long *input, uint32_t size)
+{
+ struct smu8_hwmgr *data = hwmgr->backend;
+ struct amdgpu_device *adev = hwmgr->adev;
+ struct phm_odn_clock_levels od;
+ uint32_t i;
+ int ret;
+
+ if (!hwmgr->od_enabled) {
+ dev_info(adev->dev, "OverDrive feature not enabled\n");
+ return -EINVAL;
+ }
+
+ switch (type) {
+ case PP_OD_EDIT_SCLK_VDDC_TABLE:
+ break;
+ case PP_OD_RESTORE_DEFAULT_TABLE:
+ data->od_edit_sclk = data->od_default_sclk;
+ return 0;
+ case PP_OD_COMMIT_DPM_TABLE:
+ return smu8_od_commit_sclk_table(hwmgr);
+ default:
+ return -EINVAL;
+ }
+
+ if (!input || !size || size % 3) {
+ dev_info(adev->dev,
+ "OD sclk input must be <level> <MHz> <mV>\n");
+ return -EINVAL;
+ }
+
+ od = data->od_edit_sclk;
+ for (i = 0; i < size; i += 3) {
+ ret = smu8_od_edit_sclk_level(hwmgr, &od, input[i],
+ input[i + 1], input[i + 2]);
+ if (ret)
+ return ret;
+ }
+ data->od_edit_sclk = od;
+
+ return 0;
+}
+
static const struct pp_hwmgr_func smu8_hwmgr_funcs = {
.backend_init = smu8_hwmgr_backend_init,
.backend_fini = smu8_hwmgr_backend_fini,
@@ -2095,6 +2320,7 @@ static const struct pp_hwmgr_func smu8_hwmgr_funcs = {
.dynamic_state_management_disable = smu8_disable_dpm_tasks,
.notify_cac_buffer_info = smu8_notify_cac_buffer_info,
.get_thermal_temperature_range = smu8_get_thermal_temperature_range,
+ .odn_edit_dpm_table = smu8_odn_edit_dpm_table,
};
int smu8_init_function_pointers(struct pp_hwmgr *hwmgr)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h
index 490fcc352a8f..63ae7826a2da 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h
@@ -313,6 +313,7 @@ struct smu8_hwmgr {
struct phm_odn_clock_levels od_edit_sclk;
uint32_t od_min_vddc; /* in mV */
uint32_t od_max_vddc; /* in mV */
+ bool od_update_pending; /* committed, not uploaded yet */
};
#endif /* _SMU8_HWMGR_H_ */
--
2.56.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 3/4] drm/amd/pm: allow editing the smu8 overdrive sclk table
@ 2026-12-06 4:52 ` Joshua Horne via B4 Relay
0 siblings, 0 replies; 13+ messages in thread
From: Joshua Horne via B4 Relay @ 2026-12-06 4:52 UTC (permalink / raw)
To: Alex Deucher, Kenneth Feng
Cc: Christian König, David Airlie, Simona Vetter,
Timur Kristóf, Lijo Lazar, amd-gfx, dri-devel, linux-kernel,
Joshua Horne
From: Joshua Horne <hornejd@etsu.edu>
Implement the "s <level> <MHz> <mV>", "r" and "c" commands of
pp_od_clk_voltage for Carrizo and Stoney.
The levels given in one write are checked against OD_RANGE and applied
all or none. A new clock is rounded to the one the engine PLL produces,
as reported by the ComputeMemoryEnginePLL table. OD_SCLK and OD_RANGE
show whole MHz, so a level written back with the clock OD_SCLK shows or
with its VBIOS clock keeps that exact clock, and the OD_RANGE maximum
stands for the exact limit. A voltage between two VID steps is rounded
up by convert_to_vid(). A commit is refused unless the clocks increase
from level to level over the whole table, in which the levels that the
SMU does not enable keep their VBIOS clocks.
As on smu7 and vega10, a commit only marks the table as pending. The
power state readjustment that follows it writes the clocks and VDDGFX
voltages into the dependency tables and uploads them through
smu8_upload_pptable_to_smu(), the path used at init and resume, so the
settings also survive suspend. The NB voltages (GnbVid) are not
changed. The power states refer to the levels by clock and are read by
amdgpu_dpm_get_sclk(), so update them as well, like
vega10_odn_update_power_state() does.
smu8_update_sclk_limit() sends the display's minimum engine clock to
the SMU as a level index, but only when that clock changes. The upload
clears the cached clock, so the minimum is looked up again in the new
table.
The SMU accepts the new table at runtime and switches to the new clock
and voltage of a level the next time it enters that level. No
powerplay backend forces a level change after a commit, so this one
does not either.
Signed-off-by: Joshua Horne <hornejd@etsu.edu>
---
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 226 +++++++++++++++++++++
.../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h | 1 +
2 files changed, 227 insertions(+)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
index 0bfb9ef72151..17c720d04728 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
@@ -858,10 +858,92 @@ static void smu8_populate_umdpstate_clocks(struct pp_hwmgr *hwmgr)
hwmgr->pstate_mclk_peak = 0;
}
+static void smu8_od_update_power_state(struct pp_hwmgr *hwmgr,
+ struct pp_power_state *ps)
+{
+ struct smu8_hwmgr *data = hwmgr->backend;
+ const struct phm_odn_clock_levels *od = &data->od_edit_sclk;
+ const struct phm_clock_voltage_dependency_table *old =
+ hwmgr->dyn_state.vddc_dependency_on_sclk;
+ struct smu8_power_state *smu8_ps;
+ struct smu8_power_level *level;
+ uint32_t i, j;
+
+ if (!ps)
+ return;
+
+ smu8_ps = cast_smu8_power_state(&ps->hardware);
+ if (!smu8_ps)
+ return;
+
+ for (i = 0; i < smu8_ps->level; i++) {
+ level = &smu8_ps->levels[i];
+ for (j = 0; j < od->num_of_pl; j++) {
+ if (level->engineClock == old->entries[j].clk) {
+ level->engineClock = od->entries[j].clock;
+ break;
+ }
+ }
+ }
+}
+
+static int smu8_od_upload_sclk_table(struct pp_hwmgr *hwmgr)
+{
+ struct smu8_hwmgr *data = hwmgr->backend;
+ const struct phm_odn_clock_levels *od = &data->od_edit_sclk;
+ struct phm_clock_voltage_dependency_table *vddc_table =
+ hwmgr->dyn_state.vddc_dependency_on_sclk;
+ struct phm_clock_voltage_dependency_table *vdd_gfx_table =
+ hwmgr->dyn_state.vdd_gfx_dependency_on_sclk;
+ struct pp_power_state *ps;
+ uint32_t i;
+
+ data->od_update_pending = false;
+
+ /* the power states refer to the levels by clock, update them first */
+ ps = hwmgr->ps;
+ for (i = 0; i < hwmgr->num_ps; i++) {
+ smu8_od_update_power_state(hwmgr, ps);
+ ps = (struct pp_power_state *)
+ ((unsigned long)ps + hwmgr->ps_size);
+ }
+ smu8_od_update_power_state(hwmgr, hwmgr->current_ps);
+ smu8_od_update_power_state(hwmgr, hwmgr->request_ps);
+
+ /* the NB voltages (GnbVid) of the levels are left untouched */
+ for (i = 0; i < od->num_of_pl; i++) {
+ vddc_table->entries[i].clk = od->entries[i].clock;
+ vdd_gfx_table->entries[i].clk = od->entries[i].clock;
+ vdd_gfx_table->entries[i].v =
+ convert_to_vid(od->entries[i].vddc);
+ }
+
+ smu8_populate_umdpstate_clocks(hwmgr);
+
+ /*
+ * The SMU gets the display minimum as a level index, which may differ
+ * in the new table: make smu8_update_sclk_limit() send it again.
+ */
+ data->sclk_dpm.hard_min_clk = 0;
+
+ /*
+ * The SMU switches to the new clock and voltage of a level the next
+ * time it enters that level.
+ */
+ return smu8_upload_pptable_to_smu(hwmgr);
+}
+
static int smu8_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *input)
{
+ struct smu8_hwmgr *data = hwmgr->backend;
int ret = 0;
+ if (data->od_update_pending) {
+ ret = smu8_od_upload_sclk_table(hwmgr);
+ if (ret)
+ return ret;
+ }
+
smu8_update_sclk_limit(hwmgr);
smu8_set_deep_sleep_sclk_threshold(hwmgr);
smu8_set_watermark_threshold(hwmgr);
@@ -2065,6 +2147,149 @@ static void smu8_dpm_powergate_vce(struct pp_hwmgr *hwmgr, bool bgate)
}
}
+static uint32_t smu8_od_real_sclk(struct pp_hwmgr *hwmgr, uint32_t clk)
+{
+ pp_atomctrl_clock_dividers_kong dividers;
+
+ if (atomctrl_get_engine_pll_dividers_kong(hwmgr, clk, ÷rs) ||
+ !dividers.real_clock)
+ return clk;
+
+ return dividers.real_clock;
+}
+
+static int smu8_od_edit_sclk_level(struct pp_hwmgr *hwmgr,
+ struct phm_odn_clock_levels *od,
+ long level, long mhz, long mv)
+{
+ struct smu8_hwmgr *data = hwmgr->backend;
+ struct amdgpu_device *adev = hwmgr->adev;
+ uint32_t min_clk, max_clk, clk;
+
+ min_clk = data->od_default_sclk.entries[0].clock;
+ max_clk = hwmgr->platform_descriptor.overdriveLimit.engineClock;
+
+ if (level < 0 || level >= od->num_of_pl) {
+ dev_info(adev->dev,
+ "OD sclk level %ld is out of range [0 - %u]\n",
+ level, od->num_of_pl - 1);
+ return -EINVAL;
+ }
+
+ if (mhz < min_clk / 100 || mhz > max_clk / 100) {
+ dev_info(adev->dev,
+ "OD engine clock is out of range [%u - %u] MHz\n",
+ min_clk / 100, max_clk / 100);
+ return -EINVAL;
+ }
+
+ if (mv < data->od_min_vddc || mv > data->od_max_vddc) {
+ dev_info(adev->dev, "OD voltage is out of range [%u - %u] mV\n",
+ data->od_min_vddc, data->od_max_vddc);
+ return -EINVAL;
+ }
+
+ /*
+ * OD_SCLK and OD_RANGE show whole MHz. A level written back unchanged
+ * or with its VBIOS clock keeps that exact clock, and the OD_RANGE
+ * maximum stands for the exact limit. Otherwise use the clock the PLL
+ * produces.
+ */
+ clk = mhz * 100;
+ if (clk == od->entries[level].clock / 100 * 100)
+ clk = od->entries[level].clock;
+ else if (clk == data->od_default_sclk.entries[level].clock / 100 * 100)
+ clk = data->od_default_sclk.entries[level].clock;
+ else if (clk == max_clk / 100 * 100)
+ clk = smu8_od_real_sclk(hwmgr, max_clk);
+ else
+ clk = smu8_od_real_sclk(hwmgr, clk);
+
+ if (clk < min_clk || clk > max_clk) {
+ dev_info(adev->dev,
+ "OD engine clock %u.%02u MHz is out of range\n",
+ clk / 100, clk % 100);
+ return -EINVAL;
+ }
+
+ od->entries[level].clock = clk;
+ /* a voltage between two VID steps is rounded up */
+ od->entries[level].vddc = convert_to_vddc(convert_to_vid(mv));
+
+ return 0;
+}
+
+static int smu8_od_commit_sclk_table(struct pp_hwmgr *hwmgr)
+{
+ struct smu8_hwmgr *data = hwmgr->backend;
+ struct phm_odn_clock_levels *od = &data->od_edit_sclk;
+ struct phm_clock_voltage_dependency_table *table =
+ hwmgr->dyn_state.vddc_dependency_on_sclk;
+ struct amdgpu_device *adev = hwmgr->adev;
+ uint32_t i, clk, prev = 0;
+
+ /* the levels that the SMU does not enable keep their clocks */
+ for (i = 0; i < table->count; i++) {
+ clk = i < od->num_of_pl ? od->entries[i].clock :
+ table->entries[i].clk;
+ if (clk <= prev) {
+ dev_info(adev->dev, "OD sclk levels must increase\n");
+ return -EINVAL;
+ }
+ prev = clk;
+ }
+
+ /* uploaded by the power state readjustment that follows a commit */
+ data->od_update_pending = true;
+
+ return 0;
+}
+
+static int smu8_odn_edit_dpm_table(struct pp_hwmgr *hwmgr,
+ enum PP_OD_DPM_TABLE_COMMAND type,
+ long *input, uint32_t size)
+{
+ struct smu8_hwmgr *data = hwmgr->backend;
+ struct amdgpu_device *adev = hwmgr->adev;
+ struct phm_odn_clock_levels od;
+ uint32_t i;
+ int ret;
+
+ if (!hwmgr->od_enabled) {
+ dev_info(adev->dev, "OverDrive feature not enabled\n");
+ return -EINVAL;
+ }
+
+ switch (type) {
+ case PP_OD_EDIT_SCLK_VDDC_TABLE:
+ break;
+ case PP_OD_RESTORE_DEFAULT_TABLE:
+ data->od_edit_sclk = data->od_default_sclk;
+ return 0;
+ case PP_OD_COMMIT_DPM_TABLE:
+ return smu8_od_commit_sclk_table(hwmgr);
+ default:
+ return -EINVAL;
+ }
+
+ if (!input || !size || size % 3) {
+ dev_info(adev->dev,
+ "OD sclk input must be <level> <MHz> <mV>\n");
+ return -EINVAL;
+ }
+
+ od = data->od_edit_sclk;
+ for (i = 0; i < size; i += 3) {
+ ret = smu8_od_edit_sclk_level(hwmgr, &od, input[i],
+ input[i + 1], input[i + 2]);
+ if (ret)
+ return ret;
+ }
+ data->od_edit_sclk = od;
+
+ return 0;
+}
+
static const struct pp_hwmgr_func smu8_hwmgr_funcs = {
.backend_init = smu8_hwmgr_backend_init,
.backend_fini = smu8_hwmgr_backend_fini,
@@ -2095,6 +2320,7 @@ static const struct pp_hwmgr_func smu8_hwmgr_funcs = {
.dynamic_state_management_disable = smu8_disable_dpm_tasks,
.notify_cac_buffer_info = smu8_notify_cac_buffer_info,
.get_thermal_temperature_range = smu8_get_thermal_temperature_range,
+ .odn_edit_dpm_table = smu8_odn_edit_dpm_table,
};
int smu8_init_function_pointers(struct pp_hwmgr *hwmgr)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h
index 490fcc352a8f..63ae7826a2da 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.h
@@ -313,6 +313,7 @@ struct smu8_hwmgr {
struct phm_odn_clock_levels od_edit_sclk;
uint32_t od_min_vddc; /* in mV */
uint32_t od_max_vddc; /* in mV */
+ bool od_update_pending; /* committed, not uploaded yet */
};
#endif /* _SMU8_HWMGR_H_ */
--
2.56.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 4/4] drm/amd/pm: stop disabling overdrive on Carrizo and Stoney
2026-12-06 4:52 ` Joshua Horne via B4 Relay
@ 2026-12-06 4:52 ` Joshua Horne via B4 Relay
-1 siblings, 0 replies; 13+ messages in thread
From: Joshua Horne @ 2026-12-06 4:52 UTC (permalink / raw)
To: Alex Deucher, Kenneth Feng
Cc: Christian König, David Airlie, Simona Vetter,
Timur Kristóf, Lijo Lazar, amd-gfx, dri-devel, linux-kernel,
Joshua Horne
Commit b7e919b9403f ("drm/amd/pp: Disable OD feature on APU/Iceland")
disabled overdrive on these APUs, which the smu8 backend did not
implement then. Now that it does, let the PP_OVERDRIVE_MASK bit of
amdgpu.ppfeaturemask decide, as on Tonga and newer dGPUs. The bit is
clear by default and taints the kernel when set.
Raven, disabled by the same commit, gained overdrive support with
commit 12a6727dee5d ("drm/amd/powerplay: add one sysfs file to support
the feature to modify gfx clock on Raven/Raven2/Picasso APU.").
Document the pp_od_clk_voltage format for Carrizo and Stoney.
Signed-off-by: Joshua Horne <hornejd@etsu.edu>
---
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 6 ++++++
drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c | 1 -
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 48c52ac0fc77..aeee31cc08c9 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -705,6 +705,12 @@ static ssize_t amdgpu_set_pp_table(struct device *dev,
* "c" (commit) to the file to commit your changes. If you want to reset to the
* default power levels, write "r" (reset) to the file to reset them.
*
+ * < For Carrizo and Stoney APUs >
+ *
+ * As for Vega10 and previous ASICs, without OD_MCLK. The voltages are
+ * those of the graphics (VDDGFX) rail. A level switches to its new clock
+ * and voltage the next time the GPU enters that level.
+ *
*
* < For Vega20 and newer ASICs >
*
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c
index 4d553be56396..1567b8fa2a6b 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c
@@ -120,7 +120,6 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
break;
case AMDGPU_FAMILY_CZ:
adev->pm.pp_feature &= ~PP_GFXOFF_MASK;
- hwmgr->od_enabled = false;
hwmgr->smumgr_funcs = &smu8_smu_funcs;
hwmgr->feature_mask &= ~PP_GFXOFF_MASK;
smu8_init_function_pointers(hwmgr);
--
2.56.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3 4/4] drm/amd/pm: stop disabling overdrive on Carrizo and Stoney
@ 2026-12-06 4:52 ` Joshua Horne via B4 Relay
0 siblings, 0 replies; 13+ messages in thread
From: Joshua Horne via B4 Relay @ 2026-12-06 4:52 UTC (permalink / raw)
To: Alex Deucher, Kenneth Feng
Cc: Christian König, David Airlie, Simona Vetter,
Timur Kristóf, Lijo Lazar, amd-gfx, dri-devel, linux-kernel,
Joshua Horne
From: Joshua Horne <hornejd@etsu.edu>
Commit b7e919b9403f ("drm/amd/pp: Disable OD feature on APU/Iceland")
disabled overdrive on these APUs, which the smu8 backend did not
implement then. Now that it does, let the PP_OVERDRIVE_MASK bit of
amdgpu.ppfeaturemask decide, as on Tonga and newer dGPUs. The bit is
clear by default and taints the kernel when set.
Raven, disabled by the same commit, gained overdrive support with
commit 12a6727dee5d ("drm/amd/powerplay: add one sysfs file to support
the feature to modify gfx clock on Raven/Raven2/Picasso APU.").
Document the pp_od_clk_voltage format for Carrizo and Stoney.
Signed-off-by: Joshua Horne <hornejd@etsu.edu>
---
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 6 ++++++
drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c | 1 -
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 48c52ac0fc77..aeee31cc08c9 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -705,6 +705,12 @@ static ssize_t amdgpu_set_pp_table(struct device *dev,
* "c" (commit) to the file to commit your changes. If you want to reset to the
* default power levels, write "r" (reset) to the file to reset them.
*
+ * < For Carrizo and Stoney APUs >
+ *
+ * As for Vega10 and previous ASICs, without OD_MCLK. The voltages are
+ * those of the graphics (VDDGFX) rail. A level switches to its new clock
+ * and voltage the next time the GPU enters that level.
+ *
*
* < For Vega20 and newer ASICs >
*
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c
index 4d553be56396..1567b8fa2a6b 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c
@@ -120,7 +120,6 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
break;
case AMDGPU_FAMILY_CZ:
adev->pm.pp_feature &= ~PP_GFXOFF_MASK;
- hwmgr->od_enabled = false;
hwmgr->smumgr_funcs = &smu8_smu_funcs;
hwmgr->feature_mask &= ~PP_GFXOFF_MASK;
smu8_init_function_pointers(hwmgr);
--
2.56.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v3 4/4] drm/amd/pm: stop disabling overdrive on Carrizo and Stoney
2026-12-06 4:52 ` Joshua Horne via B4 Relay
(?)
@ 2026-12-06 5:13 ` sashiko-bot
-1 siblings, 0 replies; 13+ messages in thread
From: sashiko-bot @ 2026-12-06 5:13 UTC (permalink / raw)
To: Joshua Horne; +Cc: amd-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/amd/pm: smu8_get_sclk_level() returns invalid SMU index
after OD edits
- [Medium] drm/amd/pm: TOCTOU race between smu8 OD commit validation and
upload
- [Low] drm/amd/pm: smu8 OD_RANGE upper bound conflicts with commit
check on fused parts
--
commit 410fd83012e58f829edb9505ba11ba13eadf9aa2
Author: Joshua Horne <hornejd@etsu.edu>
drm/amd/pm: stop disabling overdrive on Carrizo and Stoney
This commit stops clearing hwmgr->od_enabled on AMDGPU_FAMILY_CZ so that
PP_OVERDRIVE_MASK in amdgpu.ppfeaturemask controls overdrive on Carrizo
and Stoney APUs, and documents the pp_od_clk_voltage format for them.
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c
> index 4d553be56396f..1567b8fa2a6b7 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c
> @@ -120,7 +120,6 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
> break;
> case AMDGPU_FAMILY_CZ:
> adev->pm.pp_feature &= ~PP_GFXOFF_MASK;
> - hwmgr->od_enabled = false;
> hwmgr->smumgr_funcs = &smu8_smu_funcs;
> hwmgr->feature_mask &= ~PP_GFXOFF_MASK;
> smu8_init_function_pointers(hwmgr);
[Severity: Medium]
Can smu8_get_sclk_level() now return out-of-range SMU level indices after
overdrive edits?
With overdrive enabled, userspace can edit
hwmgr->dyn_state.vddc_dependency_on_sclk in place, but smu8_get_sclk_level()
does not clamp its loop index on fall-through or cap it to
smu8_get_max_sclk_level(hwmgr):
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c:smu8_get_sclk_level() {
...
case PPSMC_MSG_SetSclkSoftMin:
case PPSMC_MSG_SetSclkHardMin:
for (i = 0; i < (int)table->count; i++) {
if (clock <= table->entries[i].clk)
break;
}
break;
case PPSMC_MSG_SetSclkSoftMax:
case PPSMC_MSG_SetSclkHardMax:
for (i = table->count - 1; i >= 0; i--) {
if (clock >= table->entries[i].clk)
break;
}
break;
...
return i;
}
If level 0 is raised above the unchanged VBIOS bootup_engine_clock, resume
(hwmgr_resume() -> smu8_enable_dpm_tasks() -> smu8_program_bootup_state())
calls smu8_get_sclk_level() for PPSMC_MSG_SetSclkSoftMax and sends
0xffffffff to the SMU. In manual overdrive mode,
smu8_dpm_force_dpm_level(AMD_DPM_FORCED_LEVEL_MANUAL) is a no-op during
resume, leaving the invalid soft-max active and breaking DPM clock control.
Similarly, underclocking all enabled levels below
hwmgr->display_config->min_core_set_clock causes smu8_update_sclk_limit()
to send table->count or a fused-off level index for SetSclkHardMin on
overdrive commit. Clamping the return value of smu8_get_sclk_level() to
[0, min(table->count, smu8_get_max_sclk_level(hwmgr)) - 1] would prevent
passing out-of-range indices to the SMU.
[Severity: Medium]
Is there a race between overdrive commit validation in
smu8_od_commit_sclk_table() and the upload in smu8_od_upload_sclk_table()?
amdgpu_set_pp_od_clk_voltage() acquires and releases adev->pm.mutex
separately for amdgpu_dpm_odn_edit_dpm_table() and
amdgpu_dpm_dispatch_task(). Concurrent writes on separate open file
descriptors can mutate data->od_edit_sclk in that unlocked window without
re-checking monotonicity or clearing data->od_update_pending:
CPU0 (write "c") CPU1 (write "s ..." or "r")
amdgpu_set_pp_od_clk_voltage()
amdgpu_dpm_odn_edit_dpm_table()
mutex_lock(&adev->pm.mutex)
smu8_od_commit_sclk_table()
/* checks monotonicity */
data->od_update_pending = true
mutex_unlock(&adev->pm.mutex)
amdgpu_set_pp_od_clk_voltage()
amdgpu_dpm_odn_edit_dpm_table()
mutex_lock(&adev->pm.mutex)
smu8_odn_edit_dpm_table()
/* mutates od_edit_sclk */
mutex_unlock(&adev->pm.mutex)
amdgpu_dpm_dispatch_task()
mutex_lock(&adev->pm.mutex)
smu8_od_upload_sclk_table()
/* uploads live od_edit_sclk */ <-- unvalidated table uploaded
mutex_unlock(&adev->pm.mutex)
This can upload uncommitted, non-monotonic or duplicate SCLK entries into
the power states and SMU firmware via smu8_upload_pptable_to_smu(),
breaking the ascending-clock invariant assumed by smu8_get_sclk_level()
and other DPM helpers. Snapshotting the validated table in
smu8_od_commit_sclk_table() (or clearing od_update_pending on edits and
resets) would close this window.
[Severity: Low]
On fused Carrizo and Stoney parts, can the OD_RANGE upper bound disagree
with the monotonicity check in smu8_od_commit_sclk_table()?
When smu8_get_max_sclk_level(hwmgr) < vddc_table->count,
smu8_init_od_settings() exposes only levels 0 .. od->num_of_pl - 1, but
leaves a non-zero VBIOS overdriveLimit.engineClock uncapped relative to
the hidden disabled entry vddc_table->entries[od->num_of_pl].clk.
OD_RANGE advertises clocks up to overdriveLimit.engineClock and
smu8_od_edit_sclk_level() accepts them, yet smu8_od_commit_sclk_table()
checks strict monotonicity across all table->count entries and rejects
any value >= table->entries[od->num_of_pl].clk with -EINVAL.
If disabled trailing VBIOS slots (i >= od->num_of_pl) contain zero or
non-increasing clocks, smu8_od_commit_sclk_table() will reject every
commit, including after a reset.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-smu8-overdrive-v3-0-46890aa116e7@etsu.edu?part=4
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/4] drm/amd/pm: show the smu8 overdrive sclk table
2026-12-06 4:52 ` Joshua Horne via B4 Relay
(?)
@ 2026-12-06 5:14 ` sashiko-bot
-1 siblings, 0 replies; 13+ messages in thread
From: sashiko-bot @ 2026-12-06 5:14 UTC (permalink / raw)
To: Joshua Horne; +Cc: amd-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/amd/pm: OOB read in smu8_init_od_settings() when
od->num_of_pl is 0
- [Medium] drm/amd/pm: unchecked zero num_of_pl in
smu8_init_od_settings()
- [Medium] drm/amd/pm: smu8_init_od_settings() caches max SCLK before
table upload
--
commit 11d4583ffd83b39f214c04263646787bf1d2e702
Author: Joshua Horne <hornejd@etsu.edu>
drm/amd/pm: show the smu8 overdrive sclk table
This patch initializes the overdrive SCLK table for SMU8 (Carrizo and Stoney)
APUs in smu8_init_od_settings() and formats OD_SCLK and OD_RANGE output in
smu8_emit_clock_levels().
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
> index a19f7a258c674..0bfb9ef721512 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
> @@ -1078,6 +1078,54 @@ static int smu8_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,
> return 0;
> }
>
> +static void smu8_init_od_settings(struct pp_hwmgr *hwmgr)
> +{
[ ... ]
> + /*
> + * Only expose the levels that the SMU enables: the VBIOS table can
> + * list levels above the fused maximum of the part.
> + */
> + od->num_of_pl = min(vddc_table->count, smu8_get_max_sclk_level(hwmgr));
> + data->od_min_vddc = U32_MAX;
> + data->od_max_vddc = 0;
> + for (i = 0; i < od->num_of_pl; i++) {
> + mv = convert_to_vddc((uint8_t)vdd_gfx_table->entries[i].v);
> + od->entries[i].clock = vddc_table->entries[i].clk;
> + od->entries[i].vddc = mv;
> + od->entries[i].enabled = true;
> + data->od_min_vddc = min(data->od_min_vddc, mv);
> + data->od_max_vddc = max(data->od_max_vddc, mv);
> + }
[Severity: Medium]
Can od->num_of_pl end up as zero here?
smu8_send_msg_to_smc_with_parameter() treats any non-zero response register
value, including 0xFFFFFFFF on an MMIO fault, as success, and
smu8_get_max_sclk_level() ignores the return status and increments
data->max_sclk_level in uint32_t arithmetic:
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c:smu8_get_max_sclk_level() {
...
if (data->max_sclk_level == 0) {
smum_send_msg_to_smc(hwmgr,
PPSMC_MSG_GetMaxSclkLevel,
&data->max_sclk_level);
data->max_sclk_level += 1;
}
...
}
If mmSMU_MP1_SRBM2P_ARG_0 reads 0xFFFFFFFF, data->max_sclk_level wraps to 0
and od->num_of_pl becomes 0, leaving overdrive enabled with U32_MAX/0 VDDC
bounds in OD_RANGE. Checking !od->num_of_pl and clearing hwmgr->od_enabled
avoids this.
> + /*
> + * Without an overdrive limit in the VBIOS only allow underclocking,
> + * as smu7 and vega10 do. The voltages are limited to the range that
> + * the VBIOS uses for these levels.
> + */
> + if (!hwmgr->platform_descriptor.overdriveLimit.engineClock)
> + hwmgr->platform_descriptor.overdriveLimit.engineClock =
> + od->entries[od->num_of_pl - 1].clock;
[Severity: Medium]
Does od->entries[od->num_of_pl - 1] read out of bounds when od->num_of_pl is
zero?
If smu8_get_max_sclk_level() wraps to 0 as above and the VBIOS leaves
overdriveLimit.engineClock at 0, od->num_of_pl - 1 underflows uint32_t to
0xFFFFFFFFU and reads far past the 8-entry od->entries array, causing a
kernel page fault.
[ ... ]
> @@ -1105,6 +1153,9 @@ static int smu8_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
>
> hwmgr->platform_descriptor.hardwareActivityPerformanceLevels = SMU8_MAX_HARDWARE_POWERLEVELS;
>
> + if (hwmgr->od_enabled)
> + smu8_init_od_settings(hwmgr);
> +
> return result;
> }
[Severity: Medium]
Does calling smu8_init_od_settings() in smu8_hwmgr_backend_init() cache
data->max_sclk_level before the clock table is uploaded to the SMU?
In hwmgr_hw_init(), backend_init() runs before phm_setup_asic() calls
smu8_setup_asic_task(), which previously uploaded the VBIOS clock table via
smu8_upload_pptable_to_smu() before querying PPSMC_MSG_GetMaxSclkLevel.
Because smu8_get_max_sclk_level() permanently caches the first response in
data->max_sclk_level, firmware that updates MaxSclkIndex during
PPSMC_MSG_ClkTableXferToSmu will leave all later SCLK limit and overdrive
consumers with a stale max level.
Initializing OD settings in smu8_setup_asic_task() after
smu8_upload_pptable_to_smu(), guarded so resume does not overwrite user
edits, would preserve the existing hardware initialization order.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-smu8-overdrive-v3-0-46890aa116e7@etsu.edu?part=2
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 3/4] drm/amd/pm: allow editing the smu8 overdrive sclk table
2026-12-06 4:52 ` Joshua Horne via B4 Relay
(?)
@ 2026-12-06 5:15 ` sashiko-bot
-1 siblings, 0 replies; 13+ messages in thread
From: sashiko-bot @ 2026-12-06 5:15 UTC (permalink / raw)
To: Joshua Horne; +Cc: amd-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/amd/pm: smu8_get_sclk_level() returns invalid index after
OD SCLK edits
- [Medium] drm/amd/pm: TOCTOU race between smu8 OD commit validation and
table upload
- [Low] drm/amd/pm: smu8_od_commit_sclk_table() validates hidden
disabled levels
--
commit d6d2988f15e1e2d033c702075f930806b90d4b90
Author: Joshua Horne <hornejd@etsu.edu>
drm/amd/pm: allow editing the smu8 overdrive sclk table
This commit implements the "s", "r", and "c" pp_od_clk_voltage commands for
Carrizo and Stoney by adding smu8_odn_edit_dpm_table() and uploading the
edited SCLK table during power state readjustment.
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
> index 0bfb9ef721512..17c720d04728d 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
> @@ -858,10 +858,92 @@ static void smu8_populate_umdpstate_clocks(struct pp_hwmgr *hwmgr)
[ ... ]
> +static int smu8_od_upload_sclk_table(struct pp_hwmgr *hwmgr)
[ ... ]
> + /* the NB voltages (GnbVid) of the levels are left untouched */
> + for (i = 0; i < od->num_of_pl; i++) {
> + vddc_table->entries[i].clk = od->entries[i].clock;
> + vdd_gfx_table->entries[i].clk = od->entries[i].clock;
> + vdd_gfx_table->entries[i].v =
> + convert_to_vid(od->entries[i].vddc);
> + }
> +
> + smu8_populate_umdpstate_clocks(hwmgr);
> +
> + /*
> + * The SMU gets the display minimum as a level index, which may differ
> + * in the new table: make smu8_update_sclk_limit() send it again.
> + */
> + data->sclk_dpm.hard_min_clk = 0;
[Severity: Medium]
Can overwriting vddc_dependency_on_sclk cause smu8_get_sclk_level() to return
an out-of-bounds or disabled level index to the SMU?
Neither search loop in smu8_get_sclk_level() clamps its return value to the
enabled levels:
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c:smu8_get_sclk_level() {
...
case PPSMC_MSG_SetSclkSoftMin:
case PPSMC_MSG_SetSclkHardMin:
for (i = 0; i < (int)table->count; i++) {
if (clock <= table->entries[i].clk)
break;
}
break;
case PPSMC_MSG_SetSclkSoftMax:
case PPSMC_MSG_SetSclkHardMax:
for (i = table->count - 1; i >= 0; i--) {
if (clock >= table->entries[i].clk)
break;
}
break;
...
}
If all enabled levels are underclocked below display_config->min_core_set_clock,
smu8_update_sclk_limit() sends table->count (past the end of the table) or a
fused-off level >= smu8_get_max_sclk_level() to PPSMC_MSG_SetSclkHardMin.
Similarly, on resume smu8_program_bootup_state() looks up the unchanged VBIOS
bootup_engine_clock; if level 0 was raised above it, the descending loop exits
at -1 and sends 0xFFFFFFFF to PPSMC_MSG_SetSclkSoftMax, which stays active in
manual force-performance-level mode. Clamping smu8_get_sclk_level() to
[0, min(table->count, smu8_get_max_sclk_level(hwmgr)) - 1] would prevent this.
[ ... ]
> @@ -2065,6 +2147,149 @@ static void smu8_dpm_powergate_vce(struct pp_hwmgr *hwmgr, bool bgate)
[ ... ]
> +static int smu8_od_commit_sclk_table(struct pp_hwmgr *hwmgr)
> +{
> + struct smu8_hwmgr *data = hwmgr->backend;
> + struct phm_odn_clock_levels *od = &data->od_edit_sclk;
> + struct phm_clock_voltage_dependency_table *table =
> + hwmgr->dyn_state.vddc_dependency_on_sclk;
> + struct amdgpu_device *adev = hwmgr->adev;
> + uint32_t i, clk, prev = 0;
> +
> + /* the levels that the SMU does not enable keep their clocks */
> + for (i = 0; i < table->count; i++) {
> + clk = i < od->num_of_pl ? od->entries[i].clock :
> + table->entries[i].clk;
> + if (clk <= prev) {
> + dev_info(adev->dev, "OD sclk levels must increase\n");
> + return -EINVAL;
> + }
> + prev = clk;
> + }
[Severity: Low]
Will this loop reject clocks that OD_RANGE advertises and
smu8_od_edit_sclk_level() accepts on fused SKUs where od->num_of_pl <
table->count?
init_overdrive_limits_V2_1() populates overdriveLimit.engineClock directly
from the VBIOS without clamping it below table->entries[od->num_of_pl].clk,
while OD_SCLK hides levels at or above od->num_of_pl and
smu8_od_edit_sclk_level() forbids editing them. If overdriveLimit.engineClock
is at or above the first hidden level, committing an accepted clock fails with
-EINVAL against a level the user cannot see or edit.
Also, if the VBIOS contains duplicate or non-increasing clocks in the disabled
trailing entries, every commit (including voltage-only edits or "r" followed
by "c") will fail with -EINVAL.
> +
> + /* uploaded by the power state readjustment that follows a commit */
> + data->od_update_pending = true;
> +
> + return 0;
> +}
> +
> +static int smu8_odn_edit_dpm_table(struct pp_hwmgr *hwmgr,
> + enum PP_OD_DPM_TABLE_COMMAND type,
> + long *input, uint32_t size)
[ ... ]
> + switch (type) {
> + case PP_OD_EDIT_SCLK_VDDC_TABLE:
> + break;
> + case PP_OD_RESTORE_DEFAULT_TABLE:
> + data->od_edit_sclk = data->od_default_sclk;
> + return 0;
> + case PP_OD_COMMIT_DPM_TABLE:
> + return smu8_od_commit_sclk_table(hwmgr);
> + default:
> + return -EINVAL;
> + }
[ ... ]
> + data->od_edit_sclk = od;
[Severity: Medium]
Can a concurrent write to pp_od_clk_voltage overwrite data->od_edit_sclk
between commit validation and upload?
amdgpu_set_pp_od_clk_voltage() releases adev->pm.mutex between
amdgpu_dpm_odn_edit_dpm_table() and amdgpu_dpm_dispatch_task(), and neither
PP_OD_EDIT_SCLK_VDDC_TABLE nor PP_OD_RESTORE_DEFAULT_TABLE clears
data->od_update_pending:
CPU0 CPU1
amdgpu_set_pp_od_clk_voltage("c")
amdgpu_dpm_odn_edit_dpm_table()
lock(&adev->pm.mutex)
smu8_od_commit_sclk_table()
data->od_update_pending = true
unlock(&adev->pm.mutex)
amdgpu_set_pp_od_clk_voltage("s ...")
amdgpu_dpm_odn_edit_dpm_table()
lock(&adev->pm.mutex)
data->od_edit_sclk = od
unlock(&adev->pm.mutex)
amdgpu_dpm_dispatch_task(...)
lock(&adev->pm.mutex)
smu8_od_upload_sclk_table() <-- uploads unvalidated table
unlock(&adev->pm.mutex)
Because smu8_od_upload_sclk_table() reads directly from data->od_edit_sclk
without re-checking monotonicity, a non-monotonic or duplicate-clock table
can be written to the dependency tables, power states, and SMU, breaking
smu8_get_sclk_level() and clock-equality matching in
smu8_od_update_power_state(). Snapshotting the validated table on commit
(or clearing od_update_pending on edit and restore) would close this window.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-smu8-overdrive-v3-0-46890aa116e7@etsu.edu?part=3
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-12-06 5:15 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-06 4:52 [PATCH v3 0/4] drm/amd/pm: overdrive support for smu8 (Carrizo/Stoney) Joshua Horne
2026-12-06 4:52 ` Joshua Horne via B4 Relay
2026-12-06 4:52 ` [PATCH v3 1/4] drm/amd/pm: move smu8_populate_umdpstate_clocks() up Joshua Horne
2026-12-06 4:52 ` Joshua Horne via B4 Relay
2026-12-06 4:52 ` [PATCH v3 2/4] drm/amd/pm: show the smu8 overdrive sclk table Joshua Horne
2026-12-06 4:52 ` Joshua Horne via B4 Relay
2026-12-06 5:14 ` sashiko-bot
2026-12-06 4:52 ` [PATCH v3 3/4] drm/amd/pm: allow editing " Joshua Horne
2026-12-06 4:52 ` Joshua Horne via B4 Relay
2026-12-06 5:15 ` sashiko-bot
2026-12-06 4:52 ` [PATCH v3 4/4] drm/amd/pm: stop disabling overdrive on Carrizo and Stoney Joshua Horne
2026-12-06 4:52 ` Joshua Horne via B4 Relay
2026-12-06 5:13 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.