linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpuidle: change #ifdef for the declaration of cpuidle_enter_s2idle()
@ 2020-09-24  8:00 zhuguangqing83
  2020-09-25 14:41 ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: zhuguangqing83 @ 2020-09-24  8:00 UTC (permalink / raw)
  To: rjw, daniel.lezcano; +Cc: linux-pm, linux-kernel, zhuguangqing

From: zhuguangqing <zhuguangqing@xiaomi.com>

Currently, if CONFIG_SUSPEND=n and CONFIG_CPU_IDLE=y, the function
cpuidle_enter_s2idle() is declared but not defined, it may cause error
when cpuidle_enter_s2idle() is called.

If CONFIG_SUSPEND=y and CONFIG_CPU_IDLE=n, the function
cpuidle_enter_s2idle() is defined as "return -ENODEV;" which is not
supposed to be.

Change #ifdef CONFIG_CPU_IDLE to #ifdef CONFIG_SUSPEND for
cpuidle_enter_s2idle() in cpuidle.h, which is consistent with its
defination in cpuidle.c.

Signed-off-by: zhuguangqing <zhuguangqing@xiaomi.com>
---
 include/linux/cpuidle.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 6175c77bf25e..2aa8cead1727 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -216,22 +216,26 @@ static inline struct cpuidle_device *cpuidle_get_device(void) {return NULL; }
 extern int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
 				      struct cpuidle_device *dev,
 				      u64 latency_limit_ns);
-extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
-				struct cpuidle_device *dev);
 extern void cpuidle_use_deepest_state(u64 latency_limit_ns);
 #else
 static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
 					     struct cpuidle_device *dev,
 					     u64 latency_limit_ns)
 {return -ENODEV; }
-static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
-				       struct cpuidle_device *dev)
-{return -ENODEV; }
 static inline void cpuidle_use_deepest_state(u64 latency_limit_ns)
 {
 }
 #endif
 
+#ifdef CONFIG_SUSPEND
+extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
+				struct cpuidle_device *dev);
+#else
+static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
+				       struct cpuidle_device *dev)
+{return -ENODEV; }
+#endif
+
 /* kernel/sched/idle.c */
 extern void sched_idle_set_state(struct cpuidle_state *idle_state);
 extern void default_idle_call(void);
-- 
2.17.1


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

* Re: [PATCH] cpuidle: change #ifdef for the declaration of cpuidle_enter_s2idle()
  2020-09-24  8:00 [PATCH] cpuidle: change #ifdef for the declaration of cpuidle_enter_s2idle() zhuguangqing83
@ 2020-09-25 14:41 ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2020-09-25 14:41 UTC (permalink / raw)
  To: zhuguangqing83
  Cc: Rafael J. Wysocki, Daniel Lezcano, Linux PM,
	Linux Kernel Mailing List, zhuguangqing

On Thu, Sep 24, 2020 at 10:01 AM <zhuguangqing83@gmail.com> wrote:
>
> From: zhuguangqing <zhuguangqing@xiaomi.com>
>
> Currently, if CONFIG_SUSPEND=n and CONFIG_CPU_IDLE=y, the function
> cpuidle_enter_s2idle() is declared but not defined, it may cause error
> when cpuidle_enter_s2idle() is called.
>
> If CONFIG_SUSPEND=y and CONFIG_CPU_IDLE=n, the function
> cpuidle_enter_s2idle() is defined as "return -ENODEV;" which is not
> supposed to be.
>
> Change #ifdef CONFIG_CPU_IDLE to #ifdef CONFIG_SUSPEND for
> cpuidle_enter_s2idle() in cpuidle.h, which is consistent with its
> defination in cpuidle.c.

Well, what about the case when CONFIG_SUSPEND is set, but CONFIG_CPU_IDLE isn't?

