Skip to contentSkip to conversation

phy: qcom-qmp: fix init-count imbalance

PATCH Applied Johan Hovold 3 participants 6 messages May 2, 2023 – May 8, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover phy: qcom-qmp: fix init-count imbalance

Two of the dedicated QMP PHY drivers suffer from a long-standing bug in the common-block initialisation code.

Johan

Johan Hovold (2):
phy: qcom-qmp-combo: fix init-count imbalance
phy: qcom-qmp-pcie-msm8996: fix init-count imbalance

 drivers/phy/qualcomm/phy-qcom-qmp-combo.c        | 5 +++--
 drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)
Signature · 7 lines
2.39.2


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#1 lore raw

PATCH 1/2 phy: qcom-qmp-combo: fix init-count imbalance

The init counter is not decremented on initialisation errors, which prevents retrying initialisation and can lead to the runtime suspend callback attempting to disable resources that have never been enabled.

Add the missing decrement on initialisation errors so that the counter reflects the state of the device.

Fixes e78f3d15e115 ("phy: qcom-qmp: new qmp phy driver for qcom-chipsets")
---
 drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +3 -2
index c1483e157af4..ae412d64b426 100644
@@ -2487,7 +2487,7 @@ static int qmp_combo_com_init(struct qmp_combo *qmp)
 	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_unlock;
+		goto err_decrement_count;
 	}
 
 	ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets);
@@ -2537,7 +2537,8 @@ static int qmp_combo_com_init(struct qmp_combo *qmp)
 	reset_control_bulk_assert(cfg->num_resets, qmp->resets);
 err_disable_regulators:
 	regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
-err_unlock:
+err_decrement_count:
+	qmp->init_count--;
 	mutex_unlock(&qmp->phy_mutex);
 
 	return ret;
Signature · 7 lines
2.39.2


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] phy: qcom-qmp-combo: fix init-count imbalance

Quoted 8 lines · Johan Hovold

The init counter is not decremented on initialisation errors, which prevents retrying initialisation and can lead to the runtime suspend callback attempting to disable resources that have never been enabled.

Add the missing decrement on initialisation errors so that the counter reflects the state of the device.

Quoted 6 lines
Fixes e78f3d15e115 ("phy: qcom-qmp: new qmp phy driver for qcom-chipsets")
---
 drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 7 lines
With best wishes
Dmitry

-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
#3 lore raw

PATCH 2/2 phy: qcom-qmp-pcie-msm8996: fix init-count imbalance

In reply to Johan Hovold

The init counter is not decremented on initialisation errors, which prevents retrying initialisation.

Add the missing decrement on initialisation errors so that the counter reflects the state of the device.

Fixes e78f3d15e115 ("phy: qcom-qmp: new qmp phy driver for qcom-chipsets")
---
 drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c +3 -2
index 09824be088c9..0c603bc06e09 100644
@@ -379,7 +379,7 @@ static int qmp_pcie_msm8996_com_init(struct qmp_phy *qphy)
 	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_unlock;
+		goto err_decrement_count;
 	}
 
 	ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets);
@@ -409,7 +409,8 @@ static int qmp_pcie_msm8996_com_init(struct qmp_phy *qphy)
 	reset_control_bulk_assert(cfg->num_resets, qmp->resets);
 err_disable_regulators:
 	regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
-err_unlock:
+err_decrement_count:
+	qmp->init_count--;
 	mutex_unlock(&qmp->phy_mutex);
 
 	return ret;
Signature · 7 lines
2.39.2


-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] phy: qcom-qmp-pcie-msm8996: fix init-count imbalance

Quoted 10 lines · Johan Hovold

The init counter is not decremented on initialisation errors, which prevents retrying initialisation.

Add the missing decrement on initialisation errors so that the counter reflects the state of the device.

Fixes e78f3d15e115 ("phy: qcom-qmp: new qmp phy driver for qcom-chipsets")
Quoted 30 lines
---
 drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c +3 -3
index 09824be088c9..0c603bc06e09 100644
@@ -379,7 +379,7 @@ static int qmp_pcie_msm8996_com_init(struct qmp_phy *qphy)
        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_unlock;
+               goto err_decrement_count;
        }
 
        ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets);
@@ -409,7 +409,8 @@ static int qmp_pcie_msm8996_com_init(struct qmp_phy *qphy)
        reset_control_bulk_assert(cfg->num_resets, qmp->resets);
 err_disable_regulators:
        regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
-err_unlock:
+err_decrement_count:
+       qmp->init_count--;
        mutex_unlock(&qmp->phy_mutex);
 
        return ret;
--

2.39.2

Signature · 2 lines
With best wishes
Dmitry
maintainer Applied
#5 lore raw
In reply to Johan Hovold
Quoted 2 lines · Johan Hovold

Two of the dedicated QMP PHY drivers suffer from a long-standing bug in the common-block initialisation code.

Applied, thanks

Signature · 1 line
~Vinod