All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] GICv3: add 32bit compatibility
@ 2014-12-11 14:23 Jean-Philippe Brucker
  2014-12-11 14:23 ` [PATCH 1/4] arm64: GICv3: refactor the AArch64 specific parts Jean-Philippe Brucker
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Jean-Philippe Brucker @ 2014-12-11 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

This series adds 32bit compatibility to Marc's GICv3 driver. Only SGIs,
PPIs and SPIs support is present. No ITS nor virtualisation.

It is based on 3.18.

Jean-Philippe Brucker (4):
  arm64: GICv3: refactor the AArch64 specific parts
  arm64: GICv3: change unsigned types for AArch32 compatibility
  arm64: GICv3: Specialize readq and writeq accesses
  ARM: add 32bit support to GICv3

 arch/arm/include/asm/arch_gicv3.h   | 182 ++++++++++++++++++++++++++++++++++++
 arch/arm64/include/asm/arch_gicv3.h | 141 ++++++++++++++++++++++++++++
 drivers/irqchip/irq-gic-v3.c        |  69 ++++----------
 include/linux/irqchip/arm-gic-v3.h  |  95 +++----------------
 4 files changed, 356 insertions(+), 131 deletions(-)
 create mode 100644 arch/arm/include/asm/arch_gicv3.h
 create mode 100644 arch/arm64/include/asm/arch_gicv3.h

-- 
2.2.0.rc1

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

* [PATCH 1/4] arm64: GICv3: refactor the AArch64 specific parts
  2014-12-11 14:23 [PATCH 0/4] GICv3: add 32bit compatibility Jean-Philippe Brucker
@ 2014-12-11 14:23 ` Jean-Philippe Brucker
  2014-12-11 14:23 ` [PATCH 2/4] arm64: GICv3: change unsigned types for AArch32 compatibility Jean-Philippe Brucker
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Jean-Philippe Brucker @ 2014-12-11 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

This patch moves the GICv3 system register access helpers to
arch/arm64/. Their 32bit counterparts will need to use mrc/mcr accesses
instead of mrs_s/msr_s.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
 arch/arm64/include/asm/arch_gicv3.h | 133 ++++++++++++++++++++++++++++++++++++
 drivers/irqchip/irq-gic-v3.c        |  38 +----------
 include/linux/irqchip/arm-gic-v3.h  |  77 ++-------------------
 3 files changed, 142 insertions(+), 106 deletions(-)
 create mode 100644 arch/arm64/include/asm/arch_gicv3.h

diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h
new file mode 100644
index 0000000..28482d0
--- /dev/null
+++ b/arch/arm64/include/asm/arch_gicv3.h
@@ -0,0 +1,133 @@
+/*
+ * arch/arm64/include/asm/arch_gicv3.h
+ *
+ * Copyright (C) 2014 ARM Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __ASM_ARCH_GICV3_H
+#define __ASM_ARCH_GICV3_H
+
+#include <asm/sysreg.h>
+
+#define ICC_EOIR1_EL1			sys_reg(3, 0, 12, 12, 1)
+#define ICC_IAR1_EL1			sys_reg(3, 0, 12, 12, 0)
+#define ICC_SGI1R_EL1			sys_reg(3, 0, 12, 11, 5)
+#define ICC_PMR_EL1			sys_reg(3, 0, 4, 6, 0)
+#define ICC_CTLR_EL1			sys_reg(3, 0, 12, 12, 4)
+#define ICC_SRE_EL1			sys_reg(3, 0, 12, 12, 5)
+#define ICC_GRPEN1_EL1			sys_reg(3, 0, 12, 12, 7)
+
+#define ICC_SRE_EL2			sys_reg(3, 4, 12, 9, 5)
+
+/*
+ * System register definitions
+ */
+#define ICH_VSEIR_EL2			sys_reg(3, 4, 12, 9, 4)
+#define ICH_HCR_EL2			sys_reg(3, 4, 12, 11, 0)
+#define ICH_VTR_EL2			sys_reg(3, 4, 12, 11, 1)
+#define ICH_MISR_EL2			sys_reg(3, 4, 12, 11, 2)
+#define ICH_EISR_EL2			sys_reg(3, 4, 12, 11, 3)
+#define ICH_ELSR_EL2			sys_reg(3, 4, 12, 11, 5)
+#define ICH_VMCR_EL2			sys_reg(3, 4, 12, 11, 7)
+
+#define __LR0_EL2(x)			sys_reg(3, 4, 12, 12, x)
+#define __LR8_EL2(x)			sys_reg(3, 4, 12, 13, x)
+
+#define ICH_LR0_EL2			__LR0_EL2(0)
+#define ICH_LR1_EL2			__LR0_EL2(1)
+#define ICH_LR2_EL2			__LR0_EL2(2)
+#define ICH_LR3_EL2			__LR0_EL2(3)
+#define ICH_LR4_EL2			__LR0_EL2(4)
+#define ICH_LR5_EL2			__LR0_EL2(5)
+#define ICH_LR6_EL2			__LR0_EL2(6)
+#define ICH_LR7_EL2			__LR0_EL2(7)
+#define ICH_LR8_EL2			__LR8_EL2(0)
+#define ICH_LR9_EL2			__LR8_EL2(1)
+#define ICH_LR10_EL2			__LR8_EL2(2)
+#define ICH_LR11_EL2			__LR8_EL2(3)
+#define ICH_LR12_EL2			__LR8_EL2(4)
+#define ICH_LR13_EL2			__LR8_EL2(5)
+#define ICH_LR14_EL2			__LR8_EL2(6)
+#define ICH_LR15_EL2			__LR8_EL2(7)
+
+#define __AP0Rx_EL2(x)			sys_reg(3, 4, 12, 8, x)
+#define ICH_AP0R0_EL2			__AP0Rx_EL2(0)
+#define ICH_AP0R1_EL2			__AP0Rx_EL2(1)
+#define ICH_AP0R2_EL2			__AP0Rx_EL2(2)
+#define ICH_AP0R3_EL2			__AP0Rx_EL2(3)
+
+#define __AP1Rx_EL2(x)			sys_reg(3, 4, 12, 9, x)
+#define ICH_AP1R0_EL2			__AP1Rx_EL2(0)
+#define ICH_AP1R1_EL2			__AP1Rx_EL2(1)
+#define ICH_AP1R2_EL2			__AP1Rx_EL2(2)
+#define ICH_AP1R3_EL2			__AP1Rx_EL2(3)
+
+#ifndef __ASSEMBLY__
+
+#include <linux/stringify.h>
+
+/* Low level accessors */
+
+static inline void gic_write_eoir(u64 irq)
+{
+	asm volatile("msr_s " __stringify(ICC_EOIR1_EL1) ", %0" : : "r" (irq));
+	isb();
+}
+
+static inline u64 __maybe_unused gic_read_iar(void)
+{
+	u64 irqstat;
+
+	asm volatile("mrs_s %0, " __stringify(ICC_IAR1_EL1) : "=r" (irqstat));
+	return irqstat;
+}
+
+static inline void __maybe_unused gic_write_pmr(u64 val)
+{
+	asm volatile("msr_s " __stringify(ICC_PMR_EL1) ", %0" : : "r" (val));
+}
+
+static inline void __maybe_unused gic_write_ctlr(u64 val)
+{
+	asm volatile("msr_s " __stringify(ICC_CTLR_EL1) ", %0" : : "r" (val));
+	isb();
+}
+
+static inline void __maybe_unused gic_write_grpen1(u64 val)
+{
+	asm volatile("msr_s " __stringify(ICC_GRPEN1_EL1) ", %0" : : "r" (val));
+	isb();
+}
+
+static inline void __maybe_unused gic_write_sgi1r(u64 val)
+{
+	asm volatile("msr_s " __stringify(ICC_SGI1R_EL1) ", %0" : : "r" (val));
+}
+
+static inline u64 __maybe_unused gic_read_sre(void)
+{
+	u64 val;
+
+	asm volatile("mrs_s %0, " __stringify(ICC_SRE_EL1) : "=r" (val));
+	return val;
+}
+
+static inline void __maybe_unused gic_write_sre(u64 val)
+{
+	asm volatile("msr_s " __stringify(ICC_SRE_EL1) ", %0" : : "r" (val));
+	isb();
+}
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ASM_ARCH_GICV3_H */
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index aa17ae8..b85d6b6 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -104,45 +104,13 @@ static void gic_redist_wait_for_rwp(void)
 	gic_do_wait_for_rwp(gic_data_rdist_rd_base());
 }
 
-/* Low level accessors */
-static u64 __maybe_unused gic_read_iar(void)
-{
-	u64 irqstat;
-
-	asm volatile("mrs_s %0, " __stringify(ICC_IAR1_EL1) : "=r" (irqstat));
-	return irqstat;
-}
-
-static void __maybe_unused gic_write_pmr(u64 val)
-{
-	asm volatile("msr_s " __stringify(ICC_PMR_EL1) ", %0" : : "r" (val));
-}
-
-static void __maybe_unused gic_write_ctlr(u64 val)
-{
-	asm volatile("msr_s " __stringify(ICC_CTLR_EL1) ", %0" : : "r" (val));
-	isb();
-}
-
-static void __maybe_unused gic_write_grpen1(u64 val)
-{
-	asm volatile("msr_s " __stringify(ICC_GRPEN1_EL1) ", %0" : : "r" (val));
-	isb();
-}
-
-static void __maybe_unused gic_write_sgi1r(u64 val)
-{
-	asm volatile("msr_s " __stringify(ICC_SGI1R_EL1) ", %0" : : "r" (val));
-}
-
 static void gic_enable_sre(void)
 {
 	u64 val;
 
-	asm volatile("mrs_s %0, " __stringify(ICC_SRE_EL1) : "=r" (val));
+	val = gic_read_sre();
 	val |= ICC_SRE_EL1_SRE;
-	asm volatile("msr_s " __stringify(ICC_SRE_EL1) ", %0" : : "r" (val));
-	isb();
+	gic_write_sre(val);
 
 	/*
 	 * Need to check that the SRE bit has actually been set. If
@@ -151,7 +119,7 @@ static void gic_enable_sre(void)
 	 *
 	 * Kindly inform the luser.
 	 */
-	asm volatile("mrs_s %0, " __stringify(ICC_SRE_EL1) : "=r" (val));
+	val = gic_read_sre();
 	if (!(val & ICC_SRE_EL1_SRE))
 		pr_err("GIC: unable to set SRE (disabled at EL2), panic ahead\n");
 }
diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h
index 03a4ea3..e70b56f 100644
--- a/include/linux/irqchip/arm-gic-v3.h
+++ b/include/linux/irqchip/arm-gic-v3.h
@@ -18,8 +18,6 @@
 #ifndef __LINUX_IRQCHIP_ARM_GIC_V3_H
 #define __LINUX_IRQCHIP_ARM_GIC_V3_H
 
-#include <asm/sysreg.h>
-
 /*
  * Distributor registers. We assume we're running non-secure, with ARE
  * being set. Secure-only and non-ARE registers are not described.
@@ -101,6 +99,11 @@
 #define ICC_CTLR_EL1_EOImode_drop	(1U << 1)
 #define ICC_SRE_EL1_SRE			(1U << 0)
 
+#define ICC_SRE_EL2_SRE			(1 << 0)
+#define ICC_SRE_EL2_ENABLE		(1 << 3)
+
+#define ICC_IAR1_EL1_SPURIOUS		0x3ff
+
 /*
  * Hypervisor interface registers (SRE only)
  */
@@ -127,74 +130,6 @@
 #define ICH_VMCR_PMR_SHIFT		24
 #define ICH_VMCR_PMR_MASK		(0xffUL << ICH_VMCR_PMR_SHIFT)
 
-#define ICC_EOIR1_EL1			sys_reg(3, 0, 12, 12, 1)
-#define ICC_IAR1_EL1			sys_reg(3, 0, 12, 12, 0)
-#define ICC_SGI1R_EL1			sys_reg(3, 0, 12, 11, 5)
-#define ICC_PMR_EL1			sys_reg(3, 0, 4, 6, 0)
-#define ICC_CTLR_EL1			sys_reg(3, 0, 12, 12, 4)
-#define ICC_SRE_EL1			sys_reg(3, 0, 12, 12, 5)
-#define ICC_GRPEN1_EL1			sys_reg(3, 0, 12, 12, 7)
-
-#define ICC_IAR1_EL1_SPURIOUS		0x3ff
-
-#define ICC_SRE_EL2			sys_reg(3, 4, 12, 9, 5)
-
-#define ICC_SRE_EL2_SRE			(1 << 0)
-#define ICC_SRE_EL2_ENABLE		(1 << 3)
-
-/*
- * System register definitions
- */
-#define ICH_VSEIR_EL2			sys_reg(3, 4, 12, 9, 4)
-#define ICH_HCR_EL2			sys_reg(3, 4, 12, 11, 0)
-#define ICH_VTR_EL2			sys_reg(3, 4, 12, 11, 1)
-#define ICH_MISR_EL2			sys_reg(3, 4, 12, 11, 2)
-#define ICH_EISR_EL2			sys_reg(3, 4, 12, 11, 3)
-#define ICH_ELSR_EL2			sys_reg(3, 4, 12, 11, 5)
-#define ICH_VMCR_EL2			sys_reg(3, 4, 12, 11, 7)
-
-#define __LR0_EL2(x)			sys_reg(3, 4, 12, 12, x)
-#define __LR8_EL2(x)			sys_reg(3, 4, 12, 13, x)
-
-#define ICH_LR0_EL2			__LR0_EL2(0)
-#define ICH_LR1_EL2			__LR0_EL2(1)
-#define ICH_LR2_EL2			__LR0_EL2(2)
-#define ICH_LR3_EL2			__LR0_EL2(3)
-#define ICH_LR4_EL2			__LR0_EL2(4)
-#define ICH_LR5_EL2			__LR0_EL2(5)
-#define ICH_LR6_EL2			__LR0_EL2(6)
-#define ICH_LR7_EL2			__LR0_EL2(7)
-#define ICH_LR8_EL2			__LR8_EL2(0)
-#define ICH_LR9_EL2			__LR8_EL2(1)
-#define ICH_LR10_EL2			__LR8_EL2(2)
-#define ICH_LR11_EL2			__LR8_EL2(3)
-#define ICH_LR12_EL2			__LR8_EL2(4)
-#define ICH_LR13_EL2			__LR8_EL2(5)
-#define ICH_LR14_EL2			__LR8_EL2(6)
-#define ICH_LR15_EL2			__LR8_EL2(7)
-
-#define __AP0Rx_EL2(x)			sys_reg(3, 4, 12, 8, x)
-#define ICH_AP0R0_EL2			__AP0Rx_EL2(0)
-#define ICH_AP0R1_EL2			__AP0Rx_EL2(1)
-#define ICH_AP0R2_EL2			__AP0Rx_EL2(2)
-#define ICH_AP0R3_EL2			__AP0Rx_EL2(3)
-
-#define __AP1Rx_EL2(x)			sys_reg(3, 4, 12, 9, x)
-#define ICH_AP1R0_EL2			__AP1Rx_EL2(0)
-#define ICH_AP1R1_EL2			__AP1Rx_EL2(1)
-#define ICH_AP1R2_EL2			__AP1Rx_EL2(2)
-#define ICH_AP1R3_EL2			__AP1Rx_EL2(3)
-
-#ifndef __ASSEMBLY__
-
-#include <linux/stringify.h>
-
-static inline void gic_write_eoir(u64 irq)
-{
-	asm volatile("msr_s " __stringify(ICC_EOIR1_EL1) ", %0" : : "r" (irq));
-	isb();
-}
-
-#endif
+#include <asm/arch_gicv3.h>
 
 #endif
-- 
2.2.0.rc1

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

* [PATCH 2/4] arm64: GICv3: change unsigned types for AArch32 compatibility
  2014-12-11 14:23 [PATCH 0/4] GICv3: add 32bit compatibility Jean-Philippe Brucker
  2014-12-11 14:23 ` [PATCH 1/4] arm64: GICv3: refactor the AArch64 specific parts Jean-Philippe Brucker
