linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Krishna chaitanya chundru <quic_krichai@quicinc.com>
Cc: helgaas@kernel.org, linux-pci@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	mka@chromium.org, quic_vbadigan@quicinc.com,
	quic_hemantk@quicinc.com, quic_nitegupt@quicinc.com,
	quic_skananth@quicinc.com, quic_ramkri@quicinc.com,
	manivannan.sadhasivam@linaro.org, swboyd@chromium.org,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Vinod Koul <vkoul@kernel.org>,
	"open list:GENERIC PHY FRAMEWORK" <linux-phy@lists.infradead.org>
Subject: Re: [PATCH v6 3/5] phy: core: Add support for phy power down & power up
Date: Fri, 9 Sep 2022 12:04:53 +0300	[thread overview]
Message-ID: <CAA8EJppgaAuEDU44ePOt+ZWK0_rNsXHnE3WOEc9F-n=VE=3aVQ@mail.gmail.com> (raw)
In-Reply-To: <1662713084-8106-4-git-send-email-quic_krichai@quicinc.com>

On Fri, 9 Sept 2022 at 11:45, Krishna chaitanya chundru
<quic_krichai@quicinc.com> wrote:
>
> Introducing phy power down/up callbacks for allowing to park the
> link-state in L1ss without holding any PCIe resources during
> system suspend.
>
> Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
> ---
>  drivers/phy/phy-core.c  | 30 ++++++++++++++++++++++++++++++
>  include/linux/phy/phy.h | 20 ++++++++++++++++++++
>  2 files changed, 50 insertions(+)
>
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index d93ddf1..1b0b757 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -441,6 +441,36 @@ int phy_set_speed(struct phy *phy, int speed)
>  }
>  EXPORT_SYMBOL_GPL(phy_set_speed);
>
> +int phy_power_down(struct phy *phy)
> +{
> +       int ret;
> +
> +       if (!phy || !phy->ops->power_down)
> +               return 0;
> +
> +       mutex_lock(&phy->mutex);
> +       ret = phy->ops->power_down(phy);
> +       mutex_unlock(&phy->mutex);
> +
> +       return ret;
> +}
> +EXPORT_SYMBOL_GPL(phy_power_down);
> +
> +int phy_power_up(struct phy *phy)
> +{
> +       int ret;
> +
> +       if (!phy || !phy->ops->power_up)
> +               return 0;
> +
> +       mutex_lock(&phy->mutex);
> +       ret = phy->ops->power_up(phy);
> +       mutex_unlock(&phy->mutex);
> +
> +       return ret;
> +}

As it can be seen from the phy_power_off(), the PHY can be a shared
resource, with the power_count counting the number of users that
requested the PHY to be powered up. By introducing suc calls you break
directly into this by allowing a single user to power down the PHY, no
matter how many other users have requested the PHY to stay alive.

