linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode
@ 2016-11-07  9:21 Vladimir Murzin
  2016-11-07  9:21 ` [RESEND PATCH v1 1/6] irqchip/gic-v3-its: Change unsigned types for AArch32 compatibility Vladimir Murzin
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Vladimir Murzin @ 2016-11-07  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: marc.zyngier, tglx, jason

Hi,

This series introduces GICv3 ITS to 32-bit world. Since I'm limited
with real world 32-bit platforms which uses ITS it was tested with
help of vITS on 64-bit host running 32-bit guest.

I used Andrea's its/v8 branch at [1] with following option passed to
kvmtool: --aarch32 --irqchip=gicv3-its --force-pci

[1] git://www.linux-arm.org/kvmtool.git

Changelog:

    RFC -> v1
        - rebased on 4.9-rc2,  gits_read_typer() has been dropped
	- spilt ITS and vITS in separate patch sets
	
Vladimir Murzin (6):
  irqchip/gic-v3-its: Change unsigned types for AArch32 compatibility
  irqchip/gic-v3-its: Narrow down Entry Size when used as a divider
  irqchip/gicv3-its: Specialise flush_dcache operation
  irqchip/gicv3-its: Specialise readq and writeq accesses
  ARM: gic-v3-its: Add 32bit support to GICv3 ITS
  ARM: virt: Select ARM_GIC_V3_ITS

 arch/arm/Kconfig                    |    1 +
 arch/arm/include/asm/arch_gicv3.h   |   54 +++++++++++++++++++++----
 arch/arm64/include/asm/arch_gicv3.h |   17 ++++++++
 drivers/irqchip/irq-gic-v3-its.c    |   75 +++++++++++++++++------------------
 include/linux/irqchip/arm-gic-v3.h  |    4 +-
 5 files changed, 104 insertions(+), 47 deletions(-)

-- 
1.7.9.5

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

* [RESEND PATCH v1 1/6] irqchip/gic-v3-its: Change unsigned types for AArch32 compatibility
  2016-11-07  9:21 [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode Vladimir Murzin
@ 2016-11-07  9:21 ` Vladimir Murzin
  2016-11-07  9:21 ` [RESEND PATCH v1 2/6] irqchip/gic-v3-its: Narrow down Entry Size when used as a divider Vladimir Murzin
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Vladimir Murzin @ 2016-11-07  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: marc.zyngier, tglx, jason

Make sure that constants which are supposed to be applied on 64-bit
data is actually unsigned long long, so they won't be truncated when
used in 32-bit mode.

Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
---
 drivers/irqchip/irq-gic-v3-its.c   |   28 ++++++++++++++--------------
 include/linux/irqchip/arm-gic-v3.h |    4 ++--
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index c5dee30..bca125e 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -196,7 +196,7 @@ struct its_cmd_block {
 
 static void its_encode_cmd(struct its_cmd_block *cmd, u8 cmd_nr)
 {
-	cmd->raw_cmd[0] &= ~0xffUL;
+	cmd->raw_cmd[0] &= ~0xffULL;
 	cmd->raw_cmd[0] |= cmd_nr;
 }
 
@@ -208,43 +208,43 @@ static void its_encode_devid(struct its_cmd_block *cmd, u32 devid)
 
 static void its_encode_event_id(struct its_cmd_block *cmd, u32 id)
 {
-	cmd->raw_cmd[1] &= ~0xffffffffUL;
+	cmd->raw_cmd[1] &= ~0xffffffffULL;
 	cmd->raw_cmd[1] |= id;
 }
 
 static void its_encode_phys_id(struct its_cmd_block *cmd, u32 phys_id)
 {
-	cmd->raw_cmd[1] &= 0xffffffffUL;
+	cmd->raw_cmd[1] &= 0xffffffffULL;
 	cmd->raw_cmd[1] |= ((u64)phys_id) << 32;
 }
 
 static void its_encode_size(struct its_cmd_block *cmd, u8 size)
 {
-	cmd->raw_cmd[1] &= ~0x1fUL;
+	cmd->raw_cmd[1] &= ~0x1fULL;
 	cmd->raw_cmd[1] |= size & 0x1f;
 }
 
 static void its_encode_itt(struct its_cmd_block *cmd, u64 itt_addr)
 {
-	cmd->raw_cmd[2] &= ~0xffffffffffffUL;
-	cmd->raw_cmd[2] |= itt_addr & 0xffffffffff00UL;
+	cmd->raw_cmd[2] &= ~0xffffffffffffULL;
+	cmd->raw_cmd[2] |= itt_addr & 0xffffffffff00ULL;
 }
 
 static void its_encode_valid(struct its_cmd_block *cmd, int valid)
 {
-	cmd->raw_cmd[2] &= ~(1UL << 63);
+	cmd->raw_cmd[2] &= ~(1ULL << 63);
 	cmd->raw_cmd[2] |= ((u64)!!valid) << 63;
 }
 
 static void its_encode_target(struct its_cmd_block *cmd, u64 target_addr)
 {
-	cmd->raw_cmd[2] &= ~(0xffffffffUL << 16);
-	cmd->raw_cmd[2] |= (target_addr & (0xffffffffUL << 16));
+	cmd->raw_cmd[2] &= ~(0xffffffffULL << 16);
+	cmd->raw_cmd[2] |= (target_addr & (0xffffffffULL << 16));
 }
 
 static void its_encode_collection(struct its_cmd_block *cmd, u16 col)
 {
-	cmd->raw_cmd[2] &= ~0xffffUL;
+	cmd->raw_cmd[2] &= ~0xffffULL;
 	cmd->raw_cmd[2] |= col;
 }
 
@@ -657,8 +657,8 @@ static void its_irq_compose_msi_msg(struct irq_data *d, struct msi_msg *msg)
 	its = its_dev->its;
 	addr = its->phys_base + GITS_TRANSLATER;
 
-	msg->address_lo		= addr & ((1UL << 32) - 1);
-	msg->address_hi		= addr >> 32;
+	msg->address_lo		= lower_32_bits(addr);
+	msg->address_hi		= upper_32_bits(addr);
 	msg->data		= its_get_event_id(d);
 
 	iommu_dma_map_msi_msg(d->irq, msg);
@@ -935,9 +935,9 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,
 	}
 
 	if (val != tmp) {
-		pr_err("ITS@%pa: %s doesn't stick: %lx %lx\n",
+		pr_err("ITS@%pa: %s doesn't stick: %llx %llx\n",
 		       &its->phys_base, its_base_type_string[type],
-		       (unsigned long) val, (unsigned long) tmp);
+		       val, tmp);
 		free_pages((unsigned long)base, order);
 		return -ENXIO;
 	}
diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h
index b7e3431..5118d3a 100644
--- a/include/linux/irqchip/arm-gic-v3.h
+++ b/include/linux/irqchip/arm-gic-v3.h
@@ -239,7 +239,7 @@
 #define GITS_TYPER_PTA			(1UL << 19)
 #define GITS_TYPER_HWCOLLCNT_SHIFT	24
 
-#define GITS_CBASER_VALID			(1UL << 63)
+#define GITS_CBASER_VALID			(1ULL << 63)
 #define GITS_CBASER_SHAREABILITY_SHIFT		(10)
 #define GITS_CBASER_INNER_CACHEABILITY_SHIFT	(59)
 #define GITS_CBASER_OUTER_CACHEABILITY_SHIFT	(53)
@@ -265,7 +265,7 @@
 
 #define GITS_BASER_NR_REGS		8
 
-#define GITS_BASER_VALID			(1UL << 63)
+#define GITS_BASER_VALID			(1ULL << 63)
 #define GITS_BASER_INDIRECT			(1ULL << 62)
 
 #define GITS_BASER_INNER_CACHEABILITY_SHIFT	(59)
-- 
1.7.9.5

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

* [RESEND PATCH v1 2/6] irqchip/gic-v3-its: Narrow down Entry Size when used as a divider
  2016-11-07  9:21 [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode Vladimir Murzin
  2016-11-07  9:21 ` [RESEND PATCH v1 1/6] irqchip/gic-v3-its: Change unsigned types for AArch32 compatibility Vladimir Murzin
