From: Johan Hovold <johan@kernel.org>
To: Bjorn Andersson <quic_bjorande@quicinc.com>
Cc: Vinod Koul <vkoul@kernel.org>,
Kishon Vijay Abraham I <kishon@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/7] phy: qcom-qmp-combo: Move phy_mutex out of com_init/exit
Date: Tue, 2 May 2023 12:43:48 +0200 [thread overview]
Message-ID: <ZFDpZMBSM4fXWzB2@hovoldconsulting.com> (raw)
In-Reply-To: <20230425034010.3789376-3-quic_bjorande@quicinc.com>
On Mon, Apr 24, 2023 at 08:40:05PM -0700, Bjorn Andersson wrote:
> With the upcoming introduction of USB Type-C orientation switching the
> region of mutual exclusion needs to be extended to cover both the common
> init/exit as well as the individual functions.
>
> So move the phy_mutex one step up the stack.
>
> Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
> ---
> drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 51 +++++++++++++----------
> 1 file changed, 30 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> index 6850e04c329b..7280f7141961 100644
> --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
> @@ -2463,16 +2463,13 @@ static int qmp_combo_com_init(struct qmp_combo *qmp)
> void __iomem *com = qmp->com;
> int ret;
>
> - mutex_lock(&qmp->phy_mutex);
> - if (qmp->init_count++) {
> - mutex_unlock(&qmp->phy_mutex);
> + if (qmp->init_count++)
> return 0;
> - }
>
> 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;
I was going to say that you can just return ret directly but then
realised we have a counter imbalance here that should be fixed.
I've just sent a couple of fixes which you could rebase on:
https://lore.kernel.org/r/20230502103810.12061-1-johan+linaro@kernel.org
> }
>
> ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets);
> @@ -2514,16 +2511,13 @@ static int qmp_combo_com_init(struct qmp_combo *qmp)
> qphy_setbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
> SW_PWRDN);
>
> - mutex_unlock(&qmp->phy_mutex);
> -
> return 0;
>
> err_assert_reset:
> reset_control_bulk_assert(cfg->num_resets, qmp->resets);
> err_disable_regulators:
> regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
> -err_unlock:
> - mutex_unlock(&qmp->phy_mutex);
> +err:
>
> return ret;
> }
> @@ -2686,14 +2683,19 @@ static int qmp_combo_usb_init(struct phy *phy)
> struct qmp_combo *qmp = phy_get_drvdata(phy);
> int ret;
>
> + mutex_lock(&qmp->phy_mutex);
Nit: I think adding a newline here would improve readability.
> ret = qmp_combo_com_init(qmp);
> if (ret)
> - return ret;
> + goto out_unlock;
>
> ret = qmp_combo_usb_power_on(phy);
> - if (ret)
> + if (ret) {
> qmp_combo_com_exit(qmp);
> + goto out_unlock;
> + }
>
> +out_unlock:
> + mutex_unlock(&qmp->phy_mutex);
Same here.
> return ret;
> }
>
> @@ -2702,11 +2704,18 @@ static int qmp_combo_usb_exit(struct phy *phy)
> struct qmp_combo *qmp = phy_get_drvdata(phy);
> int ret;
>
> + mutex_lock(&qmp->phy_mutex);
And here.
> ret = qmp_combo_usb_power_off(phy);
> if (ret)
> - return ret;
> + goto out_unlock;
>
> - return qmp_combo_com_exit(qmp);
> + ret = qmp_combo_com_exit(qmp);
> + if (ret)
> + goto out_unlock;
> +
> +out_unlock:
> + mutex_unlock(&qmp->phy_mutex);
And here.
> + return ret;
> }
>
> static int qmp_combo_usb_set_mode(struct phy *phy, enum phy_mode mode, int submode)
Looks good otherwise:
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Johan
next prev parent reply other threads:[~2023-05-02 10:43 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-25 3:40 [PATCH 0/7] phy: qcom-qmp-combo: Support orientation switching Bjorn Andersson
2023-04-25 3:40 ` [PATCH 1/7] dt-bindings: phy: qcom,sc8280xp-qmp-usb43dp: Add ports and orientation-switch Bjorn Andersson
2023-04-25 18:58 ` Rob Herring
2023-04-26 10:21 ` Bryan O'Donoghue
2023-04-27 19:52 ` Bjorn Andersson
2023-05-03 20:37 ` Bryan O'Donoghue
2023-05-04 13:50 ` Neil Armstrong
2023-05-04 14:51 ` Bjorn Andersson
2023-04-25 3:40 ` [PATCH 2/7] phy: qcom-qmp-combo: Move phy_mutex out of com_init/exit Bjorn Andersson
2023-05-02 10:43 ` Johan Hovold [this message]
2023-04-25 3:40 ` [PATCH 3/7] phy: qcom-qmp-combo: Introduce orientation variable Bjorn Andersson
2023-04-27 13:13 ` Neil Armstrong
2023-05-02 11:48 ` Johan Hovold
2023-05-04 3:29 ` Bjorn Andersson
2023-05-04 13:44 ` Johan Hovold
2023-05-04 15:16 ` Bjorn Andersson
2023-05-04 15:41 ` Johan Hovold
2023-04-25 3:40 ` [PATCH 4/7] phy: qcom-qmp-combo: Introduce orientation switching Bjorn Andersson
2023-04-27 13:18 ` Neil Armstrong
2023-05-02 11:56 ` Johan Hovold
2023-04-25 3:40 ` [PATCH 5/7] phy: qcom-qmp-combo: Introduce drm_bridge Bjorn Andersson
2023-04-26 10:33 ` Bryan O'Donoghue
2023-04-27 13:11 ` Neil Armstrong
2023-04-27 18:00 ` Dmitry Baryshkov
2023-04-27 19:55 ` Bjorn Andersson
2023-04-28 6:55 ` Bryan O'Donoghue
2023-05-02 12:05 ` Johan Hovold
2023-05-04 3:13 ` Bjorn Andersson
2023-05-04 8:38 ` Johan Hovold
2023-05-04 8:55 ` Dmitry Baryshkov
2023-05-04 15:49 ` Bjorn Andersson
2023-04-25 3:40 ` [PATCH 6/7] arm64: dts: qcom: sc8280xp-crd: Add QMP to SuperSpeed graph Bjorn Andersson
2023-04-26 23:33 ` Konrad Dybcio
2023-04-27 13:27 ` Neil Armstrong
2023-05-02 11:03 ` Konrad Dybcio
2023-04-27 19:48 ` Bjorn Andersson
2023-05-02 12:22 ` Johan Hovold
2023-05-04 3:07 ` Bjorn Andersson
2023-04-25 3:40 ` [PATCH 7/7] arm64: dts: qcom: sc8280xp-x13s: " Bjorn Andersson
2023-04-25 4:58 ` [PATCH 0/7] phy: qcom-qmp-combo: Support orientation switching Steev Klimaszewski
2023-04-26 14:25 ` Abel Vesa
2023-05-02 12:26 ` Johan Hovold
2023-05-03 9:50 ` Neil Armstrong
2023-05-23 3:03 ` Bjorn Andersson
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=ZFDpZMBSM4fXWzB2@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=andersson@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kishon@kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=quic_bjorande@quicinc.com \
--cc=robh+dt@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).