diff mbox

[4/4] arm: psci: add cpuidle_ops support

Message ID 1436350417-6712-5-git-send-email-jszhang@marvell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jisheng Zhang July 8, 2015, 10:13 a.m. UTC
This patch implements cpuidle_ops using psci. After this patch, we can use
cpuidle-arm.c with psci backend for both arm and arm64.

Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
---
 arch/arm/kernel/psci.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Russell King - ARM Linux July 8, 2015, 10:34 a.m. UTC | #1
On Wed, Jul 08, 2015 at 06:13:37PM +0800, Jisheng Zhang wrote:
> This patch implements cpuidle_ops using psci. After this patch, we can use
> cpuidle-arm.c with psci backend for both arm and arm64.

I really don't see the point of most of the patches in this series.

To summarise, what you're doing is:

1. Renaming arch/arm/kernel/psci_smp.c to arch/arm/kernel/psci.c
2. Adding a #ifdef CONFIG_SMP around _all_ the code in psci.c
3. Adding cpuidle code with an #ifdef CONFIG_CPU_IDLE around all the
   CPU idle code.

So, we end up with a file which contains:

/*
 header
 */
#include statements

/*
 some commentry relevant to SMP code
 */
#ifdef CONFIG_CPU_IDLE
... cpu idle code ...
#endif
#ifdef CONFIG_SMP
... smp code ...
#endif

which (a) is a mess, and (b) is unnecessary.  The only relevant bits which
are shared are the #include statements.

Please try this alternative approach:

1. Leave psci_smp.c alone.
2. Add arch/arm/kernel/psci_cpuidle.c containing the #include statements
   you need, and the CPU idle code.

I think such an approach will reduce your patch series to two patches,
one moving the ARM64 code, and one adding the cpuidle code.
Jisheng Zhang July 8, 2015, 11:38 a.m. UTC | #2
Dear Russell,

On Wed, 8 Jul 2015 11:34:29 +0100
Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:

> On Wed, Jul 08, 2015 at 06:13:37PM +0800, Jisheng Zhang wrote:
> > This patch implements cpuidle_ops using psci. After this patch, we can use
> > cpuidle-arm.c with psci backend for both arm and arm64.
> 
> I really don't see the point of most of the patches in this series.
> 
> To summarise, what you're doing is:
> 
> 1. Renaming arch/arm/kernel/psci_smp.c to arch/arm/kernel/psci.c
> 2. Adding a #ifdef CONFIG_SMP around _all_ the code in psci.c
> 3. Adding cpuidle code with an #ifdef CONFIG_CPU_IDLE around all the
>    CPU idle code.
> 
> So, we end up with a file which contains:
> 
> /*
>  header
>  */
> #include statements
> 
> /*
>  some commentry relevant to SMP code
>  */
> #ifdef CONFIG_CPU_IDLE
> ... cpu idle code ...
> #endif
> #ifdef CONFIG_SMP
> ... smp code ...
> #endif
> 
> which (a) is a mess, and (b) is unnecessary.  The only relevant bits which
> are shared are the #include statements.
> 
> Please try this alternative approach:
> 
> 1. Leave psci_smp.c alone.
> 2. Add arch/arm/kernel/psci_cpuidle.c containing the #include statements
>    you need, and the CPU idle code.
> 
> I think such an approach will reduce your patch series to two patches,
> one moving the ARM64 code, and one adding the cpuidle code.
> 

Good idea! Will refine the patches as you suggested.

Thanks a lot for your review,
Jisheng
Jisheng Zhang July 8, 2015, 12:42 p.m. UTC | #3
Dear Russell,

On Wed, 8 Jul 2015 19:38:42 +0800
Jisheng Zhang <jszhang@marvell.com> wrote:

