All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] irqchip: gicv3: add initial CPU PM support
@ 2014-08-26 15:03 Sudeep Holla
  2014-08-26 15:03 ` [PATCH 1/2] GICv3: refactor gic_enable_redist to support both enabling and disabling Sudeep Holla
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Sudeep Holla @ 2014-08-26 15:03 UTC (permalink / raw)
  To: linux-arm-kernel

From: Sudeep Holla <sudeep.holla@arm.com>

This patch series adds initial support for CPU power management with GICv3.

When a CPU enters a low power state, the GICv3 system registers are lost.
They need to be saved and restored if required. Currently as the GICv3
system configuration register are not modified at runtime, the patch
just re-initialise to initial values.

This series only supports CPU power states. However, for system power
states, we may need to save and restore states of distributor and
re-distributors additionally.

Currently this is tested only on models, testing on real hardware is
much appreciated.

Regards,
Sudeep

Sudeep Holla (2):
  GICv3: refactor gic_enable_redist to support both enabling and
    disabling
  GICv3: implement CPU PM notifier

 drivers/irqchip/irq-gic-v3.c | 87 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 66 insertions(+), 21 deletions(-)

-- 
1.8.3.2

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

* [PATCH 1/2] GICv3: refactor gic_enable_redist to support both enabling and disabling
  2014-08-26 15:03 [PATCH 0/2] irqchip: gicv3: add initial CPU PM support Sudeep Holla
@ 2014-08-26 15:03 ` Sudeep Holla
  2014-08-26 15:03 ` [PATCH 2/2] GICv3: implement CPU PM notifier Sudeep Holla
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Sudeep Holla @ 2014-08-26 15:03 UTC (permalink / raw)
  To: linux-arm-kernel

From: Sudeep Holla <sudeep.holla@arm.com>

Currently gic_enable_redist configures the redistributors to never
assert WakeRequest signal. However when powering down the processors
with wake-up enabled(i.e suspend), we need to configure it to assert
that signal.

This patch extends gic_enable_redist so that the redistributor can be
configure to assert WakeRequest and hold interrupts as pending. This is
useful in suspending the processors.

This patch also adds check to make sure GICR_WAKER is accessible when
configuring it.

Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
[maz: removed reference to GICD_CTLR.DS and added read-back of
      GICR_WAKER to check that it is not RAZ/WI]
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 drivers/irqchip/irq-gic-v3.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 57eaa5a0b1e3..37062ba6704b 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -155,7 +155,7 @@ static void gic_enable_sre(void)
 		pr_err("GIC: unable to set SRE (disabled at EL2), panic ahead\n");
 }
 
-static void gic_enable_redist(void)
+static void gic_enable_redist(bool enable)
 {
 	void __iomem *rbase;
 	u32 count = 1000000;	/* 1s! */
@@ -163,20 +163,30 @@ static void gic_enable_redist(void)
 
 	rbase = gic_data_rdist_rd_base();
 
-	/* Wake up this CPU redistributor */
 	val = readl_relaxed(rbase + GICR_WAKER);
-	val &= ~GICR_WAKER_ProcessorSleep;
+	if (enable)
+		/* Wake up this CPU redistributor */
+		val &= ~GICR_WAKER_ProcessorSleep;
+	else
+		val |= GICR_WAKER_ProcessorSleep;
 	writel_relaxed(val, rbase + GICR_WAKER);
 
-	while (readl_relaxed(rbase + GICR_WAKER) & GICR_WAKER_ChildrenAsleep) {
-		count--;
-		if (!count) {
-			pr_err_ratelimited("redist didn't wake up...\n");
-			return;
-		}
+	if (!enable) {		/* Check that GICR_WAKER is writeable */
+		val = readl_relaxed(rbase + GICR_WAKER);
+		if (!(val & GICR_WAKER_ProcessorSleep))
+			return;	/* No PM support in this redistributor */
+	}
+
+	while (count--) {
+		val = readl_relaxed(rbase + GICR_WAKER);
+		if (enable ^ (val & GICR_WAKER_ChildrenAsleep))
+			break;
 		cpu_relax();
 		udelay(1);
 	};
+	if (!count)
+		pr_err_ratelimited("redistributor failed to %s...\n",
+				   enable ? "wakeup" : "sleep");
 }
 
 /*
@@ -381,7 +391,7 @@ static void gic_cpu_init(void)
 	if (gic_populate_rdist())
 		return;
 
-	gic_enable_redist();
+	gic_enable_redist(true);
 
 	rbase = gic_data_rdist_sgi_base();
 
-- 
1.8.3.2

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

* [PATCH 2/2] GICv3: implement CPU PM notifier
  2014-08-26 15:03 [PATCH 0/2] irqchip: gicv3: add initial CPU PM support Sudeep Holla
  2014-08-26 15:03 ` [PATCH 1/2] GICv3: refactor gic_enable_redist to support both enabling and disabling Sudeep Holla
