From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796200348; b=wSOCVX2PsznBDrvRtFRFhw9HUWkR9Wfs8ZvJSgXNTjb5Dtw3ajjUggaqGJ5o2C+0adNT 0lOvVV9A2mWWnGEXJV4hl/qstWRvteJc1hJnPMwpcM6Y5u3FGd6d+mHB2yEVSV3o0VU/6 7Arv1f7sLwUhuySeCziC6SoS9C2UiCvnDJEv4MU49L7FUFMW1Tax70CqTpS3gkhIKmNrk 9CnKEr98nKOUDhddMnzeXhli7HUBN/LzbZnbMQHp/A113VrdcUKxK+KYYHBsBe8jaQLFR zASwrItQkVVp1bsgsecWqT0MaOk3At9ehBEaWOD/2C5mudoDF/uUvAN4N1phbzVTqUg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796200348; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=sMh8dxEnYnADldq0LvQLNt0yDZbuUZeT2pUOFyNp2bE=; b=VKoSrUrvVNSWuizS6EpSjc7PXlPzsUXeR1fOGwPcGfDNurh4DiPSf8D2fecWhPFMDE+d EfSj7sGI33BvMD266g+9wUMTgBu5ShneiSYu79/OmoILeeKb7C9pql87Ts8ZS+f4uJc4S hGg21/5LGVEtZBzeh1jc+ssa8zhUj7vOABE1BcmPjLvYetz0VfjFuX0meyMYnJjxYnqgw gN68myN33khmP24Gint764+oaEqZuE+yuPMwSsWi2Ai3/WJJniSDZRdH8brOC3Fs6YGUy dMDtrIj3//rU37rH6gSHIRbURBrq7kv2Cukf2tlZu8YvmaJMuuGpTnqxQflN5PciTqw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GHXRCkeU; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F549606A322; Wed, 2 Dec 2026 08:32:28 +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=GHXRCkeU Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDDE01F000C1; Wed, 2 Dec 2026 08:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796200348; bh=sMh8dxEnYnADldq0LvQLNt0yDZbuUZeT2pUOFyNp2bE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=GHXRCkeUFrSwRJdZvdxtpgLFYt2Bipia8s2nwqK6AQeXZYyxCa4dyW4+ICmbiL+N4 vlMc+yh2uoB6znjpdAz3Is1WBE9xPOlGpspJXSzZ+yV4tzhsSDT5+lEXPSOS0TsL64 ZDqfoIh6O6cFYFO80cIoQlJkeFPiwY8K//uD5x9EZ+cyqqg5AUqKpH1jVHaJ2S2LAQ FjmyWwoTehW4uaciprlH5lg88HNk7EuwjlCnaetgrDbRCRi+X0/keeuydDo3QvBgXB FmOPs0+JC4EuSdQ2YKz+PCJbtZwrTxfcp4rRsY8T/6QjaOagLaSM+hkl0KKGROpJSG 7E7tLpJiZ8VEw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 1/3] scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling Reply-To: sashiko-reviews@lists.linux.dev To: "Giri Prasad Goriparthi" Cc: linux-scsi@vger.kernel.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261202-b4-ufs-qcom-multi-gear-scaling-v2-1-e2fe4cbce19d@oss.qualcomm.com> References: <20261202-b4-ufs-qcom-multi-gear-scaling-v2-0-e2fe4cbce19d@oss.qualcomm.com> <20261202-b4-ufs-qcom-multi-gear-scaling-v2-1-e2fe4cbce19d@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 08:32:27 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] scsi: ufs: ufs-qcom: opp-level gear clobbers PM domain performance state - [Medium] scsi: ufs: ufs-qcom: ufs_qcom_freq_to_gear_speed() fails to clamp opp-level -- commit 73d84f7e8cb1062be352f4560a2e81fc675ef5ff Author: Giri Prasad Goriparthi scsi: ufs: ufs-qcom: Add specified gear support for multi gear scaling This commit reads the opp-level property from the UFS OPP table in ufs_qcom_freq_to_gear_speed() to select the HS gear for a given operating frequency, falling back to the hardcoded frequency-to-gear table when opp-level is unset or exceeds the maximum Rx gear. > diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c > index 6afb8498b8c26..cc6380ebb1458 100644 > --- a/drivers/ufs/host/ufs-qcom.c > +++ b/drivers/ufs/host/ufs-qcom.c [ ... ] > @@ -2535,12 +2535,32 @@ static unsigned long ufs_qcom_opp_freq_to_clk_fre= q(struct ufs_hba *hba, > =20 > static u32 ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned lon= g freq) > { > - u32 gear =3D UFS_HS_DONT_CHANGE; > unsigned long unipro_freq; > + struct dev_pm_opp *opp; > + u32 gear =3D UFS_HS_DONT_CHANGE; > =20 > if (!hba->use_pm_opp) > return gear; > =20 > + opp =3D dev_pm_opp_find_freq_exact_indexed(hba->dev, freq, 0, true); > + if (IS_ERR_OR_NULL(opp)) { > + dev_err(hba->dev, "Failed to find OPP for exact frequency %lu\n", freq= ); > + return gear; > + } > + > + /* Get HS gear speed from 'opp-level' */ > + gear =3D dev_pm_opp_get_level(opp); > + dev_pm_opp_put(opp); [Severity: High] Does repurposing opp-level in the UFS controller's OPP table to store UFS HS gear values (1..6) overwrite the device's required-opps PM domain performance state vote when scaling up clocks? On Qualcomm SoCs, the UFS host controller has a single power-domains entry (GCC_UFS_PHY_GDSC, a subdomain of RPMHPD_CX) and per-OPP required-opps entries pointing to RPMHPD voltage corners (for example, RPMH_REGULATOR_LEVEL_NOM =3D 256). When a single power domain is attached, __genpd_dev_pm_attach() -> genpd_set_required_opp_dev() registers hba->dev itself as opp_table->required_devs[0]. During clock initialization and devfreq scaling, ufshcd_opp_set_rate() calls dev_pm_opp_set_opp(hba->dev, opp) -> _set_opp(): drivers/opp/core.c:_set_opp() { ... if (!scaling_down) { ret =3D _set_required_opps(dev, opp_table, opp, true); if (ret) { dev_err(dev, "Failed to set required opps: %d\n", ret); return ret; } ret =3D _set_opp_level(dev, opp); if (ret) return ret; ... } When scaling up, _set_required_opps() first votes the required RPMHPD corner on hba->dev via dev_pm_domain_set_performance_state(). With opp-level populated on the UFS OPP node, _set_opp_level(hba->dev, opp) immediately calls dev_pm_domain_set_performance_state(hba->dev, opp->level) on the same device, replacing the required RPMHPD corner vote with the raw UFS gear number (1..6) and dropping the CX rail vote to its floor corner before raising the UFS clock rates. > + > + /* > + * If opp-level is not configured in DT or the specified gear exceeds > + * the max supported gear, fall back to the frequency-to-gear table. > + */ > + if (gear !=3D OPP_LEVEL_UNSET && gear <=3D hba->max_pwr_info.info.gear_= rx) > + return gear; [Severity: Medium] When opp-level is configured in DT with a gear above hba->max_pwr_info.info.gear_rx (for example, when attached to a lower-gear UFS device or constrained by limit-hs-gear), should this clamp gear to hba->max_pwr_info.info.gear_rx with min_t() as the bottom of ufs_qcom_freq_to_gear_speed() does, instead of falling back to the hardcoded unipro_freq switch table? Falling back to the switch table defeats the platform-specific mapping whenever the platform's UniPro clock frequency maps to a different gear in the switch table (such as 150 MHz mapping to UFS_HS_G2 in the switch table instead of UFS_HS_G3), or returns UFS_HS_DONT_CHANGE (0) if the frequency is not in the switch table. Returning 0 causes ufshcd_scale_gear() to fall into its legacy two-gear scaling path, where a subsequent scale-up copies an uninitialized zeroed hba->clk_scaling.saved_pwr_info into new_pwr_info. Also, if opp-level is 0, gear !=3D OPP_LEVEL_UNSET && gear <=3D hba->max_pwr_info.info.gear_rx evaluates to true and returns UFS_HS_DONT_CHANGE (0) directly instead of falling back. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202-b4-ufs-qco= m-multi-gear-scaling-v2-0-e2fe4cbce19d@oss.qualcomm.com?part=3D1