All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] phy: qcom: qmp-combo: Fix AON toggle register presence check
@ 2026-12-02  4:48 ` Elson Serrao
  0 siblings, 0 replies; 3+ messages in thread
From: Elson Serrao @ 2026-12-02  4:48 UTC (permalink / raw)
  To: vkoul, neil.armstrong, mani, abelvesa, konrad.dybcio,
	dmitry.baryshkov
  Cc: linux-arm-msm, linux-phy, linux-kernel, stable

The driver decides whether to clear the AON toggle enable bits by using
the USB AON toggle enable register offset as a presence indicator. On V10
PHYs, that register resides at offset 0x00 in the COM AON register space,
causing the check to evaluate false. As a result, the AON toggle bits are
never cleared.

Add a dedicated flag to indicate the presence of AON toggle registers and
use it to guard the corresponding register accesses. Also rename the
aon_toggle mapping and offsets to com_aon, as they represent the COM AON
register space rather than a single toggle register.

Fixes: eca0e717aab1 ("phy: qualcomm: qmp-combo: Add support for Hawi SoC")
Cc: stable@vger.kernel.org
Signed-off-by: Elson Serrao <elson.serrao@oss.qualcomm.com>
---
 drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 27 +++++++++++++----------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
index 3acf28c7d7b2..35fcf8681c62 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
@@ -2513,7 +2513,7 @@ struct qmp_combo_offsets {
 	u16 dp_txa;
 	u16 dp_txb;
 	u16 dp_dp_phy;
-	u16 aon_toggle;
+	u16 com_aon;
 	u16 usb4_serdes;
 	u16 usb4_pcs;
 };
@@ -2592,6 +2592,7 @@ struct qmp_phy_cfg {
 	unsigned int pcs_usb_offset;
 
 	bool invert_cc_polarity;
+	bool has_aon_toggle;
 };
 
 struct qmp_combo {
@@ -2600,7 +2601,7 @@ struct qmp_combo {
 	const struct qmp_phy_cfg *cfg;
 
 	void __iomem *com;
-	void __iomem *aon_toggle;
+	void __iomem *com_aon;
 
 	void __iomem *serdes;
 	void __iomem *tx;
@@ -2749,7 +2750,7 @@ static const struct qmp_combo_offsets qmp_combo_offsets_v8 = {
 
 static const struct qmp_combo_offsets qmp_combo_offsets_v10 = {
 	.com		= 0x0000,
-	.aon_toggle	= 0x0400,
+	.com_aon	= 0x0400,
 	.txa		= 0x1400,
 	.rxa		= 0x1600,
 	.txb		= 0x1800,
@@ -3065,6 +3066,7 @@ static const struct qmp_phy_cfg hawi_usb3dpphy_cfg = {
 	.pcs_usb_tbl_num	= ARRAY_SIZE(hawi_usb3_pcs_usb_tbl),
 
 	.regs			= qmp_v10_usb3phy_regs_layout,
+	.has_aon_toggle		= true,
 	.reset_list		= msm8996_usb3phy_reset_l,
 	.num_resets		= ARRAY_SIZE(msm8996_usb3phy_reset_l),
 	.vreg_list		= qmp_phy_vreg_l,
@@ -3428,6 +3430,7 @@ static const struct qmp_phy_cfg glymur_usb3dpphy_cfg = {
 	.configure_dp_phy	= qmp_v8_configure_dp_phy,
 
 	.regs			= qmp_v8_n3_usb43dpphy_regs_layout,
+	.has_aon_toggle		= true,
 	.reset_list		= msm8996_usb3phy_reset_l,
 	.num_resets		= ARRAY_SIZE(msm8996_usb3phy_reset_l),
 	.vreg_list		= qmp_phy_vreg_refgen,
@@ -4095,17 +4098,17 @@ static int qmp_combo_com_init(struct qmp_combo *qmp, bool force)
 	void __iomem *pcs_aon = qmp->pcs_aon;
 	void __iomem *pcs = qmp->pcs;
 	void __iomem *com = qmp->com;
-	void __iomem *aon_toggle;
+	void __iomem *aon_base;
 	int ret;
 	u32 val;
 
 	if (!force && qmp->init_count++)
 		return 0;
 
-	if (qmp->aon_toggle)
-		aon_toggle = qmp->aon_toggle;
+	if (qmp->com_aon)
+		aon_base = qmp->com_aon;
 	else
-		aon_toggle = qmp->pcs_aon;
+		aon_base = qmp->pcs_aon;
 
 	if (qmp->qmpphy_mode == QMPPHY_MODE_USB4) {
 		pcs = qmp->usb4_pcs;
@@ -4155,9 +4158,9 @@ static int qmp_combo_com_init(struct qmp_combo *qmp, bool force)
 			SW_USB4PHY_RESET_MUX | SW_USB4PHY_RESET);
 
 	/* override hardware control for reset of qmp phy */
-	if (aon_toggle && cfg->regs[QPHY_AON_TOGGLE_ENABLE]) {
-		qphy_clrbits(aon_toggle, cfg->regs[QPHY_AON_TOGGLE_ENABLE], 0x1);
-		qphy_clrbits(aon_toggle, cfg->regs[QPHY_DP_AON_TOGGLE_ENABLE], 0x1);
+	if (aon_base && cfg->has_aon_toggle) {
+		qphy_clrbits(aon_base, cfg->regs[QPHY_AON_TOGGLE_ENABLE], 0x1);
+		qphy_clrbits(aon_base, cfg->regs[QPHY_DP_AON_TOGGLE_ENABLE], 0x1);
 	}
 
 	/* Use software based port select and switch on typec orientation */
@@ -5386,8 +5389,8 @@ static int qmp_combo_parse_dt(struct qmp_combo *qmp)
 	}
 	qmp->dp_dp_phy = base + offs->dp_dp_phy;
 
-	if (offs->aon_toggle)
-		qmp->aon_toggle = base + offs->aon_toggle;
+	if (offs->com_aon)
+		qmp->com_aon = base + offs->com_aon;
 
 	qmp->usb4_serdes = base + offs->usb4_serdes;
 	qmp->usb4_pcs = base + offs->usb4_pcs;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] phy: qcom: qmp-combo: Fix AON toggle register presence check
@ 2026-12-02  4:48 ` Elson Serrao
  0 siblings, 0 replies; 3+ messages in thread