@ 2014-12-11 14:23 ` Jean-Philippe Brucker
  2014-12-18 13:27   ` Vladimir Murzin
  2014-12-11 14:23 ` [PATCH 3/4] arm64: GICv3: Specialize readq and writeq accesses Jean-Philippe Brucker
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Jean-Philippe Brucker @ 2014-12-11 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

This patch does a few simple compatibility-related changes:
- change the system register access prototypes to their actual size,
- homogenise mpidr accesses with unsigned long,
- force the 64bit register values to unsigned long long.

Note: the list registers are 64bit on GICv3, but the AArch32 vGIC driver
will need to split their values into two 32bit registers: LRn and LRCn.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
 arch/arm64/include/asm/arch_gicv3.h | 31 ++++++++++++++++++-------------
 drivers/irqchip/irq-gic-v3.c        | 25 ++++++++++++-------------
 include/linux/irqchip/arm-gic-v3.h  | 18 +++++++++---------
 3 files changed, 39 insertions(+), 35 deletions(-)

diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h
index 28482d0..a0ea9de 100644
--- a/arch/arm64/include/asm/arch_gicv3.h
+++ b/arch/arm64/include/asm/arch_gicv3.h
@@ -77,15 +77,20 @@
 
 #include <linux/stringify.h>
 
-/* Low level accessors */
+/*
+ * Low-level accessors
+ *
+ * These system registers are 32 bits, but we make sure that the compiler
+ * sets the GP register's most significant bits to 0 with an explicit cast.
+ */
 
-static inline void gic_write_eoir(u64 irq)
+static inline void gic_write_eoir(u32 irq)
 {
-	asm volatile("msr_s " __stringify(ICC_EOIR1_EL1) ", %0" : : "r" (irq));
+	asm volatile("msr_s " __stringify(ICC_EOIR1_EL1) ", %0" : : "r" ((u64)irq));
 	isb();
 }
 
-static inline u64 __maybe_unused gic_read_iar(void)
+static inline u32 __maybe_unused gic_read_iar(void)
 {
 	u64 irqstat;
 
@@ -93,20 +98,20 @@ static inline u64 __maybe_unused gic_read_iar(void)
 	return irqstat;
 }
 
-static inline void __maybe_unused gic_write_pmr(u64 val)
+static inline void __maybe_unused gic_write_pmr(u32 val)
 {
-	asm volatile("msr_s " __stringify(ICC_PMR_EL1) ", %0" : : "r" (val));
+	asm volatile("msr_s " __stringify(ICC_PMR_EL1) ", %0" : : "r" ((u64)val));
 }
 
-static inline void __maybe_unused gic_write_ctlr(u64 val)
+static inline void __maybe_unused gic_write_ctlr(u32 val)
 {
-	asm volatile("msr_s " __stringify(ICC_CTLR_EL1) ", %0" : : "r" (val));
+	asm volatile("msr_s " __stringify(ICC_CTLR_EL1) ", %0" : : "r" ((u64)val));
 	isb();
 }
 
-static inline void __maybe_unused gic_write_grpen1(u64 val)
+static inline void __maybe_unused gic_write_grpen1(u32 val)
 {
-	asm volatile("msr_s " __stringify(ICC_GRPEN1_EL1) ", %0" : : "r" (val));
+	asm volatile("msr_s " __stringify(ICC_GRPEN1_EL1) ", %0" : : "r" ((u64)val));
 	isb();
 }
 
@@ -115,7 +120,7 @@ static inline void __maybe_unused gic_write_sgi1r(u64 val)
 	asm volatile("msr_s " __stringify(ICC_SGI1R_EL1) ", %0" : : "r" (val));
 }
 
-static inline u64 __maybe_unused gic_read_sre(void)
+static inline u32 __maybe_unused gic_read_sre(void)
 {
 	u64 val;
 
@@ -123,9 +128,9 @@ static inline u64 __maybe_unused gic_read_sre(void)
 	return val;
 }
 
-static inline void __maybe_unused gic_write_sre(u64 val)
+static inline void __maybe_unused gic_write_sre(u32 val)
 {
-	asm volatile("msr_s " __stringify(ICC_SRE_EL1) ", %0" : : "r" (val));
+	asm volatile("msr_s " __stringify(ICC_SRE_EL1) ", %0" : : "r" ((u64)val));
 	isb();
 }
 
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index b85d6b6..e2cd5ac 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -220,11 +220,11 @@ static int gic_set_type(struct irq_data *d, unsigned int type)
 	return 0;
 }
 
-static u64 gic_mpidr_to_affinity(u64 mpidr)
+static u64 gic_mpidr_to_affinity(unsigned long mpidr)
 {
 	u64 aff;
 
-	aff = (MPIDR_AFFINITY_LEVEL(mpidr, 3) << 32 |
+	aff = ((u64)MPIDR_AFFINITY_LEVEL(mpidr, 3) << 32 |
 	       MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 |
 	       MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8  |
 	       MPIDR_AFFINITY_LEVEL(mpidr, 0));
@@ -234,7 +234,7 @@ static u64 gic_mpidr_to_affinity(u64 mpidr)
 
 static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)
 {
-	u64 irqnr;
+	u32 irqnr;
 
 	do {
 		irqnr = gic_read_iar();
@@ -285,9 +285,9 @@ static void __init gic_dist_init(void)
 		writeq_relaxed(affinity, base + GICD_IROUTER + i * 8);
 }
 
-static int gic_populate_rdist(void)
+static int __init gic_populate_rdist(void)
 {
-	u64 mpidr = cpu_logical_map(smp_processor_id());
+	unsigned long mpidr = cpu_logical_map(smp_processor_id());
 	u64 typer;
 	u32 aff;
 	int i;
@@ -316,9 +316,8 @@ static int gic_populate_rdist(void)
 			typer = readq_relaxed(ptr + GICR_TYPER);
 			if ((typer >> 32) == aff) {
 				gic_data_rdist_rd_base() = ptr;
-				pr_info("CPU%d: found redistributor %llx @%p\n",
-					smp_processor_id(),
-					(unsigned long long)mpidr, ptr);
+				pr_info("CPU%d: found redistributor %lx @%p\n",
+					smp_processor_id(), mpidr, ptr);
 				return 0;
 			}
 
@@ -333,8 +332,8 @@ static int gic_populate_rdist(void)
 	}
 
 	/* We couldn't even deal with ourselves... */
-	WARN(true, "CPU%d: mpidr %llx has no re-distributor!\n",
-	     smp_processor_id(), (unsigned long long)mpidr);
+	WARN(true, "CPU%d: mpidr %lx has no re-distributor!\n",
+	     smp_processor_id(), mpidr);
 	return -ENODEV;
 }
 
@@ -403,10 +402,10 @@ static struct notifier_block gic_cpu_notifier = {
 };
 
 static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask,
-				   u64 cluster_id)
+				   unsigned long cluster_id)
 {
 	int cpu = *base_cpu;
-	u64 mpidr = cpu_logical_map(cpu);
+	unsigned long mpidr = cpu_logical_map(cpu);
 	u16 tlist = 0;
 
 	while (cpu < nr_cpu_ids) {
@@ -463,7 +462,7 @@ static void gic_raise_softirq(const struct cpumask *mask, unsigned int irq)
 	smp_wmb();
 
 	for_each_cpu_mask(cpu, *mask) {
-		u64 cluster_id = cpu_logical_map(cpu) & ~0xffUL;
+		unsigned long cluster_id = cpu_logical_map(cpu) & ~0xffUL;
 		u16 tlist;
 
 		tlist = gic_compute_target_list(&cpu, mask, cluster_id);
diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h
index e70b56f..95171d1 100644
--- a/include/linux/irqchip/arm-gic-v3.h
+++ b/include/linux/irqchip/arm-gic-v3.h
@@ -39,7 +39,7 @@
 #define GICD_ICACTIVER			0x0380
 #define GICD_IPRIORITYR			0x0400
 #define GICD_ICFGR			0x0C00
-#define GICD_IROUTER			0x6000
+#define GICD_IROUTER			0x6000		/* 64bit */
 #define GICD_PIDR2			0xFFE8
 
 #define GICD_CTLR_RWP			(1U << 31)
@@ -61,7 +61,7 @@
 #define GICR_IIDR			0x0004
 #define GICR_TYPER			0x0008
 #define GICR_STATUSR			GICD_STATUSR
-#define GICR_WAKER			0x0014
+#define GICR_WAKER			0x0014		/* 32bit */
 #define GICR_SETLPIR			0x0040
 #define GICR_CLRLPIR			0x0048
 #define GICR_SEIR			GICD_SEIR
@@ -69,7 +69,7 @@
 #define GICR_PENDBASER			0x0078
 #define GICR_INVLPIR			0x00A0
 #define GICR_INVALLR			0x00B0
-#define GICR_SYNCR			0x00C0
+#define GICR_SYNCR			0x00C0		/* 32bit */
 #define GICR_MOVLPIR			0x0100
 #define GICR_MOVALLR			0x0110
 #define GICR_PIDR2			GICD_PIDR2
@@ -107,13 +107,13 @@
 /*
  * Hypervisor interface registers (SRE only)
  */
-#define ICH_LR_VIRTUAL_ID_MASK		((1UL << 32) - 1)
+#define ICH_LR_VIRTUAL_ID_MASK		((1ULL << 32) - 1)
 
-#define ICH_LR_EOI			(1UL << 41)
-#define ICH_LR_GROUP			(1UL << 60)
-#define ICH_LR_STATE			(3UL << 62)
-#define ICH_LR_PENDING_BIT		(1UL << 62)
-#define ICH_LR_ACTIVE_BIT		(1UL << 63)
+#define ICH_LR_EOI			(1ULL << 41)
+#define ICH_LR_GROUP			(1ULL << 60)
+#define ICH_LR_STATE			(3ULL << 62)
+#define ICH_LR_PENDING_BIT		(1ULL << 62)
+#define ICH_LR_ACTIVE_BIT		(1ULL << 63)
 
 #define ICH_MISR_EOI			(1 << 0)
 #define ICH_MISR_U			(1 << 1)
-- 
2.2.0.rc1

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

* [PATCH 3/4] arm64: GICv3: Specialize readq and writeq accesses
  2014-12-11 14:23 [PATCH 0/4] GICv3: add 32bit compatibility Jean-Philippe Brucker
  2014-12-11 14:23 ` [PATCH 1/4] arm64: GICv3: refactor the AArch64 specific parts Jean-Philippe Brucker
  2014-12-11 14:23 ` [PATCH 2/4] arm64: GICv3: change unsigned types for AArch32 compatibility Jean-Philippe Brucker
@ 2014-12-11 14:23 ` Jean-Philippe Brucker
  2014-12-11 14:23 ` [PATCH 4/4] ARM: add 32bit support to GICv3 Jean-Philippe Brucker
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Jean-Philippe Brucker @ 2014-12-11 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

On 32bit platforms, we cannot assure that an I/O ldrd or strd will be
done atomically. Besides, an hypervisor would be unable to emulate such
accesses.
In order to allow the AArch32 version of the driver to split them into
two 32bit accesses while keeping the requirement for atomic writes, this
patch specializes the IROUTER and TYPER accesses.
Since the latter is an ID register, it won't need to be read atomically,
but we still avoid future confusion by using gic_read_typer instead of a
generic gic_readq.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
 arch/arm64/include/asm/arch_gicv3.h | 3 +++
 drivers/irqchip/irq-gic-v3.c        | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h
index a0ea9de..622f08a 100644
--- a/arch/arm64/include/asm/arch_gicv3.h
+++ b/arch/arm64/include/asm/arch_gicv3.h
@@ -134,5 +134,8 @@ static inline void __maybe_unused gic_write_sre(u32 val)
 	isb();
 }
 
+#define gic_read_typer(c)		readq_relaxed(c)
+#define gic_write_irouter(v, c)		writeq_relaxed(v, c)
+
 #endif /* __ASSEMBLY__ */
 #endif /* __ASM_ARCH_GICV3_H */
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index e2cd5ac..d8f30ee 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -282,7 +282,7 @@ static void __init gic_dist_init(void)
 	 */
 	affinity = gic_mpidr_to_affinity(cpu_logical_map(smp_processor_id()));
 	for (i = 32; i < gic_data.irq_nr; i++)
-		writeq_relaxed(affinity, base + GICD_IROUTER + i * 8);
+		gic_write_irouter(affinity, base + GICD_IROUTER + i * 8);
 }
 
 static int __init gic_populate_rdist(void)
@@ -313,7 +313,7 @@ static int __init gic_populate_rdist(void)
 		}
 
 		do {
-			typer = readq_relaxed(ptr + GICR_TYPER);
+			typer = gic_read_typer(ptr + GICR_TYPER);
 			if ((typer >> 32) == aff) {
 				gic_data_rdist_rd_base() = ptr;
 				pr_info("CPU%d: found redistributor %lx @%p\n",
@@ -498,7 +498,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
 	reg = gic_dist_base(d) + GICD_IROUTER + (gic_irq(d) * 8);
 	val = gic_mpidr_to_affinity(cpu_logical_map(cpu));
 
-	writeq_relaxed(val, reg);
+	gic_write_irouter(val, reg);
 
 	/*
 	 * If the interrupt was enabled, enabled it again. Otherwise,
-- 
2.2.0.rc1

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

* [PATCH 4/4] ARM: add 32bit support to GICv3
  2014-12-11 14:23 [PATCH 0/4] GICv3: add 32bit compatibility Jean-Philippe Brucker
                   ` (2 preceding siblings ...)
  2014-12-11 14:23 ` [PATCH 3/4] arm64: GICv3: Specialize readq and writeq accesses Jean-Philippe Brucker
@ 2014-12-11 14:23 ` Jean-Philippe Brucker
  2014-12-11 14:32   ` Russell King - ARM Linux
  2014-12-11 17:38 ` [PATCH 0/4] GICv3: add 32bit compatibility Marc Zyngier
  2014-12-12 16:39 ` Andre Przywara
  5 siblings, 1 reply; 14+ messages in thread
From: Jean-Philippe Brucker @ 2014-12-11 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

Implement the system and memory-mapped register accesses in
asm/arch_gicv3.h for 32bit architectures.

This patch is a straightforward translation of the arm64 header. 64bit
accesses are done in two times and don't need atomicity: TYPER is
read-only, and the upper-word of IROUTER is always zero on 32bit
architectures.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
 arch/arm/include/asm/arch_gicv3.h | 182 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 182 insertions(+)
 create mode 100644 arch/arm/include/asm/arch_gicv3.h

diff --git a/arch/arm/include/asm/arch_gicv3.h b/arch/arm/include/asm/arch_gicv3.h
new file mode 100644
index 0000000..de285aa
--- /dev/null
+++ b/arch/arm/include/asm/arch_gicv3.h
@@ -0,0 +1,182 @@
+/*
+ * arch/arm/include/asm/arch_gicv3.h
+ *
+ * Copyright (C) 2014 ARM Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __ASM_ARCH_GICV3_H
+#define __ASM_ARCH_GICV3_H
+
+#ifndef __ASSEMBLY__
+
+#include <asm/io.h>
+
+#define __ACCESS_CP15(CRn, Op1, CRm, Op2)	p15, Op1, %0, CRn, CRm, Op2
+#define __ACCESS_CP15_64(Op1, CRm)		p15, Op1, %Q0, %R0, CRm
+
+#define ICC_EOIR1			__ACCESS_CP15(c12, 0, c12, 1)
+#define ICC_IAR1			__ACCESS_CP15(c12, 0, c12, 0)
+#define ICC_SGI1R			__ACCESS_CP15_64(0, c12)
+#define ICC_PMR				__ACCESS_CP15(c4, 0, c6, 0)
+#define ICC_CTLR			__ACCESS_CP15(c12, 0, c12, 4)
+#define ICC_SRE				__ACCESS_CP15(c12, 0, c12, 5)
+#define ICC_IGRPEN1			__ACCESS_CP15(c12, 0, c12, 7)
+
+#define ICC_HSRE			__ACCESS_CP15(c12, 4, c9, 5)
+
+#define ICH_VSEIR			__ACCESS_CP15(c12, 4, c9, 4)
+#define ICH_HCR				__ACCESS_CP15(c12, 4, c11, 0)
+#define ICH_VTR				__ACCESS_CP15(c12, 4, c11, 1)
+#define ICH_MISR			__ACCESS_CP15(c12, 4, c11, 2)
+#define ICH_EISR			__ACCESS_CP15(c12, 4, c11, 3)
+#define ICH_ELSR			__ACCESS_CP15(c12, 4, c11, 5)
+#define ICH_VMCR			__ACCESS_CP15(c12, 4, c11, 7)
+
+#define __LR0(x)			__ACCESS_CP15(c12, 4, c12, x)
+#define __LR8(x)			__ACCESS_CP15(c12, 4, c13, x)
+
+#define ICH_LR0				__LR0(0)
+#define ICH_LR1				__LR0(1)
+#define ICH_LR2				__LR0(2)
+#define ICH_LR3				__LR0(3)
+#define ICH_LR4				__LR0(4)
+#define ICH_LR5				__LR0(5)
+#define ICH_LR6				__LR0(6)
+#define ICH_LR7				__LR0(7)
+#define ICH_LR8				__LR8(0)
+#define ICH_LR9				__LR8(1)
+#define ICH_LR10			__LR8(2)
+#define ICH_LR11			__LR8(3)
+#define ICH_LR12			__LR8(4)
+#define ICH_LR13			__LR8(5)
+#define ICH_LR14			__LR8(6)
+#define ICH_LR15			__LR8(7)
+
+/* LR top half */
+#define __LRC0(x)			__ACCESS_CP15(c12, 4, c14, x)
+#define __LRC8(x)			__ACCESS_CP15(c12, 4, c15, x)
+
+#define ICH_LRC0			__LRC0(0)
+#define ICH_LRC1			__LRC0(1)
+#define ICH_LRC2			__LRC0(2)
+#define ICH_LRC3			__LRC0(3)
+#define ICH_LRC4			__LRC0(4)
+#define ICH_LRC5			__LRC0(5)
+#define ICH_LRC6			__LRC0(6)
+#define ICH_LRC7			__LRC0(7)
+#define ICH_LRC8			__LRC8(0)
+#define ICH_LRC9			__LRC8(1)
+#define ICH_LRC10			__LRC8(2)
+#define ICH_LRC11			__LRC8(3)
+#define ICH_LRC12			__LRC8(4)
+#define ICH_LRC13			__LRC8(5)
+#define ICH_LRC14			__LRC8(6)
+#define ICH_LRC15			__LRC8(7)
+
+#define __AP0Rx(x)			__ACCESS_CP15(c12, 4, c8, x)
+#define ICH_AP0R0			__AP0Rx(0)
+#define ICH_AP0R1			__AP0Rx(1)
+#define ICH_AP0R2			__AP0Rx(2)
+#define ICH_AP0R3			__AP0Rx(3)
+
+#define __AP1Rx(x)			__ACCESS_CP15(c12, 4, c9, x)
+#define ICH_AP1R0			__AP1Rx(0)
+#define ICH_AP1R1			__AP1Rx(1)
+#define ICH_AP1R2			__AP1Rx(2)
+#define ICH_AP1R3			__AP1Rx(3)
+
+/* Low-level accessors */
+
+static inline void __maybe_unused gic_write_eoir(u32 irq)
+{
+	asm volatile("mcr " __stringify(ICC_EOIR1) : : "r" (irq));
+	isb();
+}
+
+static inline u32 __maybe_unused gic_read_iar(void)
+{
+	u32 irqstat;
+
+	asm volatile("mrc " __stringify(ICC_IAR1) : "=r" (irqstat));
+	return irqstat;
+}
+
+static inline void __maybe_unused gic_write_pmr(u32 val)
+{
+	asm volatile("mcr " __stringify(ICC_PMR) : : "r" (val));
+	isb();
+}
+
+static inline void __maybe_unused gic_write_ctlr(u32 val)
+{
+	asm volatile("mcr " __stringify(ICC_CTLR) : : "r" (val));
+	isb();
+}
+
+static inline void __maybe_unused gic_write_grpen1(u32 val)
+{
+	asm volatile("mcr " __stringify(ICC_IGRPEN1) : : "r" (val));
+	isb();
+}
+
+static inline void __maybe_unused gic_write_sgi1r(u64 val)
+{
+	asm volatile("mcrr " __stringify(ICC_SGI1R) : : "r" (val));
+}
+
+static inline u32 __maybe_unused gic_read_sre(void)
+{
+	u32 val;
+
+	asm volatile("mrc " __stringify(ICC_SRE) : "=r" (val));
+	return val;
+}
+
+static inline void __maybe_unused gic_write_sre(u32 val)
+{
+	asm volatile("mcr " __stringify(ICC_SRE) : : "r" (val));
+	isb();
+}
+
+/*
+ * Even in 32bit systems that use LPAE, there is no guarantee that the I/O
+ * interface provides true 64bit atomic accesses, so using strd/ldrd doesn't
+ * make much sense.
+ * Moreover, 64bit I/O emulation is extremely difficult to implement on
+ * AArch32, since the syndrome register doesn't provide any information for
+ * them.
+ * Consequently, the following IO helpers use 32bit accesses.
+ *
+ * There are only two registers that need 64bit accesses in this driver:
+ * - GICD_IROUTERn, contain the affinity values associated to each interrupt.
+ *   The upper-word (aff3) will always be 0, so there is no need for a lock.
+ * - GICR_TYPER is an ID register and doesn't need atomicity.
+ */
+static void gic_write_irouter(u64 val, volatile void __iomem *addr)
+{
+	writel_relaxed((u32)val, addr);
+	writel_relaxed((u32)(val >> 32), addr + 4);
+}
+
+static inline u64 gic_read_typer(const volatile void __iomem *addr)
+{
+	u64 val;
+
+	val = readl_relaxed(addr);
+	val |= (u64)readl_relaxed(addr + 4) << 32;
+	return val;
+}
+
+#endif /* !__ASSEMBLY__ */
+#endif /* !__ASM_ARCH_GICV3_H */
-- 
2.2.0.rc1

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

* [PATCH 4/4] ARM: add 32bit support to GICv3
  2014-12-11 14:23 ` [PATCH 4/4] ARM: add 32bit support to GICv3 Jean-Philippe Brucker
