linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] phy: qcom-qmp: fix init-count imbalance
@ 2023-05-02 10:38 Johan Hovold
  2023-05-02 10:38 ` [PATCH 1/2] phy: qcom-qmp-combo: " Johan Hovold
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Johan Hovold @ 2023-05-02 10:38 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I
  Cc: Bjorn Andersson, Andy Gross, linux-arm-msm, linux-phy,
	linux-kernel, Johan Hovold

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(-)

-- 
2.39.2


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

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

* [PATCH 1/2] phy: qcom-qmp-combo: fix init-count imbalance
  2023-05-02 10:38 [PATCH 0/2] phy: qcom-qmp: fix init-count imbalance Johan Hovold
@ 2023-05-02 10:38 ` Johan Hovold
  2023-05-02 12:24   ` Dmitry Baryshkov
  2023-05-02 10:38 ` [PATCH 2/2] phy: qcom-qmp-pcie-msm8996: " Johan Hovold
  2023-05-08  9:09 ` [PATCH 0/2] phy: qcom-qmp: " Vinod Koul
  2 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2023-05-02 10:38 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I
  Cc: Bjorn Andersson, Andy Gross, linux-arm-msm, linux-phy,
	linux-kernel, Johan Hovold, stable

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")
Cc: stable@vger.kernel.org	# 4.12
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
index c1483e157af4..ae412d64b426 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
@@ -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;
-- 
2.39.2


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

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

* [PATCH 2/2] phy: qcom-qmp-pcie-msm8996: fix init-count imbalance
  2023-05-02 10:38 [PATCH 0/2] phy: qcom-qmp: fix init-count imbalance Johan Hovold
  2023-05-02 10:38 ` [PATCH 1/2] phy: qcom-qmp-combo: " Johan Hovold
@ 2023-05-02 10:38 ` Johan Hovold
  2023-05-02 12:24   ` Dmitry Baryshkov
  2023-05-08  9:09 ` [PATCH 0/2] phy: qcom-qmp: " Vinod Koul
  2 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2023-05-02 10:38 UTC (permalink / raw)
  To: Vinod Koul, Kishon Vijay Abraham I
  Cc: Bjorn Andersson, Andy Gross, linux-arm-msm, linux-phy,
	linux-kernel, Johan Hovold, stable

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")
Cc: stable@vger.kernel.org      # 4.12
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c
index 09824be088c9..0c603bc06e09 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c
@@ -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


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

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

* Re: [PATCH 2/2] phy: qcom-qmp-pcie-msm8996: fix init-count imbalance
  2023-05-02 10:38 ` [PATCH 2/2] phy: qcom-qmp-pcie-msm8996: " Johan Hovold
@ 2023-05-02 12:24   ` Dmitry Baryshkov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Baryshkov @ 2023-05-02 12:24 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Vinod Koul, Kishon Vijay Abraham I, Bjorn Andersson, Andy Gross,
	linux-arm-msm, linux-phy, linux-kernel, stable

On Tue, 2 May 2023 at 13:39, Johan Hovold <johan+linaro@kernel.org> wrote:
>
> 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")
> Cc: stable@vger.kernel.org      # 4.12
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---
>  drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c
> index 09824be088c9..0c603bc06e09 100644
> --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c
> +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c
> @@ -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
>


-- 
With best wishes
Dmitry

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

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

* Re: [PATCH 1/2] phy: qcom-qmp-combo: fix init-count imbalance
  2023-05-02 10:38 ` [PATCH 1/2] phy: qcom-qmp-combo: " Johan Hovold
@ 2023-05-02 12:24   ` Dmitry Baryshkov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Baryshkov @ 2023-05-02 12:24 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Vinod Koul, Kishon Vijay Abraham I, Bjorn Andersson, Andy Gross,
	linux-arm-msm, linux-phy, linux-kernel, stable

On Tue, 2 May 2023 at 13:39, Johan Hovold <johan+linaro@kernel.org> wrote:
>
> 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")
> Cc: stable@vger.kernel.org      # 4.12
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
>  drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

-- 
With best wishes
Dmitry

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

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

* Re: [PATCH 0/2] phy: qcom-qmp: fix init-count imbalance
  2023-05-02 10:38 [PATCH 0/2] phy: qcom-qmp: fix init-count imbalance Johan Hovold
  2023-05-02 10:38 ` [PATCH 1/2] phy: qcom-qmp-combo: " Johan Hovold
  2023-05-02 10:38 ` [PATCH 2/2] phy: qcom-qmp-pcie-msm8996: " Johan Hovold
@ 2023-05-08  9:09 ` Vinod Koul
  2 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2023-05-08  9:09 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Kishon Vijay Abraham I, Bjorn Andersson, Andy Gross,
	linux-arm-msm, linux-phy, linux-kernel

On 02-05-23, 12:38, Johan Hovold wrote:
> Two of the dedicated QMP PHY drivers suffer from a long-standing bug in
> the common-block initialisation code.

Applied, thanks

-- 
~Vinod

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

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

end of thread, other threads:[~2023-05-08  9:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-02 10:38 [PATCH 0/2] phy: qcom-qmp: fix init-count imbalance Johan Hovold
2023-05-02 10:38 ` [PATCH 1/2] phy: qcom-qmp-combo: " Johan Hovold
2023-05-02 12:24   ` Dmitry Baryshkov
2023-05-02 10:38 ` [PATCH 2/2] phy: qcom-qmp-pcie-msm8996: " Johan Hovold
2023-05-02 12:24   ` Dmitry Baryshkov
2023-05-08  9:09 ` [PATCH 0/2] phy: qcom-qmp: " Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).