linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM
@ 2014-04-24  6:11 Dongsheng Wang
  2014-04-25 21:45 ` Scott Wood
  0 siblings, 1 reply; 8+ messages in thread
From: Dongsheng Wang @ 2014-04-24  6:11 UTC (permalink / raw)
  To: benh, scottwood; +Cc: linuxppc-dev, chenhui.zhao, jason.jin, Wang Dongsheng

From: Wang Dongsheng <dongsheng.wang@freescale.com>

Add set_pm_suspend_state & pm_suspend_state functions to set/get
suspend state. When system going to sleep or deep sleep, devices
can get the system suspend state(STANDBY/MEM) through pm_suspend_state
function and to handle different situations.

Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
---
*v2*
Move pm api from fsl platform to powerpc general framework.

diff --git a/arch/powerpc/include/asm/pm.h b/arch/powerpc/include/asm/pm.h
new file mode 100644
index 0000000..00ddbf1
--- /dev/null
+++ b/arch/powerpc/include/asm/pm.h
@@ -0,0 +1,26 @@
+/*
+ * asm/pm.h
+ *
+ * Definitions for any platform related flags or structures for
+ * Power Management.
+ *
+ * Author: Wang Dongsheng <dongsheng.wang@freescale.com>
+ *
+ * Copyright 2014 Freescale Semiconductor, Inc
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#ifndef _POWERPC_PM_H_
+#define _POWERPC_PM_H_
+#ifdef __KERNEL__
+#include <linux/suspend.h>
+
+extern void set_pm_suspend_state(suspend_state_t state);
+extern suspend_state_t pm_suspend_state(void);
+
+#endif /* __KERNEL__ */
+#endif /* _POWERPC_PM_H_ */
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index fcc9a89..2060145 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -28,7 +28,7 @@ endif
 
 obj-y				:= cputable.o ptrace.o syscalls.o \
 				   irq.o align.o signal_32.o pmc.o vdso.o \
-				   process.o systbl.o idle.o \
+				   process.o systbl.o idle.o pm.o \
 				   signal.o sysfs.o cacheinfo.o time.o \
 				   prom.o traps.o setup-common.o \
 				   udbg.o misc.o io.o dma.o \
diff --git a/arch/powerpc/kernel/pm.c b/arch/powerpc/kernel/pm.c
new file mode 100644
index 0000000..23d3c94
--- /dev/null
+++ b/arch/powerpc/kernel/pm.c
@@ -0,0 +1,26 @@
+/*
+ * PowerPC General Power Management Implementation
+ *
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ * Author: Wang Dongsheng <dongsheng.wang@freescale.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/suspend.h>
+#include <asm/pm.h>
+
+static suspend_state_t pm_state;
+
+void set_pm_suspend_state(suspend_state_t state)
+{
+	pm_state = state;
+}
+
+suspend_state_t pm_suspend_state(void)
+{
+	return pm_state;
+}
diff --git a/arch/powerpc/sysdev/fsl_pmc.c b/arch/powerpc/sysdev/fsl_pmc.c
index 8cf4aa0..fd777ca 100644
--- a/arch/powerpc/sysdev/fsl_pmc.c
+++ b/arch/powerpc/sysdev/fsl_pmc.c
@@ -21,6 +21,8 @@
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 
+#include <asm/pm.h>
+
 struct pmc_regs {
 	__be32 devdisr;
 	__be32 devdisr2;
@@ -52,12 +54,20 @@ static int pmc_suspend_valid(suspend_state_t state)
 {
 	if (state != PM_SUSPEND_STANDBY)
 		return 0;
+
+	set_pm_suspend_state(state);
 	return 1;
 }
 
+static void pmc_suspend_end(void)
+{
+	set_pm_suspend_state(PM_SUSPEND_ON);
+}
+
 static const struct platform_suspend_ops pmc_suspend_ops = {
 	.valid = pmc_suspend_valid,
 	.enter = pmc_suspend_enter,
+	.end	= pmc_suspend_end,
 };
 
 static int pmc_probe(struct platform_device *ofdev)
@@ -68,6 +78,7 @@ static int pmc_probe(struct platform_device *ofdev)
 
 	pmc_dev = &ofdev->dev;
 	suspend_set_ops(&pmc_suspend_ops);
+	set_pm_suspend_state(PM_SUSPEND_ON);
 	return 0;
 }
 
-- 
1.8.5

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

* Re: [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM
  2014-04-24  6:11 [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM Dongsheng Wang
@ 2014-04-25 21:45 ` Scott Wood
  2014-04-28  5:53   ` Leo Li
  0 siblings, 1 reply; 8+ messages in thread
From: Scott Wood @ 2014-04-25 21:45 UTC (permalink / raw)
  To: Dongsheng Wang; +Cc: linuxppc-dev, chenhui.zhao, jason.jin

On Thu, 2014-04-24 at 14:11 +0800, Dongsheng Wang wrote:
> From: Wang Dongsheng <dongsheng.wang@freescale.com>
> 
> Add set_pm_suspend_state & pm_suspend_state functions to set/get
> suspend state. When system going to sleep or deep sleep, devices
> can get the system suspend state(STANDBY/MEM) through pm_suspend_state
> function and to handle different situations.
> 
> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
> ---
> *v2*
> Move pm api from fsl platform to powerpc general framework.

What is powerpc-specific about this?

-Scott

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

* Re: [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM
  2014-04-25 21:45 ` Scott Wood