@ 2014-12-11 14:32   ` Russell King - ARM Linux
  2014-12-11 15:40     ` Marc Zyngier
  0 siblings, 1 reply; 14+ messages in thread
From: Russell King - ARM Linux @ 2014-12-11 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 11, 2014 at 02:23:08PM +0000, Jean-Philippe Brucker wrote:
> +#ifndef __ASM_ARCH_GICV3_H
> +#define __ASM_ARCH_GICV3_H
> +
> +#ifndef __ASSEMBLY__
> +
> +#include <asm/io.h>

This should be linux/io.h

> +/* Low-level accessors */
> +
> +static inline void __maybe_unused gic_write_eoir(u32 irq)

No need for __maybe_unused with static inline.

-- 
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH 4/4] ARM: add 32bit support to GICv3
  2014-12-11 14:32   ` Russell King - ARM Linux
@ 2014-12-11 15:40     ` Marc Zyngier
  2014-12-11 16:57       ` Jean-Philippe Brucker
  0 siblings, 1 reply; 14+ messages in thread
From: Marc Zyngier @ 2014-12-11 15:40 UTC (permalink / raw)
  To: linux-arm-kernel

On 11/12/14 14:32, Russell King - ARM Linux wrote:
> On Thu, Dec 11, 2014 at 02:23:08PM +0000, Jean-Philippe Brucker wrote:
>> +#ifndef __ASM_ARCH_GICV3_H
>> +#define __ASM_ARCH_GICV3_H
>> +
>> +#ifndef __ASSEMBLY__
>> +
>> +#include <asm/io.h>
> 
> This should be linux/io.h

Also, you should probably move the #ifndef down to the level of the
inline functions. The #defines are perfectly usable in assembly context.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

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

* [PATCH 4/4] ARM: add 32bit support to GICv3
  2014-12-11 15:40     ` Marc Zyngier
