From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25DB8606A31F for ; Sun, 6 Dec 2026 05:14:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nq1cfdu3 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE4AA10E25D; Sun, 6 Dec 2026 05:14:36 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id D1E2D10E25D; Sun, 6 Dec 2026 05:14:30 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 5BE3E444B5; Sun, 6 Dec 2026 05:14:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2882A1F0093B; Sun, 6 Dec 2026 05:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796534070; bh=J1Q72nxGHVOwy9/l0tNNlwzzK9zOIH1TqKme0bP/xMY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=nq1cfdu3r4myykXSYsOKSp0VbSci4GIF6abcJCDX+zFuq18+JBTcqOopC18T6pHZq /PW5ZYMOrLhdX3496PDzgs4KHnjUGYtO6N40yTz0XQKdsJ/Qzeh8ECaFNTXtQPK5Ge e5JYmW7KMAi21W1mlDVX4rIHPyB6v7ZHCZ6aKxbzK0KxThzrMpP5kpYL4MwpLgHmdK GIuANfn7PvaYEHp6n3cBm1Va8CVST+hVzf6KUecrQkxTLh8ZiiuTlhZCJtxvDBpOu+ wxuDlOXOWbbVpRyLHFT7+4vykIydlQ2d6EW+JyWB9JuPLLtJu5yo0sgpGQrxZOcfx/ jYb2UzNtGv/zg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 2/4] drm/amd/pm: show the smu8 overdrive sclk table To: "Joshua Horne" Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org In-Reply-To: <20261205-smu8-overdrive-v3-2-46890aa116e7@etsu.edu> References: <20261205-smu8-overdrive-v3-0-46890aa116e7@etsu.edu> <20261205-smu8-overdrive-v3-2-46890aa116e7@etsu.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 05:14:29 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "amd-gfx" X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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 drm/amd/pm: show the smu8 overdrive sclk table This patch initializes the overdrive SCLK table for SMU8 (Carrizo and Stone= y) 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/driver= s/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; > } > =20 > +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 =3D min(vddc_table->count, smu8_get_max_sclk_level(hwmgr)= ); > + data->od_min_vddc =3D U32_MAX; > + data->od_max_vddc =3D 0; > + for (i =3D 0; i < od->num_of_pl; i++) { > + mv =3D convert_to_vddc((uint8_t)vdd_gfx_table->entries[i].v); > + od->entries[i].clock =3D vddc_table->entries[i].clk; > + od->entries[i].vddc =3D mv; > + od->entries[i].enabled =3D true; > + data->od_min_vddc =3D min(data->od_min_vddc, mv); > + data->od_max_vddc =3D 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 =3D=3D 0) { smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetMaxSclkLevel, &data->max_sclk_level); data->max_sclk_level +=3D 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 =3D > + 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) > =20 > hwmgr->platform_descriptor.hardwareActivityPerformanceLevels =3D SMU8_= MAX_HARDWARE_POWERLEVELS; > =20 > + 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205-smu8-overd= rive-v3-0-46890aa116e7@etsu.edu?part=3D2