diff mbox series

[1/2] phy: core: Add phy_pm_runtime_enabled

Message ID 20181117133755.9129-2-tony@atomide.com (mailing list archive)
State New, archived
Headers show
Series Improve phy-mapphone pm | expand

Commit Message

Tony Lindgren Nov. 17, 2018, 1:37 p.m. UTC
The phy driver may need to check phy_pm_runtime_enabled() in suspend as
PM runtime for phy may be already disabled when phy power_off() is called.

Cc: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/phy/phy-core.c  | 9 +++++++++
 include/linux/phy/phy.h | 6 ++++++
 2 files changed, 15 insertions(+)

Comments

Johan Hovold Nov. 17, 2018, 3:38 p.m. UTC | #1
On Sat, Nov 17, 2018 at 05:37:54AM -0800, Tony Lindgren wrote:
> The phy driver may need to check phy_pm_runtime_enabled() in suspend as
> PM runtime for phy may be already disabled when phy power_off() is called.
> 
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Sebastian Reichel <sre@kernel.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/phy/phy-core.c  | 9 +++++++++
>  include/linux/phy/phy.h | 6 ++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c

> diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> --- a/include/linux/phy/phy.h
> +++ b/include/linux/phy/phy.h
> @@ -158,6 +158,7 @@ int phy_pm_runtime_get(struct phy *phy);
>  int phy_pm_runtime_get_sync(struct phy *phy);
>  int phy_pm_runtime_put(struct phy *phy);
>  int phy_pm_runtime_put_sync(struct phy *phy);
> +bool phy_pm_runtime_enabled(struct phy *phy);
>  void phy_pm_runtime_allow(struct phy *phy);
>  void phy_pm_runtime_forbid(struct phy *phy);
>  int phy_init(struct phy *phy);
> @@ -240,6 +241,11 @@ static inline int phy_pm_runtime_put_sync(struct phy *phy)
>  	return -ENOSYS;
>  }
>  
> +static inline bool phy_pm_runtime_enabled(struct phy *phy)
> +{
> +	return false

Missing semicolon.

> +}
> +
>  static inline void phy_pm_runtime_allow(struct phy *phy)
>  {
>  	return;

Johan
Tony Lindgren Nov. 17, 2018, 3:43 p.m. UTC | #2
* Johan Hovold <johan@kernel.org> [181117 15:38]:
> On Sat, Nov 17, 2018 at 05:37:54AM -0800, Tony Lindgren wrote:
> > The phy driver may need to check phy_pm_runtime_enabled() in suspend as
> > PM runtime for phy may be already disabled when phy power_off() is called.
> > 
> > Cc: Pavel Machek <pavel@ucw.cz>
> > Cc: Sebastian Reichel <sre@kernel.org>
> > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > ---
> >  drivers/phy/phy-core.c  | 9 +++++++++
> >  include/linux/phy/phy.h | 6 ++++++
> >  2 files changed, 15 insertions(+)
> > 
> > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> > --- a/drivers/phy/phy-core.c
> > +++ b/drivers/phy/phy-core.c
> 
> > diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> > --- a/include/linux/phy/phy.h
> > +++ b/include/linux/phy/phy.h
> > @@ -158,6 +158,7 @@ int phy_pm_runtime_get(struct phy *phy);
> >  int phy_pm_runtime_get_sync(struct phy *phy);
> >  int phy_pm_runtime_put(struct phy *phy);
> >  int phy_pm_runtime_put_sync(struct phy *phy);
> > +bool phy_pm_runtime_enabled(struct phy *phy);
> >  void phy_pm_runtime_allow(struct phy *phy);
> >  void phy_pm_runtime_forbid(struct phy *phy);
> >  int phy_init(struct phy *phy);
> > @@ -240,6 +241,11 @@ static inline int phy_pm_runtime_put_sync(struct phy *phy)
> >  	return -ENOSYS;
> >  }
> >  
> > +static inline bool phy_pm_runtime_enabled(struct phy *phy)
> > +{
> > +	return false
> 
> Missing semicolon.

Oops thanks for catching that. I guess I did not try building
without CONFIG_GENERIC_PHY. Will fix and repost.

Regards,

Tony
kernel test robot Nov. 19, 2018, 2:46 p.m. UTC | #3
Hi Tony,

I love your patch! Yet something to improve:

[auto build test ERROR on phy/next]
[also build test ERROR on v4.20-rc3 next-20181119]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Tony-Lindgren/Improve-phy-mapphone-pm/20181119-222603
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git next
config: riscv-tinyconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 8.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=riscv 

All errors (new ones prefixed by >>):

   In file included from include/linux/usb/otg.h:13,
                    from include/linux/usb/of.h:12,
                    from drivers/usb/phy/of.c:9:
   include/linux/phy/phy.h: In function 'phy_pm_runtime_enabled':
>> include/linux/phy/phy.h:246:14: error: expected ';' before '}' token
     return false
                 ^
                 ;
    }
    ~             