@ 2014-12-11 16:57       ` Jean-Philippe Brucker
  2014-12-11 17:23         ` Marc Zyngier
  0 siblings, 1 reply; 14+ messages in thread
From: Jean-Philippe Brucker @ 2014-12-11 16:57 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 11, 2014 at 03:40:31PM +0000, Marc Zyngier wrote:
> On 11/12/14 14:32, Russell King - ARM Linux wrote:
> > On Thu, Dec 11, 2014 at 02:23:08PM +0000, Jean-Philippe Brucker wrote:
> >> +#ifndef __ASM_ARCH_GICV3_H
> >> +#define __ASM_ARCH_GICV3_H
> >> +
> >> +#ifndef __ASSEMBLY__
> >> +
> >> +#include <asm/io.h>
> > 
> > This should be linux/io.h
> 
> Also, you should probably move the #ifndef down to the level of the
> inline functions. The #defines are perfectly usable in assembly context.
> 

This would require a change in the definition of __ACCESS_CP15, in order
to distinguish between inlined parameter '%0' and explicit registers.
I don't see any pleasant ways to do this, apart from adding a 'reg'
argument to all those #defines.
Furthermore, all other cp15 accesses from assembly on the arm/ side seem
to use raw opcodes, instead of macro names.

Thanks,
Jean

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

