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=1796431151; b=iQ8SZkiUn94Qi1OsGSHDwAmZAKL59ZjW7UUNnyIIXwE47Ab8O+xIvEYlA2IAHj8zrJJs 9D0HP0chRqfNgjZqe5z8sFjUDezZnBjpzO+A2+QfSq8Fcty1uKgucRIz8/90bwA+ZAs6L SoWCBNvE/8MY4IEAM6zkHRHb28aEhjrDUGa0cof8hdMd8K2S0p5DW6+PTL2Z4tioeJVb4 RSFyC/XLp1fXg17Yr09BpyCq4Z9/BPPQU5QFhCDa+782/YR5t5plhDNMg8sO+2JfoZqkc no4UIcKFaAmqERp07GoJF40yOsHbWKAtNxa3iDXK0iwXRz42LFWu4ZevQ5K2VpP2wsQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796431151; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ab6sE3ZtiLeV/JDm8ElvY+FRbWnzptaMBaszLaS9iuI=; b=4axv9vn9rRGxPBMBzOIzF9CapFBajUOiNshREftDd0BzZXRI6ddM+NM/vioZmclzt7LL i2AczCQOh1+r9vyOl3rp5qd58xz++J543J+Th8K1H0QH2s3V011YTWzA2aL+RHI/vNEq2 9MOXhG+vHC3DZEjFuxhQESy1Sx4diA14D8/iN9iK+eizRVP8bByFS6QzVJRH8zhZa4E+7 Ru98jMpryFnXKH5kRrvxgQ9+VvGr/iRt+TLs/GQvrUo4S1/XhZbuWRAfeVMsFBCmlIHWb 3ZNZcXmawg2gPxQcduxR/im4z6sQDPctKGxdLUAEjEjj1uWzpKcmPuQ0b59bRdb5zoA== 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=DjAUwafZ; 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 C574C606A691 for ; Sat, 5 Dec 2026 00:39:11 +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=DjAUwafZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 364171F00A18; Sat, 5 Dec 2026 00:39:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796431151; bh=ab6sE3ZtiLeV/JDm8ElvY+FRbWnzptaMBaszLaS9iuI=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=DjAUwafZOVY37G+AONznmZO26e1cvHucwXiMl4W7HlMpWwM2TViGfTIo/rflU//E2 cN0a2mhUY5j0Cx0zJ0wS3Wa+w4coZUoezcFUpsYjijWs9BnM3slcVofWpHBYK3B5q8 h7sia45ukgzqzZ+jcZCDJJd0t+gjylB5XsbEdVKRvAEX5KkFgbKJwGI8aqQNZ7Rqc4 hQMt2FjjLuLSBV4PjHIj91E613wNJ5pisumYwZTHVwBZt9qFAt4m8GPc+wgZf+1YIp 7PHG8LRHLxS0m+VWJd9w1BD3PP+GWXoCbpYZQ5dJ60FsMIQ+/PhwngVa6MbF6x0Yw8 o0n73ALDxm2pQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 v2 2/2] mmc: sdhci-msm: Add support for firmware-managed resource platforms Reply-To: sashiko-reviews@lists.linux.dev To: "Anjana Hari" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261205002150.2655647-3-anjana.hari@oss.qualcomm.com> References: <20261205002150.2655647-1-anjana.hari@oss.qualcomm.com> <20261205002150.2655647-3-anjana.hari@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 00:39:09 +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 7 potential issues to consider: - [High] mmc: sdhci-msm: uninitialized ret returned in sdhci_msm_runtime_resume() - [Medium] mmc: sdhci-msm: unused label out in sdhci_msm_runtime_resume() - [Medium] mmc: sdhci-msm: ignored error from msm_fw_set_clock_rate_for_bus_mode() - [Medium] mmc: sdhci-msm: power domains detached before devm pwr_irq is freed - [Low] mmc: sdhci-msm: commit message and probe comment disagree with code - [Low] mmc: sdhci-msm: duplicated ops, pdata, and clock helper for fw_managed - [Low] mmc: sdhci-msm: wrong format specifier and unmultiplied rate in logs -- commit 38ff9cbc8a2b7913f5a908acb8571a7d6ed30822 Author: Anjana Hari > mmc: sdhci-msm: Add support for firmware-managed resource platforms > > On certain Qualcomm automotive SoCs such as Nord, platform resources > including clocks, interconnect bandwidth, resets, and regulators are > owned and managed by firmware rather than directly by Linux. The > firmware abstracts these resources behind logical power domains and > exposes control through the SCMI power protocol. > > Introduce a firmware-managed variant of the sdhci-msm driver that > operates through this abstraction instead of directly programming GCC > clocks and PMIC regulators. > > The firmware-managed model uses two logical power domains, attached at > probe time via dev_pm_domain_attach_list(): > > - "power" domain: governs SDCC rail power state. It is activated at > probe and released at remove via pm_runtime_resume_and_get() and > pm_runtime_put_sync() on the domain device. These calls are > translated by the SCMI power protocol into firmware power-state > requests. > > - "perf" domain: the SCMI perf domain driver populates OPPs at probe > time by querying the firmware-reported performance levels via > perf_ops->device_opps_add(). Clock rate selection uses > dev_pm_opp_find_freq_floor() to locate the nearest OPP at or below > the requested frequency, then dev_pm_opp_set_opp() to apply it, > rather than directly programming the GCC clock tree. > > A new variant sdhci_msm_fw_v5_var is introduced with the compatible > string "qcom,nord-sdhci". Detection is automatic at probe: a non-NULL > pd_data.pd_names in the variant descriptor marks the platform as > firmware-managed, causing probe to select firmware-specific platform > data (sdhci_msm_fw_pdata) and ops (sdhci_msm_fw_ops). > > The firmware-managed ops provide: > - sdhci_msm_fw_get_max_clock: queries the perf domain OPP table > using dev_pm_opp_find_freq_floor() at ULONG_MAX to discover the > maximum supported frequency, replacing the direct GCC readout. > - sdhci_msm_fw_set_clock: routes clock rate programming through the > perf domain OPP path, reusing the existing bus-mode multiplier > logic to derive the target rate. > > Suspend and resume sequences bypass local clock and regulator management > for firmware-managed platforms, as firmware handles those transitions > autonomously in response to SCMI power-state transitions from the > runtime PM framework. > > Co-developed by: Shazad Hussain > Signed-off-by: Shazad Hussain > Signed-off-by: Anjana Hari [Severity: Low] The commit message describes the "power" domain as activated at probe and released at remove via pm_runtime_resume_and_get() and pm_runtime_put_sync() on the domain device, whereas the code attaches both domains with PD_FLAG_DEV_LINK_ON so they follow runtime PM transitions on the host devic= e. It also states that suspend and resume bypass local regulator management, which those callbacks never did, and the comment in sdhci_msm_probe() says skip_resource_init skips regulators and credits DL_FLAG_PM_RUNTIME alone, even though sdhci_msm_register_vreg() still runs after skip_resource_init and PD_FLAG_DEV_LINK_ON (DL_FLAG_RPM_ACTIVE) is what powers on the domain during link creation. Finally, the trailer "Co-developed by:" is missing the second hyphen and should be "Co-developed-by:". > diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c > index aecd425bf0951..2c013ee401d11 100644 > --- a/drivers/mmc/host/sdhci-msm.c > +++ b/drivers/mmc/host/sdhci-msm.c [ ... ] > @@ -414,6 +424,45 @@ static void msm_set_clock_rate_for_bus_mode(struct s= dhci_host *host, > mmc_hostname(host->mmc), achieved_rate, timing); > } > =20 > +static int msm_fw_set_clock_rate_for_bus_mode(struct sdhci_host *host, > + unsigned int clock) > +{ ... > + mult =3D msm_get_clock_mult_for_bus_mode(host, clock, ios.timing); > + desired_rate =3D clock_long * mult; > + > + /* Find the nearest OPP at or below the requested frequency. */ > + opp =3D dev_pm_opp_find_freq_floor(perf_dev, &desired_rate); > + if (IS_ERR(opp)) { > + dev_err(dev, "Failed to find OPP for freq %lu: %pe\n", clock_long, opp= ); > + return PTR_ERR(opp); > + } > + > + ret =3D dev_pm_opp_set_opp(perf_dev, opp); > + dev_pm_opp_put(opp); > + if (ret) { > + dev_err(dev, "Failed to set OPP for freq %lu: %d\n", clock_long, ret); > + return ret; > + } [Severity: Low] Should these dev_err() messages log the multiplied frequency passed to the OPP framework instead of clock_long? In DDR and HS400 modes where mult is = 2, this reports half of the OPP frequency that failed. In sdhci_msm_probe(), var_info->pd_data.num_pd_names is a u32 and should be formatted with %u rather than %d. [ ... ] > @@ -1253,7 +1302,10 @@ static int sdhci_msm_execute_tuning(struct mmc_hos= t *mmc, u32 opcode) > */ > if (host->flags & SDHCI_HS400_TUNING) { > sdhci_msm_hc_select_mode(host); > - msm_set_clock_rate_for_bus_mode(host, ios.clock, ios.timing); > + if (msm_host->fw_managed) > + msm_fw_set_clock_rate_for_bus_mode(host, ios.clock); > + else > + msm_set_clock_rate_for_bus_mode(host, ios.clock, ios.timing); > host->flags &=3D ~SDHCI_HS400_TUNING; > } [Severity: Medium] Does sdhci_msm_execute_tuning() ignore an error returned by msm_fw_set_clock_rate_for_bus_mode()? sdhci_msm_hc_select_mode() has already switched the controller to MCLK/2 for HS400 tuning, expecting MCLK to be raised to 2x ios.clock. If OPP lookup or dev_pm_opp_set_opp() fails, tuning still clears SDHCI_HS400_TUNING and runs DLL initialization and phase tuning at half the target clock frequency. Checking and returning the error avoids tuning at the wrong clock rate. [ ... ] > @@ -2587,6 +2692,21 @@ static const struct sdhci_ops sdhci_msm_ops =3D { > .set_timeout =3D sdhci_msm_set_timeout, > }; > =20 > +static const struct sdhci_ops sdhci_msm_fw_ops =3D { > + .reset =3D sdhci_and_cqhci_reset, > + .set_clock =3D sdhci_msm_fw_set_clock, > + .get_min_clock =3D sdhci_msm_get_min_clock, > + .get_max_clock =3D sdhci_msm_fw_get_max_clock, > + .set_bus_width =3D sdhci_set_bus_width, > + .set_uhs_signaling =3D sdhci_msm_set_uhs_signaling, > + .write_w =3D sdhci_msm_writew, > + .write_b =3D sdhci_msm_writeb, > + .irq =3D sdhci_msm_cqe_irq, > + .dump_vendor_regs =3D sdhci_msm_dump_vendor_regs, > + .set_power =3D sdhci_set_power_noreg, > + .set_timeout =3D sdhci_msm_set_timeout, > +}; > + > static const struct sdhci_pltfm_data sdhci_msm_pdata =3D { > .quirks =3D SDHCI_QUIRK_BROKEN_CARD_DETECTION | > SDHCI_QUIRK_SINGLE_POWER_WRITE | > @@ -2597,6 +2717,16 @@ static const struct sdhci_pltfm_data sdhci_msm_pda= ta =3D { > .ops =3D &sdhci_msm_ops, > }; > =20 > +static const struct sdhci_pltfm_data sdhci_msm_fw_pdata =3D { > + .quirks =3D SDHCI_QUIRK_BROKEN_CARD_DETECTION | > + SDHCI_QUIRK_SINGLE_POWER_WRITE | > + SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN | > + SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12, > + > + .quirks2 =3D SDHCI_QUIRK2_PRESET_VALUE_BROKEN, > + .ops =3D &sdhci_msm_fw_ops, > +}; [Severity: Low] This isn't a bug, but sdhci_msm_fw_ops duplicates 10 of 12 callbacks from sdhci_msm_ops, sdhci_msm_fw_pdata duplicates all quirks from sdhci_msm_pdata, and sdhci_msm_fw_set_clock() duplicates the control flow of sdhci_msm_set_clock(). Since msm_host->fw_managed is already stored in struct sdhci_msm_host, dispatching on it inside sdhci_msm_get_max_clock() and msm_set_clock_rate_for_bus_mode() would drop the duplicated tables and helper and prevent future quirks or callback drift. Using devm_pm_domain_attach_list() would also remove the duplicated manual dev_pm_domain_detach_list() calls in probe error unwind and remove. [ ... ] > @@ -2934,6 +3102,11 @@ static void sdhci_msm_remove(struct platform_devic= e *pdev) > pm_runtime_disable(&pdev->dev); > pm_runtime_put_noidle(&pdev->dev); > =20 > + if (msm_host->fw_managed) { > + dev_pm_domain_detach_list(msm_host->pd_list); > + msm_host->pd_list =3D NULL; > + } > + > clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks), > msm_host->bulk_clks); > if (!IS_ERR(msm_host->bus_clk)) [Severity: Medium] Can sdhci_msm_pwr_irq() access controller registers after the SCMI power domain is powered off? sdhci_msm_probe() unmasks core_pwrctl_mask and registers sdhci_msm_pwr_irq() with devm_request_threaded_irq(), so pwr_irq is not freed and synchronized until devres_release_all() runs after sdhci_msm_remove() (or a failed probe) returns. Meanwhile, dev_pm_domain_detach_list() deletes the device links and powers off the domain immediately via dev_pm_domain_detach(dev, true). CPU0 CPU1 sdhci_msm_remove() sdhci_remove_host() sdhci_reset_for_all() sdhci_msm_pwr_irq() sdhci_msm_handle_pwr_irq() dev_pm_domain_detach_list() dev_pm_domain_detach() msm_host_readl(...) <-- unpowered MMIO devres_release_all() devm_irq_release() Reading or writing controller registers while the power domain is off can trigger a synchronous external abort. Attaching the domains with devm_pm_domain_attach_list() before devm_request_threaded_irq() preserves LIFO teardown order. [ ... ] > @@ -2967,6 +3143,9 @@ static int sdhci_msm_runtime_resume(struct device *= dev) > unsigned long flags; > int ret; > =20 > + if (msm_host->fw_managed) > + goto clr_suspended; > + > ret =3D clk_bulk_prepare_enable(ARRAY_SIZE(msm_host->bulk_clks), > msm_host->bulk_clks); > if (ret) [Severity: High] Does sdhci_msm_runtime_resume() return an uninitialized ret when msm_host->fw_managed is true? Jumping to clr_suspended skips every assignment to ret and returns stack garbage to the runtime PM core. Whenever that value is non-zero, __rpm_callback() treats runtime resume as failed, latches dev->power.runtime_error, and calls __rpm_put_suppliers() to drop the SCMI power and perf domain references even though host->runtime_suspended was already cleared to false. Subsequent sdhci_irq() or sdhci_led_control() calls can then access unpowered MMIO and trigger a synchronous external abort. [ ... ] > @@ -2987,10 +3166,11 @@ static int sdhci_msm_runtime_resume(struct device= *dev) > if (ret) > return ret; > =20 > +clr_suspended: > spin_lock_irqsave(&host->lock, flags); > host->runtime_suspended =3D false; > spin_unlock_irqrestore(&host->lock, flags); > - > +out: > return ret; > } [Severity: Medium] Is the out: label unused in sdhci_msm_runtime_resume()? Nothing jumps to it, which triggers a -Wunused-label warning and breaks builds with CONFIG_WERROR=3Dy. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205002150.2655= 647-1-anjana.hari@oss.qualcomm.com?part=3D2