@ 2014-04-28  5:53   ` Leo Li
  2014-04-29 22:47     ` Scott Wood
  0 siblings, 1 reply; 8+ messages in thread
From: Leo Li @ 2014-04-28  5:53 UTC (permalink / raw)
  To: Scott Wood
  Cc: linuxppc-dev, Dongsheng Wang, 正雄 金,
	Zhao Chenhui

On Sat, Apr 26, 2014 at 5:45 AM, Scott Wood <scottwood@freescale.com> wrote:
> On Thu, 2014-04-24 at 14:11 +0800, Dongsheng Wang wrote:
>> From: Wang Dongsheng <dongsheng.wang@freescale.com>
>>
>> Add set_pm_suspend_state & pm_suspend_state functions to set/get
>> suspend state. When system going to sleep or deep sleep, devices
>> can get the system suspend state(STANDBY/MEM) through pm_suspend_state
>> function and to handle different situations.
>>
>> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
>> ---
>> *v2*
>> Move pm api from fsl platform to powerpc general framework.
>
> What is powerpc-specific about this?

Generally I agree with you.  But I had the discussion about this topic
a while ago with the PM maintainer.  He suggestion to go with the
platform way.

https://lkml.org/lkml/2013/8/16/505

Regards,
Leo

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

* Re: [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM
  2014-04-28  5:53   ` Leo Li
@ 2014-04-29 22:47     ` Scott Wood
  2014-04-29 23:07       ` Rafael J. Wysocki
  2014-05-09  9:33       ` Li Yang
  0 siblings, 2 replies; 8+ messages in thread
From: Scott Wood @ 2014-04-29 22:47 UTC (permalink / raw)
  To: Leo Li
  Cc: Zhao Chenhui, linux-pm, Rafael J. Wysocki, Dongsheng Wang,
	正雄 金, linuxppc-dev

On Mon, 2014-04-28 at 13:53 +0800, Leo Li wrote:
> On Sat, Apr 26, 2014 at 5:45 AM, Scott Wood <scottwood@freescale.com> wrote:
> > On Thu, 2014-04-24 at 14:11 +0800, Dongsheng Wang wrote:
> >> From: Wang Dongsheng <dongsheng.wang@freescale.com>
> >>
> >> Add set_pm_suspend_state & pm_suspend_state functions to set/get
> >> suspend state. When system going to sleep or deep sleep, devices
> >> can get the system suspend state(STANDBY/MEM) through pm_suspend_state
> >> function and to handle different situations.
> >>
> >> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
> >> ---
> >> *v2*
> >> Move pm api from fsl platform to powerpc general framework.
> >
> > What is powerpc-specific about this?
> 
> Generally I agree with you.  But I had the discussion about this topic
> a while ago with the PM maintainer.  He suggestion to go with the
> platform way.
> 
> https://lkml.org/lkml/2013/8/16/505

If what he meant was whether you could do what this patch does, then you
can answer him with, "No, because it got nacked as not being platform or
arch specific."  Oh, and you're still using .valid as the hook to set
the platform state, which is awful -- I think .begin is what you want to
use.

If we did it in powerpc code, then what would we do on ARM?  Copy the
code?  No.

Now, a more legitimate objection to putting it in generic code might be
that "standby" and "mem" are loosely defined and the knowledge of how a
driver should react to each is platform specific -- but your patch
doesn't address that.  You still have the driver itself interpret what
"standby" and "mem" mean.

As for "in analogy with ACPI suspend operations", can someone familiar
with ACPI explain what is meant?

-Scott

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

* Re: [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM
  2014-04-29 22:47     ` Scott Wood
@ 2014-04-29 23:07       ` Rafael J. Wysocki
  2014-05-09  9:33       ` Li Yang
  1 sibling, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2014-04-29 23:07 UTC (permalink / raw)
  To: Scott Wood
  Cc: Zhao Chenhui, linux-pm, Dongsheng Wang, Leo Li,
	正雄 金, linuxppc-dev

On Tuesday, April 29, 2014 05:47:12 PM Scott Wood wrote:
> On Mon, 2014-04-28 at 13:53 +0800, Leo Li wrote:
> > On Sat, Apr 26, 2014 at 5:45 AM, Scott Wood <scottwood@freescale.com> wrote:
> > > On Thu, 2014-04-24 at 14:11 +0800, Dongsheng Wang wrote:
> > >> From: Wang Dongsheng <dongsheng.wang@freescale.com>
> > >>
> > >> Add set_pm_suspend_state & pm_suspend_state functions to set/get
> > >> suspend state. When system going to sleep or deep sleep, devices
> > >> can get the system suspend state(STANDBY/MEM) through pm_suspend_state
> > >> function and to handle different situations.
> > >>
> > >> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
> > >> ---
> > >> *v2*
> > >> Move pm api from fsl platform to powerpc general framework.
> > >
> > > What is powerpc-specific about this?
> > 
> > Generally I agree with you.  But I had the discussion about this topic
> > a while ago with the PM maintainer.  He suggestion to go with the
> > platform way.
> > 
> > https://lkml.org/lkml/2013/8/16/505
> 
> If what he meant was whether you could do what this patch does, then you
> can answer him with, "No, because it got nacked as not being platform or
> arch specific."  Oh, and you're still using .valid as the hook to set
> the platform state, which is awful -- I think .begin is what you want to
> use.
> 
> If we did it in powerpc code, then what would we do on ARM?  Copy the
> code?  No.
> 
> Now, a more legitimate objection to putting it in generic code might be
> that "standby" and "mem" are loosely defined and the knowledge of how a
> driver should react to each is platform specific -- but your patch
> doesn't address that.  You still have the driver itself interpret what
> "standby" and "mem" mean.
> 
> As for "in analogy with ACPI suspend operations", can someone familiar
> with ACPI explain what is meant?

ACPI defines sleep states S3 and S1 which are mappend to "mem" and
"standby" currently, but that may change in the future.

Generally speaking the meaning of "mem" and "standby" is platform-specific
except that "mem" should be a deeper (lower-power) sleep state than "standby".

Thanks!

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM
  2014-04-29 22:47     ` Scott Wood
  2014-04-29 23:07       ` Rafael J. Wysocki
@ 2014-05-09  9:33       ` Li Yang
  2014-05-09 17:09         ` Scott Wood
  1 sibling, 1 reply; 8+ messages in thread
From: Li Yang @ 2014-05-09  9:33 UTC (permalink / raw)
  To: Scott Wood
  Cc: Zhao Chenhui, linux-pm@vger.kernel.org, Rafael J. Wysocki,
	Dongsheng Wang, 正雄 金, linuxppc-dev

On Wed, Apr 30, 2014 at 6:47 AM, Scott Wood <scottwood@freescale.com> wrote:
> On Mon, 2014-04-28 at 13:53 +0800, Leo Li wrote:
>> On Sat, Apr 26, 2014 at 5:45 AM, Scott Wood <scottwood@freescale.com> wrote:
>> > On Thu, 2014-04-24 at 14:11 +0800, Dongsheng Wang wrote:
>> >> From: Wang Dongsheng <dongsheng.wang@freescale.com>
>> >>
>> >> Add set_pm_suspend_state & pm_suspend_state functions to set/get
>> >> suspend state. When system going to sleep or deep sleep, devices
>> >> can get the system suspend state(STANDBY/MEM) through pm_suspend_state
>> >> function and to handle different situations.
>> >>
>> >> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
>> >> ---
>> >> *v2*
>> >> Move pm api from fsl platform to powerpc general framework.
>> >
>> > What is powerpc-specific about this?
>>
>> Generally I agree with you.  But I had the discussion about this topic
>> a while ago with the PM maintainer.  He suggestion to go with the
>> platform way.
>>
>> https://lkml.org/lkml/2013/8/16/505
>
> If what he meant was whether you could do what this patch does, then you
> can answer him with, "No, because it got nacked as not being platform or
> arch specific."  Oh, and you're still using .valid as the hook to set
> the platform state, which is awful -- I think .begin is what you want to
> use.

I'm not saying the current patch is good for upstream.  Actually I did
say that the patch need to be updated for upstream purpose.  I only
meant that we discussed about having the mem/standby passed by generic
kernel/power interface as you suggested internally and got an negative
feedback.

>
> If we did it in powerpc code, then what would we do on ARM?  Copy the
> code?  No.

If you are saying that this shouldn't be done in arch/powerpc  Yes.
We have determined to use drivers/platform folder for the re-used code
with ARM.  Platform power management code will be moved there.

>
> Now, a more legitimate objection to putting it in generic code might be
> that "standby" and "mem" are loosely defined and the knowledge of how a
> driver should react to each is platform specific -- but your patch
> doesn't address that.  You still have the driver itself interpret what
> "standby" and "mem" mean.
>

Yup, we will address it in next batch.

- Leo

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

* Re: [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM
  2014-05-09  9:33       ` Li Yang
@ 2014-05-09 17:09         ` Scott Wood
  2014-05-10 12:35           ` Li Yang
  0 siblings, 1 reply; 8+ messages in thread
From: Scott Wood @ 2014-05-09 17:09 UTC (permalink / raw)
  To: Li Yang
  Cc: Zhao Chenhui, linux-pm@vger.kernel.org, Rafael J. Wysocki,
	Dongsheng Wang, 正雄 金, linuxppc-dev

On Fri, 2014-05-09 at 17:33 +0800, Li Yang wrote:
> On Wed, Apr 30, 2014 at 6:47 AM, Scott Wood <scottwood@freescale.com> wrote:
> > On Mon, 2014-04-28 at 13:53 +0800, Leo Li wrote:
> >> On Sat, Apr 26, 2014 at 5:45 AM, Scott Wood <scottwood@freescale.com> wrote:
> >> > On Thu, 2014-04-24 at 14:11 +0800, Dongsheng Wang wrote:
> >> >> From: Wang Dongsheng <dongsheng.wang@freescale.com>
> >> >>
> >> >> Add set_pm_suspend_state & pm_suspend_state functions to set/get
> >> >> suspend state. When system going to sleep or deep sleep, devices
> >> >> can get the system suspend state(STANDBY/MEM) through pm_suspend_state
> >> >> function and to handle different situations.
> >> >>
> >> >> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
> >> >> ---
> >> >> *v2*
> >> >> Move pm api from fsl platform to powerpc general framework.
> >> >
> >> > What is powerpc-specific about this?
> >>
> >> Generally I agree with you.  But I had the discussion about this topic
> >> a while ago with the PM maintainer.  He suggestion to go with the
> >> platform way.
> >>
> >> https://lkml.org/lkml/2013/8/16/505
> >
> > If what he meant was whether you could do what this patch does, then you
> > can answer him with, "No, because it got nacked as not being platform or
> > arch specific."  Oh, and you're still using .valid as the hook to set
> > the platform state, which is awful -- I think .begin is what you want to
> > use.
> 
> I'm not saying the current patch is good for upstream.  Actually I did
> say that the patch need to be updated for upstream purpose. 

I don't follow -- this thread is an upstream submission.

> > Now, a more legitimate objection to putting it in generic code might be
> > that "standby" and "mem" are loosely defined and the knowledge of how a
> > driver should react to each is platform specific -- but your patch
> > doesn't address that.  You still have the driver itself interpret what
> > "standby" and "mem" mean.
> >
> 
> Yup, we will address it in next batch.

Thanks.

-Scott

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

* Re: [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM
  2014-05-09 17:09         ` Scott Wood
@ 2014-05-10 12:35           ` Li Yang
  0 siblings, 0 replies; 8+ messages in thread
From: Li Yang @ 2014-05-10 12:35 UTC (permalink / raw)
  To: Scott Wood
  Cc: Zhao Chenhui, linux-pm@vger.kernel.org, Rafael J. Wysocki,
	Dongsheng Wang, 正雄 金, linuxppc-dev

On Sat, May 10, 2014 at 1:09 AM, Scott Wood <scottwood@freescale.com> wrote:
> On Fri, 2014-05-09 at 17:33 +0800, Li Yang wrote:
>> On Wed, Apr 30, 2014 at 6:47 AM, Scott Wood <scottwood@freescale.com> wrote:
>> > On Mon, 2014-04-28 at 13:53 +0800, Leo Li wrote:
>> >> On Sat, Apr 26, 2014 at 5:45 AM, Scott Wood <scottwood@freescale.com> wrote:
>> >> > On Thu, 2014-04-24 at 14:11 +0800, Dongsheng Wang wrote:
>> >> >> From: Wang Dongsheng <dongsheng.wang@freescale.com>
>> >> >>
>> >> >> Add set_pm_suspend_state & pm_suspend_state functions to set/get
>> >> >> suspend state. When system going to sleep or deep sleep, devices
>> >> >> can get the system suspend state(STANDBY/MEM) through pm_suspend_state
>> >> >> function and to handle different situations.
>> >> >>
>> >> >> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
>> >> >> ---
>> >> >> *v2*
>> >> >> Move pm api from fsl platform to powerpc general framework.
>> >> >
>> >> > What is powerpc-specific about this?
>> >>
>> >> Generally I agree with you.  But I had the discussion about this topic
>> >> a while ago with the PM maintainer.  He suggestion to go with the
>> >> platform way.
>> >>
>> >> https://lkml.org/lkml/2013/8/16/505
>> >
>> > If what he meant was whether you could do what this patch does, then you
>> > can answer him with, "No, because it got nacked as not being platform or
>> > arch specific."  Oh, and you're still using .valid as the hook to set
>> > the platform state, which is awful -- I think .begin is what you want to
>> > use.
>>
>> I'm not saying the current patch is good for upstream.  Actually I did
>> say that the patch need to be updated for upstream purpose.
>
> I don't follow -- this thread is an upstream submission.

Thought you were suggesting to change the generic PM interface for
this as discussed internally.  So I was just providing the information
about previous discussion.  Nothing more.

Regards,
Leo

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

end of thread, other threads:[~2014-05-10 12:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-24  6:11 [PATCH v2 1/2] powerpc/pm: add api to get suspend state which is STANDBY or MEM Dongsheng Wang
2014-04-25 21:45 ` Scott Wood
2014-04-28  5:53   ` Leo Li
2014-04-29 22:47     ` Scott Wood
2014-04-29 23:07       ` Rafael J. Wysocki
2014-05-09  9:33       ` Li Yang
2014-05-09 17:09         ` Scott Wood
2014-05-10 12:35           ` Li Yang

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