* [PATCH 4/4] ARM: add 32bit support to GICv3
  2014-12-11 16:57       ` Jean-Philippe Brucker
@ 2014-12-11 17:23         ` Marc Zyngier
  0 siblings, 0 replies; 14+ messages in thread
From: Marc Zyngier @ 2014-12-11 17:23 UTC (permalink / raw)
  To: linux-arm-kernel

On 11/12/14 16:57, Jean-Philippe Brucker wrote:
> On Thu, Dec 11, 2014 at 03:40:31PM +0000, Marc Zyngier wrote:
>> On 11/12/14 14:32, Russell King - ARM Linux wrote:
>>> On Thu, Dec 11, 2014 at 02:23:08PM +0000, Jean-Philippe Brucker wrote:
>>>> +#ifndef __ASM_ARCH_GICV3_H
>>>> +#define __ASM_ARCH_GICV3_H
>>>> +
>>>> +#ifndef __ASSEMBLY__
>>>> +
>>>> +#include <asm/io.h>
>>>
>>> This should be linux/io.h
>>
>> Also, you should probably move the #ifndef down to the level of the
>> inline functions. The #defines are perfectly usable in assembly context.
>>
> 
> This would require a change in the definition of __ACCESS_CP15, in order
> to distinguish between inlined parameter '%0' and explicit registers.
> I don't see any pleasant ways to do this, apart from adding a 'reg'
> argument to all those #defines.
> Furthermore, all other cp15 accesses from assembly on the arm/ side seem
> to use raw opcodes, instead of macro names.