>
> Signed-off-by: zhuguangqing <zhuguangqing@xiaomi.com>
> ---
>  include/linux/cpuidle.h | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
> index 6175c77bf25e..2aa8cead1727 100644
> --- a/include/linux/cpuidle.h
> +++ b/include/linux/cpuidle.h
> @@ -216,22 +216,26 @@ static inline struct cpuidle_device *cpuidle_get_device(void) {return NULL; }
>  extern int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
>                                       struct cpuidle_device *dev,
>                                       u64 latency_limit_ns);
> -extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
> -                               struct cpuidle_device *dev);
>  extern void cpuidle_use_deepest_state(u64 latency_limit_ns);
>  #else
>  static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
>                                              struct cpuidle_device *dev,
>                                              u64 latency_limit_ns)
>  {return -ENODEV; }
> -static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
> -                                      struct cpuidle_device *dev)
> -{return -ENODEV; }
>  static inline void cpuidle_use_deepest_state(u64 latency_limit_ns)
>  {
>  }
>  #endif
>
> +#ifdef CONFIG_SUSPEND
> +extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
> +                               struct cpuidle_device *dev);
> +#else
> +static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
> +                                      struct cpuidle_device *dev)
> +{return -ENODEV; }
> +#endif
> +
>  /* kernel/sched/idle.c */
>  extern void sched_idle_set_state(struct cpuidle_state *idle_state);
>  extern void default_idle_call(void);
> --
> 2.17.1
>

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

* Re: [PATCH] cpuidle: change #ifdef for the declaration of cpuidle_enter_s2idle()
  2020-09-26  1:30 zhuguangqing83
@ 2020-09-28 14:10 ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2020-09-28 14:10 UTC (permalink / raw)
  To: zhuguangqing83
  Cc: Rafael J. Wysocki, Rafael J. Wysocki, Daniel Lezcano, Linux PM,
	Linux Kernel Mailing List, zhuguangqing

On Sat, Sep 26, 2020 at 3:30 AM zhuguangqing83 <zhuguangqing83@gmail.com> wrote:
>
>
> > On Thu, Sep 24, 2020 at 10:01 AM <zhuguangqing83@gmail.com> wrote:
> > >
> > > From: zhuguangqing <zhuguangqing@xiaomi.com>
> > >
> > > Currently, if CONFIG_SUSPEND=n and CONFIG_CPU_IDLE=y, the function
> > > cpuidle_enter_s2idle() is declared but not defined, it may cause error
> > > when cpuidle_enter_s2idle() is called.
> > >
> > > If CONFIG_SUSPEND=y and CONFIG_CPU_IDLE=n, the function
> > > cpuidle_enter_s2idle() is defined as "return -ENODEV;" which is not
> > > supposed to be.
> > >
> > > Change #ifdef CONFIG_CPU_IDLE to #ifdef CONFIG_SUSPEND for
> > > cpuidle_enter_s2idle() in cpuidle.h, which is consistent with its
> > > defination in cpuidle.c.
> >
> > Well, what about the case when CONFIG_SUSPEND is set, but CONFIG_CPU_IDLE
> > isn't?
> >
>
> When CONFIG_SUSPEND is set, but CONFIG_CPU_IDLE isn't, the function
> cpuidle_enter_s2idle() is defined in cpuidle.c, but the defination in
> cpuidle.c is not used actually because CONFIG_CPU_IDLE isn't set, we
> only use its defination as "return -ENODEV;" in cpuidle.h.

Actually, if CONFIG_CPU_IDLE is not set, cpuidle.c is not compiled at
all AFAICS, but after the $subject patch the compiler will be looking
for cpuidle_enter_s2idle() in that case, won't it? [The static inline
stub is only present for CONFIG_SUSPEND unset.]

> > > Signed-off-by: zhuguangqing <zhuguangqing@xiaomi.com>
> > > ---
> > >  include/linux/cpuidle.h | 14 +++++++++-----
> > >  1 file changed, 9 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
> > > index 6175c77bf25e..2aa8cead1727 100644
> > > --- a/include/linux/cpuidle.h
> > > +++ b/include/linux/cpuidle.h
> > > @@ -216,22 +216,26 @@ static inline struct cpuidle_device
> > *cpuidle_get_device(void) {return NULL; }
> > >  extern int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
> > >                                       struct cpuidle_device *dev,
> > >                                       u64 latency_limit_ns);
> > > -extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
> > > -                               struct cpuidle_device *dev);
> > >  extern void cpuidle_use_deepest_state(u64 latency_limit_ns);
> > >  #else
> > >  static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
> > >                                              struct cpuidle_device *dev,
> > >                                              u64 latency_limit_ns)
> > >  {return -ENODEV; }
> > > -static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
> > > -                                      struct cpuidle_device *dev)
> > > -{return -ENODEV; }
> > >  static inline void cpuidle_use_deepest_state(u64 latency_limit_ns)
> > >  {
> > >  }
> > >  #endif
> > >
> > > +#ifdef CONFIG_SUSPEND
> > > +extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
> > > +                               struct cpuidle_device *dev);
> > > +#else
> > > +static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
> > > +                                      struct cpuidle_device *dev)
> > > +{return -ENODEV; }
> > > +#endif
> > > +
> > >  /* kernel/sched/idle.c */
> > >  extern void sched_idle_set_state(struct cpuidle_state *idle_state);
> > >  extern void default_idle_call(void);
> > > --
> > > 2.17.1
> > >
>

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