@ 2014-08-26 15:03 ` Sudeep Holla
  2014-09-14  5:27 ` [PATCH 0/2] irqchip: gicv3: add initial CPU PM support Jason Cooper
  2014-09-14  9:01 ` Jason Cooper
  3 siblings, 0 replies; 6+ messages in thread
From: Sudeep Holla @ 2014-08-26 15:03 UTC (permalink / raw)
  To: linux-arm-kernel

From: Sudeep Holla <sudeep.holla@arm.com>

When a CPU enters a low power state, the contents of the GICv3/4 system
registers are lost. They need to be saved and restored if required.

For now, since most of the GICv3 register are set some initial values and
not modified at runtime, it is better to re-initialise rather than saving
and restoring them. It may need to be saved and restored in future if
required.

This patch adds a notifier to disable the redistributor(if allowed) and
Group1 interrupts when powering down the processor and to re-initialise
the system registers on wakeup.

Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 drivers/irqchip/irq-gic-v3.c | 57 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 46 insertions(+), 11 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index 37062ba6704b..4afbbc835939 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -16,6 +16,7 @@
  */
 
 #include <linux/cpu.h>
+#include <linux/cpu_pm.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/of.h>
@@ -383,6 +384,21 @@ static int gic_populate_rdist(void)
 	return -ENODEV;
 }
 
+static void gic_cpu_sys_reg_init(void)
+{
+	/* Enable system registers */
+	gic_enable_sre();
+
+	/* Set priority mask register */
+	gic_write_pmr(DEFAULT_PMR_VALUE);
+
+	/* EOI deactivates interrupt too (mode 0) */
+	gic_write_ctlr(ICC_CTLR_EL1_EOImode_drop_dir);
+
+	/* ... and let's hit the road... */
+	gic_write_grpen1(1);
+}
+
 static void gic_cpu_init(void)
 {
 	void __iomem *rbase;
@@ -397,17 +413,8 @@ static void gic_cpu_init(void)
 
 	gic_cpu_config(rbase, gic_redist_wait_for_rwp);
 
-	/* Enable system registers */
-	gic_enable_sre();
-
-	/* Set priority mask register */
-	gic_write_pmr(DEFAULT_PMR_VALUE);
-
-	/* EOI deactivates interrupt too (mode 0) */
-	gic_write_ctlr(ICC_CTLR_EL1_EOImode_drop_dir);
-
-	/* ... and let's hit the road... */
-	gic_write_grpen1(1);
+	/* initialise system registers */
+	gic_cpu_sys_reg_init();
 }
 
 #ifdef CONFIG_SMP
@@ -543,6 +550,33 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
 #define gic_smp_init()		do { } while(0)
 #endif
 
+#ifdef CONFIG_CPU_PM
+static int gic_cpu_pm_notifier(struct notifier_block *self,
+			       unsigned long cmd, void *v)
+{
+	if (cmd == CPU_PM_EXIT) {
+		gic_enable_redist(true);
+		gic_cpu_sys_reg_init();
+	} else if (cmd == CPU_PM_ENTER) {
+		gic_write_grpen1(0);
+		gic_enable_redist(false);
+	}
+	return NOTIFY_OK;
+}
+
+static struct notifier_block gic_cpu_pm_notifier_block = {
+	.notifier_call = gic_cpu_pm_notifier,
+};
+
+static void gic_cpu_pm_init(void)
+{
+	cpu_pm_register_notifier(&gic_cpu_pm_notifier_block);
+}
+
+#else
+static inline void gic_cpu_pm_init(void) { }
+#endif /* CONFIG_CPU_PM */
+
 static struct irq_chip gic_chip = {
 	.name			= "GICv3",
 	.irq_mask		= gic_mask_irq,
@@ -682,6 +716,7 @@ static int __init gic_of_init(struct device_node *node, struct device_node *pare
 	gic_smp_init();
 	gic_dist_init();
 	gic_cpu_init();
+	gic_cpu_pm_init();
 
 	return 0;
 
-- 
1.8.3.2

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

* [PATCH 0/2] irqchip: gicv3: add initial CPU PM support
  2014-08-26 15:03 [PATCH 0/2] irqchip: gicv3: add initial CPU PM support Sudeep Holla
  2014-08-26 15:03 ` [PATCH 1/2] GICv3: refactor gic_enable_redist to support both enabling and disabling Sudeep Holla
  2014-08-26 15:03 ` [PATCH 2/2] GICv3: implement CPU PM notifier Sudeep Holla
@ 2014-09-14  5:27 ` Jason Cooper
  2014-09-14  8:40   ` Marc Zyngier
  2014-09-14  9:01 ` Jason Cooper
  3 siblings, 1 reply; 6+ messages in thread