Ah, fair enough. I guess we can rework that part, should we ever support
KVM on 32bit ARMv8 CPUs...

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

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

* [PATCH 0/4] GICv3: add 32bit compatibility
  2014-12-11 14:23 [PATCH 0/4] GICv3: add 32bit compatibility Jean-Philippe Brucker
                   ` (3 preceding siblings ...)
  2014-12-11 14:23 ` [PATCH 4/4] ARM: add 32bit support to GICv3 Jean-Philippe Brucker
@ 2014-12-11 17:38 ` Marc Zyngier
  2014-12-12 16:39 ` Andre Przywara
  5 siblings, 0 replies; 14+ messages in thread
From: Marc Zyngier @ 2014-12-11 17:38 UTC (permalink / raw)
  To: linux-arm-kernel

On 11/12/14 14:23, Jean-Philippe Brucker wrote:

Hi Jean-Philippe,

> This series adds 32bit compatibility to Marc's GICv3 driver. Only SGIs,
> PPIs and SPIs support is present. No ITS nor virtualisation.
> 
> It is based on 3.18.
> 
> Jean-Philippe Brucker (4):
>   arm64: GICv3: refactor the AArch64 specific parts
>   arm64: GICv3: change unsigned types for AArch32 compatibility
>   arm64: GICv3: Specialize readq and writeq accesses
>   ARM: add 32bit support to GICv3
> 
>  arch/arm/include/asm/arch_gicv3.h   | 182 ++++++++++++++++++++++++++++++++++++
>  arch/arm64/include/asm/arch_gicv3.h | 141 ++++++++++++++++++++++++++++
>  drivers/irqchip/irq-gic-v3.c        |  69 ++++----------
>  include/linux/irqchip/arm-gic-v3.h  |  95 +++----------------
>  4 files changed, 356 insertions(+), 131 deletions(-)
>  create mode 100644 arch/arm/include/asm/arch_gicv3.h
>  create mode 100644 arch/arm64/include/asm/arch_gicv3.h
> 

