All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Varadarajan Narayanan" <varadarajan.narayanan@oss.qualcomm.com>
Cc: vkoul@kernel.org, robh@kernel.org, linux-phy@lists.infradead.org,
	neil.armstrong@linaro.org, olteanv@gmail.com,
	conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 4/5] phy: qcom: snps-femto-v2: Move PHY init registers to config tables
Date: Mon, 24 Aug 2026 06:49:32 +0000	[thread overview]
Message-ID: <20260824064933.2D09C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824-phy-v1-4-257d68a3210b@oss.qualcomm.com>

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

Pre-existing issues:
- [High] The mask and value arguments for the `USB2_PHY_USB_PHY_REFCLK_CTRL` register write are swapped in the `hs_5nm_phy_pre` configuration table.
- [High] The `USB2_AUTO_RESUME` bit is never cleared in `qcom_snps_hsphy_suspend()` due to an incorrect mask of 0.
--

--- Patch [4]: [PATCH 4/5] phy: qcom: snps-femto-v2: Move PHY init registers to config tables ---
commit 5e719820e4a23178ca8190ffc88ff2f741947939
Author: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>

phy: qcom: snps-femto-v2: Move PHY init registers to config tables

This commit refactors the SNPS Femto v2 PHY driver to use per-compatible
configuration tables for fixed pre- and post-override register sequences.
This allows the driver to share the common sequence while adding SoC-specific
sequences for future platforms.

> diff --git a/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c b/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
> index eb0b0f61d98e0..a34027b215f9b 100644
> --- a/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
> +++ b/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
[ ... ]
> @@ -383,13 +395,42 @@ static const struct override_param_map sc7280_snps_7nm_phy[] = {
>  	{},
>  };
>  
> +static const struct phy_reg_config hs_5nm_phy_pre[] = {
> +	{ USB2_PHY_USB_PHY_CFG0, UTMI_PHY_CMN_CTRL_OVERRIDE_EN, UTMI_PHY_CMN_CTRL_OVERRIDE_EN },
> +	{ USB2_PHY_USB_PHY_UTMI_CTRL5, POR, POR },
> +	{ USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0, FSEL_MASK, 0 },
> +	{ USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1, PLLBTUNE, PLLBTUNE },
> +	{ USB2_PHY_USB_PHY_REFCLK_CTRL, REFCLK_SEL_DEFAULT, REFCLK_SEL_MASK },

[Severity: High]
This is a pre-existing issue, but are the mask and value arguments swapped
here?

The phy_reg_config structure expects the order { offset, mask, val }. By
passing REFCLK_SEL_DEFAULT as the mask and REFCLK_SEL_MASK as the value,
qcom_snps_hsphy_write_mask() will evaluate:

    reg &= ~REFCLK_SEL_DEFAULT;
    reg |= REFCLK_SEL_MASK & REFCLK_SEL_DEFAULT;

Because REFCLK_SEL_DEFAULT is 0x2 and REFCLK_SEL_MASK is 0x3, bit 0 is excluded
from the mask and remains unchanged. If bit 0 was set by the bootloader, the
final register value incorrectly becomes 0x3 instead of 0x2, selecting the
wrong reference clock.

(Notice that in another patch of this series, hs_6nm_phy_pre correctly uses
REFCLK_SEL_MASK as the mask, but hs_5nm_phy_pre was not corrected here.)

> +	{ USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1, VBUSVLDEXTSEL0, VBUSVLDEXTSEL0 },
> +	{ USB2_PHY_USB_PHY_HS_PHY_CTRL1, VBUSVLDEXT0, VBUSVLDEXT0 },
> +	{ UINT_MAX, 0, 0 },
> +};

[ ... ]

While looking at how qcom_snps_hsphy_write_mask() is used in the driver, I
noticed another pre-existing issue in qcom_snps_hsphy_suspend(), which is not
modified by this patch:

[Severity: High]
This isn't a bug introduced by this patch, but does qcom_snps_hsphy_suspend()
fail to clear the USB2_AUTO_RESUME bit?

drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c:qcom_snps_hsphy_suspend() {
    ...
    qcom_snps_hsphy_write_mask(hsphy->base,
                               USB2_PHY_USB_PHY_HS_PHY_CTRL2,
                               0, USB2_AUTO_RESUME);
    ...
}

By passing 0 as the mask, qcom_snps_hsphy_write_mask() will do:

    reg &= ~0;
    reg |= USB2_AUTO_RESUME & 0;

This leaves the register entirely unaffected, and the auto-resume bit is
left set indefinitely instead of being cleared.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260824-phy-v1-0-257d68a3210b@oss.qualcomm.com?part=4

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

WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Varadarajan Narayanan" <varadarajan.narayanan@oss.qualcomm.com>
Cc: vkoul@kernel.org, robh@kernel.org, linux-phy@lists.infradead.org,
	neil.armstrong@linaro.org, olteanv@gmail.com,
	conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 4/5] phy: qcom: snps-femto-v2: Move PHY init registers to config tables
Date: Mon, 24 Aug 2026 06:49:32 +0000	[thread overview]
Message-ID: <20260824064933.2D09C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824-phy-v1-4-257d68a3210b@oss.qualcomm.com>

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

Pre-existing issues:
- [High] The mask and value arguments for the `USB2_PHY_USB_PHY_REFCLK_CTRL` register write are swapped in the `hs_5nm_phy_pre` configuration table.
- [High] The `USB2_AUTO_RESUME` bit is never cleared in `qcom_snps_hsphy_suspend()` due to an incorrect mask of 0.
--

--- Patch [4]: [PATCH 4/5] phy: qcom: snps-femto-v2: Move PHY init registers to config tables ---
commit 5e719820e4a23178ca8190ffc88ff2f741947939
Author: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>

phy: qcom: snps-femto-v2: Move PHY init registers to config tables

This commit refactors the SNPS Femto v2 PHY driver to use per-compatible
configuration tables for fixed pre- and post-override register sequences.
This allows the driver to share the common sequence while adding SoC-specific
sequences for future platforms.

> diff --git a/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c b/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
> index eb0b0f61d98e0..a34027b215f9b 100644
> --- a/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
> +++ b/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
[ ... ]
> @@ -383,13 +395,42 @@ static const struct override_param_map sc7280_snps_7nm_phy[] = {
>  	{},
>  };
>  
> +static const struct phy_reg_config hs_5nm_phy_pre[] = {
> +	{ USB2_PHY_USB_PHY_CFG0, UTMI_PHY_CMN_CTRL_OVERRIDE_EN, UTMI_PHY_CMN_CTRL_OVERRIDE_EN },
> +	{ USB2_PHY_USB_PHY_UTMI_CTRL5, POR, POR },
> +	{ USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0, FSEL_MASK, 0 },
> +	{ USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1, PLLBTUNE, PLLBTUNE },
> +	{ USB2_PHY_USB_PHY_REFCLK_CTRL, REFCLK_SEL_DEFAULT, REFCLK_SEL_MASK },

[Severity: High]
This is a pre-existing issue, but are the mask and value arguments swapped
here?

The phy_reg_config structure expects the order { offset, mask, val }. By
passing REFCLK_SEL_DEFAULT as the mask and REFCLK_SEL_MASK as the value,
qcom_snps_hsphy_write_mask() will evaluate:

    reg &= ~REFCLK_SEL_DEFAULT;
    reg |= REFCLK_SEL_MASK & REFCLK_SEL_DEFAULT;

Because REFCLK_SEL_DEFAULT is 0x2 and REFCLK_SEL_MASK is 0x3, bit 0 is excluded
from the mask and remains unchanged. If bit 0 was set by the bootloader, the
final register value incorrectly becomes 0x3 instead of 0x2, selecting the
wrong reference clock.

(Notice that in another patch of this series, hs_6nm_phy_pre correctly uses
REFCLK_SEL_MASK as the mask, but hs_5nm_phy_pre was not corrected here.)

> +	{ USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1, VBUSVLDEXTSEL0, VBUSVLDEXTSEL0 },
> +	{ USB2_PHY_USB_PHY_HS_PHY_CTRL1, VBUSVLDEXT0, VBUSVLDEXT0 },
> +	{ UINT_MAX, 0, 0 },
> +};

[ ... ]

While looking at how qcom_snps_hsphy_write_mask() is used in the driver, I
noticed another pre-existing issue in qcom_snps_hsphy_suspend(), which is not
modified by this patch:

[Severity: High]
This isn't a bug introduced by this patch, but does qcom_snps_hsphy_suspend()
fail to clear the USB2_AUTO_RESUME bit?

drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c:qcom_snps_hsphy_suspend() {
    ...
    qcom_snps_hsphy_write_mask(hsphy->base,
                               USB2_PHY_USB_PHY_HS_PHY_CTRL2,
                               0, USB2_AUTO_RESUME);
    ...
}

By passing 0 as the mask, qcom_snps_hsphy_write_mask() will do:

    reg &= ~0;
    reg |= USB2_AUTO_RESUME & 0;

This leaves the register entirely unaffected, and the auto-resume bit is
left set indefinitely instead of being cleared.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260824-phy-v1-0-257d68a3210b@oss.qualcomm.com?part=4

  reply	other threads:[~2026-08-24  6:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24  6:37 [PATCH 0/5] Add support for USB phys in IPQ9650 Varadarajan Narayanan
2026-08-24  6:37 ` Varadarajan Narayanan
2026-08-24  6:37 ` [PATCH 1/5] dt-bindings: phy: qcom,qmp-usb: Add IPQ9650 USB3 PHY Varadarajan Narayanan
2026-08-24  6:37   ` Varadarajan Narayanan
2026-08-28  9:32   ` Krzysztof Kozlowski
2026-08-28  9:32     ` Krzysztof Kozlowski
2026-08-24  6:37 ` [PATCH 2/5] dt-bindings: phy: qcom,usb-snps-femto-v2: Add IPQ9650 compatible Varadarajan Narayanan
2026-08-24  6:37   ` Varadarajan Narayanan
2026-08-28  9:36   ` Krzysztof Kozlowski
2026-08-28  9:36     ` Krzysztof Kozlowski
2026-08-24  6:37 ` [PATCH 3/5] phy: qcom: qmp-usb: Add IPQ9650 USB3 PHY configuration Varadarajan Narayanan
2026-08-24  6:37   ` Varadarajan Narayanan
2026-08-24  6:37 ` [PATCH 4/5] phy: qcom: snps-femto-v2: Move PHY init registers to config tables Varadarajan Narayanan
2026-08-24  6:37   ` Varadarajan Narayanan
2026-08-24  6:49   ` sashiko-bot [this message]
2026-08-24  6:49     ` sashiko-bot
2026-08-25  8:54   ` Konrad Dybcio
2026-08-25  8:54     ` Konrad Dybcio
2026-08-27  4:29     ` Varadarajan Narayanan
2026-08-27  4:29       ` Varadarajan Narayanan
2026-08-25  8:56   ` Konrad Dybcio
2026-08-25  8:56     ` Konrad Dybcio
2026-08-24  6:37 ` [PATCH 5/5] phy: qcom: snps-femto-v2: Add IPQ9650 support Varadarajan Narayanan
2026-08-24  6:37   ` Varadarajan Narayanan
2026-08-24  6:50   ` sashiko-bot
2026-08-24  6:50     ` sashiko-bot

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=20260824064933.2D09C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=varadarajan.narayanan@oss.qualcomm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.