> +EXPORT_SYMBOL_GPL(phy_power_up);
> +
>  int phy_reset(struct phy *phy)
>  {
>         int ret;
> diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> index b141375..3a45f4d 100644
> --- a/include/linux/phy/phy.h
> +++ b/include/linux/phy/phy.h
> @@ -76,6 +76,8 @@ union phy_configure_opts {
>   * @set_mode: set the mode of the phy
>   * @set_media: set the media type of the phy (optional)
>   * @set_speed: set the speed of the phy (optional)
> + * @power_down: parking the phy in power down state
> + * @power_up: pulling back the phy from power down
>   * @reset: resetting the phy
>   * @calibrate: calibrate the phy
>   * @release: ops to be performed while the consumer relinquishes the PHY
> @@ -89,6 +91,8 @@ struct phy_ops {
>         int     (*set_mode)(struct phy *phy, enum phy_mode mode, int submode);
>         int     (*set_media)(struct phy *phy, enum phy_media media);
>         int     (*set_speed)(struct phy *phy, int speed);
> +       int     (*power_down)(struct phy *phy);
> +       int     (*power_up)(struct phy *phy);
>
>         /**
>          * @configure:
> @@ -226,6 +230,8 @@ int phy_init(struct phy *phy);
>  int phy_exit(struct phy *phy);
>  int phy_power_on(struct phy *phy);
>  int phy_power_off(struct phy *phy);
> +int phy_power_down(struct phy *phy);
> +int phy_power_up(struct phy *phy);
>  int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode);
>  #define phy_set_mode(phy, mode) \
>         phy_set_mode_ext(phy, mode, 0)
> @@ -349,6 +355,20 @@ static inline int phy_power_off(struct phy *phy)
>         return -ENOSYS;
>  }
>
> +static inline int phy_power_down(struct phy *phy)
> +{
> +       if (!phy)
> +               return 0;
> +       return -ENOSYS;
> +}
> +
> +static inline int phy_power_up(struct phy *phy)
> +{
> +       if (!phy)
> +               return 0;
> +       return -ENOSYS;
> +}
> +
>  static inline int phy_set_mode_ext(struct phy *phy, enum phy_mode mode,
>                                    int submode)
>  {
> --
> 2.7.4
>


-- 
With best wishes
Dmitry

  reply	other threads:[~2022-09-09  9:06 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09  8:44 [PATCH v6 0/5] PCI: qcom: Add system suspend & resume support Krishna chaitanya chundru
2022-09-09  8:44 ` [PATCH v6 1/5] PCI: qcom: Add system suspend and " Krishna chaitanya chundru
2022-09-09 17:31   ` Matthias Kaehlcke
2022-09-12 16:06     ` Krishna Chaitanya Chundru
2022-09-12 16:54       ` Matthias Kaehlcke
2022-09-12 17:09     ` Manivannan Sadhasivam
2022-09-09  8:44 ` [PATCH v6 2/5] PCI: qcom: Add retry logic for link to be stable in L1ss Krishna chaitanya chundru
2022-09-09 19:50   ` Bjorn Helgaas
2022-09-12 16:09     ` Krishna Chaitanya Chundru
2022-09-12 17:33       ` Manivannan Sadhasivam
2022-09-13 14:24         ` Krishna Chaitanya Chundru
2022-09-13 16:39           ` Manivannan Sadhasivam
2022-09-14  1:45             ` Krishna Chaitanya Chundru
2022-09-14  5:59               ` Manivannan Sadhasivam
2022-09-19 16:23   ` kernel test robot
2022-09-09  8:44 ` [PATCH v6 3/5] phy: core: Add support for phy power down & power up Krishna chaitanya chundru
2022-09-09  9:04   ` Dmitry Baryshkov [this message]
2022-09-14 14:50     ` Krishna Chaitanya Chundru
2022-09-19 17:29       ` Dmitry Baryshkov
2022-09-20  9:41         ` Krishna Chaitanya Chundru
2022-09-13 14:58   ` Vinod Koul
2022-09-13 16:41     ` Bjorn Helgaas
2022-09-09  8:44 ` [PATCH v6 4/5] phy: qcom: Add power down/up callbacks to pcie phy Krishna chaitanya chundru
2022-09-09  8:44 ` [PATCH v6 5/5] clk: qcom: Alwaya on pcie gdsc Krishna chaitanya chundru
2022-09-12 17:04   ` Manivannan Sadhasivam
2022-09-13  6:42     ` Rajendra Nayak
2022-09-13 16:42       ` Manivannan Sadhasivam
2022-09-14  1:47         ` Krishna Chaitanya Chundru
2022-09-13 16:34     ` Bjorn Helgaas
2022-09-14  1:48       ` Krishna Chaitanya Chundru
2022-09-09 19:51 ` [PATCH v6 0/5] PCI: qcom: Add system suspend & resume support Bjorn Helgaas
2022-09-12 16:10   ` Krishna Chaitanya Chundru
2022-09-12 17:08     ` Bjorn Helgaas
2022-09-12 17:21       ` Manivannan Sadhasivam
2022-09-12 17:37 ` Manivannan Sadhasivam
2022-09-14  1:47   ` Krishna Chaitanya Chundru

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='CAA8EJppgaAuEDU44ePOt+ZWK0_rNsXHnE3WOEc9F-n=VE=3aVQ@mail.gmail.com' \
    --to=dmitry.baryshkov@linaro.org \
    --cc=helgaas@kernel.org \
    --cc=kishon@ti.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=mka@chromium.org \
    --cc=quic_hemantk@quicinc.com \
    --cc=quic_krichai@quicinc.com \
    --cc=quic_nitegupt@quicinc.com \
    --cc=quic_ramkri@quicinc.com \
    --cc=quic_skananth@quicinc.com \
    --cc=quic_vbadigan@quicinc.com \
    --cc=swboyd@chromium.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).