From: Elson Serrao @ 2026-12-02  4:48 UTC (permalink / raw)
  To: vkoul, neil.armstrong, mani, abelvesa, konrad.dybcio,
	dmitry.baryshkov
  Cc: linux-arm-msm, linux-phy, linux-kernel, stable

The driver decides whether to clear the AON toggle enable bits by using
the USB AON toggle enable register offset as a presence indicator. On V10
PHYs, that register resides at offset 0x00 in the COM AON register space,
causing the check to evaluate false. As a result, the AON toggle bits are
never cleared.

Add a dedicated flag to indicate the presence of AON toggle registers and
use it to guard the corresponding register accesses. Also rename the
aon_toggle mapping and offsets to com_aon, as they represent the COM AON
register space rather than a single toggle register.

Fixes: eca0e717aab1 ("phy: qualcomm: qmp-combo: Add support for Hawi SoC")
Cc: stable@vger.kernel.org
Signed-off-by: Elson Serrao <elson.serrao@oss.qualcomm.com>
---
 drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 27 +++++++++++++----------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
index 3acf28c7d7b2..35fcf8681c62 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
@@ -2513,7 +2513,7 @@ struct qmp_combo_offsets {
 	u16 dp_txa;
 	u16 dp_txb;
 	u16 dp_dp_phy;
-	u16 aon_toggle;
+	u16 com_aon;
 	u16 usb4_serdes;
 	u16 usb4_pcs;
 };