@ 2016-11-07  9:21 ` Vladimir Murzin
  2016-11-07  9:21 ` [RESEND PATCH v1 3/6] irqchip/gicv3-its: Specialise flush_dcache operation Vladimir Murzin
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Vladimir Murzin @ 2016-11-07  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: marc.zyngier, tglx, jason

GITS_BASER<n>'s Entry Size is much smaller than 64-bit, but when it
used as a divider it forces compiler to generate __aeabi_uldivmod if
build in 32-bit mode. So, casting it to int (like it is done in other
places) where used as a divider would give a hint to compiler that
32-bit division can be used.

Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
---
 drivers/irqchip/irq-gic-v3-its.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index bca125e..312dd55 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -948,7 +948,7 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,
 	tmp = indirect ? GITS_LVL1_ENTRY_SIZE : esz;
 
 	pr_info("ITS@%pa: allocated %d %s @%lx (%s, esz %d, psz %dK, shr %d)\n",
-		&its->phys_base, (int)(PAGE_ORDER_TO_SIZE(order) / tmp),
+		&its->phys_base, (int)(PAGE_ORDER_TO_SIZE(order) / (int)tmp),
 		its_base_type_string[type],
 		(unsigned long)virt_to_phys(base),
 		indirect ? "indirect" : "flat", (int)esz,
@@ -983,7 +983,7 @@ static bool its_parse_baser_device(struct its_node *its, struct its_baser *baser
 			 * which is reported by ITS hardware times lvl1 table
 			 * entry size.
 			 */
-			ids -= ilog2(psz / esz);
+			ids -= ilog2(psz / (int)esz);
 			esz = GITS_LVL1_ENTRY_SIZE;
 		}
 	}
