Skip to contentSkip to conversation

implement workaround for Socionext Synquacer pre-ITS

PATCH New Ard Biesheuvel 2 participants 5 messages Oct 17, 2017 – Oct 18, 2017

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

v5 cover implement workaround for Socionext Synquacer pre-ITS

Quoted 1 line

From patch 3/3:

The Socionext Synquacer SoC's implementation of GICv3 has a so-called 'pre-ITS', which maps 32-bit writes targeted at a separate window of size '4 << device_id_bits' onto writes to GITS_TRANSLATER with device ID taken from bits [device_id_bits + 1:2] of the window offset. Writes that target GITS_TRANSLATER directly are reported as originating from device ID #0.

So add a workaround for this. Given that this breaks isolation, clear the IRQ_DOMAIN_FLAG_MSI_REMAP flag as well.

v5: - move back to using a single DT property to describe the window; this
is appropriate given that the CPU never accesses the window, and so modelling it using the standard DT idiom involving buses and ranges is not necessary
v4: - add patch to allow the quirk hook to signal whether it was applied or
not; this is necessary for hardware whose IIDR is not sufficient to identify it
- use DT sub-node rather than property to describe the quirk
- remove pre_its_size field, and use get_msi_base() function pointer instead
v3: - add patch to pull device ID space discovery forward, so we can quirk
it as well (as we already do for Cavium)
- use existing quirks framework as much as possible
- get rid of ITS_WORKAROUND_xxx flag: it is no longer needed after the refactoring

v2: - use a 32-bit host address/size rather than a PCI address, to factor
out the involvement of an SMMU (which the platform does have, but it is unclear atm if it can be exposed to the OS)
- add msi_domain_flags member to move the quirk flag checks out of the common code path*

Ard Biesheuvel (3):
drivers/irqchip: gicv3: probe device ID space before quirks handling drivers/irqchip: gic: make quirks matching conditional on init return
value
drivers/irqchip: gicv3: add workaround for Synquacer pre-ITS

 Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt |   4 +
 arch/arm64/Kconfig                                                    |   8 ++
 drivers/irqchip/irq-gic-common.c                                      |   5 +-
 drivers/irqchip/irq-gic-common.h                                      |   2 +-
 drivers/irqchip/irq-gic-v3-its.c                                      | 102 ++++++++++++++++----
 5 files changed, 101 insertions(+), 20 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH v5 1/3 drivers/irqchip: gicv3: probe device ID space before quirks handling

Before adding another SoC whose device ID space deviates from the value presented in the GIC ID registers, let's slightly refactor the code so that the ID registers are probed before that quirks handling executes. This allows us to move the device ID override into the quirk handler itself.

---
 drivers/irqchip/irq-gic-v3-its.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +6 -12