> Dear Russell,
> 
> On Wed, 8 Jul 2015 11:34:29 +0100
> Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
> 
> > On Wed, Jul 08, 2015 at 06:13:37PM +0800, Jisheng Zhang wrote:
> > > This patch implements cpuidle_ops using psci. After this patch, we can use
> > > cpuidle-arm.c with psci backend for both arm and arm64.
> > 
> > I really don't see the point of most of the patches in this series.
> > 
> > To summarise, what you're doing is:
> > 
> > 1. Renaming arch/arm/kernel/psci_smp.c to arch/arm/kernel/psci.c
> > 2. Adding a #ifdef CONFIG_SMP around _all_ the code in psci.c
> > 3. Adding cpuidle code with an #ifdef CONFIG_CPU_IDLE around all the
> >    CPU idle code.
> > 
> > So, we end up with a file which contains:
> > 
> > /*
> >  header
> >  */
> > #include statements
> > 
> > /*
> >  some commentry relevant to SMP code
> >  */
> > #ifdef CONFIG_CPU_IDLE
> > ... cpu idle code ...
> > #endif
> > #ifdef CONFIG_SMP
> > ... smp code ...
> > #endif
> > 
> > which (a) is a mess, and (b) is unnecessary.  The only relevant bits which
> > are shared are the #include statements.
> > 
> > Please try this alternative approach:
> > 
> > 1. Leave psci_smp.c alone.
> > 2. Add arch/arm/kernel/psci_cpuidle.c containing the #include statements
> >    you need, and the CPU idle code.

After more consideration, I have one concern.

Currently, cpuidle_ops is defined as the following,

> struct cpuidle_ops {
>        int (*suspend)(int cpu, unsigned long arg);

the cpu may not be necessary, because to-be-suspended cpu is always the calling
cpu itself.

>	int (*init)(struct device_node *, int cpu);

the device_node here may not be necessary either, because we can get the node
via. of_get_cpu_node.

So if we refine cpuidle_ops defintion, the code would be as simple as

static struct cpuidle_ops psci_cpuidle_ops __initdata = {
        .suspend = cpu_psci_cpu_suspend,
        .init = cpu_psci_cpu_init_idle,
};
CPUIDLE_METHOD_OF_DECLARE(psci_idle, "psci", &psci_cpuidle_ops);

I'm not sure a new psci_cpuidle.c only with above 5 lines is acceptable or not.

Thanks,
Jisheng




> > 
> > I think such an approach will reduce your patch series to two patches,
> > one moving the ARM64 code, and one adding the cpuidle code.
> > 
> 
> Good idea! Will refine the patches as you suggested.
>
diff mbox

Patch

diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
index 7f6ff02..c5b94f5 100644
--- a/arch/arm/kernel/psci.c
+++ b/arch/arm/kernel/psci.c
@@ -13,6 +13,7 @@ 
  * Author: Will Deacon <will.deacon@arm.com>
  */
 
+#include <linux/cpuidle.h>
 #include <linux/init.h>
 #include <linux/smp.h>
 #include <linux/of.h>
@@ -21,6 +22,7 @@ 
 
 #include <uapi/linux/psci.h>
 
+#include <asm/cpuidle.h>
 #include <asm/psci.h>
 #include <asm/smp_plat.h>
 
@@ -47,6 +49,24 @@ 
  *
  */
 
+#ifdef CONFIG_CPU_IDLE
+static int psci_cpuidle_suspend(int cpu, unsigned long arg)
+{
+	return cpu_psci_cpu_suspend(arg);
+}
+
+static int psci_cpuidle_init(struct device_node *node, int cpu)
+{
+	return cpu_psci_cpu_init_idle(cpu);
+}
+
+static struct cpuidle_ops psci_cpuidle_ops __initdata = {
+	.suspend = psci_cpuidle_suspend,
+	.init = psci_cpuidle_init,
+};
+CPUIDLE_METHOD_OF_DECLARE(psci_idle, "psci", &psci_cpuidle_ops);
+#endif
+
 #ifdef CONFIG_SMP
 extern void secondary_startup(void);