Skip to contentSkip to conversation

gic: preserve gic V2 bypass bits in cpu ctrl register

PATCH Superseded Feng Kan 2 participants 2 messages May 8, 2014

Subsystems (2)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Feng Kan

author
#0 lore raw

PATCH v5 1/1 gic: preserve gic V2 bypass bits in cpu ctrl register

This change is made to preserve the GIC v2 bypass bits in the GIC_CPU_CTRL register (also known as the GICC_CTLR register in spec). This code will preserve all bits configured by the bootload regarding v2 bypass group bits. In the X-Gene platform, the bypass functionality is not used and bypass bits should not be changed by the kernel gic code as it could lead to incorrect behavior.

---
V5: Use macro to replace read modify write of cpu_ctrl register.
V4: Change to use bypass mask, change ot user more suitable variable name.

 drivers/irqchip/irq-gic.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
drivers/irqchip/irq-gic.c +13 -3
index 4300b66..42e9bf4 100644
@@ -97,6 +97,13 @@ struct irq_chip gic_arch_extn = {
 #define MAX_GIC_NR	1
 #endif
 
+#define set_cpuctrl(base, val)					\
+	do {							\
+		u32 bypass;					\
+		bypass = readl(base + GIC_CPU_CTRL) & 0x1e0;	\
+		writel_relaxed(bypass | val, base + GIC_CPU_CTRL);\
+	} while (0)
+
 static struct gic_chip_data gic_data[MAX_GIC_NR] __read_mostly;
 
 #ifdef CONFIG_GIC_NON_BANKED
@@ -449,13 +456,15 @@ static void gic_cpu_init(struct gic_chip_data *gic)
 		writel_relaxed(0xa0a0a0a0, dist_base + GIC_DIST_PRI + i * 4 / 4);
 
 	writel_relaxed(0xf0, base + GIC_CPU_PRIMASK);
-	writel_relaxed(1, base + GIC_CPU_CTRL);
+
+	set_cpuctrl(base, 1);
 }
 
 void gic_cpu_if_down(void)
 {
 	void __iomem *cpu_base = gic_data_cpu_base(&gic_data[0]);
-	writel_relaxed(0, cpu_base + GIC_CPU_CTRL);
+
+	set_cpuctrl(cpu_base, 0);
 }
 
 #ifdef CONFIG_CPU_PM
@@ -590,7 +599,8 @@ static void gic_cpu_restore(unsigned int gic_nr)
 		writel_relaxed(0xa0a0a0a0, dist_base + GIC_DIST_PRI + i * 4);
 
 	writel_relaxed(0xf0, cpu_base + GIC_CPU_PRIMASK);
-	writel_relaxed(1, cpu_base + GIC_CPU_CTRL);
+	
+	set_cpuctrl(cpu_base, 1);
 }
 
 static int gic_notifier(struct notifier_block *self, unsigned long cmd,	void *v)
Signature · 1 line
1.7.6.1
#1 lore raw
Quoted 21 lines · Feng Kan

This change is made to preserve the GIC v2 bypass bits in the GIC_CPU_CTRL register (also known as the GICC_CTLR register in spec). This code will preserve all bits configured by the bootload regarding v2 bypass group bits. In the X-Gene platform, the bypass functionality is not used and bypass bits should not be changed by the kernel gic code as it could lead to incorrect behavior.

---
V5: Use macro to replace read modify write of cpu_ctrl register.
V4: Change to use bypass mask, change ot user more suitable variable name.

 drivers/irqchip/irq-gic.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
drivers/irqchip/irq-gic.c +0 -0
index 4300b66..42e9bf4 100644

drivers/irqchip/irq-gic.c struct irq_chip gic_arch_extn = { · line 106

Quoted 10 lines
drivers/irqchip/irq-gic.c +7 -0
@@ -97,6 +97,13 @@ struct irq_chip gic_arch_extn = {
 #define MAX_GIC_NR	1
 #endif
 
+#define set_cpuctrl(base, val)					\
+	do {							\
+		u32 bypass;					\
+		bypass = readl(base + GIC_CPU_CTRL) & 0x1e0;	\
+		writel_relaxed(bypass | val, base + GIC_CPU_CTRL);\
+	} while (0)
+

Please use a function. A macro doesn't buy us anything here, and lacks type safety.

Your previous patch was nicer in that respect. You just had to move the enable code to a gic_cpu_if_up() function, and you were done...

Quoted 22 lines
drivers/irqchip/irq-gic.c +4 -2
 static struct gic_chip_data gic_data[MAX_GIC_NR] __read_mostly;
 
 #ifdef CONFIG_GIC_NON_BANKED
@@ -449,13 +456,15 @@ static void gic_cpu_init(struct gic_chip_data *gic)
 		writel_relaxed(0xa0a0a0a0, dist_base + GIC_DIST_PRI + i * 4 / 4);
 
 	writel_relaxed(0xf0, base + GIC_CPU_PRIMASK);
-	writel_relaxed(1, base + GIC_CPU_CTRL);
+
+	set_cpuctrl(base, 1);
 }
 
 void gic_cpu_if_down(void)
 {
 	void __iomem *cpu_base = gic_data_cpu_base(&gic_data[0]);
-	writel_relaxed(0, cpu_base + GIC_CPU_CTRL);
+
+	set_cpuctrl(cpu_base, 0);
 }
 
 #ifdef CONFIG_CPU_PM

drivers/irqchip/irq-gic.c static void gic_cpu_restore(unsigned int gic_nr) · line 606

Quoted 9 lines
drivers/irqchip/irq-gic.c +2 -1
@@ -590,7 +599,8 @@ static void gic_cpu_restore(unsigned int gic_nr)
 		writel_relaxed(0xa0a0a0a0, dist_base + GIC_DIST_PRI + i * 4);
 
 	writel_relaxed(0xf0, cpu_base + GIC_CPU_PRIMASK);
-	writel_relaxed(1, cpu_base + GIC_CPU_CTRL);
+	
+	set_cpuctrl(cpu_base, 1);
 }
 
 static int gic_notifier(struct notifier_block *self, unsigned long cmd,	void *v)
	M.
Signature · 1 line
Jazz is not dead. It just smells funny.