From: sashiko-bot@kernel.org
To: "Joshua Horne" <hornejd@etsu.edu>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 3/4] drm/amd/pm: allow editing the smu8 overdrive sclk table
Date: Sun, 06 Dec 2026 05:15:26 +0000 [thread overview]
Message-ID: <sashiko-outbox-252163@kernel.org> (raw)
In-Reply-To: <20261205-smu8-overdrive-v3-3-46890aa116e7@etsu.edu>
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
next prev parent reply other threads:[~2026-12-06 5:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-252163@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hornejd@etsu.edu \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.