Overall, this looks good to me (once you've sorted the nits spotted by
Russell). It is going to conflict quite badly with what is going to be
merged in 3.19 though. Any chance you could rebase it on top of -rc1
once it is out?

Also, I don't see an obvious way to select CONFIG_ARM_GIC_V3 for ARM
(arm64 selects it automatically). What about selecting it from
ARCH_VIRT, which is likely to be the primary user of this?

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

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

* [PATCH 0/4] GICv3: add 32bit compatibility
  2014-12-11 14:23 [PATCH 0/4] GICv3: add 32bit compatibility Jean-Philippe Brucker
                   ` (4 preceding siblings ...)
  2014-12-11 17:38 ` [PATCH 0/4] GICv3: add 32bit compatibility Marc Zyngier
@ 2014-12-12 16:39 ` Andre Przywara
  2014-12-12 16:52   ` Marc Zyngier
  5 siblings, 1 reply; 14+ messages in thread
From: Andre Przywara @ 2014-12-12 16:39 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Jean-Philippe,

On 11/12/14 14:23, Jean-Philippe Brucker wrote:
> This series adds 32bit compatibility to Marc's GICv3 driver. Only SGIs,
> PPIs and SPIs support is present. No ITS nor virtualisation.
> 
> It is based on 3.18.
> 
> Jean-Philippe Brucker (4):
>   arm64: GICv3: refactor the AArch64 specific parts
>   arm64: GICv3: change unsigned types for AArch32 compatibility
>   arm64: GICv3: Specialize readq and writeq accesses
>   ARM: add 32bit support to GICv3
> 
>  arch/arm/include/asm/arch_gicv3.h   | 182 ++++++++++++++++++++++++++++++++++++
>  arch/arm64/include/asm/arch_gicv3.h | 141 ++++++++++++++++++++++++++++
>  drivers/irqchip/irq-gic-v3.c        |  69 ++++----------
>  include/linux/irqchip/arm-gic-v3.h  |  95 +++----------------
>  4 files changed, 356 insertions(+), 131 deletions(-)
>  create mode 100644 arch/arm/include/asm/arch_gicv3.h
>  create mode 100644 arch/arm64/include/asm/arch_gicv3.h