@@ -998,7 +998,7 @@ static bool its_parse_baser_device(struct its_node *its, struct its_baser *baser
 	new_order = max_t(u32, get_order(esz << ids), new_order);
 	if (new_order >= MAX_ORDER) {
 		new_order = MAX_ORDER - 1;
-		ids = ilog2(PAGE_ORDER_TO_SIZE(new_order) / esz);
+		ids = ilog2(PAGE_ORDER_TO_SIZE(new_order) / (int)esz);
 		pr_warn("ITS@%pa: Device Table too large, reduce ids %u->%u\n",
 			&its->phys_base, its->device_ids, ids);
 	}
-- 
1.7.9.5

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

* [RESEND PATCH v1 3/6] irqchip/gicv3-its: Specialise flush_dcache operation
  2016-11-07  9:21 [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode Vladimir Murzin
  2016-11-07  9:21 ` [RESEND PATCH v1 1/6] irqchip/gic-v3-its: Change unsigned types for AArch32 compatibility Vladimir Murzin
  2016-11-07  9:21 ` [RESEND PATCH v1 2/6] irqchip/gic-v3-its: Narrow down Entry Size when used as a divider Vladimir Murzin
@ 2016-11-07  9:21 ` Vladimir Murzin
  2016-11-07  9:21 ` [RESEND PATCH v1 4/6] irqchip/gicv3-its: Specialise readq and writeq accesses Vladimir Murzin
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Vladimir Murzin @ 2016-11-07  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: marc.zyngier, tglx, jason

It'd be better to switch to CMA... but before that done redirect
flush_dcache operation, so 32-bit implementation could be wired
latter.

Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
---
 arch/arm64/include/asm/arch_gicv3.h |    3 +++
 drivers/irqchip/irq-gic-v3-its.c    |   17 ++++++++---------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h
index f8ae6d6..4f0402a 100644
--- a/arch/arm64/include/asm/arch_gicv3.h
+++ b/arch/arm64/include/asm/arch_gicv3.h
@@ -79,6 +79,7 @@
 
 #include <linux/stringify.h>
 #include <asm/barrier.h>
+#include <asm/cacheflush.h>
 
 #define read_gicreg(r)							\
 	({								\
@@ -187,5 +188,7 @@ static inline void gic_write_bpr1(u32 val)
 #define gic_read_typer(c)		readq_relaxed(c)
 #define gic_write_irouter(v, c)		writeq_relaxed(v, c)
 
+#define gic_flush_dcache_to_poc(a,l)	__flush_dcache_area((a), (l))
+
 #endif /* __ASSEMBLY__ */
 #endif /* __ASM_ARCH_GICV3_H */
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 312dd55..b2a6e7b 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -37,7 +37,6 @@
 #include <linux/irqchip.h>
 #include <linux/irqchip/arm-gic-v3.h>
 
-#include <asm/cacheflush.h>
 #include <asm/cputype.h>
 #include <asm/exception.h>
 
@@ -433,7 +432,7 @@ static void its_flush_cmd(struct its_node *its, struct its_cmd_block *cmd)
 	 * the ITS.
 	 */
 	if (its->flags & ITS_FLAGS_CMDQ_NEEDS_FLUSHING)
-		__flush_dcache_area(cmd, sizeof(*cmd));
+		gic_flush_dcache_to_poc(cmd, sizeof(*cmd));
 	else
 		dsb(ishst);
 }
@@ -602,7 +601,7 @@ static void lpi_set_config(struct irq_data *d, bool enable)
 	 * Humpf...
 	 */
 	if (gic_rdists->flags & RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING)
-		__flush_dcache_area(cfg, sizeof(*cfg));
+		gic_flush_dcache_to_poc(cfg, sizeof(*cfg));
 	else
 		dsb(ishst);
 	its_send_inv(its_dev, id);
@@ -817,7 +816,7 @@ static int __init its_alloc_lpi_tables(void)
 	       LPI_PROPBASE_SZ);
 
 	/* Make sure the GIC will observe the written configuration */
-	__flush_dcache_area(page_address(gic_rdists->prop_page), LPI_PROPBASE_SZ);
+	gic_flush_dcache_to_poc(page_address(gic_rdists->prop_page), LPI_PROPBASE_SZ);
 
 	return 0;
 }
@@ -910,7 +909,7 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,
 		shr = tmp & GITS_BASER_SHAREABILITY_MASK;
 		if (!shr) {
 			cache = GITS_BASER_nC;
-			__flush_dcache_area(base, PAGE_ORDER_TO_SIZE(order));
+			gic_flush_dcache_to_poc(base, PAGE_ORDER_TO_SIZE(order));
 		}
 		goto retry_baser;
 	}
