All of lore.kernel.org
 help / color / mirror / Atom feed
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 2/4] drm/amd/pm: show the smu8 overdrive sclk table
Date: Sun, 06 Dec 2026 05:14:29 +0000	[thread overview]
Message-ID: <sashiko-outbox-252161@kernel.org> (raw)
In-Reply-To: <20261205-smu8-overdrive-v3-2-46890aa116e7@etsu.edu>

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

  reply	other threads:[~2026-12-06  5:14 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 [this message]
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

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-252161@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.