Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Oleg Keri" <okerixx@gmail.com>
Cc: vkoul@kernel.org, olteanv@gmail.com,
	linux-phy@lists.infradead.org, neil.armstrong@linaro.org
Subject: Re: [PATCH] phy: qcom: qmp-combo: hold a runtime PM reference in the typec callbacks
Date: Wed, 09 Sep 2026 14:18:40 +0000	[thread overview]
Message-ID: <20260909141841.532191F00A3F@smtp.kernel.org> (raw)
In-Reply-To: <20260909140345.4239-1-okerixx@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Ignored return value of qmp_combo_com_init() leads to unclocked register access crashes and init_count state corruption.
--

commit e725afa70b650e2a1f27710fa3b4e0c5a5568682
Author: Oleg Keri <okerixx@gmail.com>

    phy: qcom: qmp-combo: hold a runtime PM reference in the typec callbacks
    
    qmp_combo_typec_switch_set() and qmp_combo_typec_mux_set() tear the common
    block down and bring it straight back up, calling qmp_combo_com_exit() and
    qmp_combo_com_init() with force=true. Hold a runtime PM reference across the
    teardown and bringup so releasing the clocks cannot re-enter the driver's
    own suspend callback.

> diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> index c39ced168d035..c08a22681e0e2 100644
> --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
[ ... ]
> @@ -4786,6 +4787,8 @@ static int qmp_combo_typec_switch_set(struct typec_switch_dev *sw,
>  	qmp->orientation = orientation;
>  
>  	if (qmp->init_count) {
> +		guard(pm_runtime_active)(qmp->dev);
> +
>  		if (qmp->usb_init_count)
>  			qmp_combo_usb_power_off(qmp->usb_phy);
>  		qmp_combo_com_exit(qmp, true);

[Severity: High]
This isn't a regression introduced by this patch, but I noticed the return
value of qmp_combo_com_init() is ignored just below this diff in
drivers/phy/qualcomm/phy-qcom-qmp-combo.c:

qmp_combo_typec_switch_set() {
    ...
		qmp_combo_com_init(qmp, true);
		if (qmp->usb_init_count)
			qmp_combo_usb_power_on(qmp->usb_phy);
    ...
}

If qmp_combo_com_init() fails to enable clocks (e.g., clk_bulk_prepare_enable
fails), it leaves the clocks disabled and returns an error code.

Because this return value is ignored, the code proceeds to access hardware
registers via qmp_combo_usb_power_on().

Can accessing mapped peripheral registers while their clocks are disabled
cause a System Error (SError) exception on ARM/ARM64, resulting in a kernel
panic?

Additionally, if qmp_combo_com_init() fails when force=true, it can corrupt
the initialization state:

qmp_combo_com_init() {
    ...
	if (!force && qmp->init_count++)
		return 0;
    ...
err_decrement_count:
	qmp->init_count--;

	return ret;
}

The force=true flag causes the function to skip the corresponding increment
of init_count.

Does the error path need to avoid decrementing init_count when force=true?

> @@ -4853,6 +4856,8 @@ static int qmp_combo_typec_mux_set(struct typec_mux_dev *mux, struct typec_mux_s
>  	qmp->qmpphy_mode = new_mode;
>  
>  	if (qmp->init_count) {
> +		guard(pm_runtime_active)(qmp->dev);
> +
>  		if (qmp->usb_init_count)
>  			qmp_combo_usb_power_off(qmp->usb_phy);
>  

[Severity: High]
This is a pre-existing issue, but the return value of qmp_combo_com_init()
is similarly ignored in qmp_combo_typec_mux_set() in
drivers/phy/qualcomm/phy-qcom-qmp-combo.c:

qmp_combo_typec_mux_set() {
    ...
		qmp_combo_com_init(qmp, true);

		if (new_mode == QMPPHY_MODE_DP_ONLY) {
    ...
}

If the clock initialization fails here, does this also lead to subsequent
hardware accesses without active clocks?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260909140345.4239-1-okerixx@gmail.com?part=1

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2026-09-09 14:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 14:03 [PATCH] phy: qcom: qmp-combo: hold a runtime PM reference in the typec callbacks Oleg Keri
2026-09-09 14:18 ` sashiko-bot [this message]
2026-09-09 15:15   ` Oleg Keri

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=20260909141841.532191F00A3F@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=okerixx@gmail.com \
    --cc=olteanv@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /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