All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: Andy Gross <andy.gross@linaro.org>,
	Evan Green <evgreen@chromium.org>,
	Kishon Vijay Abraham I <kishon@ti.com>
Cc: Marc Gonzalez <marc.w.gonzalez@free.fr>,
	Can Guo <cang@codeaurora.org>,
	Vivek Gautam <vivek.gautam@codeaurora.org>,
	Douglas Anderson <dianders@chromium.org>,
	Asutosh Das <asutoshd@codeaurora.org>,
	Evan Green <evgreen@chromium.org>,
	Jeffrey Hugo <jhugo@codeaurora.org>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-scsi@vger.kernel.org,
	Grygorii Strashko <grygorii.strashko@ti.com>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	linux-kernel@vger.kernel.org,
	Manu Gautam <mgautam@codeaurora.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	Vinayak Holikatti <vinholikatti@gmail.com>
Subject: Re: [PATCH v3 7/8] phy: qcom: Utilize UFS reset controller
Date: Wed, 06 Feb 2019 13:33:03 -0800	[thread overview]
Message-ID: <154948878332.115909.8361746129233481633@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <20190205185902.106085-8-evgreen@chromium.org>

Quoting Evan Green (2019-02-05 10:59:01)
> diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
> index aef40f7a41d4..b05f89d734f0 100644
> --- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
> +++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
> @@ -67,6 +67,16 @@ static int ufs_qcom_phy_qmp_20nm_init(struct phy *generic_phy)
>         bool is_rate_B = false;
>         int ret;
>  
> +       ret = ufs_qcom_phy_get_reset(phy_common);
> +       if (ret)
> +               return ret;
> +
> +       if (phy_common->ufs_reset) {
> +               ret = reset_control_assert(phy_common->ufs_reset);

It looks like you can always call this and set phy_common->ufs_reset to
NULL when it should be a no-op. But it would never be NULL because we
would always fail earlier in ufs_qcom_phy_get_reset()?

> +               if (ret)
> +                       return ret;
> +       }
> +
>         if (phy_common->mode == PHY_MODE_UFS_HS_B)
>                 is_rate_B = true;
>  
> diff --git a/drivers/phy/qualcomm/phy-qcom-ufs.c b/drivers/phy/qualcomm/phy-qcom-ufs.c
> index f2979ccad00a..9cc8aa0b7a4f 100644
> --- a/drivers/phy/qualcomm/phy-qcom-ufs.c
> +++ b/drivers/phy/qualcomm/phy-qcom-ufs.c
> @@ -147,6 +147,22 @@ struct phy *ufs_qcom_phy_generic_probe(struct platform_device *pdev,
>  }
>  EXPORT_SYMBOL_GPL(ufs_qcom_phy_generic_probe);
>  
> +int ufs_qcom_phy_get_reset(struct ufs_qcom_phy *phy_common)
> +{
> +       struct reset_control *reset;
> +
> +       if (phy_common->ufs_reset)
> +               return 0;
> +
> +       reset = devm_reset_control_get_exclusive_by_index(phy_common->dev, 0);
> +       if (IS_ERR(reset))
> +               return PTR_ERR(reset);
> +
> +       phy_common->ufs_reset = reset;
> +       return 0;

I find this API weird that it doesn't return the pointer to the reset
controller. It would be more kernel idiomatic if it returned the pointer
and used error pointers.

Are there now two places where we're getting the reset controller? I'm
confused now.

> +}
> +EXPORT_SYMBOL_GPL(ufs_qcom_phy_get_reset);
> +
>  static int __ufs_qcom_phy_clk_get(struct device *dev,
>                          const char *name, struct clk **clk_out, bool err_print)
>  {
> @@ -533,6 +549,14 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
>         if (phy_common->is_powered_on)
>                 return 0;
>  
> +       if (phy_common->ufs_reset) {
> +               err = reset_control_deassert(phy_common->ufs_reset);
> +               if (err) {
> +                       dev_err(dev, "Failed to assert UFS PHY reset");
> +                       return err;
> +               }
> +       }
> +
>         if (!phy_common->is_started) {
>                 err = ufs_qcom_phy_start_serdes(phy_common);
>                 if (err)
> @@ -620,6 +644,9 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy)
>  
>         ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_pll);
>         ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_phy);
> +       if (phy_common->ufs_reset)
> +               reset_control_assert(phy_common->ufs_reset);

