Skip to contentSkip to conversation

ARM: exynos: Save combiner registers on suspend

PATCH Superseded Jonathan Kliegman 3 participants 8 messages Jul 20, 2012 – Aug 3, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ARM: exynos: Save combiner registers on suspend

The interupt combiner registers need to be saved on suspend resume or its interrupts (trackpad and keyboard most noticeably) won't work after resume.

---
 arch/arm/mach-exynos/common.c |   74 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 67 insertions(+), 7 deletions(-)
arch/arm/mach-exynos/common.c +67 -7
index 4eb39cd..1b28aa6 100644
@@ -22,6 +22,7 @@
 #include <linux/export.h>
 #include <linux/irqdomain.h>
 #include <linux/of_address.h>
+#include <linux/cpu_pm.h>
 
 #include <asm/proc-fns.h>
 #include <asm/exception.h>
@@ -405,10 +406,14 @@ struct combiner_chip_data {
 	unsigned int irq_offset;
 	unsigned int irq_mask;
 	void __iomem *base;
+#ifdef CONFIG_PM
+	bool saved_on;
+#endif
 };
 
 static struct irq_domain *combiner_irq_domain;
 static struct combiner_chip_data combiner_data[MAX_COMBINER_NR];
+static unsigned int rt_max_combiner_nr;
 
 static inline void __iomem *combiner_base(struct irq_data *data)
 {
@@ -535,6 +540,55 @@ static int combiner_irq_domain_map(struct irq_domain *d, unsigned int irq,
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static void combiner_save(void)
+{
+	int i;
+
+	for (i = 0; i < rt_max_combiner_nr; i++) {
+		if (combiner_data[i].irq_mask &
+		    __raw_readl(combiner_data[i].base + COMBINER_ENABLE_SET)) {
+			combiner_data[i].saved_on = true;
+		} else {
+			combiner_data[i].saved_on = false;
+		}
+	}
+}
+
+static void combiner_restore(void)
+{
+	int i;
+
+	for (i = 0; i < rt_max_combiner_nr; i++) {
+		if (!combiner_data[i].saved_on)
+			continue;
+
+		__raw_writel(combiner_data[i].irq_mask,
+			     combiner_data[i].base + COMBINER_ENABLE_SET);
+	}
+}
+
+
+static int combiner_notifier(struct notifier_block *self, unsigned long cmd,
+			     void *v)
+{
+	switch (cmd) {
+	case CPU_PM_ENTER:
+		combiner_save();
+		break;
+	case CPU_PM_EXIT:
+		combiner_restore();
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block combiner_notifier_block = {
+	.notifier_call = combiner_notifier,
+};
+#endif
+
 static struct irq_domain_ops combiner_irq_domain_ops = {
 	.xlate	= combiner_irq_domain_xlate,
 	.map	= combiner_irq_domain_map,
@@ -544,20 +598,21 @@ static void __init combiner_init(void __iomem *combiner_base,
 				 struct device_node *np)
 {
 	int i, irq, irq_base;
-	unsigned int max_nr, nr_irq;
+	unsigned int nr_irq;
 
 	if (np) {
-		if (of_property_read_u32(np, "samsung,combiner-nr", &max_nr)) {
+		if (of_property_read_u32(np, "samsung,combiner-nr",
+					 &rt_max_combiner_nr)) {
 			pr_warning("%s: number of combiners not specified, "
 				"setting default as %d.\n",
 				__func__, EXYNOS4_MAX_COMBINER_NR);
-			max_nr = EXYNOS4_MAX_COMBINER_NR;
+			rt_max_combiner_nr = EXYNOS4_MAX_COMBINER_NR;
 		}
 	} else {
-		max_nr = soc_is_exynos5250() ? EXYNOS5_MAX_COMBINER_NR :
-						EXYNOS4_MAX_COMBINER_NR;
+		rt_max_combiner_nr = soc_is_exynos5250() ?
+			EXYNOS5_MAX_COMBINER_NR : EXYNOS4_MAX_COMBINER_NR;
 	}
-	nr_irq = max_nr * MAX_IRQ_IN_COMBINER;
+	nr_irq = rt_max_combiner_nr * MAX_IRQ_IN_COMBINER;
 
 	irq_base = irq_alloc_descs(COMBINER_IRQ(0, 0), 1, nr_irq, 0);
 	if (IS_ERR_VALUE(irq_base)) {
@@ -572,7 +627,7 @@ static void __init combiner_init(void __iomem *combiner_base,
 		return;
 	}
 
-	for (i = 0; i < max_nr; i++) {
+	for (i = 0; i < rt_max_combiner_nr; i++) {
 		combiner_init_one(i, combiner_base + (i >> 2) * 0x10);
 		irq = IRQ_SPI(i);
 #ifdef CONFIG_OF
@@ -581,6 +636,11 @@ static void __init combiner_init(void __iomem *combiner_base,
 #endif
 		combiner_cascade_irq(i, irq);
 	}
+
+#ifdef CONFIG_PM
+	/* Setup suspend/resume combiner saving */
+	cpu_pm_register_notifier(&combiner_notifier_block);
+#endif
 }
 
 #ifdef CONFIG_OF
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH 2/3 ARM: exynos: change local variable combiner_data to use unique name

combiner_data in combiner_base() has the same name as the global combiner_data array. Clean this up.

---
 arch/arm/mach-exynos/common.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-exynos/common.c +2 -2
index 1b28aa6..3627869 100644
@@ -417,10 +417,10 @@ static unsigned int rt_max_combiner_nr;
 
 static inline void __iomem *combiner_base(struct irq_data *data)
 {
-	struct combiner_chip_data *combiner_data =
+	struct combiner_chip_data *irq_combiner_data =
 		irq_data_get_irq_chip_data(data);
 
-	return combiner_data->base;
+	return irq_combiner_data->base;
 }
 
 static void combiner_mask_irq(struct irq_data *data)
Signature · 1 line
1.7.7.3
#2 lore raw

PATCH 3/3 ARM: exynos: Size combiner_data dynamically after dt parsing

In reply to Jonathan Kliegman

The number of combiner_data entries depends on the device tree parsing now. Allocate the array based on the results of the parsing or fall back on EXYNOS4 or EXYNOS5 defaults based on the SOC running.

---
 arch/arm/mach-exynos/common.c |   41 +++++++++++++++++++++++++----------------
 1 files changed, 25 insertions(+), 16 deletions(-)
arch/arm/mach-exynos/common.c +25 -16
index 3627869..5075e0c 100644
@@ -412,7 +412,7 @@ struct combiner_chip_data {
 };
 
 static struct irq_domain *combiner_irq_domain;
-static struct combiner_chip_data combiner_data[MAX_COMBINER_NR];
+static struct combiner_chip_data *combiner_data;
 static unsigned int rt_max_combiner_nr;
 
 static inline void __iomem *combiner_base(struct irq_data *data)
@@ -474,15 +474,6 @@ static struct irq_chip combiner_chip = {
 
 static void __init combiner_cascade_irq(unsigned int combiner_nr, unsigned int irq)
 {
-	unsigned int max_nr;
-
-	if (soc_is_exynos5250())
-		max_nr = EXYNOS5_MAX_COMBINER_NR;
-	else
-		max_nr = EXYNOS4_MAX_COMBINER_NR;
-
-	if (combiner_nr >= max_nr)
-		BUG();
 	if (irq_set_handler_data(irq, &combiner_data[combiner_nr]) != 0)
 		BUG();
 	irq_set_chained_handler(irq, combiner_handle_cascade_irq);
@@ -598,20 +589,37 @@ static void __init combiner_init(void __iomem *combiner_base,
 				 struct device_node *np)
 {
 	int i, irq, irq_base;
-	unsigned int nr_irq;
+	unsigned int nr_irq, soc_max_nr;
+
+	soc_max_nr = soc_is_exynos5250() ? EXYNOS5_MAX_COMBINER_NR :
+		EXYNOS4_MAX_COMBINER_NR;
 
 	if (np) {
 		if (of_property_read_u32(np, "samsung,combiner-nr",
 					 &rt_max_combiner_nr)) {
+			rt_max_combiner_nr = soc_max_nr;
 			pr_warning("%s: number of combiners not specified, "
-				"setting default as %d.\n",
-				__func__, EXYNOS4_MAX_COMBINER_NR);
-			rt_max_combiner_nr = EXYNOS4_MAX_COMBINER_NR;
+				   "setting default as %d.\n",
+				   __func__, rt_max_combiner_nr);
 		}
 	} else {
-		rt_max_combiner_nr = soc_is_exynos5250() ?
-			EXYNOS5_MAX_COMBINER_NR : EXYNOS4_MAX_COMBINER_NR;
+		rt_max_combiner_nr = soc_max_nr;
 	}
+	if (WARN_ON(rt_max_combiner_nr > soc_max_nr)) {
+		pr_warning("%s: more combiners specified (%d) than "
+			   "architecture (%d) supports.",
+			   __func__, rt_max_combiner_nr, soc_max_nr);
+		return;
+	}
+
+	combiner_data = kmalloc(sizeof(struct combiner_chip_data) *
+				rt_max_combiner_nr, GFP_KERNEL);
+	if (WARN_ON(!combiner_data)) {
+		pr_warning("%s: combiner_data memory allocation failed for %d "
+			   "entries", __func__, rt_max_combiner_nr);
+		return;
+	}
+
 	nr_irq = rt_max_combiner_nr * MAX_IRQ_IN_COMBINER;
 
 	irq_base = irq_alloc_descs(COMBINER_IRQ(0, 0), 1, nr_irq, 0);
@@ -624,6 +632,7 @@ static void __init combiner_init(void __iomem *combiner_base,
 				&combiner_irq_domain_ops, &combiner_data);
 	if (WARN_ON(!combiner_irq_domain)) {
 		pr_warning("%s: irq domain init failed\n", __func__);
+		kfree(combiner_data);
 		return;
 	}
 
Signature · 1 line
1.7.7.3
#3 lore raw
In reply to Jonathan Kliegman
Quoted 10 lines · Jonathan Kliegman

The interupt combiner registers need to be saved on suspend resume or its interrupts (trackpad and keyboard most noticeably) won't work after resume.

---
 arch/arm/mach-exynos/common.c |   74
+++++++++++++++++++++++++++++++++++++----
 1 files changed, 67 insertions(+), 7 deletions(-)

[...]

Quoted 1 line

+#ifdef CONFIG_PM

#ifdef CONFIG_CPU_PM?

arch/arm/mach-exynos/common.c static int combiner_irq_domain_map(struct irq_domain *d, unsigned int irq,

Quoted 7 lines
arch/arm/mach-exynos/common.c +7 -0
+static void combiner_save(void)
+{
+	int i;
+
+	for (i = 0; i < rt_max_combiner_nr; i++) {
+		if (combiner_data[i].irq_mask &
+		    __raw_readl(combiner_data[i].base +

COMBINER_ENABLE_SET))

Quoted 12 lines

{

arch/arm/mach-exynos/common.c +11 -0
+			combiner_data[i].saved_on = true;
+		} else {
+			combiner_data[i].saved_on = false;
+		}
+	}
+}
+
+static void combiner_restore(void)
+{
+	int i;
+

arch/arm/mach-exynos/common.c static int combiner_irq_domain_map(struct irq_domain *d, unsigned int irq, · line 571

Quoted 10 lines
arch/arm/mach-exynos/common.c +10 -0
+	for (i = 0; i < rt_max_combiner_nr; i++) {
+		if (!combiner_data[i].saved_on)
+			continue;
+
+		__raw_writel(combiner_data[i].irq_mask,
+			     combiner_data[i].base + COMBINER_ENABLE_SET);
+	}
+}
+
+

No need double empty lines :)

arch/arm/mach-exynos/common.c static int combiner_irq_domain_map(struct irq_domain *d, unsigned int irq, · line 576

Quoted 6 lines

+static int combiner_notifier(struct notifier_block *self, unsigned long cmd,

arch/arm/mach-exynos/common.c +4 -0
+			     void *v)
+{
+	switch (cmd) {
+	case CPU_PM_ENTER:

Should be CPU_CLUSTER_PM_ENTER?

arch/arm/mach-exynos/common.c static int combiner_irq_domain_map(struct irq_domain *d, unsigned int irq, · line 579

Quoted 3 lines
arch/arm/mach-exynos/common.c +3 -0
+		combiner_save();
+		break;
+	case CPU_PM_EXIT:

CPU_CLUSTER_PM_EXIT?

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

#4 lore raw

PATCH v2 1/3 ARM: exynos: Save combiner registers on suspend

The interupt combiner registers need to be saved on suspend and restored on resume or combiner-based intterupts won't work after resume.

---
 arch/arm/mach-exynos/common.c |   74 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 67 insertions(+), 7 deletions(-)
arch/arm/mach-exynos/common.c +67 -7
index 4eb39cd..af296e5 100644
@@ -22,6 +22,7 @@
 #include <linux/export.h>
 #include <linux/irqdomain.h>
 #include <linux/of_address.h>
+#include <linux/cpu_pm.h>
 
 #include <asm/proc-fns.h>
 #include <asm/exception.h>
@@ -405,10 +406,14 @@ struct combiner_chip_data {
 	unsigned int irq_offset;
 	unsigned int irq_mask;
 	void __iomem *base;
+#ifdef CONFIG_CPU_PM
+	bool saved_on;
+#endif
 };
 
 static struct irq_domain *combiner_irq_domain;
 static struct combiner_chip_data combiner_data[MAX_COMBINER_NR];
+static unsigned int rt_max_combiner_nr;
 
 static inline void __iomem *combiner_base(struct irq_data *data)
 {
@@ -535,6 +540,55 @@ static int combiner_irq_domain_map(struct irq_domain *d, unsigned int irq,
 	return 0;
 }
 
+#ifdef CONFIG_CPU_PM
+static void combiner_save(void)
+{
+	int i;
+
+	for (i = 0; i < rt_max_combiner_nr; i++) {
+		if (combiner_data[i].irq_mask &
+		    __raw_readl(combiner_data[i].base + COMBINER_ENABLE_SET)) {
+			combiner_data[i].saved_on = true;
+		} else {
+			combiner_data[i].saved_on = false;
+		}
+	}
+}
+
+static void combiner_restore(void)
+{
+	int i;
+
+	for (i = 0; i < rt_max_combiner_nr; i++) {
+		if (!combiner_data[i].saved_on)
+			continue;
+
+		__raw_writel(combiner_data[i].irq_mask,
+			     combiner_data[i].base + COMBINER_ENABLE_SET);
+	}
+}
+
+
+static int combiner_notifier(struct notifier_block *self, unsigned long cmd,
+			     void *v)
+{
+	switch (cmd) {
+	case CPU_CLUSTER_PM_ENTER:
+		combiner_save();
+		break;
+	case CPU_CLSUTER_PM_EXIT:
+		combiner_restore();
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block combiner_notifier_block = {
+	.notifier_call = combiner_notifier,
+};
+#endif
+
 static struct irq_domain_ops combiner_irq_domain_ops = {
 	.xlate	= combiner_irq_domain_xlate,
 	.map	= combiner_irq_domain_map,
@@ -544,20 +598,21 @@ static void __init combiner_init(void __iomem *combiner_base,
 				 struct device_node *np)
 {
 	int i, irq, irq_base;
-	unsigned int max_nr, nr_irq;
+	unsigned int nr_irq;
 
 	if (np) {
-		if (of_property_read_u32(np, "samsung,combiner-nr", &max_nr)) {
+		if (of_property_read_u32(np, "samsung,combiner-nr",
+					 &rt_max_combiner_nr)) {
 			pr_warning("%s: number of combiners not specified, "
 				"setting default as %d.\n",
 				__func__, EXYNOS4_MAX_COMBINER_NR);
-			max_nr = EXYNOS4_MAX_COMBINER_NR;
+			rt_max_combiner_nr = EXYNOS4_MAX_COMBINER_NR;
 		}
 	} else {
-		max_nr = soc_is_exynos5250() ? EXYNOS5_MAX_COMBINER_NR :
-						EXYNOS4_MAX_COMBINER_NR;
+		rt_max_combiner_nr = soc_is_exynos5250() ?
+			EXYNOS5_MAX_COMBINER_NR : EXYNOS4_MAX_COMBINER_NR;
 	}
-	nr_irq = max_nr * MAX_IRQ_IN_COMBINER;
+	nr_irq = rt_max_combiner_nr * MAX_IRQ_IN_COMBINER;
 
 	irq_base = irq_alloc_descs(COMBINER_IRQ(0, 0), 1, nr_irq, 0);
 	if (IS_ERR_VALUE(irq_base)) {
@@ -572,7 +627,7 @@ static void __init combiner_init(void __iomem *combiner_base,
 		return;
 	}
 
-	for (i = 0; i < max_nr; i++) {
+	for (i = 0; i < rt_max_combiner_nr; i++) {
 		combiner_init_one(i, combiner_base + (i >> 2) * 0x10);
 		irq = IRQ_SPI(i);
 #ifdef CONFIG_OF
@@ -581,6 +636,11 @@ static void __init combiner_init(void __iomem *combiner_base,
 #endif
 		combiner_cascade_irq(i, irq);
 	}
+
+#ifdef CONFIG_PM
+	/* Setup suspend/resume combiner saving */
+	cpu_pm_register_notifier(&combiner_notifier_block);
+#endif
 }
 
 #ifdef CONFIG_OF
Signature · 1 line
1.7.7.3
#5 lore raw

Hi Jonathan,

Quoted 2 lines · Jonathan Kliegman

The interupt combiner registers need to be saved on suspend and restored on resume or combiner-based intterupts won't work after resume.

intterupts -> interrupts

Quoted 63 lines
---
  arch/arm/mach-exynos/common.c |   74 +++++++++++++++++++++++++++++++++++++----
  1 files changed, 67 insertions(+), 7 deletions(-)
arch/arm/mach-exynos/common.c +32 -0
index 4eb39cd..af296e5 100644
@@ -22,6 +22,7 @@
  #include<linux/export.h>
  #include<linux/irqdomain.h>
  #include<linux/of_address.h>
+#include<linux/cpu_pm.h>
 
  #include<asm/proc-fns.h>
  #include<asm/exception.h>
@@ -405,10 +406,14 @@ struct combiner_chip_data {
  	unsigned int irq_offset;
  	unsigned int irq_mask;
  	void __iomem *base;
+#ifdef CONFIG_CPU_PM
+	bool saved_on;
+#endif
  };
 
  static struct irq_domain *combiner_irq_domain;
  static struct combiner_chip_data combiner_data[MAX_COMBINER_NR];
+static unsigned int rt_max_combiner_nr;
 
  static inline void __iomem *combiner_base(struct irq_data *data)
  {
@@ -535,6 +540,55 @@ static int combiner_irq_domain_map(struct irq_domain *d, unsigned int irq,
  	return 0;
  }
 
+#ifdef CONFIG_CPU_PM
+static void combiner_save(void)
+{
+	int i;
+
+	for (i = 0; i<  rt_max_combiner_nr; i++) {
+		if (combiner_data[i].irq_mask&
+		    __raw_readl(combiner_data[i].base + COMBINER_ENABLE_SET)) {
+			combiner_data[i].saved_on = true;
+		} else {
+			combiner_data[i].saved_on = false;
+		}
+	}
+}
+
+static void combiner_restore(void)
+{
+	int i;
+
+	for (i = 0; i<  rt_max_combiner_nr; i++) {
+		if (!combiner_data[i].saved_on)
+			continue;
+
+		__raw_writel(combiner_data[i].irq_mask,
+			     combiner_data[i].base + COMBINER_ENABLE_SET);
+	}
+}

arch/arm/mach-exynos/common.c static int combiner_irq_domain_map(struct irq_domain *d, unsigned int irq, · line 579

Quoted 10 lines
arch/arm/mach-exynos/common.c +10 -0
+
+
+static int combiner_notifier(struct notifier_block *self, unsigned long cmd,
+			     void *v)
+{
+	switch (cmd) {
+	case CPU_CLUSTER_PM_ENTER:
+		combiner_save();
+		break;
+	case CPU_CLSUTER_PM_EXIT:

Looks like this part of code wasn't compiled or some last minute changes introduced this typo ?

Quoted 53 lines
arch/arm/mach-exynos/common.c +20 -7
+		combiner_restore();
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block combiner_notifier_block = {
+	.notifier_call = combiner_notifier,
+};
+#endif
+
  static struct irq_domain_ops combiner_irq_domain_ops = {
  	.xlate	= combiner_irq_domain_xlate,
  	.map	= combiner_irq_domain_map,
@@ -544,20 +598,21 @@ static void __init combiner_init(void __iomem *combiner_base,
  				 struct device_node *np)
  {
  	int i, irq, irq_base;
-	unsigned int max_nr, nr_irq;
+	unsigned int nr_irq;
 
  	if (np) {
-		if (of_property_read_u32(np, "samsung,combiner-nr",&max_nr)) {
+		if (of_property_read_u32(np, "samsung,combiner-nr",
+					&rt_max_combiner_nr)) {
  			pr_warning("%s: number of combiners not specified, "
  				"setting default as %d.\n",
  				__func__, EXYNOS4_MAX_COMBINER_NR);
-			max_nr = EXYNOS4_MAX_COMBINER_NR;
+			rt_max_combiner_nr = EXYNOS4_MAX_COMBINER_NR;
  		}
  	} else {
-		max_nr = soc_is_exynos5250() ? EXYNOS5_MAX_COMBINER_NR :
-						EXYNOS4_MAX_COMBINER_NR;
+		rt_max_combiner_nr = soc_is_exynos5250() ?
+			EXYNOS5_MAX_COMBINER_NR : EXYNOS4_MAX_COMBINER_NR;
  	}
-	nr_irq = max_nr * MAX_IRQ_IN_COMBINER;
+	nr_irq = rt_max_combiner_nr * MAX_IRQ_IN_COMBINER;
 
  	irq_base = irq_alloc_descs(COMBINER_IRQ(0, 0), 1, nr_irq, 0);
  	if (IS_ERR_VALUE(irq_base)) {
@@ -572,7 +627,7 @@ static void __init combiner_init(void __iomem *combiner_base,
  		return;
  	}
 
-	for (i = 0; i<  max_nr; i++) {
+	for (i = 0; i<  rt_max_combiner_nr; i++) {
  		combiner_init_one(i, combiner_base + (i>>  2) * 0x10);
  		irq = IRQ_SPI(i);
  #ifdef CONFIG_OF

arch/arm/mach-exynos/common.c static void __init combiner_init(void __iomem *combiner_base, · line 640

Quoted 5 lines
arch/arm/mach-exynos/common.c +2 -0
@@ -581,6 +636,11 @@ static void __init combiner_init(void __iomem *combiner_base,
  #endif
  		combiner_cascade_irq(i, irq);
  	}
+
+#ifdef CONFIG_PM

Shouldn't this also be CONFIG_CPU_PM ? Declaration of combiner_notifier_block is compiled in only when CONFIG_CPU_PM is defined.

arch/arm/mach-exynos/common.c static void __init combiner_init(void __iomem *combiner_base, · line 646

Quoted 6 lines
arch/arm/mach-exynos/common.c +3 -0
+	/* Setup suspend/resume combiner saving */
+	cpu_pm_register_notifier(&combiner_notifier_block);
+#endif
  }
 
  #ifdef CONFIG_OF

Thanks,
Sylwester

#6 lore raw
Quoted 7 lines · Sylwester Nawrocki

Hi Jonathan,

Quoted 2 lines · Jonathan Kliegman

The interupt combiner registers need to be saved on suspend and restored on resume or combiner-based intterupts won't work after resume.

intterupts -> interrupts

Thanks, will fix.

Quoted 69 lines
Quoted 69 lines
---
  arch/arm/mach-exynos/common.c |   74 +++++++++++++++++++++++++++++++++++++----
  1 files changed, 67 insertions(+), 7 deletions(-)
arch/arm/mach-exynos/common.c +37 -0
index 4eb39cd..af296e5 100644
@@ -22,6 +22,7 @@
  #include<linux/export.h>
  #include<linux/irqdomain.h>
  #include<linux/of_address.h>
+#include<linux/cpu_pm.h>
 
  #include<asm/proc-fns.h>
  #include<asm/exception.h>
@@ -405,10 +406,14 @@ struct combiner_chip_data {
      unsigned int irq_offset;
      unsigned int irq_mask;
      void __iomem *base;
+#ifdef CONFIG_CPU_PM
+     bool saved_on;
+#endif
  };
 
  static struct irq_domain *combiner_irq_domain;
  static struct combiner_chip_data combiner_data[MAX_COMBINER_NR];
+static unsigned int rt_max_combiner_nr;
 
  static inline void __iomem *combiner_base(struct irq_data *data)
  {
@@ -535,6 +540,55 @@ static int combiner_irq_domain_map(struct irq_domain *d, unsigned int irq,
      return 0;
  }
 
+#ifdef CONFIG_CPU_PM
+static void combiner_save(void)
+{
+     int i;
+
+     for (i = 0; i<  rt_max_combiner_nr; i++) {
+             if (combiner_data[i].irq_mask&
+                 __raw_readl(combiner_data[i].base + COMBINER_ENABLE_SET)) {
+                     combiner_data[i].saved_on = true;
+             } else {
+                     combiner_data[i].saved_on = false;
+             }
+     }
+}
+
+static void combiner_restore(void)
+{
+     int i;
+
+     for (i = 0; i<  rt_max_combiner_nr; i++) {
+             if (!combiner_data[i].saved_on)
+                     continue;
+
+             __raw_writel(combiner_data[i].irq_mask,
+                          combiner_data[i].base + COMBINER_ENABLE_SET);
+     }
+}
+
+
+static int combiner_notifier(struct notifier_block *self, unsigned long cmd,
+                          void *v)
+{
Quoted 8 lines

arch/arm/mach-exynos/common.c static int combiner_irq_domain_map(struct irq_domain *d, unsigned int irq, · line 579

Quoted 5 lines
arch/arm/mach-exynos/common.c +5 -0
+     switch (cmd) {
+     case CPU_CLUSTER_PM_ENTER:
+             combiner_save();
+             break;
+     case CPU_CLSUTER_PM_EXIT:

Looks like this part of code wasn't compiled or some last minute changes introduced this typo ?

I had tested it (compiled and ran) but on a different branch. The typo must have been introduced when I manually rebased against head. Thanks for catching this.

Quoted 48 lines
Quoted 48 lines
arch/arm/mach-exynos/common.c +19 -6
+             combiner_restore();
+             break;
+     }
+
+     return NOTIFY_OK;
+}
+
+static struct notifier_block combiner_notifier_block = {
+     .notifier_call = combiner_notifier,
+};
+#endif
+
  static struct irq_domain_ops combiner_irq_domain_ops = {
      .xlate  = combiner_irq_domain_xlate,
      .map    = combiner_irq_domain_map,
@@ -544,20 +598,21 @@ static void __init combiner_init(void __iomem *combiner_base,
                               struct device_node *np)
  {
      int i, irq, irq_base;
-     unsigned int max_nr, nr_irq;
+     unsigned int nr_irq;
 
      if (np) {
-             if (of_property_read_u32(np, "samsung,combiner-nr",&max_nr)) {
+             if (of_property_read_u32(np, "samsung,combiner-nr",
+                                     &rt_max_combiner_nr)) {
                      pr_warning("%s: number of combiners not specified, "
                              "setting default as %d.\n",
                              __func__, EXYNOS4_MAX_COMBINER_NR);
-                     max_nr = EXYNOS4_MAX_COMBINER_NR;
+                     rt_max_combiner_nr = EXYNOS4_MAX_COMBINER_NR;
              }
      } else {
-             max_nr = soc_is_exynos5250() ? EXYNOS5_MAX_COMBINER_NR :
-                                             EXYNOS4_MAX_COMBINER_NR;
+             rt_max_combiner_nr = soc_is_exynos5250() ?
+                     EXYNOS5_MAX_COMBINER_NR : EXYNOS4_MAX_COMBINER_NR;
      }
-     nr_irq = max_nr * MAX_IRQ_IN_COMBINER;
+     nr_irq = rt_max_combiner_nr * MAX_IRQ_IN_COMBINER;
 
      irq_base = irq_alloc_descs(COMBINER_IRQ(0, 0), 1, nr_irq, 0);
      if (IS_ERR_VALUE(irq_base)) {
@@ -572,7 +627,7 @@ static void __init combiner_init(void __iomem *combiner_base,
              return;
      }
 
Quoted 14 lines

arch/arm/mach-exynos/common.c static void __init combiner_init(void __iomem *combiner_base, · line 640

Quoted 11 lines
arch/arm/mach-exynos/common.c +3 -1
-     for (i = 0; i<  max_nr; i++) {
+     for (i = 0; i<  rt_max_combiner_nr; i++) {
              combiner_init_one(i, combiner_base + (i>>  2) * 0x10);
              irq = IRQ_SPI(i);
  #ifdef CONFIG_OF
@@ -581,6 +636,11 @@ static void __init combiner_init(void __iomem *combiner_base,
  #endif
              combiner_cascade_irq(i, irq);
      }
+
+#ifdef CONFIG_PM

Shouldn't this also be CONFIG_CPU_PM ? Declaration of combiner_notifier_block is compiled in only when CONFIG_CPU_PM is defined.

Correct, in fixing the previous two I missed this one. Will fix and update patch.

Thanks for catching these.

Quoted 10 lines

arch/arm/mach-exynos/common.c static void __init combiner_init(void __iomem *combiner_base, · line 646

Quoted 7 lines
arch/arm/mach-exynos/common.c +3 -0
+     /* Setup suspend/resume combiner saving */
+     cpu_pm_register_notifier(&combiner_notifier_block);
+#endif
  }
 
  #ifdef CONFIG_OF

Thanks,
Sylwester

#7 lore raw

PATCH v3 1/3 ARM: exynos: Save combiner registers on suspend

The interrupt combiner registers need to be saved on suspend and restored on resume or combiner-based interrupts won't work after resume.

---
 arch/arm/mach-exynos/common.c |   74 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 67 insertions(+), 7 deletions(-)
arch/arm/mach-exynos/common.c +67 -7
index 4eb39cd..b51b9fb 100644
@@ -22,6 +22,7 @@
 #include <linux/export.h>
 #include <linux/irqdomain.h>
 #include <linux/of_address.h>
+#include <linux/cpu_pm.h>
 
 #include <asm/proc-fns.h>
 #include <asm/exception.h>
@@ -405,10 +406,14 @@ struct combiner_chip_data {
 	unsigned int irq_offset;
 	unsigned int irq_mask;
 	void __iomem *base;
+#ifdef CONFIG_CPU_PM
+	bool saved_on;
+#endif
 };
 
 static struct irq_domain *combiner_irq_domain;
 static struct combiner_chip_data combiner_data[MAX_COMBINER_NR];
+static unsigned int rt_max_combiner_nr;
 
 static inline void __iomem *combiner_base(struct irq_data *data)
 {
@@ -535,6 +540,55 @@ static int combiner_irq_domain_map(struct irq_domain *d, unsigned int irq,
 	return 0;
 }
 
+#ifdef CONFIG_CPU_PM
+static void combiner_save(void)
+{
+	int i;
+
+	for (i = 0; i < rt_max_combiner_nr; i++) {
+		if (combiner_data[i].irq_mask &
+		    __raw_readl(combiner_data[i].base + COMBINER_ENABLE_SET)) {
+			combiner_data[i].saved_on = true;
+		} else {
+			combiner_data[i].saved_on = false;
+		}
+	}
+}
+
+static void combiner_restore(void)
+{
+	int i;
+
+	for (i = 0; i < rt_max_combiner_nr; i++) {
+		if (!combiner_data[i].saved_on)
+			continue;
+
+		__raw_writel(combiner_data[i].irq_mask,
+			     combiner_data[i].base + COMBINER_ENABLE_SET);
+	}
+}
+
+
+static int combiner_notifier(struct notifier_block *self, unsigned long cmd,
+			     void *v)
+{
+	switch (cmd) {
+	case CPU_CLUSTER_PM_ENTER:
+		combiner_save();
+		break;
+	case CPU_CLUSTER_PM_EXIT:
+		combiner_restore();
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block combiner_notifier_block = {
+	.notifier_call = combiner_notifier,
+};
+#endif
+
 static struct irq_domain_ops combiner_irq_domain_ops = {
 	.xlate	= combiner_irq_domain_xlate,
 	.map	= combiner_irq_domain_map,
@@ -544,20 +598,21 @@ static void __init combiner_init(void __iomem *combiner_base,
 				 struct device_node *np)
 {
 	int i, irq, irq_base;
-	unsigned int max_nr, nr_irq;
+	unsigned int nr_irq;
 
 	if (np) {
-		if (of_property_read_u32(np, "samsung,combiner-nr", &max_nr)) {
+		if (of_property_read_u32(np, "samsung,combiner-nr",
+					 &rt_max_combiner_nr)) {
 			pr_warning("%s: number of combiners not specified, "
 				"setting default as %d.\n",
 				__func__, EXYNOS4_MAX_COMBINER_NR);
-			max_nr = EXYNOS4_MAX_COMBINER_NR;
+			rt_max_combiner_nr = EXYNOS4_MAX_COMBINER_NR;
 		}
 	} else {
-		max_nr = soc_is_exynos5250() ? EXYNOS5_MAX_COMBINER_NR :
-						EXYNOS4_MAX_COMBINER_NR;
+		rt_max_combiner_nr = soc_is_exynos5250() ?
+			EXYNOS5_MAX_COMBINER_NR : EXYNOS4_MAX_COMBINER_NR;
 	}
-	nr_irq = max_nr * MAX_IRQ_IN_COMBINER;
+	nr_irq = rt_max_combiner_nr * MAX_IRQ_IN_COMBINER;
 
 	irq_base = irq_alloc_descs(COMBINER_IRQ(0, 0), 1, nr_irq, 0);
 	if (IS_ERR_VALUE(irq_base)) {
@@ -572,7 +627,7 @@ static void __init combiner_init(void __iomem *combiner_base,
 		return;
 	}
 
-	for (i = 0; i < max_nr; i++) {
+	for (i = 0; i < rt_max_combiner_nr; i++) {
 		combiner_init_one(i, combiner_base + (i >> 2) * 0x10);
 		irq = IRQ_SPI(i);
 #ifdef CONFIG_OF
@@ -581,6 +636,11 @@ static void __init combiner_init(void __iomem *combiner_base,
 #endif
 		combiner_cascade_irq(i, irq);
 	}
+
+#ifdef CONFIG_CPU_PM
+	/* Setup suspend/resume combiner saving */
+	cpu_pm_register_notifier(&combiner_notifier_block);
+#endif
 }
 
 #ifdef CONFIG_OF
Signature · 1 line
1.7.7.3