Skip to contentSkip to conversation

arch: arm: gic-v3-its: stop abusing the device tree

PATCH In review Michael Walle 6 participants 28 messages Oct 27, 2021 – Nov 1, 2021 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover arch: arm: gic-v3-its: stop abusing the device tree

Please stop throwing every ad-hoc information in the device tree. Use the official bindings (or maybe some bindings which will get approved soon).

On the quest of syncing the device tree used in u-boot with the one used in linux, there is this nice piece:

	gic_lpi_base: syscon@0x80000000 {
		compatible = "gic-lpi-base";
		reg = <0x0 0x80000000 0x0 0x100000>;
		max-gic-redistributors = <2>;
	};

There is no offical binding for it. Also, the chances that there will be one are virtually zero. We need to get rid of it. In fact, most information there are already known or can be deduced via the offical binding.

More than a month ago NXP [1] said they will look into it and try to get the bindings together. I don't think this will happen. Actually, I don't think the culprit is that commit, but rather the one which introduced that broken binding in the first place [2]. Therefore, revert it, too.

The funny thing is, I don't even know why this is needed at all. Linux will happily setup the LPI for us. At least for the LS1028A (but I guess also for all other layerscape SoC) the u-boot LPI setup code is only called right before we jump to linux. So u-boot doesn't even seem to use the interrupts. Now I can't speak of the Broadcom NS3 SoC where this 'feature' was introduced in the first place [3]. Unfortunately, it's not mentioned in the commit log *why* it was introduced. But this also seem to have crept into the layerscape SoCs [4]. All layerscape boards have CONFIG_GIC_V3_ITS enabled, well except for one; mine, the kontron_sl28 (which has a LS1028A). I haven't noticed anything out of the ordinary, though. Why is CONFIG_GIC_V3_ITS needed?

I briefly tested this on my board with CONFIG_GIC_V3_ITS enabled, at least linux prints:

[    0.000000] GICv3: Using preallocated redistributor tables

and there will be a reserved memory area:

	reserved-memory {
		#address-cells = <0x02>;
		#size-cells = <0x02>;
		ranges;

		gic-rd-tables@20,fff00000 {
			reg = <0x20 0xfff00000 0x00 0x100000>;
		};
	};

Also please note, that the reverts needed some manual adjustments because there were changes in the meantime.

While this will hopefully not break the layerscape boards, it will definetly break the Broadcom NS3, because the gic_lpi_tables_init() is called without arguments. But, these information are also not available in u-boot't device tree for the ns3. Soooo..

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/u-boot/[email protected]/
[3] https://lore.kernel.org/u-boot/[email protected]/
[4] https://lore.kernel.org/u-boot/[email protected]/

Michael Walle (1):
Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

Tom Rini (1):
Revert "arm64: Layerscape: Survive LPI one-way reset workaround"

 arch/arm/Kconfig                        |  2 -
 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 41 +++++++++------
 arch/arm/dts/fsl-ls1028a.dtsi           |  6 ---
 arch/arm/dts/fsl-ls1088a.dtsi           |  6 ---
 arch/arm/dts/fsl-ls2080a.dtsi           |  6 ---
 arch/arm/dts/fsl-lx2160a.dtsi           |  6 ---
 arch/arm/include/asm/gic-v3.h           |  4 +-
 arch/arm/lib/gic-v3-its.c               | 66 +++----------------------
 8 files changed, 35 insertions(+), 102 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 Revert "arm64: Layerscape: Survive LPI one-way reset workaround"

From: Tom Rini <[email protected]>

Ad-hoc bindings that are not part of the upstream device tree / bindings are not allowed in-tree. Only bindings that are in-progress with upstream and then re-synced once agreed upon are.

This reverts commit af288cb291da3abef6be0875527729296f7de7a0.

---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 18 +-----------------
 arch/arm/dts/fsl-ls1028a.dtsi           |  6 ------
 arch/arm/dts/fsl-ls1088a.dtsi           |  6 ------
 arch/arm/dts/fsl-ls2080a.dtsi           |  6 ------
 arch/arm/dts/fsl-lx2160a.dtsi           |  6 ------
 5 files changed, 1 insertion(+), 41 deletions(-)
arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -17
index 9820d3290e..c0e100d21c 100644
@@ -43,23 +43,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #ifdef CONFIG_GIC_V3_ITS
 int ls_gic_rd_tables_init(void *blob)
 {
-	struct fdt_memory lpi_base;
-	fdt_addr_t addr;
-	fdt_size_t size;
-	int offset, ret;
-
-	offset = fdt_path_offset(gd->fdt_blob, "/syscon@0x80000000");
-	addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, offset, "reg",
-						  0, &size, false);
-
-	lpi_base.start = addr;
-	lpi_base.end = addr + size - 1;
-	ret = fdtdec_add_reserved_memory(blob, "lpi_rd_table", &lpi_base, NULL,
-					 0, NULL, 0);
-	if (ret) {
-		debug("%s: failed to add reserved memory\n", __func__);
-		return ret;
-	}
+	int ret;
 
 	ret = gic_lpi_tables_init();
 	if (ret)
arch/arm/dts/fsl-ls1028a.dtsi +0 -6
index 50f9b527cd..53b052ed32 100644
@@ -44,12 +44,6 @@
 					 IRQ_TYPE_LEVEL_LOW)>;
 	};
 
-	gic_lpi_base: syscon@0x80000000 {
-		compatible = "gic-lpi-base";
-		reg = <0x0 0x80000000 0x0 0x100000>;
-		max-gic-redistributors = <2>;
-	};
-
 	timer {
 		compatible = "arm,armv8-timer";
 		interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) |
arch/arm/dts/fsl-ls1088a.dtsi +0 -6
index 64caa600ad..3a5a50fb83 100644
@@ -27,12 +27,6 @@
 		interrupts = <1 9 0x4>;
 	};
 
-	gic_lpi_base: syscon@0x80000000 {
-		compatible = "gic-lpi-base";
-		reg = <0x0 0x80000000 0x0 0x100000>;
-		max-gic-redistributors = <8>;
-	};
-
 	timer {
 		compatible = "arm,armv8-timer";
 		interrupts = <1 13 0x8>, /* Physical Secure PPI, active-low */
arch/arm/dts/fsl-ls2080a.dtsi +0 -6
index 7374d580e0..278daeeb6e 100644
@@ -27,12 +27,6 @@
 		interrupts = <1 9 0x4>;
 	};
 
-	gic_lpi_base: syscon@0x80000000 {
-		compatible = "gic-lpi-base";
-		reg = <0x0 0x80000000 0x0 0x100000>;
-		max-gic-redistributors = <8>;
-	};
-
 	timer {
 		compatible = "arm,armv8-timer";
 		interrupts = <1 13 0x8>, /* Physical Secure PPI, active-low */
arch/arm/dts/fsl-lx2160a.dtsi +0 -6
index a6f0e9bc56..3b5f0d119e 100644
@@ -43,12 +43,6 @@
 		interrupts = <1 9 0x4>;
 	};
 
-	gic_lpi_base: syscon@0x80000000 {
-		compatible = "gic-lpi-base";
-		reg = <0x0 0x80000000 0x0 0x200000>;
-		max-gic-redistributors = <16>;
-	};
-
 	timer {
 		compatible = "arm,armv8-timer";
 		interrupts = <1 13 0x8>, /* Physical Secure PPI, active-low */
Signature · 1 line
2.30.2
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] Revert "arm64: Layerscape: Survive LPI one-way reset workaround"

Quoted 13 lines · Michael Walle

From: Tom Rini <[email protected]>

Ad-hoc bindings that are not part of the upstream device tree / bindings are not allowed in-tree. Only bindings that are in-progress with upstream and then re-synced once agreed upon are.

This reverts commit af288cb291da3abef6be0875527729296f7de7a0.

Quoted 7 lines
---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 18 +-----------------
 arch/arm/dts/fsl-ls1028a.dtsi           |  6 ------
 arch/arm/dts/fsl-ls1088a.dtsi           |  6 ------
 arch/arm/dts/fsl-ls2080a.dtsi           |  6 ------
 arch/arm/dts/fsl-lx2160a.dtsi           |  6 ------
 5 files changed, 1 insertion(+), 41 deletions(-)

I have a number of comments on the second patch, but getting rid of this gunk is a good start.

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#3 lore raw

Re: [PATCH 1/2] Revert "arm64: Layerscape: Survive LPI one-way reset workaround"

In reply to Michael Walle
Quoted 6 lines · Michael Walle

From: Tom Rini <[email protected]>

Ad-hoc bindings that are not part of the upstream device tree / bindings are not allowed in-tree. Only bindings that are in-progress with upstream and then re-synced once agreed upon are.

Quoted 7 lines

This reverts commit af288cb291da3abef6be0875527729296f7de7a0.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#4 lore raw

PATCH 2/2 Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

In reply to Michael Walle

Stop using the device tree as a source for ad-hoc information.

This reverts commit 2ae7adc659f7fca9ea65df4318e5bca2b8274310.

---
 arch/arm/Kconfig                        |  2 -
 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 27 +++++++++-
 arch/arm/include/asm/gic-v3.h           |  4 +-
 arch/arm/lib/gic-v3-its.c               | 66 +++----------------------
 4 files changed, 36 insertions(+), 63 deletions(-)
arch/arm/Kconfig +0 -2
index 02f8306f15..86c1ebde05 100644
@@ -82,8 +82,6 @@ config GICV3
 
 config GIC_V3_ITS
 	bool "ARM GICV3 ITS"
