From: sashiko-bot@kernel.org
To: "Anjana Hari" <anjana.hari@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 v2 2/2] mmc: sdhci-msm: Add support for firmware-managed resource platforms
Date: Sat, 05 Dec 2026 00:39:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-250841@kernel.org> (raw)
In-Reply-To: <20261205002150.2655647-3-anjana.hari@oss.qualcomm.com>
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 <anjana.hari@oss.qualcomm.com>
> 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 <shazad.hussain@oss.qualcomm.com>
> Signed-off-by: Shazad Hussain <shazad.hussain@oss.qualcomm.com>
> Signed-off-by: Anjana Hari <anjana.hari@oss.qualcomm.com>
[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 device.
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 sdhci_host *host,
> mmc_hostname(host->mmc), achieved_rate, timing);
> }
>
> +static int msm_fw_set_clock_rate_for_bus_mode(struct sdhci_host *host,
> + unsigned int clock)
> +{
...
> + mult = msm_get_clock_mult_for_bus_mode(host, clock, ios.timing);
> + desired_rate = clock_long * mult;
> +
> + /* Find the nearest OPP at or below the requested frequency. */
> + opp = 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 = 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_host *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 &= ~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 = {
> .set_timeout = sdhci_msm_set_timeout,
> };
>
> +static const struct sdhci_ops sdhci_msm_fw_ops = {
> + .reset = sdhci_and_cqhci_reset,
> + .set_clock = sdhci_msm_fw_set_clock,
> + .get_min_clock = sdhci_msm_get_min_clock,
> + .get_max_clock = sdhci_msm_fw_get_max_clock,
> + .set_bus_width = sdhci_set_bus_width,
> + .set_uhs_signaling = sdhci_msm_set_uhs_signaling,
> + .write_w = sdhci_msm_writew,
> + .write_b = sdhci_msm_writeb,
> + .irq = sdhci_msm_cqe_irq,
> + .dump_vendor_regs = sdhci_msm_dump_vendor_regs,
> + .set_power = sdhci_set_power_noreg,
> + .set_timeout = sdhci_msm_set_timeout,
> +};
> +
> static const struct sdhci_pltfm_data sdhci_msm_pdata = {
> .quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION |
> SDHCI_QUIRK_SINGLE_POWER_WRITE |
> @@ -2597,6 +2717,16 @@ static const struct sdhci_pltfm_data sdhci_msm_pdata = {
> .ops = &sdhci_msm_ops,
> };
>
> +static const struct sdhci_pltfm_data sdhci_msm_fw_pdata = {
> + .quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION |
> + SDHCI_QUIRK_SINGLE_POWER_WRITE |
> + SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN |
> + SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12,
> +
> + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
> + .ops = &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_device *pdev)
> pm_runtime_disable(&pdev->dev);
> pm_runtime_put_noidle(&pdev->dev);
>
> + if (msm_host->fw_managed) {
> + dev_pm_domain_detach_list(msm_host->pd_list);
> + msm_host->pd_list = 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;
>
> + if (msm_host->fw_managed)
> + goto clr_suspended;
> +
> ret = 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;
>
> +clr_suspended:
> spin_lock_irqsave(&host->lock, flags);
> host->runtime_suspended = 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=y.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205002150.2655647-1-anjana.hari@oss.qualcomm.com?part=2
prev parent reply other threads:[~2026-12-05 0:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 0:21 [PATCH v2 v2 0/2] mmc: sdhci-msm: Add firmware-managed resource support for Nord SDCC Anjana Hari
2026-12-05 0:21 ` [PATCH v2 v2 1/2] dt-bindings: mmc: sdhci-msm: Document " Anjana Hari
2026-12-05 0:35 ` sashiko-bot
2026-12-05 0:21 ` [PATCH v2 v2 2/2] mmc: sdhci-msm: Add support for firmware-managed resource platforms Anjana Hari
2026-12-05 0:39 ` sashiko-bot [this message]
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-250841@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=anjana.hari@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox