From: sashiko-bot@kernel.org
To: "Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>
Cc: linux-phy@lists.infradead.org, conor+dt@kernel.org,
robh@kernel.org, devicetree@vger.kernel.org, vkoul@kernel.org,
olteanv@gmail.com, neil.armstrong@linaro.org
Subject: Re: [PATCH 06/10] phy: qcom-ipq806x-usb: fix the PHY_PARAM_CTRL1 field masks
Date: Mon, 10 Aug 2026 11:57:07 +0000 [thread overview]
Message-ID: <20260810115707.94AD61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260810-msm8974-usb3-v1-6-1a47e1185524@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
Pre-existing issues:
- [High] The patch fixes overlapping off-by-one field masks for PHY_PARAM_CTRL1, but fails to address identical off-by-one overlaps in RX_OVRD_IN_HI and TX_OVRD_DRV_LO register masks which cause active initialization bugs.
- [High] Missing clock cleanup on error paths in qcom_ipq806x_usb_ss_phy_init().
- [High] TEST_POWERDOWN is incorrectly cleared instead of being set during PHY exit.
- [High] Missing -EPROBE_DEFER handling for the optional xo_clk.
- [Medium] qcom_ipq806x_usb_ss_phy_init() incorrectly passes a fully assembled register value to usb_phy_write_readback(), causing spurious readback verification failures.
--
--- Patch [6]: [PATCH 06/10] phy: qcom-ipq806x-usb: fix the PHY_PARAM_CTRL1 field masks ---
commit cc9548cb27cc0af73d58ff5dfbb1d43ff53c1b2b
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
phy: qcom-ipq806x-usb: fix the PHY_PARAM_CTRL1 field masks
This patch aligns the PHY_PARAM_CTRL1 field masks with their documented
positions to prevent values from landing shifted. The previous off-by-one
masks corrupted neighboring fields and caused spurious write-readback
failures during PHY initialization.
> diff --git a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> index cf77e0a66e20d..3d3e9d6da298c 100644
> --- a/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> +++ b/drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
> @@ -68,15 +68,17 @@
> #define SSPHY_MPLL_VALUE 0
>
> /* QSCRATCH PHY_PARAM_CTRL1 fields */
> -#define PHY_PARAM_CTRL1_TX_FULL_SWING_MASK GENMASK(26, 19)
> -#define PHY_PARAM_CTRL1_TX_DEEMPH_6DB_MASK GENMASK(19, 13)
> -#define PHY_PARAM_CTRL1_TX_DEEMPH_3_5DB_MASK GENMASK(13, 7)
> -#define PHY_PARAM_CTRL1_LOS_BIAS_MASK GENMASK(7, 2)
> +#define PHY_PARAM_CTRL1_TX_FULL_SWING_MASK GENMASK(26, 20)
> +#define PHY_PARAM_CTRL1_TX_DEEMPH_6DB_MASK GENMASK(19, 14)
> +#define PHY_PARAM_CTRL1_TX_DEEMPH_3_5DB_MASK GENMASK(13, 8)
> +#define PHY_PARAM_CTRL1_LOS_LEVEL_MASK GENMASK(7, 3)
> +#define PHY_PARAM_CTRL1_LOS_BIAS_MASK GENMASK(2, 0)
>
> #define PHY_PARAM_CTRL1_MASK \
> (PHY_PARAM_CTRL1_TX_FULL_SWING_MASK | \
> PHY_PARAM_CTRL1_TX_DEEMPH_6DB_MASK | \
> PHY_PARAM_CTRL1_TX_DEEMPH_3_5DB_MASK | \
> + PHY_PARAM_CTRL1_LOS_LEVEL_MASK | \
> PHY_PARAM_CTRL1_LOS_BIAS_MASK)
[Severity: High]
This is a pre-existing issue, but while fixing the overlapping field masks for
PHY_PARAM_CTRL1, are there identical overlaps in the RX_OVRD_IN_HI and
TX_OVRD_DRV_LO masks that break the initialization logic?
For example:
#define RX_OVRD_IN_HI_RX_EQ_MASK GENMASK(10, 7)
#define RX_OVRD_IN_HI_RX_EQ_EN_OVRD BIT(7)
Because these masks overlap at bit 7, does qcom_ipq806x_usb_ss_phy_init()
silently disable the override right after enabling it?
data |= RX_OVRD_IN_HI_RX_EQ_EN_OVRD;
data &= ~RX_OVRD_IN_HI_RX_EQ_MASK;
data |= RX_OVRD_IN_HI_RX_EQ(phy_dwc3->rx_eq);
[ ... ]
> @@ -436,7 +440,8 @@ static int qcom_ipq806x_usb_ss_phy_init(struct phy *phy)
> data |= PHY_PARAM_CTRL1_TX_FULL_SWING(0x6e) |
> PHY_PARAM_CTRL1_TX_DEEMPH_6DB(0x20) |
> PHY_PARAM_CTRL1_TX_DEEMPH_3_5DB(phy_dwc3->tx_deamp_3_5db) |
> - PHY_PARAM_CTRL1_LOS_BIAS(0x9);
> + PHY_PARAM_CTRL1_LOS_LEVEL(0x9) |
> + PHY_PARAM_CTRL1_LOS_BIAS(0x0);
>
> usb_phy_write_readback(phy_dwc3, SSUSB_PHY_PARAM_CTRL_1,
> PHY_PARAM_CTRL1_MASK, data);
[Severity: Medium]
This isn't a bug introduced by this patch, but does this call to
usb_phy_write_readback() always fail spuriously on probe?
It looks like we are passing a fully assembled register value (`data`) as `val`
instead of passing just the masked bits:
data = readl(phy_dwc3->base + SSUSB_PHY_PARAM_CTRL_1);
data &= ~PHY_PARAM_CTRL1_MASK;
data |= PHY_PARAM_CTRL1_TX_FULL_SWING(0x6e) | ...
usb_phy_write_readback(phy_dwc3, SSUSB_PHY_PARAM_CTRL_1,
PHY_PARAM_CTRL1_MASK, data);
Inside usb_phy_write_readback(), it uses the provided `mask` when checking `val`:
/* Read back to see if val was written */
tmp = readl(phy_dwc3->base + offset);
tmp &= mask; /* clear other bits */
if (tmp != val)
dev_err(...);
Since `data` contains unmasked bits from the initial readl() and `tmp` masks
them out, won't this check unconditionally fail if any unmasked bits are non-zero?
[Severity: High]
This is a pre-existing issue, but does qcom_ipq806x_usb_ss_phy_init() leak
the clock references if it fails?
When a hardware read/write fails, the error path returns without unwinding
the enabled clocks:
err_phy_trans:
return ret;
Since the PHY core doesn't call phy_exit() when phy_init() fails, it seems
xo_clk and ref_clk remain permanently prepared and enabled?
[ ... ]
[Severity: High]
This isn't a bug introduced by this patch, but does the PHY exit sequence in
qcom_ipq806x_usb_ss_phy_exit() disable PHY retention instead of enabling it?
The comment indicates we want to set TEST_POWERDOWN:
/* 3. Set TEST_POWERED_DOWN in PHY_CTRL_REG to enable PHY retention */
...
usb_phy_write_readback(phy_dwc3, SSUSB_PHY_CTRL_REG,
SSUSB_CTRL_TEST_POWERDOWN, 0x0);
Since 0x0 is passed as the `val`, usb_phy_write_readback() clears the
SSUSB_CTRL_TEST_POWERDOWN bit rather than setting it. Should this pass
SSUSB_CTRL_TEST_POWERDOWN as the value?
[ ... ]
[Severity: High]
This is a pre-existing issue, but does qcom_ipq806x_usb_phy_probe() handle
probe deferral correctly for the optional xo_clk?
phy_dwc3->xo_clk = devm_clk_get(phy_dwc3->dev, "xo");
if (IS_ERR(phy_dwc3->xo_clk)) {
dev_dbg(phy_dwc3->dev, "cannot get TCXO clock\n");
phy_dwc3->xo_clk = NULL;
}
devm_clk_get() returns -EPROBE_DEFER when the clock is not yet ready. By
checking IS_ERR and masking all errors to NULL, wouldn't the driver fail to
defer its probe and silently operate without the TCXO clock if it probes
before the clock provider is ready?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260810-msm8974-usb3-v1-0-1a47e1185524@oss.qualcomm.com?part=6
next prev parent reply other threads:[~2026-08-10 11:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 11:42 [PATCH 00/10] ARM: qcom: enable USB3 (DWC3) controller on MSM8974 platform Dmitry Baryshkov
2026-08-10 11:42 ` [PATCH 01/10] dt-bindings: usb: qcom,snps-dwc3: document the MSM8974 controller Dmitry Baryshkov
2026-08-10 11:42 ` [PATCH 02/10] dt-bindings: phy: qcom,ipq806x-usb-phy-hs: document the MSM8974 HS PHY Dmitry Baryshkov
2026-08-10 11:42 ` [PATCH 03/10] dt-bindings: phy: qcom,ipq806x-usb-phy-ss: add MSM8974 SS PHY Dmitry Baryshkov
2026-08-10 11:54 ` sashiko-bot
2026-08-10 13:05 ` Rob Herring (Arm)
2026-08-10 11:42 ` [PATCH 04/10] phy: qcom-ipq806x-usb: add MSM8974 HS PHY support Dmitry Baryshkov
2026-08-10 11:51 ` sashiko-bot
2026-08-10 11:42 ` [PATCH 05/10] phy: qcom-ipq806x-usb: fix the SS PHY TEST_POWERDOWN bit Dmitry Baryshkov
2026-08-10 11:53 ` sashiko-bot
2026-08-10 11:42 ` [PATCH 06/10] phy: qcom-ipq806x-usb: fix the PHY_PARAM_CTRL1 field masks Dmitry Baryshkov
2026-08-10 11:57 ` sashiko-bot [this message]
2026-08-10 11:42 ` [PATCH 07/10] phy: qcom-ipq806x-usb: parse the tx-deamp-3_5db property as documented Dmitry Baryshkov
2026-08-10 11:49 ` sashiko-bot
2026-08-10 11:42 ` [PATCH 08/10] phy: qcom-ipq806x-usb: support the MSM8974 SS PHY parameters Dmitry Baryshkov
2026-08-10 11:56 ` sashiko-bot
2026-08-10 11:42 ` [PATCH 09/10] ARM: dts: qcom: msm8974: add the USB3 controller and its PHYs Dmitry Baryshkov
2026-08-10 12:04 ` sashiko-bot
2026-08-10 11:42 ` [PATCH 10/10] ARM: dts: qcom: apq8074-dragonboard: enable the USB3 host Dmitry Baryshkov
2026-08-10 12:07 ` 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=20260810115707.94AD61F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--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=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