-	select REGMAP
-	select SYSCON
 	select IRQ
 	help
 	  ARM GICV3 Interrupt translation service (ITS).
arch/arm/cpu/armv8/fsl-layerscape/soc.c +26 -1
index c0e100d21c..a08ed3f544 100644
@@ -41,11 +41,36 @@ DECLARE_GLOBAL_DATA_PTR;
 #endif
 
 #ifdef CONFIG_GIC_V3_ITS
+#define PENDTABLE_MAX_SZ	ALIGN(BIT(ITS_MAX_LPI_NRBITS), SZ_64K)
+#define PROPTABLE_MAX_SZ	ALIGN(BIT(ITS_MAX_LPI_NRBITS) / 8, SZ_64K)
+#define GIC_LPI_SIZE		ALIGN(cpu_numcores() * PENDTABLE_MAX_SZ + \
+				PROPTABLE_MAX_SZ, SZ_1M)
+static int fdt_add_resv_mem_gic_rd_tables(void *blob, u64 base, size_t size)
+{
+	int err;
+	struct fdt_memory gic_rd_tables;
+
+	gic_rd_tables.start = base;
+	gic_rd_tables.end = base + size - 1;
+	err = fdtdec_add_reserved_memory(blob, "gic-rd-tables", &gic_rd_tables,
+					 NULL, 0, NULL, 0);
+	if (err < 0)
+		debug("%s: failed to add reserved memory: %d\n", __func__, err);
+
+	return err;
+}
+
 int ls_gic_rd_tables_init(void *blob)
 {
+	u64 gic_lpi_base;
 	int ret;
 
-	ret = gic_lpi_tables_init();
+	gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
+	ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
+	if (ret)
+		return ret;
+
+	ret = gic_lpi_tables_init(gic_lpi_base, cpu_numcores());
 	if (ret)
 		debug("%s: failed to init gic-lpi-tables\n", __func__);
 
arch/arm/include/asm/gic-v3.h +2 -2
index 35efec78c3..5131fabec4 100644
@@ -127,9 +127,9 @@
 #define GIC_REDISTRIBUTOR_OFFSET 0x20000
 
 #ifdef CONFIG_GIC_V3_ITS
-int gic_lpi_tables_init(void);
+int gic_lpi_tables_init(u64 base, u32 max_redist);
 #else
-int gic_lpi_tables_init(void)
+int gic_lpi_tables_init(u64 base, u32 max_redist)
 {
 	return 0;
 }
arch/arm/lib/gic-v3-its.c +8 -58

135 lines not on this page · raw message

Signature · 1 line
2.30.2
#5 lore raw

Re: [PATCH 2/2] Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

arch/arm/cpu/armv8/fsl-layerscape/soc.c

Quoted 30 lines · Michael Walle

Stop using the device tree as a source for ad-hoc information.

This reverts commit 2ae7adc659f7fca9ea65df4318e5bca2b8274310.

---
 arch/arm/Kconfig                        |  2 -
 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 27 +++++++++-
 arch/arm/include/asm/gic-v3.h           |  4 +-
 arch/arm/lib/gic-v3-its.c               | 66 +++----------------------
 4 files changed, 36 insertions(+), 63 deletions(-)
arch/arm/Kconfig +0 -2
index 02f8306f15..86c1ebde05 100644
@@ -82,8 +82,6 @@ config GICV3
 
 config GIC_V3_ITS
 	bool "ARM GICV3 ITS"
-	select REGMAP
-	select SYSCON
 	select IRQ
 	help
 	  ARM GICV3 Interrupt translation service (ITS).
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
index c0e100d21c..a08ed3f544 100644

Why is this FSL specific?

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; · line 45

Quoted 6 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
@@ -41,11 +41,36 @@ DECLARE_GLOBAL_DATA_PTR;
 #endif
 
 #ifdef CONFIG_GIC_V3_ITS
+#define PENDTABLE_MAX_SZ	ALIGN(BIT(ITS_MAX_LPI_NRBITS), SZ_64K)
+#define PROPTABLE_MAX_SZ	ALIGN(BIT(ITS_MAX_LPI_NRBITS) / 8, SZ_64K)

This looks completely wrong.

The pending table needs one bit per LPI, and the property table one byte per LPI. Here, you have it the other way around. Also, the property table alignment requirement is 4kB, not 64kB, and its size is defined as the maximum number of LPIs - 8192.

Finally, ITS_MAX_LPI_NRBITS is hardcoded to 16, while it can actually vary from 14 to 32 (and even further limited by some hypervisors), depending on the implementation. Granted, this was broken before this patch, and in most cases, 64k is more than enough.

However, given that this defining the number of LPIs for the lifetime of the system, it would be better to actually allocate what the HW advertises (GICD_TYPER.IDbits, capped by GICD_TYPER.num_LPIs).

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; · line 47

Quoted 2 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
+#define GIC_LPI_SIZE		ALIGN(cpu_numcores() * PENDTABLE_MAX_SZ + \
+				PROPTABLE_MAX_SZ, SZ_1M)

Why the 1MB alignment? There is no such requirement in the architecture (64kB for the pending tables, 4kB for the property table).

Quoted 17 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +15 -0
+static int fdt_add_resv_mem_gic_rd_tables(void *blob, u64 base, size_t size)
+{
+	int err;
+	struct fdt_memory gic_rd_tables;
+
+	gic_rd_tables.start = base;
+	gic_rd_tables.end = base + size - 1;
+	err = fdtdec_add_reserved_memory(blob, "gic-rd-tables", &gic_rd_tables,
+					 NULL, 0, NULL, 0);
+	if (err < 0)
+		debug("%s: failed to add reserved memory: %d\n", __func__, err);
+
+	return err;
+}
+
 int ls_gic_rd_tables_init(void *blob)
 {

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; · line 73

Quoted 10 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +7 -1
+	u64 gic_lpi_base;
 	int ret;
 
-	ret = gic_lpi_tables_init();
+	gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
+	ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
+	if (ret)
+		return ret;
+
+	ret = gic_lpi_tables_init(gic_lpi_base, cpu_numcores());

This really should fetch the number of CPUs from the DT rather then some SoC specific black magic...

Quoted 33 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
 	if (ret)
 		debug("%s: failed to init gic-lpi-tables\n", __func__);
 
arch/arm/include/asm/gic-v3.h +2 -2
index 35efec78c3..5131fabec4 100644
@@ -127,9 +127,9 @@
 #define GIC_REDISTRIBUTOR_OFFSET 0x20000
 
 #ifdef CONFIG_GIC_V3_ITS
-int gic_lpi_tables_init(void);
+int gic_lpi_tables_init(u64 base, u32 max_redist);
 #else
-int gic_lpi_tables_init(void)
+int gic_lpi_tables_init(u64 base, u32 max_redist)
 {
 	return 0;
 }
arch/arm/lib/gic-v3-its.c +0 -2
index 2d3fdb600e..f6211a2d92 100644
@@ -5,8 +5,6 @@
 #include <common.h>
 #include <cpu_func.h>
 #include <dm.h>
-#include <regmap.h>
-#include <syscon.h>
 #include <asm/gic.h>
 #include <asm/gic-v3.h>
 #include <asm/io.h>

arch/arm/lib/gic-v3-its.c static u32 lpi_id_bits; · line 18

Quoted 2 lines
arch/arm/lib/gic-v3-its.c +0 -0
@@ -19,22 +17,15 @@ static u32 lpi_id_bits;
 #define LPI_PROPBASE_SZ		ALIGN(BIT(LPI_NRBITS), SZ_64K)
 #define LPI_PENDBASE_SZ		ALIGN(BIT(LPI_NRBITS) / 8, SZ_64K)

This is marginally more correct, but you have to wonder why you have the same thing defined twice...

Quoted 44 lines
arch/arm/lib/gic-v3-its.c +0 -28
-/* Number of GIC re-distributors */
-#define MAX_GIC_REDISTRIBUTORS	8
-
 /*
  * gic_v3_its_priv - gic details
  *
  * @gicd_base: gicd base address
  * @gicr_base: gicr base address
- * @lpi_base: gic lpi base address
- * @num_redist: number of gic re-distributors
  */
 struct gic_v3_its_priv {
 	ulong gicd_base;
 	ulong gicr_base;
-	ulong lpi_base;
-	u32 num_redist;
 };
 
 static int gic_v3_its_get_gic_addr(struct gic_v3_its_priv *priv)
@@ -68,39 +59,13 @@ static int gic_v3_its_get_gic_addr(struct gic_v3_its_priv *priv)
 	return 0;
 }
 
-static int gic_v3_its_get_gic_lpi_addr(struct gic_v3_its_priv *priv)
-{
-	struct regmap *regmap;
-	struct udevice *dev;
-	int ret;
-
-	ret = uclass_get_device_by_driver(UCLASS_SYSCON,
-					  DM_DRIVER_GET(gic_lpi_syscon), &dev);
-	if (ret) {
-		pr_err("%s: failed to get %s syscon device\n", __func__,
-		       DM_DRIVER_GET(gic_lpi_syscon)->name);
-		return ret;
-	}
-
-	regmap = syscon_get_regmap(dev);
-	if (!regmap) {
-		pr_err("%s: failed to regmap for %s syscon device\n", __func__,
-		       DM_DRIVER_GET(gic_lpi_syscon)->name);
-		return -ENODEV;
-	}
-	priv->lpi_base = regmap->ranges[0].start;

arch/arm/lib/gic-v3-its.c static int gic_v3_its_get_gic_addr(struct gic_v3_its_priv *priv) · line 64

Quoted 10 lines
arch/arm/lib/gic-v3-its.c +0 -7
-
-	priv->num_redist = dev_read_u32_default(dev, "max-gic-redistributors",
-						MAX_GIC_REDISTRIBUTORS);
-
-	return 0;
-}
-
 /*
  * Program the GIC LPI configuration tables for all
  * the re-distributors and enable the LPI table

... enable LPI forwarding, not the tables...

Quoted 67 lines
arch/arm/lib/gic-v3-its.c +8 -11
+ * base: Configuration table address
+ * num_redist: number of redistributors
  */