@@ -2592,6 +2592,7 @@ struct qmp_phy_cfg {
 	unsigned int pcs_usb_offset;
 
 	bool invert_cc_polarity;
+	bool has_aon_toggle;
 };
 
 struct qmp_combo {
@@ -2600,7 +2601,7 @@ struct qmp_combo {
 	const struct qmp_phy_cfg *cfg;
 
 	void __iomem *com;
-	void __iomem *aon_toggle;
+	void __iomem *com_aon;
 
 	void __iomem *serdes;
 	void __iomem *tx;
@@ -2749,7 +2750,7 @@ static const struct qmp_combo_offsets qmp_combo_offsets_v8 = {
 
 static const struct qmp_combo_offsets qmp_combo_offsets_v10 = {
 	.com		= 0x0000,
-	.aon_toggle	= 0x0400,
+	.com_aon	= 0x0400,
 	.txa		= 0x1400,
 	.rxa		= 0x1600,
 	.txb		= 0x1800,
@@ -3065,6 +3066,7 @@ static const struct qmp_phy_cfg hawi_usb3dpphy_cfg = {
 	.pcs_usb_tbl_num	= ARRAY_SIZE(hawi_usb3_pcs_usb_tbl),
 
 	.regs			= qmp_v10_usb3phy_regs_layout,
+	.has_aon_toggle		= true,
 	.reset_list		= msm8996_usb3phy_reset_l,
 	.num_resets		= ARRAY_SIZE(msm8996_usb3phy_reset_l),
 	.vreg_list		= qmp_phy_vreg_l,
@@ -3428,6 +3430,7 @@ static const struct qmp_phy_cfg glymur_usb3dpphy_cfg = {
 	.configure_dp_phy	= qmp_v8_configure_dp_phy,
 
 	.regs			= qmp_v8_n3_usb43dpphy_regs_layout,
+	.has_aon_toggle		= true,
 	.reset_list		= msm8996_usb3phy_reset_l,
 	.num_resets		= ARRAY_SIZE(msm8996_usb3phy_reset_l),
 	.vreg_list		= qmp_phy_vreg_refgen,
@@ -4095,17 +4098,17 @@ static int qmp_combo_com_init(struct qmp_combo *qmp, bool force)
 	void __iomem *pcs_aon = qmp->pcs_aon;
 	void __iomem *pcs = qmp->pcs;
 	void __iomem *com = qmp->com;
-	void __iomem *aon_toggle;
+	void __iomem *aon_base;
 	int ret;
 	u32 val;
 
 	if (!force && qmp->init_count++)
 		return 0;
 
-	if (qmp->aon_toggle)
-		aon_toggle = qmp->aon_toggle;
+	if (qmp->com_aon)
+		aon_base = qmp->com_aon;
 	else
-		aon_toggle = qmp->pcs_aon;
+		aon_base = qmp->pcs_aon;
 
 	if (qmp->qmpphy_mode == QMPPHY_MODE_USB4) {
 		pcs = qmp->usb4_pcs;
@@ -4155,9 +4158,9 @@ static int qmp_combo_com_init(struct qmp_combo *qmp, bool force)
 			SW_USB4PHY_RESET_MUX | SW_USB4PHY_RESET);
 
 	/* override hardware control for reset of qmp phy */
-	if (aon_toggle && cfg->regs[QPHY_AON_TOGGLE_ENABLE]) {
-		qphy_clrbits(aon_toggle, cfg->regs[QPHY_AON_TOGGLE_ENABLE], 0x1);
-		qphy_clrbits(aon_toggle, cfg->regs[QPHY_DP_AON_TOGGLE_ENABLE], 0x1);
+	if (aon_base && cfg->has_aon_toggle) {
+		qphy_clrbits(aon_base, cfg->regs[QPHY_AON_TOGGLE_ENABLE], 0x1);
+		qphy_clrbits(aon_base, cfg->regs[QPHY_DP_AON_TOGGLE_ENABLE], 0x1);
 	}
 
 	/* Use software based port select and switch on typec orientation */
@@ -5386,8 +5389,8 @@ static int qmp_combo_parse_dt(struct qmp_combo *qmp)
 	}
 	qmp->dp_dp_phy = base + offs->dp_dp_phy;
 
-	if (offs->aon_toggle)
-		qmp->aon_toggle = base + offs->aon_toggle;
+	if (offs->com_aon)
+		qmp->com_aon = base + offs->com_aon;
 
 	qmp->usb4_serdes = base + offs->usb4_serdes;
 	qmp->usb4_pcs = base + offs->usb4_pcs;
-- 
2.34.1


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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] phy: qcom: qmp-combo: Fix AON toggle register presence check
  2026-12-02  4:48 ` Elson Serrao
  (?)
@ 2026-12-02  4:52 ` sashiko-bot
  -1 siblings, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-02  4:52 UTC (permalink / raw)
  To: Elson Serrao; +Cc: linux-phy, vkoul, neil.armstrong, olteanv

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] phy: qcom-qmp-combo: reference count corruption in
  qmp_combo_com_init() [1]
--

commit dccf447e1e62578f09efd8227671a2f8922cab99
Author: Elson Serrao <elson.serrao@oss.qualcomm.com>

phy: qcom: qmp-combo: Fix AON toggle register presence check

This commit adds a has_aon_toggle flag to struct qmp_phy_cfg to indicate
the presence of AON toggle registers instead of checking the register
offset, which can be 0x00 on V10 PHYs, and renames the aon_toggle mapping
to com_aon.

> diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> index 3acf28c7d7b21..35fcf8681c627 100644
> --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c

[ ... ]

> @@ -4095,17 +4098,17 @@ static int qmp_combo_com_init(struct qmp_combo *qmp, bool force)
>  	void __iomem *pcs_aon = qmp->pcs_aon;
>  	void __iomem *pcs = qmp->pcs;
>  	void __iomem *com = qmp->com;
> -	void __iomem *aon_toggle;
> +	void __iomem *aon_base;
>  	int ret;
>  	u32 val;
>  
>  	if (!force && qmp->init_count++)
>  		return 0;

[Severity: High]
This problem wasn't introduced by this patch, but can qmp->init_count
become unbalanced in qmp_combo_com_init() [1] when force is true?

When force is true, qmp->init_count++ is skipped on entry, but if
regulator_bulk_enable(), reset control, or clock enabling fails, the
err_decrement_count path unconditionally decrements qmp->init_count:

drivers/phy/qualcomm/phy-qcom-qmp-combo.c:qmp_combo_com_init() {
	...
	ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs);
	if (ret) {
		dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret);
		goto err_decrement_count;
	}
	...
err_decrement_count:
	qmp->init_count--;

	return ret;
}

Later calls to qmp_combo_com_exit() can then see a corrupted init_count
and disable regulators and clocks that are already disabled.

[1] https://sashiko.dev/#/bug/linux-10d6c507-1390-4fe5-8fd5-650aea6f4e69

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202044831.3528405-1-elson.serrao@oss.qualcomm.com?part=1

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-02  4:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  4:48 [PATCH] phy: qcom: qmp-combo: Fix AON toggle register presence check Elson Serrao
2026-12-02  4:48 ` Elson Serrao
2026-12-02  4:52 ` sashiko-bot

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.