@@ -1102,7 +1101,7 @@ static void its_cpu_init_lpis(void)
 		}
 
 		/* Make sure the GIC will observe the zero-ed page */
-		__flush_dcache_area(page_address(pend_page), LPI_PENDBASE_SZ);
+		gic_flush_dcache_to_poc(page_address(pend_page), LPI_PENDBASE_SZ);
 
 		paddr = page_to_phys(pend_page);
 		pr_info("CPU%d: using LPI pending table @%pa\n",
@@ -1287,13 +1286,13 @@ static bool its_alloc_device_table(struct its_node *its, u32 dev_id)
 
 		/* Flush Lvl2 table to PoC if hw doesn't support coherency */
 		if (!(baser->val & GITS_BASER_SHAREABILITY_MASK))
-			__flush_dcache_area(page_address(page), baser->psz);
+			gic_flush_dcache_to_poc(page_address(page), baser->psz);
 
 		table[idx] = cpu_to_le64(page_to_phys(page) | GITS_BASER_VALID);
 
 		/* Flush Lvl1 entry to PoC if hw doesn't support coherency */
 		if (!(baser->val & GITS_BASER_SHAREABILITY_MASK))
-			__flush_dcache_area(table + idx, GITS_LVL1_ENTRY_SIZE);
+			gic_flush_dcache_to_poc(table + idx, GITS_LVL1_ENTRY_SIZE);
 
 		/* Ensure updated table contents are visible to ITS hardware */
 		dsb(sy);
@@ -1340,7 +1339,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,
 		return NULL;
 	}
 
-	__flush_dcache_area(itt, sz);
+	gic_flush_dcache_to_poc(itt, sz);
 
 	dev->its = its;
 	dev->itt = itt;
-- 
1.7.9.5

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