-int gic_lpi_tables_init(void)
+int gic_lpi_tables_init(u64 base, u32 num_redist)
 {
 	struct gic_v3_its_priv priv;
 	u32 gicd_typer;
@@ -109,15 +74,12 @@ int gic_lpi_tables_init(void)
 	int i;
 	u64 redist_lpi_base;
 	u64 pend_base;
-	ulong pend_tab_total_sz;
+	ulong pend_tab_total_sz = num_redist * LPI_PENDBASE_SZ;
 	void *pend_tab_va;
 
 	if (gic_v3_its_get_gic_addr(&priv))
 		return -EINVAL;
 
-	if (gic_v3_its_get_gic_lpi_addr(&priv))
-		return -EINVAL;
-
 	gicd_typer = readl((uintptr_t)(priv.gicd_base + GICD_TYPER));
 	/* GIC support for Locality specific peripheral interrupts (LPI's) */
 	if (!(gicd_typer & GICD_TYPER_LPIS)) {
@@ -130,7 +92,7 @@ int gic_lpi_tables_init(void)
 	 * Once the LPI table is enabled, can not program the
 	 * LPI configuration tables again, unless the GIC is reset.
 	 */
-	for (i = 0; i < priv.num_redist; i++) {
+	for (i = 0; i < num_redist; i++) {
 		u32 offset = i * GIC_REDISTRIBUTOR_OFFSET;
 
 		if ((readl((uintptr_t)(priv.gicr_base + offset))) &
@@ -146,7 +108,7 @@ int gic_lpi_tables_init(void)
 			    ITS_MAX_LPI_NRBITS);
 
 	/* Set PropBase */
-	val = (priv.lpi_base |
+	val = (base |
 	       GICR_PROPBASER_INNERSHAREABLE |
 	       GICR_PROPBASER_RAWAWB |
 	       ((LPI_NRBITS - 1) & GICR_PROPBASER_IDBITS_MASK));
@@ -163,8 +125,7 @@ int gic_lpi_tables_init(void)
 		}
 	}
 
-	redist_lpi_base = priv.lpi_base + LPI_PROPBASE_SZ;
-	pend_tab_total_sz = priv.num_redist * LPI_PENDBASE_SZ;
+	redist_lpi_base = base + LPI_PROPBASE_SZ;
 	pend_tab_va = map_physmem(redist_lpi_base, pend_tab_total_sz,
 				  MAP_NOCACHE);
 	memset(pend_tab_va, 0, pend_tab_total_sz);
@@ -172,7 +133,7 @@ int gic_lpi_tables_init(void)
 	unmap_physmem(pend_tab_va, MAP_NOCACHE);
 
 	pend_base = priv.gicr_base + GICR_PENDBASER;
-	for (i = 0; i < priv.num_redist; i++) {
+	for (i = 0; i < num_redist; i++) {
 		u32 offset = i * GIC_REDISTRIBUTOR_OFFSET;
 
 		val = ((redist_lpi_base + (i * LPI_PENDBASE_SZ)) |
@@ -207,14 +168,3 @@ U_BOOT_DRIVER(arm_gic_v3_its) = {
 	.id		= UCLASS_IRQ,
 	.of_match	= gic_v3_its_ids,
 };
-

arch/arm/lib/gic-v3-its.c U_BOOT_DRIVER(arm_gic_v3_its) = { · line 220

Quoted 10 lines
arch/arm/lib/gic-v3-its.c +0 -10
-static const struct udevice_id gic_lpi_syscon_ids[] = {
-	{ .compatible = "gic-lpi-base" },
-	{}
-};
-
-U_BOOT_DRIVER(gic_lpi_syscon) = {
-	.name		= "gic-lpi-base",
-	.id		= UCLASS_SYSCON,
-	.of_match	= gic_lpi_syscon_ids,
-};

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#6 lore raw

Re: [PATCH 2/2] Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

Quoted 21 lines · Marc Zyngier
Quoted 19 lines · Michael Walle

Stop using the device tree as a source for ad-hoc information.

This reverts commit 2ae7adc659f7fca9ea65df4318e5bca2b8274310.

---
 arch/arm/Kconfig                        |  2 -
 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 27 +++++++++-
 arch/arm/include/asm/gic-v3.h           |  4 +-
 arch/arm/lib/gic-v3-its.c               | 66 +++----------------------
 4 files changed, 36 insertions(+), 63 deletions(-)
arch/arm/Kconfig +0 -0
index 02f8306f15..86c1ebde05 100644
@@ -82,8 +82,6 @@ config GICV3
 
Quoted 13 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c

Quoted 11 lines
arch/arm/Kconfig +0 -2
 config GIC_V3_ITS
 	bool "ARM GICV3 ITS"
-	select REGMAP
-	select SYSCON
 	select IRQ
 	help
 	  ARM GICV3 Interrupt translation service (ITS).
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
index c0e100d21c..a08ed3f544 100644

Why is this FSL specific?

Note that this is a fairly direct revert. Based on your comments a follow-up patch to correct things is in order.

Signature · 1 line
Tom
#7 lore raw

Re: [PATCH 2/2] Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

In reply to Marc Zyngier

Hi,

thanks for the review, as Tom already mentioned this is just a revert. I'm still unsure wether I should care or not. Actually, NXP or Broadcom should. OTOH it would be nice if the kontron_sl28 can do kexec also with booti (and not just bootefi). Anyway, I still have some remarks.

Am 2021-10-28 23:09, schrieb Marc Zyngier:

Quoted 15 lines
Quoted 13 lines · Michael Walle

Stop using the device tree as a source for ad-hoc information.

This reverts commit 2ae7adc659f7fca9ea65df4318e5bca2b8274310.

---

int ls_gic_rd_tables_init(void *blob)
{

arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -0
+	u64 gic_lpi_base;
 	int ret;
Quoted 11 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; · line 73

Quoted 8 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -1
-	ret = gic_lpi_tables_init();
+	gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
+	ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, 

GIC_LPI_SIZE);

arch/arm/cpu/armv8/fsl-layerscape/soc.c +4 -0
+	if (ret)
+		return ret;
+
+	ret = gic_lpi_tables_init(gic_lpi_base, cpu_numcores());

This really should fetch the number of CPUs from the DT rather then some SoC specific black magic...

Remember that this is the bootloader. There might be a chicken egg problem. I guess, usually the bootloader will fixup the number of cores in the DT. Therefore, if we rely on the DT here, it has to be fixed up before this code is run.

Conceptually, I'm unsure if this should actually be a driver (UCLASS_IRQ). It's just setting up the interrupt controller, it doesn't provide any ops. So it might well be called from somewhere else instead of binding as a driver to the gic.

If it will be a driver, then the call to gic_lpi_tables_init() should go away. Instead the driver should just set the tables up.

If its not a driver, then gic_lpi_tables_init() (maybe renamed to gic_v3_lpi_tables_init()) should work without anything else and it should scan the device tree for the compatible node and fetch all needed information to set up the tables.

In any case, all this code should be guarded by a Kconfig option which clearly states *why* this is needed.

Thoughts?

Signature · 1 line
-michael
#8 lore raw

Re: [PATCH 2/2] Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

Michael,

Quoted 37 lines · Michael Walle

Hi,

thanks for the review, as Tom already mentioned this is just a revert. I'm still unsure wether I should care or not. Actually, NXP or Broadcom should. OTOH it would be nice if the kontron_sl28 can do kexec also with booti (and not just bootefi). Anyway, I still have some remarks.

Am 2021-10-28 23:09, schrieb Marc Zyngier:

Quoted 15 lines
Quoted 13 lines · Michael Walle

Stop using the device tree as a source for ad-hoc information.

This reverts commit 2ae7adc659f7fca9ea65df4318e5bca2b8274310.

---

int ls_gic_rd_tables_init(void *blob)
{

arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -0
+	u64 gic_lpi_base;
 	int ret;
Quoted 11 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; · line 73

Quoted 8 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -1
-	ret = gic_lpi_tables_init();
+	gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
+	ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base,

GIC_LPI_SIZE);

arch/arm/cpu/armv8/fsl-layerscape/soc.c +4 -0
+	if (ret)
+		return ret;
+
+	ret = gic_lpi_tables_init(gic_lpi_base, cpu_numcores());

This really should fetch the number of CPUs from the DT rather then some SoC specific black magic...

Quoted 4 lines

Remember that this is the bootloader. There might be a chicken egg problem. I guess, usually the bootloader will fixup the number of cores in the DT. Therefore, if we rely on the DT here, it has to be fixed up before this code is run.

I appreciate that. However...

Quoted 6 lines

Conceptually, I'm unsure if this should actually be a driver (UCLASS_IRQ). It's just setting up the interrupt controller, it doesn't provide any ops. So it might well be called from somewhere else instead of binding as a driver to the gic.

Quoted 7 lines

If it will be a driver, then the call to gic_lpi_tables_init() should go away. Instead the driver should just set the tables up.

If its not a driver, then gic_lpi_tables_init() (maybe renamed to gic_v3_lpi_tables_init()) should work without anything else and it should scan the device tree for the compatible node and fetch all needed information to set up the tables.

Exactly. This thing doesn't provide *any* service to u-boot itself. It just grabs some memory, point a couple of registers at it, and flip a bit. There is no actual ITS driver, so nothing makes use of it.

So this can be run as late as you want, long after you have worked out how many CPUs you really have. Which means this can be done in a SoC-agnostic way.

Quoted 2 lines

In any case, all this code should be guarded by a Kconfig option which clearly states *why* this is needed.

Even more: if it is selected, it should be possible to disable this at runtime (environment variable?) and leave the OS in charge of it. This really should an opt-in, instead of being forced on the users.

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#9 lore raw

RE: [PATCH 2/2] Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

In reply to Marc Zyngier
Quoted 57 lines

-----Original Message-----
From: Marc Zyngier [mailto:[email protected]]
Sent: 2021年10月29日 5:09
To: Michael Walle <[email protected]>
Cc: [email protected]; Vladimir Oltean <[email protected]>; Z.Q. Hou <[email protected]>; Bharat Gooty <[email protected]>; Rayagonda Kokatanur <[email protected]>; Simon Glass <[email protected]>; Priyanka Jain <[email protected]>; Tom Rini <[email protected]>
Subject: Re: [PATCH 2/2] Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

arch/arm/cpu/armv8/fsl-layerscape/soc.c

Quoted 31 lines · Michael Walle

Stop using the device tree as a source for ad-hoc information.

This reverts commit 2ae7adc659f7fca9ea65df4318e5bca2b8274310.

---
 arch/arm/Kconfig                        |  2 -
 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 27 +++++++++-
 arch/arm/include/asm/gic-v3.h           |  4 +-
 arch/arm/lib/gic-v3-its.c               | 66 +++----------------------
 4 files changed, 36 insertions(+), 63 deletions(-)
arch/arm/Kconfig index renamed from arch/arm/Kconfig +0 -0

02f8306f15..86c1ebde05 100644

arch/arm/Kconfig +0 -2
@@ -82,8 +82,6 @@ config GICV3
 
 config GIC_V3_ITS
 	bool "ARM GICV3 ITS"
-	select REGMAP
-	select SYSCON
 	select IRQ
 	help
 	  ARM GICV3 Interrupt translation service (ITS).
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
index c0e100d21c..a08ed3f544 100644

Why is this FSL specific?

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; #endif · line 44

Quoted 5 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
@@ -41,11 +41,36 @@ DECLARE_GLOBAL_DATA_PTR;  #endif
 
 #ifdef CONFIG_GIC_V3_ITS
+#define PENDTABLE_MAX_SZ	ALIGN(BIT(ITS_MAX_LPI_NRBITS), SZ_64K)
+#define PROPTABLE_MAX_SZ	ALIGN(BIT(ITS_MAX_LPI_NRBITS) / 8,

SZ_64K)

Quoted 4 lines

This looks completely wrong.

The pending table needs one bit per LPI, and the property table one byte per LPI. Here, you have it the other way around.

It's a typo, will fix after the revert patch applied.

Quoted 3 lines

Also, the property table alignment
requirement is 4kB, not 64kB, and its size is defined as the maximum number of LPIs - 8192.

As in the accessor gic_lpi_tables_init() there isn't alignment operation for both property table and pending table, we have to pass a 64KB alignment address, even though the property table only requires 4KB alignment.

Quoted 6 lines

Finally, ITS_MAX_LPI_NRBITS is hardcoded to 16, while it can actually vary from 14 to 32 (and even further limited by some hypervisors), depending on the implementation. Granted, this was broken before this patch, and in most cases, 64k is more than enough.

This is only for Layerscape platforms, so hardcoded to 16 bit works.

Quoted 9 lines

However, given that this defining the number of LPIs for the lifetime of the system, it would be better to actually allocate what the HW advertises (GICD_TYPER.IDbits, capped by GICD_TYPER.num_LPIs).

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; · line 47

Quoted 2 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
+#define GIC_LPI_SIZE		ALIGN(cpu_numcores() * PENDTABLE_MAX_SZ + \
+				PROPTABLE_MAX_SZ, SZ_1M)

Why the 1MB alignment? There is no such requirement in the architecture (64kB for the pending tables, 4kB for the property table).

This is definition of the size instead of address, 1MB size alignment is to ensure we have enough space to do address alignment, perhaps 64KB should be enough.

Quoted 20 lines
Quoted 20 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +16 -0
+static int fdt_add_resv_mem_gic_rd_tables(void *blob, u64 base,
+size_t size) {
+	int err;
+	struct fdt_memory gic_rd_tables;
+
+	gic_rd_tables.start = base;
+	gic_rd_tables.end = base + size - 1;
+	err = fdtdec_add_reserved_memory(blob, "gic-rd-tables", &gic_rd_tables,
+					 NULL, 0, NULL, 0);
+	if (err < 0)
+		debug("%s: failed to add reserved memory: %d\n", __func__, err);
+
+	return err;
+}
+
 int ls_gic_rd_tables_init(void *blob)  {
+	u64 gic_lpi_base;
 	int ret;
 
Quoted 10 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; · line 73

Quoted 7 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +6 -1
-	ret = gic_lpi_tables_init();
+	gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
+	ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
+	if (ret)
+		return ret;
+
+	ret = gic_lpi_tables_init(gic_lpi_base, cpu_numcores());

This really should fetch the number of CPUs from the DT rather then some SoC specific black magic...

Currently in most Layerscape platforms' DTS file there isn't cpu nodes. On Layerscape platforms the implemented core number can be get from GUT register.

Thanks,
Zhiqiang

Quoted 182 lines
Quoted 34 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
 	if (ret)
 		debug("%s: failed to init gic-lpi-tables\n", __func__);
 
(quoted diff) +0 -0

b/arch/arm/include/asm/gic-v3.h index 35efec78c3..5131fabec4 100644

arch/arm/include/asm/gic-v3.h +2 -2
@@ -127,9 +127,9 @@
 #define GIC_REDISTRIBUTOR_OFFSET 0x20000
 
 #ifdef CONFIG_GIC_V3_ITS
-int gic_lpi_tables_init(void);
+int gic_lpi_tables_init(u64 base, u32 max_redist);
 #else
-int gic_lpi_tables_init(void)
+int gic_lpi_tables_init(u64 base, u32 max_redist)
 {
 	return 0;
 }
arch/arm/lib/gic-v3-its.c +0 -2
index 2d3fdb600e..f6211a2d92 100644
@@ -5,8 +5,6 @@
 #include <common.h>
 #include <cpu_func.h>
 #include <dm.h>
-#include <regmap.h>
-#include <syscon.h>
 #include <asm/gic.h>
 #include <asm/gic-v3.h>
 #include <asm/io.h>

arch/arm/lib/gic-v3-its.c static u32 lpi_id_bits; · line 18

Quoted 2 lines
arch/arm/lib/gic-v3-its.c +0 -0
@@ -19,22 +17,15 @@ static u32 lpi_id_bits;
 #define LPI_PROPBASE_SZ		ALIGN(BIT(LPI_NRBITS), SZ_64K)
 #define LPI_PENDBASE_SZ		ALIGN(BIT(LPI_NRBITS) / 8, SZ_64K)

This is marginally more correct, but you have to wonder why you have the same thing defined twice...

Quoted 10 lines
arch/arm/lib/gic-v3-its.c +0 -5
-/* Number of GIC re-distributors */
-#define MAX_GIC_REDISTRIBUTORS	8
-
 /*
  * gic_v3_its_priv - gic details
  *
  * @gicd_base: gicd base address
  * @gicr_base: gicr base address
- * @lpi_base: gic lpi base address
- * @num_redist: number of gic re-distributors

arch/arm/lib/gic-v3-its.c static u32 lpi_id_bits;

Quoted 10 lines
arch/arm/lib/gic-v3-its.c +0 -3
  */
 struct gic_v3_its_priv {
 	ulong gicd_base;
 	ulong gicr_base;
-	ulong lpi_base;
-	u32 num_redist;
 };
 
 static int gic_v3_its_get_gic_addr(struct gic_v3_its_priv *priv) @@
-68,39 +59,13 @@ static int gic_v3_its_get_gic_addr(struct gic_v3_its_priv

*priv)

Quoted 24 lines
arch/arm/lib/gic-v3-its.c +0 -21
 	return 0;
 }
 
-static int gic_v3_its_get_gic_lpi_addr(struct gic_v3_its_priv *priv)
-{
-	struct regmap *regmap;
-	struct udevice *dev;
-	int ret;
-
-	ret = uclass_get_device_by_driver(UCLASS_SYSCON,
-					  DM_DRIVER_GET(gic_lpi_syscon), &dev);
-	if (ret) {
-		pr_err("%s: failed to get %s syscon device\n", __func__,
-		       DM_DRIVER_GET(gic_lpi_syscon)->name);
-		return ret;
-	}
-
-	regmap = syscon_get_regmap(dev);
-	if (!regmap) {
-		pr_err("%s: failed to regmap for %s syscon device\n", __func__,
-		       DM_DRIVER_GET(gic_lpi_syscon)->name);
-		return -ENODEV;
-	}
-	priv->lpi_base = regmap->ranges[0].start;

arch/arm/lib/gic-v3-its.c static int gic_v3_its_get_gic_addr(struct gic_v3_its_priv *priv) · line 64

Quoted 10 lines
arch/arm/lib/gic-v3-its.c +0 -7
-
-	priv->num_redist = dev_read_u32_default(dev, "max-gic-redistributors",
-						MAX_GIC_REDISTRIBUTORS);
-
-	return 0;
-}
-
 /*
  * Program the GIC LPI configuration tables for all
  * the re-distributors and enable the LPI table

... enable LPI forwarding, not the tables...

Quoted 67 lines

+ * base: Configuration table address
+ * num_redist: number of redistributors
*/

arch/arm/lib/gic-v3-its.c +2 -5
-int gic_lpi_tables_init(void)
+int gic_lpi_tables_init(u64 base, u32 num_redist)
 {
 	struct gic_v3_its_priv priv;
 	u32 gicd_typer;
@@ -109,15 +74,12 @@ int gic_lpi_tables_init(void)
 	int i;
 	u64 redist_lpi_base;
 	u64 pend_base;
-	ulong pend_tab_total_sz;
+	ulong pend_tab_total_sz = num_redist * LPI_PENDBASE_SZ;
 	void *pend_tab_va;
 
 	if (gic_v3_its_get_gic_addr(&priv))
 		return -EINVAL;
 
-	if (gic_v3_its_get_gic_lpi_addr(&priv))
-		return -EINVAL;
-
 	gicd_typer = readl((uintptr_t)(priv.gicd_base + GICD_TYPER));
 	/* GIC support for Locality specific peripheral interrupts (LPI's) */
 	if (!(gicd_typer & GICD_TYPER_LPIS)) { @@ -130,7 +92,7 @@ int

gic_lpi_tables_init(void)

arch/arm/lib/gic-v3-its.c +5 -4
 	 * Once the LPI table is enabled, can not program the
 	 * LPI configuration tables again, unless the GIC is reset.
 	 */
-	for (i = 0; i < priv.num_redist; i++) {
+	for (i = 0; i < num_redist; i++) {
 		u32 offset = i * GIC_REDISTRIBUTOR_OFFSET;
 
 		if ((readl((uintptr_t)(priv.gicr_base + offset))) & @@ -146,7
+108,7 @@ int gic_lpi_tables_init(void)
 			    ITS_MAX_LPI_NRBITS);
 
 	/* Set PropBase */
-	val = (priv.lpi_base |
+	val = (base |
 	       GICR_PROPBASER_INNERSHAREABLE |
 	       GICR_PROPBASER_RAWAWB |
 	       ((LPI_NRBITS - 1) & GICR_PROPBASER_IDBITS_MASK)); @@ -163,8
+125,7 @@ int gic_lpi_tables_init(void)
 		}
 	}
 
-	redist_lpi_base = priv.lpi_base + LPI_PROPBASE_SZ;
-	pend_tab_total_sz = priv.num_redist * LPI_PENDBASE_SZ;
+	redist_lpi_base = base + LPI_PROPBASE_SZ;
 	pend_tab_va = map_physmem(redist_lpi_base, pend_tab_total_sz,
 				  MAP_NOCACHE);
 	memset(pend_tab_va, 0, pend_tab_total_sz); @@ -172,7 +133,7 @@ int

gic_lpi_tables_init(void)

arch/arm/lib/gic-v3-its.c +2 -2
 	unmap_physmem(pend_tab_va, MAP_NOCACHE);
 
 	pend_base = priv.gicr_base + GICR_PENDBASER;
-	for (i = 0; i < priv.num_redist; i++) {
+	for (i = 0; i < num_redist; i++) {
 		u32 offset = i * GIC_REDISTRIBUTOR_OFFSET;
 
 		val = ((redist_lpi_base + (i * LPI_PENDBASE_SZ)) | @@ -207,14
+168,3 @@ U_BOOT_DRIVER(arm_gic_v3_its) = {
 	.id		= UCLASS_IRQ,
 	.of_match	= gic_v3_its_ids,
 };
-

arch/arm/lib/gic-v3-its.c U_BOOT_DRIVER(arm_gic_v3_its) = { · line 220

Quoted 10 lines
arch/arm/lib/gic-v3-its.c +0 -10
-static const struct udevice_id gic_lpi_syscon_ids[] = {
-	{ .compatible = "gic-lpi-base" },
-	{}
-};
-
-U_BOOT_DRIVER(gic_lpi_syscon) = {
-	.name		= "gic-lpi-base",
-	.id		= UCLASS_SYSCON,
-	.of_match	= gic_lpi_syscon_ids,
-};

Thanks,

	M.

--
Without deviation from the norm, progress is not possible.

#10 lore raw

Re: [PATCH 2/2] Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

Hi,

Am 2021-10-31 17:45, schrieb Z.Q. Hou:

Quoted 55 lines
Quoted 55 lines

-----Original Message-----
From: Marc Zyngier [mailto:[email protected]]
Sent: 2021年10月29日 5:09
To: Michael Walle <[email protected]>
Cc: [email protected]; Vladimir Oltean <[email protected]>; Z.Q. Hou <[email protected]>; Bharat Gooty <[email protected]>; Rayagonda Kokatanur <[email protected]>; Simon Glass <[email protected]>; Priyanka Jain <[email protected]>; Tom Rini <[email protected]>
Subject: Re: [PATCH 2/2] Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

arch/arm/cpu/armv8/fsl-layerscape/soc.c

Quoted 31 lines · Michael Walle

Stop using the device tree as a source for ad-hoc information.

This reverts commit 2ae7adc659f7fca9ea65df4318e5bca2b8274310.

---
 arch/arm/Kconfig                        |  2 -
 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 27 +++++++++-
 arch/arm/include/asm/gic-v3.h           |  4 +-
 arch/arm/lib/gic-v3-its.c               | 66 +++----------------------
 4 files changed, 36 insertions(+), 63 deletions(-)
arch/arm/Kconfig index renamed from arch/arm/Kconfig +0 -0

02f8306f15..86c1ebde05 100644

arch/arm/Kconfig +0 -2
@@ -82,8 +82,6 @@ config GICV3
 
 config GIC_V3_ITS
 	bool "ARM GICV3 ITS"
-	select REGMAP
-	select SYSCON
 	select IRQ
 	help
 	  ARM GICV3 Interrupt translation service (ITS).
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
index c0e100d21c..a08ed3f544 100644

Why is this FSL specific?

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; #endif · line 44

Quoted 5 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
@@ -41,11 +41,36 @@ DECLARE_GLOBAL_DATA_PTR;  #endif
 
 #ifdef CONFIG_GIC_V3_ITS
+#define PENDTABLE_MAX_SZ	ALIGN(BIT(ITS_MAX_LPI_NRBITS), SZ_64K)
+#define PROPTABLE_MAX_SZ	ALIGN(BIT(ITS_MAX_LPI_NRBITS) / 8,

SZ_64K)

Quoted 6 lines
Quoted 4 lines

This looks completely wrong.

The pending table needs one bit per LPI, and the property table one byte per LPI. Here, you have it the other way around.

It's a typo, will fix after the revert patch applied.

Please keep me on CC.

..

Quoted 7 lines
Quoted 5 lines

Finally, ITS_MAX_LPI_NRBITS is hardcoded to 16, while it can actually vary from 14 to 32 (and even further limited by some hypervisors), depending on the implementation. Granted, this was broken before this patch, and in most cases, 64k is more than enough.

This is only for Layerscape platforms, so hardcoded to 16 bit works.

But why is this layerscape only? Can't we make it so it works on any platform. If I understand Marc correctly, it should be possible.

..

Quoted 8 lines
Quoted 4 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; · line 73

Quoted 1 line
arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -0
+	ret = gic_lpi_tables_init(gic_lpi_base, cpu_numcores());

This really should fetch the number of CPUs from the DT rather then some SoC specific black magic...

Currently in most Layerscape platforms' DTS file there isn't cpu nodes. On Layerscape platforms the implemented core number can be get from GUT register.

So this would be the perfect time to actually sync the device trees with linux.

-michael

#11 lore raw

Re: [PATCH 2/2] Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

In reply to Z.Q. Hou
Quoted 58 lines · Z.Q. Hou
Quoted 58 lines

-----Original Message-----
From: Marc Zyngier [mailto:[email protected]]
Sent: 2021年10月29日 5:09
To: Michael Walle <[email protected]>
Cc: [email protected]; Vladimir Oltean <[email protected]>; Z.Q. Hou <[email protected]>; Bharat Gooty <[email protected]>; Rayagonda Kokatanur <[email protected]>; Simon Glass <[email protected]>; Priyanka Jain <[email protected]>; Tom Rini <[email protected]>
Subject: Re: [PATCH 2/2] Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

arch/arm/cpu/armv8/fsl-layerscape/soc.c

Quoted 31 lines · Michael Walle

Stop using the device tree as a source for ad-hoc information.

This reverts commit 2ae7adc659f7fca9ea65df4318e5bca2b8274310.

---
 arch/arm/Kconfig                        |  2 -
 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 27 +++++++++-
 arch/arm/include/asm/gic-v3.h           |  4 +-
 arch/arm/lib/gic-v3-its.c               | 66 +++----------------------
 4 files changed, 36 insertions(+), 63 deletions(-)
arch/arm/Kconfig index renamed from arch/arm/Kconfig +0 -0

02f8306f15..86c1ebde05 100644

arch/arm/Kconfig +0 -2
@@ -82,8 +82,6 @@ config GICV3
 
 config GIC_V3_ITS
 	bool "ARM GICV3 ITS"
-	select REGMAP
-	select SYSCON
 	select IRQ
 	help
 	  ARM GICV3 Interrupt translation service (ITS).
arch/arm/cpu/armv8/fsl-layerscape/soc.c +0 -0
index c0e100d21c..a08ed3f544 100644

Why is this FSL specific?

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; #endif · line 44

Quoted 5 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
@@ -41,11 +41,36 @@ DECLARE_GLOBAL_DATA_PTR;  #endif
 
 #ifdef CONFIG_GIC_V3_ITS
+#define PENDTABLE_MAX_SZ	ALIGN(BIT(ITS_MAX_LPI_NRBITS), SZ_64K)
+#define PROPTABLE_MAX_SZ	ALIGN(BIT(ITS_MAX_LPI_NRBITS) / 8,

SZ_64K)

Quoted 6 lines
Quoted 4 lines

This looks completely wrong.

The pending table needs one bit per LPI, and the property table one byte per LPI. Here, you have it the other way around.

It's a typo, will fix after the revert patch applied.

A typo that has the potential to corrupt to corrupt memory. This clearly was never tested.

Quoted 8 lines
Quoted 3 lines

Also, the property table alignment requirement is 4kB, not 64kB, and its size is defined as the maximum number of LPIs - 8192.

As in the accessor gic_lpi_tables_init() there isn't alignment operation for both property table and pending table, we have to pass a 64KB alignment address, even though the property table only requires 4KB alignment.

So how about fixing it?

Quoted 10 lines
Quoted 8 lines

Finally, ITS_MAX_LPI_NRBITS is hardcoded to 16, while it can actually vary from 14 to 32 (and even further limited by some hypervisors), depending on the implementation. Granted, this was broken before this patch, and in most cases, 64k is more than enough.

This is only for Layerscape platforms, so hardcoded to 16 bit works.

Let me say it again: hardcoding things for a specific platform for no good reason is utterly wasteful. There is no reason to write SoC specific code here, and allocating tables should be done in an architectural way.

Quoted 13 lines
Quoted 6 lines

However, given that this defining the number of LPIs for the lifetime of the system, it would be better to actually allocate what the HW advertises (GICD_TYPER.IDbits, capped by GICD_TYPER.num_LPIs).

Quoted 6 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; · line 47

Quoted 2 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +2 -0
+#define GIC_LPI_SIZE		ALIGN(cpu_numcores() * PENDTABLE_MAX_SZ + \
+				PROPTABLE_MAX_SZ, SZ_1M)

Why the 1MB alignment? There is no such requirement in the architecture (64kB for the pending tables, 4kB for the property table).

Quoted 3 lines

This is definition of the size instead of address, 1MB size alignment is to ensure we have enough space to do address alignment, perhaps 64KB should be enough.

Again: straying out of the architecture requirement is wasteful. The architecture states all the requirements. How about you follow them instead of picking random numbers?

Quoted 32 lines
Quoted 21 lines
Quoted 21 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +16 -0
+static int fdt_add_resv_mem_gic_rd_tables(void *blob, u64 base,
+size_t size) {
+	int err;
+	struct fdt_memory gic_rd_tables;
+
+	gic_rd_tables.start = base;
+	gic_rd_tables.end = base + size - 1;
+	err = fdtdec_add_reserved_memory(blob, "gic-rd-tables", &gic_rd_tables,
+					 NULL, 0, NULL, 0);
+	if (err < 0)
+		debug("%s: failed to add reserved memory: %d\n", __func__, err);
+
+	return err;
+}
+
 int ls_gic_rd_tables_init(void *blob)  {
+	u64 gic_lpi_base;
 	int ret;
 
Quoted 10 lines

arch/arm/cpu/armv8/fsl-layerscape/soc.c DECLARE_GLOBAL_DATA_PTR; · line 73

Quoted 7 lines
arch/arm/cpu/armv8/fsl-layerscape/soc.c +6 -1
-	ret = gic_lpi_tables_init();
+	gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
+	ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
+	if (ret)
+		return ret;
+
+	ret = gic_lpi_tables_init(gic_lpi_base, cpu_numcores());

This really should fetch the number of CPUs from the DT rather then some SoC specific black magic...

Quoted 3 lines

Currently in most Layerscape platforms' DTS file there isn't cpu nodes. On Layerscape platforms the implemented core number can be get from GUT register.

The CPU nodes will eventually be generated, if only for the sake of being able to boot an operating system. Given that the table allocation serves no purpose for u-boot itself, such allocation can be delayed until the nodes are populated, and the number of CPUs known.

No need for anything SoC specific whatsoever. Really, you should lose the SoC-specific mindset here, because you are:

- reinventing the wheel
- introducing stupid bugs
- making life difficult for everyone else

All of which are the hallmarks of bad engineering.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#12 lore raw

Re: [PATCH 2/2] Revert "arch: arm: use dt and UCLASS_SYSCON to get gic lpi details"

In reply to Michael Walle
Quoted 5 lines · Michael Walle

Stop using the device tree as a source for ad-hoc information.

This reverts commit 2ae7adc659f7fca9ea65df4318e5bca2b8274310.

With a quick change to make ns3 build but note the problem at runtime, applied to u-boot/master, thanks. And note that I expect a follow-up from interested parties to implement the required changes here correctly.

Signature · 1 line
Tom
#13 lore raw
In reply to Michael Walle
Quoted 13 lines · Michael Walle

Please stop throwing every ad-hoc information in the device tree. Use the official bindings (or maybe some bindings which will get approved soon).

On the quest of syncing the device tree used in u-boot with the one used in linux, there is this nice piece:

	gic_lpi_base: syscon@0x80000000 {
		compatible = "gic-lpi-base";
		reg = <0x0 0x80000000 0x0 0x100000>;
		max-gic-redistributors = <2>;
	};
Quoted 3 lines

There is no offical binding for it. Also, the chances that there will be one are virtually zero. We need to get rid of it. In fact, most information there are already known or can be deduced via the offical binding.

It is not "virtually zero". It is *exactly* zero. This node only shows that the author didn't understand the nature of the problem, nor were they aware of the existing solution which has been around since July 2018. This solution doesn't require any update to the binding, only to reserve the memory.

I really wish people would stop piling crap in u-boot, and that the u-boot maintainers would reach out to people familiar with the architecture before merging this sort of changes.

Quoted 6 lines

More than a month ago NXP [1] said they will look into it and try to get the bindings together. I don't think this will happen. Actually, I don't think the culprit is that commit, but rather the one which introduced that broken binding in the first place [2]. Therefore, revert it, too.

Quoted 11 lines

The funny thing is, I don't even know why this is needed at all. Linux will happily setup the LPI for us. At least for the LS1028A (but I guess also for all other layerscape SoC) the u-boot LPI setup code is only called right before we jump to linux. So u-boot doesn't even seem to use the interrupts. Now I can't speak of the Broadcom NS3 SoC where this 'feature' was introduced in the first place [3]. Unfortunately, it's not mentioned in the commit log *why* it was introduced. But this also seem to have crept into the layerscape SoCs [4]. All layerscape boards have CONFIG_GIC_V3_ITS enabled, well except for one; mine, the kontron_sl28 (which has a LS1028A). I haven't noticed anything out of the ordinary, though. Why is CONFIG_GIC_V3_ITS needed?

Now, that's a very interesting question: u-boot doesn't know how to drive an ITS (there is no support code for it, despite what arch/arm/lib/gic-v3-its.c suggest). Only the LPI allocation code is there. For what purpose? This is a pretty useless piece of code as far as I can see, unless the author had some unspecified ulterior motives (in which case a bit of documentation and a renaming of this file wouldn't go amiss).

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#14 lore raw
Quoted 63 lines · Marc Zyngier
Quoted 5 lines · Michael Walle

Please stop throwing every ad-hoc information in the device tree. Use the official bindings (or maybe some bindings which will get approved soon).

On the quest of syncing the device tree used in u-boot with the one used

in

Quoted 10 lines

linux, there is this nice piece:

      gic_lpi_base: syscon@0x80000000 {
              compatible = "gic-lpi-base";
              reg = <0x0 0x80000000 0x0 0x100000>;
              max-gic-redistributors = <2>;
      };

There is no offical binding for it. Also, the chances that there will be one are virtually zero. We need to get rid of it. In fact, most

information

Quoted 1 line

there are already known or can be deduced via the offical binding.

It is not "virtually zero". It is *exactly* zero. This node only shows that the author didn't understand the nature of the problem, nor were they aware of the existing solution which has been around since July 2018. This solution doesn't require any update to the binding, only to reserve the memory.

I really wish people would stop piling crap in u-boot, and that the u-boot maintainers would reach out to people familiar with the architecture before merging this sort of changes.

Quoted 4 lines

More than a month ago NXP [1] said they will look into it and try to get the bindings together. I don't think this will happen. Actually, I don't think the culprit is that commit, but rather the one which introduced

that

Quoted 3 lines

broken binding in the first place [2]. Therefore, revert it, too.

The funny thing is, I don't even know why this is needed at all. Linux

will

Quoted 4 lines

happily setup the LPI for us. At least for the LS1028A (but I guess also for all other layerscape SoC) the u-boot LPI setup code is only called right before we jump to linux. So u-boot doesn't even seem to use the interrupts. Now I can't speak of the Broadcom NS3 SoC where this

'feature'

Quoted 1 line

was introduced in the first place [3]. Unfortunately, it's not mentioned

in

Quoted 2 lines

the commit log *why* it was introduced. But this also seem to have crept into the layerscape SoCs [4]. All layerscape boards have

CONFIG_GIC_V3_ITS

Quoted 1 line

enabled, well except for one; mine, the kontron_sl28 (which has a

LS1028A).

Quoted 2 lines

I haven't noticed anything out of the ordinary, though. Why is CONFIG_GIC_V3_ITS needed?

Now, that's a very interesting question: u-boot doesn't know how to drive an ITS (there is no support code for it, despite what arch/arm/lib/gic-v3-its.c suggest). Only the LPI allocation code is there. For what purpose? This is a pretty useless piece of code as far as I can see, unless the author had some unspecified ulterior motives (in which case a bit of documentation and a renaming of this file wouldn't go amiss).

Quoted 8 lines

Thanks,

        M.

--
Without deviation from the norm, progress is not possible.

For GIC V3, once the LPI tables are programmed, we can not update it, unless we do a reset.
For the kexec kernel, where the reboot does not happen, in this case, during the new kernel boot, the new LPI tables address will not be updated. For these reasons, We allocate the LPI table memory in u-boot and reserve that memory.
Sorry, I have not followed the code. Initially the GIC_LPI_BASE memory is defined in the platform file.

Thanks,
-Bharat

Signature · 11 lines
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.
#15 lore raw
Quoted 3 lines · Bharat Gooty

For GIC V3, once the LPI tables are programmed, we can not update it, unless we do a reset.

Please tell me something I don't know...

Quoted 2 lines

For the kexec kernel, where the reboot does not happen, in this case, during the new kernel boot, the new LPI tables address will not be updated.

Since July 2018, the Linux kernel is perfectly able to deal with this without any extra support. It will communicate the reservation to the secondary kernel, and the secondary kernel will happily use this.

Quoted 2 lines

For these reasons, We allocate the LPI table memory in u-boot and reserve that memory.

What sort of antiquated kernel are you using? And even if you are running something that predates the kernel changes, reserving the memory in the DT serves the same purpose. Why the custom node declaring the allocation?

And since your kernel is able to kexec, it obviously knows about the reservation/pre-programming trick. This hardly makes any sense.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#16 lore raw
Quoted 9 lines · Marc Zyngier
Quoted 3 lines · Bharat Gooty

For GIC V3, once the LPI tables are programmed, we can not update it, unless we do a reset.

Please tell me something I don't know...

For GIC V3 , once the Locality specific peripheral interrupts (LPI) table

is programmed and enabled, unless the GIC is reset, we can not re-program the LPI tables. For these reasons, reserve the memory and program the GIC redistributor PROPBASER and LPI_PENDBASE registers.
If we do not program the LPI table in the bootloader, during the Linux boot, Linux will allocate the LPI table memory. Assume you want to boot a new kernel and do the kexec kernel. For the kexec kernel boot, Linux will again allocate the LPI table memory. But writing to the GIC registers will fail. As the LPI for the redistributors is already enabled by the previous Linux kernel, unless we do GIC reset, we can not update the LPI tables.

Quoted 14 lines
Quoted 2 lines

For the kexec kernel, where the reboot does not happen, in this case, during the new kernel boot, the new LPI tables address will not be

updated.

Since July 2018, the Linux kernel is perfectly able to deal with this without any extra support. It will communicate the reservation to the secondary kernel, and the secondary kernel will happily use this.

Can you specify the kernel version and the GIC versions which were used?

Quoted 2 lines

For these reasons, We allocate the LPI table memory in u-boot and reserve that memory.

Quoted 6 lines

What sort of antiquated kernel are you using? And even if you are running something that predates the kernel changes, reserving the memory in the DT serves the same purpose. Why the custom node declaring the allocation?

Tried using LTS 5.4 and 5.9 Linux kernels. Problem is updating the GIC V3

registers with the new LPI table memory after enabling the LPI for the redistributors.

And since your kernel is able to kexec, it obviously knows about the

Quoted 7 lines

reservation/pre-programming trick. This hardly makes any sense.

        M.

--
Without deviation from the norm, progress is not possible.

Signature · 11 lines
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.
Tested-by Jeremy Linton Tested-by Bhupesh Sharma Tested-by Lei Zhang
#17 lore raw
Quoted 13 lines · Bharat Gooty

[1 <text/plain; UTF-8 (7bit)>]

Quoted 9 lines · Marc Zyngier
Quoted 3 lines · Bharat Gooty

For GIC V3, once the LPI tables are programmed, we can not update it, unless we do a reset.

Please tell me something I don't know...

For GIC V3 , once the Locality specific peripheral interrupts (LPI) table

Quoted 10 lines

is programmed and enabled, unless the GIC is reset, we can not re-program the LPI tables. For these reasons, reserve the memory and program the GIC redistributor PROPBASER and LPI_PENDBASE registers.
If we do not program the LPI table in the bootloader, during the Linux boot, Linux will allocate the LPI table memory. Assume you want to boot a new kernel and do the kexec kernel. For the kexec kernel boot, Linux will again allocate the LPI table memory. But writing to the GIC registers will fail. As the LPI for the redistributors is already enabled by the previous Linux kernel, unless we do GIC reset, we can not update the LPI tables.

This really was a rhetorical question. I am painfully aware of most of the GIC's "features", having dealt with it in Linux and at the architecture level for the past 10+ years.

Quoted 11 lines
Quoted 11 lines
Quoted 4 lines

For the kexec kernel, where the reboot does not happen, in this case, during the new kernel boot, the new LPI tables address will not be

updated.

Since July 2018, the Linux kernel is perfectly able to deal with this without any extra support. It will communicate the reservation to the secondary kernel, and the secondary kernel will happily use this.

Can you specify the kernel version and the GIC versions which were used?

Any kernel containing this commit:

commit 5e2c9f9a627772672accd80fa15359c0de6aa894

Author: Marc Zyngier <[email protected]>
Date:   Fri Jul 27 16:23:18 2018 +0100

irqchip/gic-v3-its: Allow use of LPI tables in reserved memory

If the LPI tables have been reserved with the EFI reservation mechanism, we assume that these tables are safe to use even when we find the redistributors to have LPIs enabled at boot time, meaning that kexec can now work with GICv3.

You're welcome.

And the version of the IP doesn't matter at all.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

For these reasons, We allocate the LPI table memory in u-boot and reserve that memory.

Quoted 8 lines
Quoted 6 lines

What sort of antiquated kernel are you using? And even if you are running something that predates the kernel changes, reserving the memory in the DT serves the same purpose. Why the custom node declaring the allocation?

Tried using LTS 5.4 and 5.9 Linux kernels. Problem is updating the GIC V3

registers with the new LPI table memory after enabling the LPI for the redistributors.

Then you are doing something wrong. There are two cases that work:

(1) You are using EFI: nothing to do. The kernel will reserve the memory, configure the RDs, and the secondary kernel will happily use the same memory, as the address is conveyed in an EFI-specific table, without attempting to reprogram the RDs

(2) You are not using EFI, and you need to reserve the memory *using the appropriate DT reservation mechanism* as well as program the RDs. The kernel will detect the reservation, and will not attempt to reprogram the RDs.

If you invent your own binding, use another reservation mechanism or otherwise, this will not work. u-boot shouldn't expose this syscon node, because it makes no sense at all, and no upstream software knows about it. This code must die.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#18 lore raw
In reply to Bharat Gooty

Am 2021-10-28 11:20, schrieb Bharat Gooty:

Quoted 7 lines · Marc Zyngier

For GIC V3, once the LPI tables are programmed, we can not update it, unless we do a reset.
For the kexec kernel, where the reboot does not happen, in this case, during the new kernel boot, the new LPI tables address will not be updated.

kexec.. this should have really gone into both the commit message _and_ the kconfig menu. In fact, it is really just a workaround for the kexec case. If I understand it correctly, the kernel is able to communicate the reserved memory area, but only if you have EFI support. So, as a workaround, the bootloader can pre-allocate the memory and put it in the device tree, which is then passed from the old to the new kernel and the reservation is preserved. Correct, Marc?

But all of this doesn't need any new device tree node.

-michael

#19 lore raw
Quoted 17 lines · Michael Walle

Am 2021-10-28 11:20, schrieb Bharat Gooty:

Quoted 7 lines · Marc Zyngier

For GIC V3, once the LPI tables are programmed, we can not update it, unless we do a reset.
For the kexec kernel, where the reboot does not happen, in this case, during the new kernel boot, the new LPI tables address will not be updated.

kexec.. this should have really gone into both the commit message _and_ the kconfig menu. In fact, it is really just a workaround for the kexec case. If I understand it correctly, the kernel is able to communicate the reserved memory area, but only if you have EFI support. So, as a workaround, the bootloader can pre-allocate the memory and put it in the device tree, which is then passed from the old to the new kernel and the reservation is preserved. Correct, Marc?

Quoted 1 line

If EFI support is enabled, that's true, Pre-allocate the memory and Kernel

can get that memory using EFI.
What if EFI support is not enabled, like in a Broadcom NS3 or NXP platform? What is your suggestion for solving the kexec problem?

Quoted 4 lines

But all of this doesn't need any new device tree node.

-michael

Signature · 11 lines
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.
#20 lore raw

Am 2021-10-28 13:35, schrieb Bharat Gooty:

Quoted 26 lines
Quoted 12 lines · Michael Walle

Am 2021-10-28 11:20, schrieb Bharat Gooty:

Quoted 1 line

On Thu, Oct 28, 2021 at 2:33 PM Marc Zyngier <[email protected]>

Quoted 1 line · wrote:

For GIC V3, once the LPI tables are programmed, we can not update

it,

Quoted 2 lines

unless we do a reset.
For the kexec kernel, where the reboot does not happen, in this

case,

Quoted 2 lines

during the new kernel boot, the new LPI tables address will not be updated.

Quoted 10 lines

kexec.. this should have really gone into both the commit message _and_
the kconfig menu. In fact, it is really just a workaround for the kexec
case. If I understand it correctly, the kernel is able to communicate
the reserved memory area, but only if you have EFI support. So, as a workaround, the bootloader can pre-allocate the memory and put it in the device tree, which is then passed from the old to the new kernel and the reservation is preserved. Correct, Marc?

Quoted 4 lines

If EFI support is enabled, that's true, Pre-allocate the memory and Kernel can get that memory using EFI.
What if EFI support is not enabled, like in a Broadcom NS3 or NXP platform? What is your suggestion for solving the kexec problem?

Iff that is correct what I've said above, then
(1) rename the config symbol (I'm not sure, Tom?) and provide a better help text
(2) drop the device tree node. after all you only have to allocate the node
(3) keep most of the current code, but instead of reading the address from the device tree. Just allocate memory (within the alignment restrictions or whatever) and mark it as reserve it in the device tree. If I understood Marc correct, you can read the number of redistributors from the current gic-v3 binding.

Now, how and if this will fit into the u-boot device model, that's up to you.

In the meantime, it would be great if you can have a look at these two patches and trying to get them work for the ns3, so I can move forward with the device tree sync.

-michael

#21 lore raw
In reply to Michael Walle
Quoted 10 lines · Michael Walle

Am 2021-10-28 11:20, schrieb Bharat Gooty:

Quoted 7 lines · Marc Zyngier

For GIC V3, once the LPI tables are programmed, we can not update it, unless we do a reset.
For the kexec kernel, where the reboot does not happen, in this case, during the new kernel boot, the new LPI tables address will not be updated.

Quoted 7 lines

kexec.. this should have really gone into both the commit message _and_ the kconfig menu. In fact, it is really just a workaround for the kexec case. If I understand it correctly, the kernel is able to communicate the reserved memory area, but only if you have EFI support. So, as a workaround, the bootloader can pre-allocate the memory and put it in the device tree, which is then passed from the old to the new kernel and the reservation is preserved. Correct, Marc?

See my reply to Bharat. Either you use EFI, or you reserve the memory and program the RDs. In either of these two cases, kexec will just work.

Quoted 1 line

But all of this doesn't need any new device tree node.

Exactly. The whole syscon stuff is a point hack that makes no sense, and which isn't parsed by any upstream SW.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#22 lore raw
In reply to Marc Zyngier
Quoted 25 lines · Marc Zyngier
Quoted 13 lines · Michael Walle

Please stop throwing every ad-hoc information in the device tree. Use the official bindings (or maybe some bindings which will get approved soon).

On the quest of syncing the device tree used in u-boot with the one used in linux, there is this nice piece:

	gic_lpi_base: syscon@0x80000000 {
		compatible = "gic-lpi-base";
		reg = <0x0 0x80000000 0x0 0x100000>;
		max-gic-redistributors = <2>;
	};
Quoted 3 lines

There is no offical binding for it. Also, the chances that there will be one are virtually zero. We need to get rid of it. In fact, most information there are already known or can be deduced via the offical binding.

It is not "virtually zero". It is *exactly* zero. This node only shows that the author didn't understand the nature of the problem, nor were they aware of the existing solution which has been around since July 2018. This solution doesn't require any update to the binding, only to reserve the memory.

Quoted 3 lines

I really wish people would stop piling crap in u-boot, and that the u-boot maintainers would reach out to people familiar with the architecture before merging this sort of changes.

I'd be happy to reach out to people if I knew who would be receptive to spending some of their already I assume overload spare time looking in to things. If you're volunteering for "GIC related things" I'd be happy to CC you when patches come up. Thanks!

Signature · 1 line
Tom
#23 lore raw
Quoted 27 lines · Tom Rini
Quoted 25 lines · Marc Zyngier
Quoted 13 lines · Michael Walle

Please stop throwing every ad-hoc information in the device tree. Use the official bindings (or maybe some bindings which will get approved soon).

On the quest of syncing the device tree used in u-boot with the one used in linux, there is this nice piece:

	gic_lpi_base: syscon@0x80000000 {
		compatible = "gic-lpi-base";
		reg = <0x0 0x80000000 0x0 0x100000>;
		max-gic-redistributors = <2>;
	};
Quoted 3 lines

There is no offical binding for it. Also, the chances that there will be one are virtually zero. We need to get rid of it. In fact, most information there are already known or can be deduced via the offical binding.

It is not "virtually zero". It is *exactly* zero. This node only shows that the author didn't understand the nature of the problem, nor were they aware of the existing solution which has been around since July 2018. This solution doesn't require any update to the binding, only to reserve the memory.

Quoted 8 lines
Quoted 3 lines

I really wish people would stop piling crap in u-boot, and that the u-boot maintainers would reach out to people familiar with the architecture before merging this sort of changes.

I'd be happy to reach out to people if I knew who would be receptive to spending some of their already I assume overload spare time looking in to things. If you're volunteering for "GIC related things" I'd be happy to CC you when patches come up. Thanks!

Absolutely. It is far less painful for me to quickly eyeball a change and ask pointed questions on the spot, rather than having to reverse engineer a set of dubious changes months after they have been merged.

I already provide similar "services" for EDK2, for example, so getting the odd u-boot patch in my k.org inbox isn't a big deal.

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#24 lore raw
Quoted 38 lines · Marc Zyngier
Quoted 27 lines · Tom Rini
Quoted 25 lines · Marc Zyngier
Quoted 13 lines · Michael Walle

Please stop throwing every ad-hoc information in the device tree. Use the official bindings (or maybe some bindings which will get approved soon).

On the quest of syncing the device tree used in u-boot with the one used in linux, there is this nice piece:

	gic_lpi_base: syscon@0x80000000 {
		compatible = "gic-lpi-base";
		reg = <0x0 0x80000000 0x0 0x100000>;
		max-gic-redistributors = <2>;
	};
Quoted 3 lines

There is no offical binding for it. Also, the chances that there will be one are virtually zero. We need to get rid of it. In fact, most information there are already known or can be deduced via the offical binding.

It is not "virtually zero". It is *exactly* zero. This node only shows that the author didn't understand the nature of the problem, nor were they aware of the existing solution which has been around since July 2018. This solution doesn't require any update to the binding, only to reserve the memory.

Quoted 8 lines
Quoted 3 lines

I really wish people would stop piling crap in u-boot, and that the u-boot maintainers would reach out to people familiar with the architecture before merging this sort of changes.

I'd be happy to reach out to people if I knew who would be receptive to spending some of their already I assume overload spare time looking in to things. If you're volunteering for "GIC related things" I'd be happy to CC you when patches come up. Thanks!

Quoted 6 lines

Absolutely. It is far less painful for me to quickly eyeball a change and ask pointed questions on the spot, rather than having to reverse engineer a set of dubious changes months after they have been merged.

I already provide similar "services" for EDK2, for example, so getting the odd u-boot patch in my k.org inbox isn't a big deal.

Will do, thanks!

Signature · 1 line
Tom
#25 lore raw
In reply to Michael Walle

Hi Michael,

Quoted 3 lines · Michael Walle

Please stop throwing every ad-hoc information in the device tree. Use the official bindings (or maybe some bindings which will get approved soon).

Can I suggest that your commit subject be a little more specific? Perhaps 'Drop use of unwanted binding' ? It seems quite vague to me, like 'Fix a horrible bug' or 'Sort out all the problems' :-)

Regards,
Simon

#26 lore raw

Am 2021-10-29 00:36, schrieb Simon Glass:

Quoted 6 lines · Michael Walle
Quoted 3 lines

Please stop throwing every ad-hoc information in the device tree. Use the official bindings (or maybe some bindings which will get approved soon).

Can I suggest that your commit subject be a little more specific?

Sure. Actually, it should have be a bit provocant; and the cover letter subject doesn't really matter, does it?

Quoted 2 lines

Perhaps 'Drop use of unwanted binding' ? It seems quite vague to me, like 'Fix a horrible bug' or 'Sort out all the problems' :-)

-michael

#27 lore raw

Hi Michael,

Quoted 9 lines · Michael Walle

Am 2021-10-29 00:36, schrieb Simon Glass:

Quoted 7 lines · Michael Walle
Quoted 5 lines

Please stop throwing every ad-hoc information in the device tree. Use the
official bindings (or maybe some bindings which will get approved soon).

Quoted 4 lines
Quoted 1 line

Can I suggest that your commit subject be a little more specific?

Sure. Actually, it should have be a bit provocant; and the cover letter subject doesn't really matter, does it?

I suppose not and it is somewhat entertaining.

Quoted 3 lines
Quoted 3 lines

Perhaps 'Drop use of unwanted binding' ? It seems quite vague to me, like 'Fix a horrible bug' or 'Sort out all the problems' :-)

Regards,
SImon