From: Jason Cooper @ 2014-09-14  5:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Aug 26, 2014 at 04:03:33PM +0100, Sudeep Holla wrote:
> Currently this is tested only on models, testing on real hardware is
> much appreciated.

If I could get a Tested-by or an Acked-by from Marc, I can apply this.

thx,

Jason.

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

* [PATCH 0/2] irqchip: gicv3: add initial CPU PM support
  2014-09-14  5:27 ` [PATCH 0/2] irqchip: gicv3: add initial CPU PM support Jason Cooper
@ 2014-09-14  8:40   ` Marc Zyngier
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2014-09-14  8:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Jason,

On 2014-09-14 06:27, Jason Cooper wrote:
> On Tue, Aug 26, 2014 at 04:03:33PM +0100, Sudeep Holla wrote:
>> Currently this is tested only on models, testing on real hardware is
>> much appreciated.
>
> If I could get a Tested-by or an Acked-by from Marc, I can apply 
> this.

I've reviewd these patches a while ago, so:

Acked-by: Marc Zyngier <marc.zyngier@arm.com>

Thanks for picking that up.

         M.
-- 
Fast, cheap, reliable. Pick two.

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

* [PATCH 0/2] irqchip: gicv3: add initial CPU PM support
  2014-08-26 15:03 [PATCH 0/2] irqchip: gicv3: add initial CPU PM support Sudeep Holla
                   ` (2 preceding siblings ...)
  2014-09-14  5:27 ` [PATCH 0/2] irqchip: gicv3: add initial CPU PM support Jason Cooper
@ 2014-09-14  9:01 ` Jason Cooper
  3 siblings, 0 replies; 6+ messages in thread
From: Jason Cooper @ 2014-09-14  9:01 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Aug 26, 2014 at 04:03:33PM +0100, Sudeep Holla wrote:
> From: Sudeep Holla <sudeep.holla@arm.com>
> 
> This patch series adds initial support for CPU power management with GICv3.
> 
> When a CPU enters a low power state, the GICv3 system registers are lost.
> They need to be saved and restored if required. Currently as the GICv3
> system configuration register are not modified at runtime, the patch
> just re-initialise to initial values.
> 
> This series only supports CPU power states. However, for system power
> states, we may need to save and restore states of distributor and
> re-distributors additionally.
> 
> Currently this is tested only on models, testing on real hardware is
> much appreciated.
> 
> Regards,
> Sudeep
> 
> Sudeep Holla (2):
>   GICv3: refactor gic_enable_redist to support both enabling and
>     disabling
>   GICv3: implement CPU PM notifier
> 
>  drivers/irqchip/irq-gic-v3.c | 87 +++++++++++++++++++++++++++++++++-----------
>  1 file changed, 66 insertions(+), 21 deletions(-)

Series applied to irqchip/gic with Marc's Ack.

thx,

Jason.

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

end of thread, other threads:[~2014-09-14  9:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-26 15:03 [PATCH 0/2] irqchip: gicv3: add initial CPU PM support Sudeep Holla
2014-08-26 15:03 ` [PATCH 1/2] GICv3: refactor gic_enable_redist to support both enabling and disabling Sudeep Holla
2014-08-26 15:03 ` [PATCH 2/2] GICv3: implement CPU PM notifier Sudeep Holla
2014-09-14  5:27 ` [PATCH 0/2] irqchip: gicv3: add initial CPU PM support Jason Cooper
2014-09-14  8:40   ` Marc Zyngier
2014-09-14  9:01 ` Jason Cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.