so if I compile this with CONFIG_KVM_ARM_VGIC on, I get a compilation error:
  LD      init/built-in.o
arch/arm/kvm/built-in.o: In function `svc_die_str':
arch_timer.c:(.rodata+0xf7c): undefined reference to `vgic_v3_probe'
make[2]: *** [vmlinux] Error 1

The svc_die_str reference is probably bogus, but if I protect the
vgic_v3_probe reference in virt/kvm/arm/vgic.c with "#ifdef ARM64" it
compiles fine. Disabling CONFIG_KVM_ARM_VGIC in the .config also fixes
this also.
I leave it up to you whether you want to take your "no virtualisation"
statement above serious and fix Kconfig accordingly or use the ifdef
solution.

After fixing that, adding CONFIG_ARM_GIC_V3 as Marc suggested (and
adding AArch32 support for the ICC_SGI1R trap in my patches ;-) I could
run a 32-bit GICv3 guest with your patches on a GICv3 64-bit host.

Cheers,
Andre.

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

* [PATCH 0/4] GICv3: add 32bit compatibility
  2014-12-12 16:39 ` Andre Przywara
@ 2014-12-12 16:52   ` Marc Zyngier
  0 siblings, 0 replies; 14+ messages in thread
From: Marc Zyngier @ 2014-12-12 16:52 UTC (permalink / raw)
  To: linux-arm-kernel

On 12/12/14 16:39, Andre Przywara wrote:
> Hi Jean-Philippe,
> 
> On 11/12/14 14:23, Jean-Philippe Brucker wrote:
>> This series adds 32bit compatibility to Marc's GICv3 driver. Only SGIs,
>> PPIs and SPIs support is present. No ITS nor virtualisation.
>>
>> It is based on 3.18.
>>
>> Jean-Philippe Brucker (4):
>>   arm64: GICv3: refactor the AArch64 specific parts
>>   arm64: GICv3: change unsigned types for AArch32 compatibility
>>   arm64: GICv3: Specialize readq and writeq accesses
>>   ARM: add 32bit support to GICv3
>>
>>  arch/arm/include/asm/arch_gicv3.h   | 182 ++++++++++++++++++++++++++++++++++++
>>  arch/arm64/include/asm/arch_gicv3.h | 141 ++++++++++++++++++++++++++++
>>  drivers/irqchip/irq-gic-v3.c        |  69 ++++----------
>>  include/linux/irqchip/arm-gic-v3.h  |  95 +++----------------
>>  4 files changed, 356 insertions(+), 131 deletions(-)
>>  create mode 100644 arch/arm/include/asm/arch_gicv3.h
>>  create mode 100644 arch/arm64/include/asm/arch_gicv3.h
> 
> so if I compile this with CONFIG_KVM_ARM_VGIC on, I get a compilation error:
>   LD      init/built-in.o
> arch/arm/kvm/built-in.o: In function `svc_die_str':
> arch_timer.c:(.rodata+0xf7c): undefined reference to `vgic_v3_probe'
> make[2]: *** [vmlinux] Error 1
> 
> The svc_die_str reference is probably bogus, but if I protect the
> vgic_v3_probe reference in virt/kvm/arm/vgic.c with "#ifdef ARM64" it
> compiles fine. Disabling CONFIG_KVM_ARM_VGIC in the .config also fixes
> this also.

That's an absolute no-no. I want to be able to run the exact same kernel
as a KVM host *and* a guest. So disabling the vgic can never be the
right solution.

Either wrapping the vgic_v3_probe reference with CONFIG_ARM64 or having
a non "static inline" vgic_v3_probe for 32bit are acceptable solutions.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

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

* [PATCH 2/4] arm64: GICv3: change unsigned types for AArch32 compatibility
  2014-12-11 14:23 ` [PATCH 2/4] arm64: GICv3: change unsigned types for AArch32 compatibility Jean-Philippe Brucker
@ 2014-12-18 13:27   ` Vladimir Murzin
  2014-12-18 14:42     ` Jean-Philippe Brucker
  0 siblings, 1 reply; 14+ messages in thread
From: Vladimir Murzin @ 2014-12-18 13:27 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Jean,

On 11/12/14 14:23, Jean-Philippe Brucker wrote:
> -static int gic_populate_rdist(void)
> +static int __init gic_populate_rdist(void)
              ^^^^^^
This change breaks cpu hotplug. Is it intentional?

Vladimir

>  {
> -     u64 mpidr = cpu_logical_map(smp_processor_id());
> +     unsigned long mpidr = cpu_logical_map(smp_processor_id());
>       u64 typer;

-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No:  2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No:  2548782

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

* [PATCH 2/4] arm64: GICv3: change unsigned types for AArch32 compatibility
  2014-12-18 13:27   ` Vladimir Murzin
@ 2014-12-18 14:42     ` Jean-Philippe Brucker
  0 siblings, 0 replies; 14+ messages in thread
From: Jean-Philippe Brucker @ 2014-12-18 14:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Dec 18, 2014 at 01:27:04PM +0000, Vladimir Murzin wrote:
> Hi Jean,
> 
> On 11/12/14 14:23, Jean-Philippe Brucker wrote:
> > -static int gic_populate_rdist(void)
> > +static int __init gic_populate_rdist(void)
>               ^^^^^^
> This change breaks cpu hotplug. Is it intentional?
> 
No, that must be a rebase mistake.

Thanks,
Jean

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

end of thread, other threads:[~2014-12-18 14:42 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-11 14:23 [PATCH 0/4] GICv3: add 32bit compatibility Jean-Philippe Brucker
2014-12-11 14:23 ` [PATCH 1/4] arm64: GICv3: refactor the AArch64 specific parts Jean-Philippe Brucker
2014-12-11 14:23 ` [PATCH 2/4] arm64: GICv3: change unsigned types for AArch32 compatibility Jean-Philippe Brucker
2014-12-18 13:27   ` Vladimir Murzin
2014-12-18 14:42     ` Jean-Philippe Brucker
2014-12-11 14:23 ` [PATCH 3/4] arm64: GICv3: Specialize readq and writeq accesses Jean-Philippe Brucker
2014-12-11 14:23 ` [PATCH 4/4] ARM: add 32bit support to GICv3 Jean-Philippe Brucker
2014-12-11 14:32   ` Russell King - ARM Linux
2014-12-11 15:40     ` Marc Zyngier
2014-12-11 16:57       ` Jean-Philippe Brucker
2014-12-11 17:23         ` Marc Zyngier
2014-12-11 17:38 ` [PATCH 0/4] GICv3: add 32bit compatibility Marc Zyngier
2014-12-12 16:39 ` Andre Przywara
2014-12-12 16:52   ` Marc Zyngier

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.