vim +246 include/linux/phy/phy.h

   243	
   244	static inline bool phy_pm_runtime_enabled(struct phy *phy)
   245	{
 > 246		return false
   247	}
   248	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Pavel Machek June 2, 2019, 10:14 a.m. UTC | #4
Hi!

> > > The phy driver may need to check phy_pm_runtime_enabled() in suspend as
> > > PM runtime for phy may be already disabled when phy power_off() is called.
> > > 
> > > Cc: Pavel Machek <pavel@ucw.cz>
> > > Cc: Sebastian Reichel <sre@kernel.org>
> > > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > ---
> > >  drivers/phy/phy-core.c  | 9 +++++++++
> > >  include/linux/phy/phy.h | 6 ++++++
> > >  2 files changed, 15 insertions(+)
> > > 
> > > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> > > --- a/drivers/phy/phy-core.c
> > > +++ b/drivers/phy/phy-core.c
> > 
> > > diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> > > --- a/include/linux/phy/phy.h
> > > +++ b/include/linux/phy/phy.h
> > > @@ -158,6 +158,7 @@ int phy_pm_runtime_get(struct phy *phy);
> > >  int phy_pm_runtime_get_sync(struct phy *phy);
> > >  int phy_pm_runtime_put(struct phy *phy);
> > >  int phy_pm_runtime_put_sync(struct phy *phy);
> > > +bool phy_pm_runtime_enabled(struct phy *phy);
> > >  void phy_pm_runtime_allow(struct phy *phy);
> > >  void phy_pm_runtime_forbid(struct phy *phy);
> > >  int phy_init(struct phy *phy);
> > > @@ -240,6 +241,11 @@ static inline int phy_pm_runtime_put_sync(struct phy *phy)
> > >  	return -ENOSYS;
> > >  }
> > >  
> > > +static inline bool phy_pm_runtime_enabled(struct phy *phy)
> > > +{
> > > +	return false
> > 
> > Missing semicolon.
> 
> Oops thanks for catching that. I guess I did not try building
> without CONFIG_GENERIC_PHY. Will fix and repost.

Did this series get lost/forgotten somewhere? Is it still needed? Any
way I can help?
									Pavel
Pavel Machek June 2, 2019, 10:25 a.m. UTC | #5
Hi!

> > > > @@ -240,6 +241,11 @@ static inline int phy_pm_runtime_put_sync(struct phy *phy)
> > > >  	return -ENOSYS;
> > > >  }
> > > >  
> > > > +static inline bool phy_pm_runtime_enabled(struct phy *phy)
> > > > +{
> > > > +	return false
> > > 
> > > Missing semicolon.
> > 
> > Oops thanks for catching that. I guess I did not try building
> > without CONFIG_GENERIC_PHY. Will fix and repost.
> 
> Did this series get lost/forgotten somewhere? Is it still needed? Any
> way I can help?

Aha, it seems v2 of the series was applied, which touches different
files and that's why I did not detect it. Sorry for the noise.

									Pavel
diff mbox series

Patch

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -209,6 +209,15 @@  int phy_pm_runtime_put_sync(struct phy *phy)
 }
 EXPORT_SYMBOL_GPL(phy_pm_runtime_put_sync);
 
+bool phy_pm_runtime_enabled(struct phy *phy)
+{
+	if (!phy)
+		return false;
+
+	return pm_runtime_enabled(&phy->dev);
+}
+EXPORT_SYMBOL_GPL(phy_pm_runtime_enabled);
+
 void phy_pm_runtime_allow(struct phy *phy)
 {
 	if (!phy)
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -158,6 +158,7 @@  int phy_pm_runtime_get(struct phy *phy);
 int phy_pm_runtime_get_sync(struct phy *phy);
 int phy_pm_runtime_put(struct phy *phy);
 int phy_pm_runtime_put_sync(struct phy *phy);
+bool phy_pm_runtime_enabled(struct phy *phy);
 void phy_pm_runtime_allow(struct phy *phy);
 void phy_pm_runtime_forbid(struct phy *phy);
 int phy_init(struct phy *phy);
@@ -240,6 +241,11 @@  static inline int phy_pm_runtime_put_sync(struct phy *phy)
 	return -ENOSYS;
 }
 
+static inline bool phy_pm_runtime_enabled(struct phy *phy)
+{
+	return false
+}
+
 static inline void phy_pm_runtime_allow(struct phy *phy)
 {
 	return;