index e8d89343d613..891de07fd4cc 100644
@@ -1650,23 +1650,14 @@ static void its_free_tables(struct its_node *its)
 
 static int its_alloc_tables(struct its_node *its)
 {
-	u64 typer = gic_read_typer(its->base + GITS_TYPER);
-	u32 ids = GITS_TYPER_DEVBITS(typer);
 	u64 shr = GITS_BASER_InnerShareable;
 	u64 cache = GITS_BASER_RaWaWb;
 	u32 psz = SZ_64K;
 	int err, i;
 
-	if (its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_22375) {
-		/*
-		* erratum 22375: only alloc 8MB table size
-		* erratum 24313: ignore memory access type
-		*/
-		cache   = GITS_BASER_nCnB;
-		ids     = 0x14;                 /* 20 bits, 8MB */
-	}
-
-	its->device_ids = ids;
+	if (its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_22375)
+		/* erratum 24313: ignore memory access type */
+		cache = GITS_BASER_nCnB;
 
 	for (i = 0; i < GITS_BASER_NR_REGS; i++) {
 		struct its_baser *baser = its->tables + i;
@@ -2741,6 +2732,8 @@ static void __maybe_unused its_enable_quirk_cavium_22375(void *data)
 {
 	struct its_node *its = data;
 
+	/* erratum 22375: only alloc 8MB table size */
+	its->device_ids = 0x14;		/* 20 bits, 8MB */
 	its->flags |= ITS_FLAGS_WORKAROUND_CAVIUM_22375;
 }
 
@@ -2942,6 +2935,7 @@ static int __init its_probe_one(struct resource *res,
 	its->base = its_base;
 	its->phys_base = res->start;
 	its->ite_size = GITS_TYPER_ITT_ENTRY_SIZE(typer);
+	its->device_ids = GITS_TYPER_DEVBITS(typer);
 	its->is_v4 = !!(typer & GITS_TYPER_VLPIS);
 	if (its->is_v4) {
 		if (!(typer & GITS_TYPER_VMOVP)) {
Signature · 1 line
2.11.0
#2 lore raw

PATCH v5 2/3 drivers/irqchip: gic: make quirks matching conditional on init return value

In reply to Ard Biesheuvel

As it turns out, the IIDR is not sufficient to distinguish between GICv3 implementations when it comes to enabling quirks. So update the prototype of the init() hook to return a bool, and interpret a 'false' return value as no match, in which case the 'enabling workaround' log message should not be printed.

---
 drivers/irqchip/irq-gic-common.c |  5 +++--
 drivers/irqchip/irq-gic-common.h |  2 +-
 drivers/irqchip/irq-gic-v3-its.c | 12 +++++++++---
 3 files changed, 13 insertions(+), 6 deletions(-)
drivers/irqchip/irq-gic-common.c +3 -2
index 9ae71804b5dd..30017df5b54c 100644
@@ -40,8 +40,9 @@ void gic_enable_quirks(u32 iidr, const struct gic_quirk *quirks,
 	for (; quirks->desc; quirks++) {
 		if (quirks->iidr != (quirks->mask & iidr))
 			continue;
-		quirks->init(data);
-		pr_info("GIC: enabling workaround for %s\n", quirks->desc);
+		if (quirks->init(data))
+			pr_info("GIC: enabling workaround for %s\n",
+				quirks->desc);
 	}
 }
 
drivers/irqchip/irq-gic-common.h +1 -1
index 205e5fddf6da..3919cd7c5285 100644
@@ -23,7 +23,7 @@
 
 struct gic_quirk {
 	const char *desc;
-	void (*init)(void *data);
+	bool (*init)(void *data);
 	u32 iidr;
 	u32 mask;
 };
drivers/irqchip/irq-gic-v3-its.c +9 -3
index 891de07fd4cc..c34f21c7a38e 100644
@@ -2728,28 +2728,34 @@ static int its_force_quiescent(void __iomem *base)
 	}
 }
 
-static void __maybe_unused its_enable_quirk_cavium_22375(void *data)
+static bool __maybe_unused its_enable_quirk_cavium_22375(void *data)
 {
 	struct its_node *its = data;
 
 	/* erratum 22375: only alloc 8MB table size */
 	its->device_ids = 0x14;		/* 20 bits, 8MB */
 	its->flags |= ITS_FLAGS_WORKAROUND_CAVIUM_22375;
+
+	return true;
 }
 
-static void __maybe_unused its_enable_quirk_cavium_23144(void *data)
+static bool __maybe_unused its_enable_quirk_cavium_23144(void *data)
 {
 	struct its_node *its = data;
 
 	its->flags |= ITS_FLAGS_WORKAROUND_CAVIUM_23144;
+
+	return true;
 }
 
-static void __maybe_unused its_enable_quirk_qdf2400_e0065(void *data)
+static bool __maybe_unused its_enable_quirk_qdf2400_e0065(void *data)
 {
 	struct its_node *its = data;
 
 	/* On QDF2400, the size of the ITE is 16Bytes */
 	its->ite_size = 16;
+
+	return true;
 }
 
 static const struct gic_quirk its_quirks[] = {
Signature · 1 line
2.11.0
#3 lore raw

PATCH v5 3/3 drivers/irqchip: gicv3: add workaround for Synquacer pre-ITS

In reply to Ard Biesheuvel

The Socionext Synquacer SoC's implementation of GICv3 has a so-called 'pre-ITS', which maps 32-bit writes targeted at a separate window of size '4 << device_id_bits' onto writes to GITS_TRANSLATER with device ID taken from bits [device_id_bits + 1:2] of the window offset. Writes that target GITS_TRANSLATER directly are reported as originating from device ID #0.

So add a workaround for this. Given that this breaks isolation, clear the IRQ_DOMAIN_FLAG_MSI_REMAP flag as well.

---
 Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt |  4 ++
 arch/arm64/Kconfig                                                    |  8 +++
 drivers/irqchip/irq-gic-v3-its.c                                      | 72 +++++++++++++++++++-
 3 files changed, 82 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt +4 -0
index 4c29cdab0ea5..c3e6092f3add 100644
@@ -75,6 +75,10 @@ These nodes must have the following properties:
 - reg: Specifies the base physical address and size of the ITS
   registers.
 
+Optional:
+- socionext,synquacer-pre-its: (u32, u32) tuple describing the untranslated
+  address and size of the pre-ITS window.
+
 The main GIC node must contain the appropriate #address-cells,
 #size-cells and ranges properties for the reg property of all ITS
 nodes.
arch/arm64/Kconfig +8 -0
index 0df64a6a56d4..c4361dff2b74 100644
@@ -539,6 +539,14 @@ config QCOM_QDF2400_ERRATUM_0065
 
 	  If unsure, say Y.
 
+config SOCIONEXT_SYNQUACER_PREITS
+	bool "Socionext Synquacer: Workaround for GICv3 pre-ITS"
+	default y
+	help
+	  Socionext Synquacer SoCs implement a separate h/w block to generate
+	  MSI doorbell writes with non-zero values for the device ID.
+
+	  If unsure, say Y.
 endmenu
 
 
drivers/irqchip/irq-gic-v3-its.c +70 -2

125 lines not on this page · raw message

Signature · 1 line
2.11.0
#4 lore raw

PATCH v5 3/3 drivers/irqchip: gicv3: add workaround for Synquacer pre-ITS

Quoted 7 lines · Ard Biesheuvel

The Socionext Synquacer SoC's implementation of GICv3 has a so-called 'pre-ITS', which maps 32-bit writes targeted at a separate window of size '4 << device_id_bits' onto writes to GITS_TRANSLATER with device ID taken from bits [device_id_bits + 1:2] of the window offset. Writes that target GITS_TRANSLATER directly are reported as originating from device ID #0.

Quoted 6 lines

So add a workaround for this. Given that this breaks isolation, clear the IRQ_DOMAIN_FLAG_MSI_REMAP flag as well.

---
 Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt |  4 ++
Quoted 3 lines
 arch/arm64/Kconfig                                                    |  8 +++
 drivers/irqchip/irq-gic-v3-its.c                                      | 72 +++++++++++++++++++-
 3 files changed, 82 insertions(+), 2 deletions(-)