* Re: [PATCH] cpuidle: change #ifdef for the declaration of cpuidle_enter_s2idle()
@ 2020-09-26  1:30 zhuguangqing83
  2020-09-28 14:10 ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: zhuguangqing83 @ 2020-09-26  1:30 UTC (permalink / raw)
  To: 'Rafael J. Wysocki'
  Cc: 'Rafael J. Wysocki', 'Daniel Lezcano',
	'Linux PM', 'Linux Kernel Mailing List',
	'zhuguangqing'


> On Thu, Sep 24, 2020 at 10:01 AM <zhuguangqing83@gmail.com> wrote:
> >
> > From: zhuguangqing <zhuguangqing@xiaomi.com>
> >
> > Currently, if CONFIG_SUSPEND=n and CONFIG_CPU_IDLE=y, the function
> > cpuidle_enter_s2idle() is declared but not defined, it may cause error
> > when cpuidle_enter_s2idle() is called.
> >
> > If CONFIG_SUSPEND=y and CONFIG_CPU_IDLE=n, the function
> > cpuidle_enter_s2idle() is defined as "return -ENODEV;" which is not
> > supposed to be.
> >
> > Change #ifdef CONFIG_CPU_IDLE to #ifdef CONFIG_SUSPEND for
> > cpuidle_enter_s2idle() in cpuidle.h, which is consistent with its
> > defination in cpuidle.c.
> 
> Well, what about the case when CONFIG_SUSPEND is set, but CONFIG_CPU_IDLE
> isn't?
> 

When CONFIG_SUSPEND is set, but CONFIG_CPU_IDLE isn't, the function
cpuidle_enter_s2idle() is defined in cpuidle.c, but the defination in
cpuidle.c is not used actually because CONFIG_CPU_IDLE isn't set, we
only use its defination as "return -ENODEV;" in cpuidle.h.

> >
> > Signed-off-by: zhuguangqing <zhuguangqing@xiaomi.com>
> > ---
> >  include/linux/cpuidle.h | 14 +++++++++-----
> >  1 file changed, 9 insertions(+), 5 deletions(-)
> >
> > diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
> > index 6175c77bf25e..2aa8cead1727 100644
> > --- a/include/linux/cpuidle.h
> > +++ b/include/linux/cpuidle.h
> > @@ -216,22 +216,26 @@ static inline struct cpuidle_device
> *cpuidle_get_device(void) {return NULL; }
> >  extern int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
> >                                       struct cpuidle_device *dev,
> >                                       u64 latency_limit_ns);
> > -extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
> > -                               struct cpuidle_device *dev);
> >  extern void cpuidle_use_deepest_state(u64 latency_limit_ns);
> >  #else
> >  static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
> >                                              struct cpuidle_device *dev,
> >                                              u64 latency_limit_ns)
> >  {return -ENODEV; }
> > -static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
> > -                                      struct cpuidle_device *dev)
> > -{return -ENODEV; }
> >  static inline void cpuidle_use_deepest_state(u64 latency_limit_ns)
> >  {
> >  }
> >  #endif
> >
> > +#ifdef CONFIG_SUSPEND
> > +extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
> > +                               struct cpuidle_device *dev);
> > +#else
> > +static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv,
> > +                                      struct cpuidle_device *dev)
> > +{return -ENODEV; }
> > +#endif
> > +
> >  /* kernel/sched/idle.c */
> >  extern void sched_idle_set_state(struct cpuidle_state *idle_state);
> >  extern void default_idle_call(void);
> > --
> > 2.17.1
> >


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

end of thread, other threads:[~2020-09-28 14:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24  8:00 [PATCH] cpuidle: change #ifdef for the declaration of cpuidle_enter_s2idle() zhuguangqing83
2020-09-25 14:41 ` Rafael J. Wysocki
2020-09-26  1:30 zhuguangqing83
2020-09-28 14:10 ` Rafael J. Wysocki

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