All these ifs can go away basically.

> +
>         phy_common->is_powered_on = false;
>  
>         return 0;

WARNING: multiple messages have this Message-ID (diff)
From: Stephen Boyd <swboyd@chromium.org>
To: Andy Gross <andy.gross@linaro.org>,
	Kishon Vijay Abraham I <kishon@ti.com>
Cc: Marc Gonzalez <marc.w.gonzalez@free.fr>,
	Can Guo <cang@codeaurora.org>,
	Vivek Gautam <vivek.gautam@codeaurora.org>,
	Douglas Anderson <dianders@chromium.org>,
	Asutosh Das <asutoshd@codeaurora.org>,
	Evan Green <evgreen@chromium.org>,
	Jeffrey Hugo <jhugo@codeaurora.org>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-scsi@vger.kernel.org,
	Grygorii Strashko <grygorii.strashko@ti.com>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	linux-kernel@vger.kernel.org,
	Manu Gautam <mgautam@codeaurora.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	Vinayak Holikatti <vinholikatti@gmail.com>
Subject: Re: [PATCH v3 7/8] phy: qcom: Utilize UFS reset controller
Date: Wed, 06 Feb 2019 13:33:03 -0800	[thread overview]
Message-ID: <154948878332.115909.8361746129233481633@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <20190205185902.106085-8-evgreen@chromium.org>

Quoting Evan Green (2019-02-05 10:59:01)
> diff --git a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
> index aef40f7a41d4..b05f89d734f0 100644
> --- a/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
> +++ b/drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
> @@ -67,6 +67,16 @@ static int ufs_qcom_phy_qmp_20nm_init(struct phy *generic_phy)
>         bool is_rate_B = false;
>         int ret;
>  
> +       ret = ufs_qcom_phy_get_reset(phy_common);
> +       if (ret)
> +               return ret;
> +
> +       if (phy_common->ufs_reset) {
> +               ret = reset_control_assert(phy_common->ufs_reset);

It looks like you can always call this and set phy_common->ufs_reset to
NULL when it should be a no-op. But it would never be NULL because we
would always fail earlier in ufs_qcom_phy_get_reset()?

> +               if (ret)
> +                       return ret;
> +       }
> +
>         if (phy_common->mode == PHY_MODE_UFS_HS_B)
>                 is_rate_B = true;
>  
> diff --git a/drivers/phy/qualcomm/phy-qcom-ufs.c b/drivers/phy/qualcomm/phy-qcom-ufs.c
> index f2979ccad00a..9cc8aa0b7a4f 100644
> --- a/drivers/phy/qualcomm/phy-qcom-ufs.c
> +++ b/drivers/phy/qualcomm/phy-qcom-ufs.c
> @@ -147,6 +147,22 @@ struct phy *ufs_qcom_phy_generic_probe(struct platform_device *pdev,
>  }
>  EXPORT_SYMBOL_GPL(ufs_qcom_phy_generic_probe);
>  
> +int ufs_qcom_phy_get_reset(struct ufs_qcom_phy *phy_common)
> +{
> +       struct reset_control *reset;
> +
> +       if (phy_common->ufs_reset)
> +               return 0;
> +
> +       reset = devm_reset_control_get_exclusive_by_index(phy_common->dev, 0);
> +       if (IS_ERR(reset))
> +               return PTR_ERR(reset);
> +
> +       phy_common->ufs_reset = reset;
> +       return 0;

I find this API weird that it doesn't return the pointer to the reset
controller. It would be more kernel idiomatic if it returned the pointer
and used error pointers.

Are there now two places where we're getting the reset controller? I'm
confused now.

> +}
> +EXPORT_SYMBOL_GPL(ufs_qcom_phy_get_reset);
> +
>  static int __ufs_qcom_phy_clk_get(struct device *dev,
>                          const char *name, struct clk **clk_out, bool err_print)
>  {
> @@ -533,6 +549,14 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy)
>         if (phy_common->is_powered_on)
>                 return 0;
>  
> +       if (phy_common->ufs_reset) {
> +               err = reset_control_deassert(phy_common->ufs_reset);
> +               if (err) {
> +                       dev_err(dev, "Failed to assert UFS PHY reset");
> +                       return err;
> +               }
> +       }
> +
>         if (!phy_common->is_started) {
>                 err = ufs_qcom_phy_start_serdes(phy_common);
>                 if (err)
> @@ -620,6 +644,9 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy)
>  
>         ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_pll);
>         ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_phy);
> +       if (phy_common->ufs_reset)
> +               reset_control_assert(phy_common->ufs_reset);