* [RESEND PATCH v1 4/6] irqchip/gicv3-its: Specialise readq and writeq accesses
  2016-11-07  9:21 [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode Vladimir Murzin
                   ` (2 preceding siblings ...)
  2016-11-07  9:21 ` [RESEND PATCH v1 3/6] irqchip/gicv3-its: Specialise flush_dcache operation Vladimir Murzin
@ 2016-11-07  9:21 ` Vladimir Murzin
  2016-11-07  9:21 ` [RESEND PATCH v1 5/6] ARM: gic-v3-its: Add 32bit support to GICv3 ITS Vladimir Murzin
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Vladimir Murzin @ 2016-11-07  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: marc.zyngier, tglx, jason

readq and writeq type of assessors are not supported in AArch32, so we
need to specialise them and glue later with series of 32-bit accesses
on AArch32 side.

Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
---
 arch/arm64/include/asm/arch_gicv3.h |   14 ++++++++++++++
 drivers/irqchip/irq-gic-v3-its.c    |   24 ++++++++++++------------
 2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/arch/arm64/include/asm/arch_gicv3.h b/arch/arm64/include/asm/arch_gicv3.h
index 4f0402a..022523b 100644
--- a/arch/arm64/include/asm/arch_gicv3.h
+++ b/arch/arm64/include/asm/arch_gicv3.h
@@ -190,5 +190,19 @@ static inline void gic_write_bpr1(u32 val)
 
 #define gic_flush_dcache_to_poc(a,l)	__flush_dcache_area((a), (l))
 
+#define gits_read_baser(c)		readq_relaxed(c)
+#define gits_write_baser(v, c)		writeq_relaxed(v, c)
+
+#define gits_read_cbaser(c)		readq_relaxed(c)
+#define gits_write_cbaser(v, c)		writeq_relaxed(v, c)
+
+#define gits_write_cwriter(v, c)	writeq_relaxed(v, c)
+
+#define gicr_read_propbaser(c)		readq_relaxed(c)
+#define gicr_write_propbaser(v, c)	writeq_relaxed(v, c)
+
+#define gicr_write_pendbaser(v, c)	writeq_relaxed(v, c)
+#define gicr_read_pendbaser(c)		readq_relaxed(c)
+
 #endif /* __ASSEMBLY__ */
 #endif /* __ASM_ARCH_GICV3_H */
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index b2a6e7b..69b040f 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -835,7 +835,7 @@ static u64 its_read_baser(struct its_node *its, struct its_baser *baser)
 {
 	u32 idx = baser - its->tables;
 
-	return readq_relaxed(its->base + GITS_BASER + (idx << 3));
+	return gits_read_baser(its->base + GITS_BASER + (idx << 3));
 }
 
 static void its_write_baser(struct its_node *its, struct its_baser *baser,
@@ -843,7 +843,7 @@ static void its_write_baser(struct its_node *its, struct its_baser *baser,
 {
 	u32 idx = baser - its->tables;
 
-	writeq_relaxed(val, its->base + GITS_BASER + (idx << 3));
+	gits_write_baser(val, its->base + GITS_BASER + (idx << 3));
 	baser->val = its_read_baser(its, baser);
 }
 
@@ -1125,8 +1125,8 @@ static void its_cpu_init_lpis(void)
 	       GICR_PROPBASER_WaWb |
 	       ((LPI_NRBITS - 1) & GICR_PROPBASER_IDBITS_MASK));
 
-	writeq_relaxed(val, rbase + GICR_PROPBASER);
-	tmp = readq_relaxed(rbase + GICR_PROPBASER);
+	gicr_write_propbaser(val, rbase + GICR_PROPBASER);
+	tmp = gicr_read_propbaser(rbase + GICR_PROPBASER);
 
 	if ((tmp ^ val) & GICR_PROPBASER_SHAREABILITY_MASK) {
 		if (!(tmp & GICR_PROPBASER_SHAREABILITY_MASK)) {
@@ -1138,7 +1138,7 @@ static void its_cpu_init_lpis(void)
 			val &= ~(GICR_PROPBASER_SHAREABILITY_MASK |
 				 GICR_PROPBASER_CACHEABILITY_MASK);
 			val |= GICR_PROPBASER_nC;
-			writeq_relaxed(val, rbase + GICR_PROPBASER);
+			gicr_write_propbaser(val, rbase + GICR_PROPBASER);
 		}
 		pr_info_once("GIC: using cache flushing for LPI property table\n");
 		gic_rdists->flags |= RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING;
@@ -1149,8 +1149,8 @@ static void its_cpu_init_lpis(void)
 	       GICR_PENDBASER_InnerShareable |
 	       GICR_PENDBASER_WaWb);
 
-	writeq_relaxed(val, rbase + GICR_PENDBASER);
-	tmp = readq_relaxed(rbase + GICR_PENDBASER);
+	gicr_write_pendbaser(val, rbase + GICR_PENDBASER);
+	tmp = gicr_read_pendbaser(rbase + GICR_PENDBASER);
 
 	if (!(tmp & GICR_PENDBASER_SHAREABILITY_MASK)) {
 		/*
@@ -1160,7 +1160,7 @@ static void its_cpu_init_lpis(void)
 		val &= ~(GICR_PENDBASER_SHAREABILITY_MASK |
 			 GICR_PENDBASER_CACHEABILITY_MASK);
 		val |= GICR_PENDBASER_nC;
-		writeq_relaxed(val, rbase + GICR_PENDBASER);
+		gicr_write_pendbaser(val, rbase + GICR_PENDBASER);
 	}
 
 	/* Enable LPIs */
@@ -1716,8 +1716,8 @@ static int __init its_probe_one(struct resource *res,
 		 (ITS_CMD_QUEUE_SZ / SZ_4K - 1)	|
 		 GITS_CBASER_VALID);
 
-	writeq_relaxed(baser, its->base + GITS_CBASER);
-	tmp = readq_relaxed(its->base + GITS_CBASER);
+	gits_write_cbaser(baser, its->base + GITS_CBASER);
+	tmp = gits_read_cbaser(its->base + GITS_CBASER);
 
 	if ((tmp ^ baser) & GITS_CBASER_SHAREABILITY_MASK) {
 		if (!(tmp & GITS_CBASER_SHAREABILITY_MASK)) {
@@ -1729,13 +1729,13 @@ static int __init its_probe_one(struct resource *res,
 			baser &= ~(GITS_CBASER_SHAREABILITY_MASK |
 				   GITS_CBASER_CACHEABILITY_MASK);
 			baser |= GITS_CBASER_nC;
-			writeq_relaxed(baser, its->base + GITS_CBASER);
+			gits_write_cbaser(baser, its->base + GITS_CBASER);
 		}
 		pr_info("ITS: using cache flushing for cmd queue\n");
 		its->flags |= ITS_FLAGS_CMDQ_NEEDS_FLUSHING;
 	}
 
-	writeq_relaxed(0, its->base + GITS_CWRITER);
+	gits_write_cwriter(0, its->base + GITS_CWRITER);
 	writel_relaxed(GITS_CTLR_ENABLE, its->base + GITS_CTLR);
 
 	err = its_init_domain(handle, its);
-- 
1.7.9.5

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

* [RESEND PATCH v1 5/6] ARM: gic-v3-its: Add 32bit support to GICv3 ITS
  2016-11-07  9:21 [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode Vladimir Murzin
                   ` (3 preceding siblings ...)
  2016-11-07  9:21 ` [RESEND PATCH v1 4/6] irqchip/gicv3-its: Specialise readq and writeq accesses Vladimir Murzin
@ 2016-11-07  9:21 ` Vladimir Murzin
  2016-11-07  9:21 ` [RESEND PATCH v1 6/6] ARM: virt: Select ARM_GIC_V3_ITS Vladimir Murzin
  2016-11-14 10:06 ` [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode Marc Zyngier
  6 siblings, 0 replies; 9+ messages in thread
From: Vladimir Murzin @ 2016-11-07  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: marc.zyngier, tglx, jason

Wire-up flush_dcache, readq- and writeq-like gic-v3-its assessors, so
GICv3 ITS gets all it needs to be built and run.

Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
---
 arch/arm/include/asm/arch_gicv3.h |   54 ++++++++++++++++++++++++++++++++-----
 1 file changed, 47 insertions(+), 7 deletions(-)

diff --git a/arch/arm/include/asm/arch_gicv3.h b/arch/arm/include/asm/arch_gicv3.h
index a808829..2747590 100644
--- a/arch/arm/include/asm/arch_gicv3.h
+++ b/arch/arm/include/asm/arch_gicv3.h
@@ -22,6 +22,7 @@
 
 #include <linux/io.h>
 #include <asm/barrier.h>
+#include <asm/cacheflush.h>
 #include <asm/cp15.h>
 
 #define ICC_EOIR1			__ACCESS_CP15(c12, 0, c12, 1)
@@ -230,19 +231,14 @@ static inline void gic_write_bpr1(u32 val)
  * 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 inline void gic_write_irouter(u64 val, volatile void __iomem *addr)
+static inline void __gic_writeq_nonatomic(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)
+static inline u64 __gic_readq_nonatomic(const volatile void __iomem *addr)
 {
 	u64 val;
 
@@ -251,5 +247,49 @@ static inline u64 gic_read_typer(const volatile void __iomem *addr)
 	return val;
 }
 
+#define gic_flush_dcache_to_poc(a,l)    __cpuc_flush_dcache_area((a), (l))
+
+/*
+ *  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.
+ */
+#define gic_write_irouter(v, c)		__gic_writeq_nonatomic(v, c)
+
+/*
+ * GICR_TYPER is an ID register and doesn't need atomicity.
+ */
+#define gic_read_typer(c)		__gic_readq_nonatomic(c)
+
+/*
+ * GITS_BASER - hi and lo bits may be accessed independently.
+ */
+#define gits_read_baser(c)		__gic_readq_nonatomic(c)
+#define gits_write_baser(v, c)		__gic_writeq_nonatomic(v, c)
+
+/*
+ * GICR_PENDBASER and GICR_PROPBASE are changed with LPIs disabled, so they
+ * won't be being used during any updates and can be changed non-atomically
+ */
+#define gicr_read_propbaser(c)		__gic_readq_nonatomic(c)
+#define gicr_write_propbaser(v, c)	__gic_writeq_nonatomic(v, c)
+#define gicr_read_pendbaser(c)		__gic_readq_nonatomic(c)
+#define gicr_write_pendbaser(v, c)	__gic_writeq_nonatomic(v, c)
+
+/*
+ * GITS_TYPER is an ID register and doesn't need atomicity.
+ */
+#define gits_read_typer(c)		__gic_readq_nonatomic(c)
+
+/*
+ * GITS_CBASER - hi and lo bits may be accessed independently.
+ */
+#define gits_read_cbaser(c)		__gic_readq_nonatomic(c)
+#define gits_write_cbaser(v, c)		__gic_writeq_nonatomic(v, c)
+
+/*
+ * GITS_CWRITER - hi and lo bits may be accessed independently.
+ */
+#define gits_write_cwriter(v, c)	__gic_writeq_nonatomic(v, c)
+
 #endif /* !__ASSEMBLY__ */
 #endif /* !__ASM_ARCH_GICV3_H */
-- 
1.7.9.5

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

* [RESEND PATCH v1 6/6] ARM: virt: Select ARM_GIC_V3_ITS
  2016-11-07  9:21 [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode Vladimir Murzin
                   ` (4 preceding siblings ...)
  2016-11-07  9:21 ` [RESEND PATCH v1 5/6] ARM: gic-v3-its: Add 32bit support to GICv3 ITS Vladimir Murzin
@ 2016-11-07  9:21 ` Vladimir Murzin
  2016-11-14 10:06 ` [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode Marc Zyngier
  6 siblings, 0 replies; 9+ messages in thread
From: Vladimir Murzin @ 2016-11-07  9:21 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel; +Cc: marc.zyngier, tglx, jason

This patch allows ARM guests to use GICv3 ITS on an arm64 host

Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
---
 arch/arm/Kconfig |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index b5d529f..caef684 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -703,6 +703,7 @@ config ARCH_VIRT
 	select ARM_GIC
 	select ARM_GIC_V2M if PCI
 	select ARM_GIC_V3
+	select ARM_GIC_V3_ITS if PCI
 	select ARM_PSCI
 	select HAVE_ARM_ARCH_TIMER
 
-- 
1.7.9.5

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

* Re: [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode
  2016-11-07  9:21 [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode Vladimir Murzin
                   ` (5 preceding siblings ...)
  2016-11-07  9:21 ` [RESEND PATCH v1 6/6] ARM: virt: Select ARM_GIC_V3_ITS Vladimir Murzin
@ 2016-11-14 10:06 ` Marc Zyngier
  2016-11-14 10:16   ` Vladimir Murzin
  6 siblings, 1 reply; 9+ messages in thread
From: Marc Zyngier @ 2016-11-14 10:06 UTC (permalink / raw)
  To: Vladimir Murzin, linux-kernel, linux-arm-kernel; +Cc: tglx, jason

Hi Vladimir,

On 07/11/16 09:21, Vladimir Murzin wrote:
> Hi,
> 
> This series introduces GICv3 ITS to 32-bit world. Since I'm limited
> with real world 32-bit platforms which uses ITS it was tested with
> help of vITS on 64-bit host running 32-bit guest.
> 
> I used Andrea's its/v8 branch at [1] with following option passed to
> kvmtool: --aarch32 --irqchip=gicv3-its --force-pci
> 
> [1] git://www.linux-arm.org/kvmtool.git
> 
> Changelog:
> 
>     RFC -> v1
>         - rebased on 4.9-rc2,  gits_read_typer() has been dropped
> 	- spilt ITS and vITS in separate patch sets
> 	
> Vladimir Murzin (6):
>   irqchip/gic-v3-its: Change unsigned types for AArch32 compatibility
>   irqchip/gic-v3-its: Narrow down Entry Size when used as a divider
>   irqchip/gicv3-its: Specialise flush_dcache operation
>   irqchip/gicv3-its: Specialise readq and writeq accesses
>   ARM: gic-v3-its: Add 32bit support to GICv3 ITS
>   ARM: virt: Select ARM_GIC_V3_ITS
> 
>  arch/arm/Kconfig                    |    1 +
>  arch/arm/include/asm/arch_gicv3.h   |   54 +++++++++++++++++++++----
>  arch/arm64/include/asm/arch_gicv3.h |   17 ++++++++
>  drivers/irqchip/irq-gic-v3-its.c    |   75 +++++++++++++++++------------------
>  include/linux/irqchip/arm-gic-v3.h  |    4 +-
>  5 files changed, 104 insertions(+), 47 deletions(-)

I've queued all of this in my irq/gic-4.10 branch.

Thanks,

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

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

* Re: [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode
  2016-11-14 10:06 ` [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode Marc Zyngier
@ 2016-11-14 10:16   ` Vladimir Murzin
  0 siblings, 0 replies; 9+ messages in thread
From: Vladimir Murzin @ 2016-11-14 10:16 UTC (permalink / raw)
  To: Marc Zyngier, linux-kernel, linux-arm-kernel; +Cc: tglx, jason

Hi,

On 14/11/16 10:06, Marc Zyngier wrote:
> Hi Vladimir,
> 
> On 07/11/16 09:21, Vladimir Murzin wrote:
>> Hi,
>>
>> This series introduces GICv3 ITS to 32-bit world. Since I'm limited
>> with real world 32-bit platforms which uses ITS it was tested with
>> help of vITS on 64-bit host running 32-bit guest.
>>
>> I used Andrea's its/v8 branch at [1] with following option passed to
>> kvmtool: --aarch32 --irqchip=gicv3-its --force-pci
>>
>> [1] git://www.linux-arm.org/kvmtool.git
>>
>> Changelog:
>>
>>     RFC -> v1
>>         - rebased on 4.9-rc2,  gits_read_typer() has been dropped
>> 	- spilt ITS and vITS in separate patch sets
>> 	
>> Vladimir Murzin (6):
>>   irqchip/gic-v3-its: Change unsigned types for AArch32 compatibility
>>   irqchip/gic-v3-its: Narrow down Entry Size when used as a divider
>>   irqchip/gicv3-its: Specialise flush_dcache operation
>>   irqchip/gicv3-its: Specialise readq and writeq accesses
>>   ARM: gic-v3-its: Add 32bit support to GICv3 ITS
>>   ARM: virt: Select ARM_GIC_V3_ITS
>>
>>  arch/arm/Kconfig                    |    1 +
>>  arch/arm/include/asm/arch_gicv3.h   |   54 +++++++++++++++++++++----
>>  arch/arm64/include/asm/arch_gicv3.h |   17 ++++++++
>>  drivers/irqchip/irq-gic-v3-its.c    |   75 +++++++++++++++++------------------
>>  include/linux/irqchip/arm-gic-v3.h  |    4 +-
>>  5 files changed, 104 insertions(+), 47 deletions(-)
> 
> I've queued all of this in my irq/gic-4.10 branch.
> 

Great!

Thanks
Vladimir

> Thanks,
> 
> 	M.
> 

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

end of thread, other threads:[~2016-11-14 10:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-07  9:21 [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode Vladimir Murzin
2016-11-07  9:21 ` [RESEND PATCH v1 1/6] irqchip/gic-v3-its: Change unsigned types for AArch32 compatibility Vladimir Murzin
2016-11-07  9:21 ` [RESEND PATCH v1 2/6] irqchip/gic-v3-its: Narrow down Entry Size when used as a divider Vladimir Murzin
2016-11-07  9:21 ` [RESEND PATCH v1 3/6] irqchip/gicv3-its: Specialise flush_dcache operation Vladimir Murzin
2016-11-07  9:21 ` [RESEND PATCH v1 4/6] irqchip/gicv3-its: Specialise readq and writeq accesses Vladimir Murzin
2016-11-07  9:21 ` [RESEND PATCH v1 5/6] ARM: gic-v3-its: Add 32bit support to GICv3 ITS Vladimir Murzin
2016-11-07  9:21 ` [RESEND PATCH v1 6/6] ARM: virt: Select ARM_GIC_V3_ITS Vladimir Murzin
2016-11-14 10:06 ` [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode Marc Zyngier
2016-11-14 10:16   ` Vladimir Murzin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).