All these ifs can go away basically.

> +
>         phy_common->is_powered_on = false;
>  
>         return 0;

  reply	other threads:[~2019-02-06 21:33 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05 18:58 [PATCH v3 0/8] phy: qcom-ufs: Enable regulators to be off in suspend Evan Green
2019-02-05 18:58 ` Evan Green
2019-02-05 18:58 ` [PATCH v3 1/8] dt-bindings: ufs: Add #reset-cells for Qualcomm controllers Evan Green
2019-02-05 18:58 ` [PATCH v3 2/8] dt-bindings: phy-qcom-qmp: Add UFS PHY reset Evan Green
2019-02-05 18:58 ` [PATCH v3 3/8] dt-bindings: phy: qcom-ufs: Add resets property Evan Green
2019-02-05 18:58 ` [PATCH v3 4/8] arm64: dts: sdm845: Add UFS PHY reset Evan Green
2019-02-05 18:58 ` [PATCH v3 5/8] arm64: dts: msm8996: Add UFS PHY reset controller Evan Green
2019-02-05 18:59 ` [PATCH v3 6/8] scsi: ufs: qcom: Expose the reset controller for PHY Evan Green
2019-02-06 11:42   ` Kishon Vijay Abraham I
2019-02-06 11:42     ` Kishon Vijay Abraham I
2019-02-06 11:54     ` Marc Gonzalez
2019-02-06 12:12       ` Kishon Vijay Abraham I
2019-02-06 13:57     ` Avri Altman
2019-02-06 19:48       ` Stephen Boyd
2019-02-06 21:04   ` Stephen Boyd
2019-02-06 21:04     ` Stephen Boyd
2019-02-05 18:59 ` [PATCH v3 7/8] phy: qcom: Utilize UFS reset controller Evan Green
2019-02-06 21:33   ` Stephen Boyd [this message]
2019-02-06 21:33     ` Stephen Boyd
2019-02-08 18:59     ` Evan Green
2019-02-05 18:59 ` [PATCH v3 8/8] phy: ufs-qcom: Refactor all init steps into phy_poweron Evan Green
2019-02-06 22:04   ` Stephen Boyd
2019-02-06 22:04     ` Stephen Boyd
2019-03-19 20:04 ` [PATCH v3 0/8] phy: qcom-ufs: Enable regulators to be off in suspend Evan Green
2019-03-19 20:04   ` Evan Green
2019-03-20  9:06   ` Kishon Vijay Abraham I
2019-03-20  9:06     ` Kishon Vijay Abraham I
2019-03-21 17:19     ` Evan Green
2019-03-21 17:19       ` Evan Green

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=154948878332.115909.8361746129233481633@swboyd.mtv.corp.google.com \
    --to=swboyd@chromium.org \
    --cc=andy.gross@linaro.org \
    --cc=arnd@arndb.de \
    --cc=asutoshd@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=cang@codeaurora.org \
    --cc=dianders@chromium.org \
    --cc=evgreen@chromium.org \
    --cc=grygorii.strashko@ti.com \
    --cc=jejb@linux.ibm.com \
    --cc=jhugo@codeaurora.org \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=marc.w.gonzalez@free.fr \
    --cc=martin.petersen@oracle.com \
    --cc=mgautam@codeaurora.org \
    --cc=vinholikatti@gmail.com \
    --cc=vivek.gautam@codeaurora.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 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.