Skip to contentSkip to conversation

MIPS: Support I6500 multi-cluster configuration

PATCH Applied Aleksandar Rikalo 8 participants 34 messages Oct 28, 2024 – Feb 19, 2025

Subsystems (6)

v8 of 9 Applied Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v8 cover MIPS: Support I6500 multi-cluster configuration

Taken from Paul Burton MIPS repo with minor changes from Chao-ying Fu. Tested with 64r6el_defconfig on Boston board in 2 cluster/2 VPU and 1 cluster/4 VPU configurations.

v8:
- irqchip: mips-gic: Handle case with cluster without CPU cores.
- Add Tested-by: Gregory CLEMENT <[email protected]> for the entire series.
- Re-base onto the master branch, with no functionality impact.

v7:
- Add fixes for specific CM3.5 which is used in EyeQ6H SoCs, suggested by Gregory Clement.
- Re-base onto the master branch, with no functionality impact.

v6:
- Re-base onto the master branch, with no functionality impact.
- Correct the issue reported by the kernel test robot.

v5:
- Drop FDC related changes (patches 12, 13, and 14).
- Apply changes suggested by Thomas Gleixner (patches 3 and 4).
- Add #include <linux/cpumask.h> to patch 1, suggested by Thomas Bogendoerfer.
- Add Reviewed-by: Philippe Mathieu-Daudé <[email protected]> for the patch 08/11.
- Add Tested-by: Serge Semin <[email protected]> for the entire series.
- Correct some commit messages.

v4:
- Re-base onto the master branch, with no functionality impact.
- Refactor MIPS FDC driver in the context of multicluster support.

v3:
- Add Reviewed-by: Jiaxun Yang <[email protected]> for the patch 02/12.
- Add the changes requested by Marc Zyngier for the 3/12 patch.
- Remove the patch 11/12 (a consequence of a discussion between Jiaxun Yang and Marc Zyngier.
- Re-base onto the master branch, with no functionality impact.

v2:
- Apply correct Signed-off-by to avoid confusion.

Chao-ying Fu (1):
irqchip/mips-gic: Setup defaults in each cluster

Gregory CLEMENT (4):
dt-bindings: mips: cpu: Add property for broken HCI information
MIPS: CPS: Support broken HCI for multicluster
MIPS: mobileye: dts: eyeq6h: Enable cluster support
irqchip: mips-gic: Handle case with cluster without CPU cores

Paul Burton (8):
irqchip/mips-gic: Introduce for_each_online_cpu_gic() irqchip/mips-gic: Support multi-cluster in for_each_online_cpu_gic() irqchip/mips-gic: Multi-cluster support
clocksource: mips-gic-timer: Always use cluster 0 counter as
clocksource
clocksource: mips-gic-timer: Enable counter when CPUs start
MIPS: pm-cps: Use per-CPU variables as per-CPU, not per-core
MIPS: CPS: Introduce struct cluster_boot_config
MIPS: CPS: Boot CPUs in secondary clusters

 .../devicetree/bindings/mips/cpus.yaml        |   6 +
 arch/mips/boot/dts/mobileye/eyeq6h.dtsi       |   1 +
 arch/mips/include/asm/mips-cm.h               |  18 ++
 arch/mips/include/asm/smp-cps.h               |   7 +-
 arch/mips/kernel/asm-offsets.c                |   3 +
 arch/mips/kernel/cps-vec.S                    |  19 +-
 arch/mips/kernel/mips-cm.c                    |   4 +-
 arch/mips/kernel/pm-cps.c                     |  35 +-
 arch/mips/kernel/smp-cps.c                    | 305 +++++++++++++++---
 drivers/clocksource/mips-gic-timer.c          |  45 ++-
 drivers/irqchip/Kconfig                       |   1 +
 drivers/irqchip/irq-mips-gic.c                | 269 ++++++++++++---
 12 files changed, 599 insertions(+), 114 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v8 1/13 irqchip/mips-gic: Introduce for_each_online_cpu_gic()

From: Paul Burton <[email protected]>

Parts of code in the MIPS GIC driver operate on the GIC local register block for each online CPU, accessing each via the GIC's other/redirect register block.

Abstract the process of iterating over online CPUs & configuring the other/redirect region to access their registers through a new for_each_online_cpu_gic() macro.

---
 drivers/irqchip/irq-mips-gic.c | 59 +++++++++++++++++++++++-----------
 1 file changed, 41 insertions(+), 18 deletions(-)
drivers/irqchip/irq-mips-gic.c +41 -18
index 76253e864f23..6c7a7d2f0438 100644
@@ -66,6 +66,44 @@ static struct gic_all_vpes_chip_data {
 	bool	mask;
 } gic_all_vpes_chip_data[GIC_NUM_LOCAL_INTRS];
 
+static int __gic_with_next_online_cpu(int prev)
+{
+	unsigned int cpu;
+
+	/* Discover the next online CPU */
+	cpu = cpumask_next(prev, cpu_online_mask);
+
+	/* If there isn't one, we're done */
+	if (cpu >= nr_cpu_ids)
+		return cpu;
+
+	/*
+	 * Move the access lock to the next CPU's GIC local register block.
+	 *
+	 * Set GIC_VL_OTHER. Since the caller holds gic_lock nothing can
+	 * clobber the written value.
+	 */
+	write_gic_vl_other(mips_cm_vp_id(cpu));
+
+	return cpu;
+}
+
+/**
+ * for_each_online_cpu_gic() - Iterate over online CPUs, access local registers
+ * @cpu: An integer variable to hold the current CPU number
+ * @gic_lock: A pointer to raw spin lock used as a guard
+ *
+ * Iterate over online CPUs & configure the other/redirect register region to
+ * access each CPUs GIC local register block, which can be accessed from the
+ * loop body using read_gic_vo_*() or write_gic_vo_*() accessor functions or
+ * their derivatives.
+ */
+#define for_each_online_cpu_gic(cpu, gic_lock)		\
+	guard(raw_spinlock_irqsave)(gic_lock);		\
+	for ((cpu) = __gic_with_next_online_cpu(-1);	\
+	     (cpu) < nr_cpu_ids;			\
+	     (cpu) = __gic_with_next_online_cpu(cpu))
+
 static void gic_clear_pcpu_masks(unsigned int intr)
 {
 	unsigned int i;
@@ -350,37 +388,27 @@ static struct irq_chip gic_local_irq_controller = {
 static void gic_mask_local_irq_all_vpes(struct irq_data *d)
 {
 	struct gic_all_vpes_chip_data *cd;
-	unsigned long flags;
 	int intr, cpu;
 
 	intr = GIC_HWIRQ_TO_LOCAL(d->hwirq);
 	cd = irq_data_get_irq_chip_data(d);
 	cd->mask = false;
 
-	raw_spin_lock_irqsave(&gic_lock, flags);
-	for_each_online_cpu(cpu) {
-		write_gic_vl_other(mips_cm_vp_id(cpu));
+	for_each_online_cpu_gic(cpu, &gic_lock)
 		write_gic_vo_rmask(BIT(intr));
-	}
-	raw_spin_unlock_irqrestore(&gic_lock, flags);
 }
 
 static void gic_unmask_local_irq_all_vpes(struct irq_data *d)
 {
 	struct gic_all_vpes_chip_data *cd;
-	unsigned long flags;
 	int intr, cpu;
 
 	intr = GIC_HWIRQ_TO_LOCAL(d->hwirq);
 	cd = irq_data_get_irq_chip_data(d);
 	cd->mask = true;
 
-	raw_spin_lock_irqsave(&gic_lock, flags);
-	for_each_online_cpu(cpu) {
-		write_gic_vl_other(mips_cm_vp_id(cpu));
+	for_each_online_cpu_gic(cpu, &gic_lock)
 		write_gic_vo_smask(BIT(intr));
-	}
-	raw_spin_unlock_irqrestore(&gic_lock, flags);
 }
 
 static void gic_all_vpes_irq_cpu_online(void)
@@ -469,7 +497,6 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,
 			      irq_hw_number_t hwirq)
 {
 	struct gic_all_vpes_chip_data *cd;
-	unsigned long flags;
 	unsigned int intr;
 	int err, cpu;
 	u32 map;
@@ -533,12 +560,8 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,
 	if (!gic_local_irq_is_routable(intr))
 		return -EPERM;
 
-	raw_spin_lock_irqsave(&gic_lock, flags);
-	for_each_online_cpu(cpu) {
-		write_gic_vl_other(mips_cm_vp_id(cpu));
+	for_each_online_cpu_gic(cpu, &gic_lock)
 		write_gic_vo_map(mips_gic_vx_map_reg(intr), map);
-	}
-	raw_spin_unlock_irqrestore(&gic_lock, flags);
 
 	return 0;
 }
Signature · 1 line
2.25.1
#3 lore raw

PATCH v8 2/13 irqchip/mips-gic: Support multi-cluster in for_each_online_cpu_gic()

In reply to Aleksandar Rikalo

From: Paul Burton <[email protected]>

Use CM's GCR_CL_REDIRECT register to access registers in remote clusters, so users of gic_with_each_online_cpu() gain support for multi-cluster with no further changes.

---
 drivers/irqchip/irq-mips-gic.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/irqchip/irq-mips-gic.c +7 -0
index 6c7a7d2f0438..29bdfdce2123 100644
@@ -88,6 +88,12 @@ static int __gic_with_next_online_cpu(int prev)
 	return cpu;
 }
 
+static inline void gic_unlock_cluster(void)
+{
+	if (mips_cps_multicluster_cpus())
+		mips_cm_unlock_other();
+}
+
 /**
  * for_each_online_cpu_gic() - Iterate over online CPUs, access local registers
  * @cpu: An integer variable to hold the current CPU number
@@ -102,6 +108,7 @@ static int __gic_with_next_online_cpu(int prev)
 	guard(raw_spinlock_irqsave)(gic_lock);		\
 	for ((cpu) = __gic_with_next_online_cpu(-1);	\
 	     (cpu) < nr_cpu_ids;			\
+	     gic_unlock_cluster(),			\
 	     (cpu) = __gic_with_next_online_cpu(cpu))
 
 static void gic_clear_pcpu_masks(unsigned int intr)
Signature · 1 line
2.25.1
#5 lore raw

PATCH v8 3/13 irqchip/mips-gic: Setup defaults in each cluster

In reply to Aleksandar Rikalo

From: Chao-ying Fu <[email protected]>

In multi-cluster MIPS I6500 systems, there is a GIC per cluster. The default shared interrupt setup configured in gic_of_init() will only apply to the GIC in the cluster containing the boot CPU, leaving the GICs of other clusters unconfigured.

Similarly configure other clusters.

---
 drivers/irqchip/irq-mips-gic.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)
drivers/irqchip/irq-mips-gic.c +24 -6
index 29bdfdce2123..d93a076620c7 100644
@@ -764,7 +764,7 @@ static int gic_cpu_startup(unsigned int cpu)
 static int __init gic_of_init(struct device_node *node,
 			      struct device_node *parent)
 {
-	unsigned int cpu_vec, i, gicconfig;
+	unsigned int cpu_vec, i, gicconfig, cl, nclusters;
 	unsigned long reserved;
 	phys_addr_t gic_base;
 	struct resource res;
@@ -845,11 +845,29 @@ static int __init gic_of_init(struct device_node *node,
 
 	board_bind_eic_interrupt = &gic_bind_eic_interrupt;
 
-	/* Setup defaults */
-	for (i = 0; i < gic_shared_intrs; i++) {
-		change_gic_pol(i, GIC_POL_ACTIVE_HIGH);
-		change_gic_trig(i, GIC_TRIG_LEVEL);
-		write_gic_rmask(i);
+	/*
+	 * Initialise each cluster's GIC shared registers to sane default
+	 * values.
+	 * Otherwise, the IPI set up will be erased if we move code
+	 * to gic_cpu_startup for each cpu.
+	 */
+	nclusters = mips_cps_numclusters();
+	for (cl = 0; cl < nclusters; cl++) {
+		if (cl == cpu_cluster(&current_cpu_data)) {
+			for (i = 0; i < gic_shared_intrs; i++) {
+				change_gic_pol(i, GIC_POL_ACTIVE_HIGH);
+				change_gic_trig(i, GIC_TRIG_LEVEL);
+				write_gic_rmask(i);
+			}
+		} else {
+			mips_cm_lock_other(cl, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL);
+			for (i = 0; i < gic_shared_intrs; i++) {
+				change_gic_redir_pol(i, GIC_POL_ACTIVE_HIGH);
+				change_gic_redir_trig(i, GIC_TRIG_LEVEL);
+				write_gic_redir_rmask(i);
+			}
+			mips_cm_unlock_other();
+		}
 	}
 
 	return cpuhp_setup_state(CPUHP_AP_IRQ_MIPS_GIC_STARTING,
Signature · 1 line
2.25.1
#7 lore raw

PATCH v8 4/13 irqchip/mips-gic: Multi-cluster support

In reply to Aleksandar Rikalo

From: Paul Burton <[email protected]>

The MIPS I6500 CPU & CM (Coherence Manager) 3.5 introduce the concept of multiple clusters to the system. In these systems, each cluster contains its own GIC, so the GIC isn't truly global any longer. Access to registers in the GICs of remote clusters is possible using a redirect register block much like the redirect register blocks provided by the CM & CPC, and configured through the same GCR_REDIRECT register that mips_cm_lock_other() abstraction builds upon.

It is expected that external interrupts are connected identically on all clusters. That is, if there is a device providing an interrupt connected to GIC interrupt pin 0 then it should be connected to pin 0 of every GIC in the system. For the most part, the GIC can be treated as though it is still truly global, so long as interrupts in the cluster are configured properly.

This patch introduces support for such multi-cluster systems in the MIPS GIC irqchip driver. A newly introduced gic_irq_lock_cluster() function allows:

1) Configure access to a GIC in a remote cluster via the redirect register block, using mips_cm_lock_other().

Or:

2) Detect that the interrupt in question is affine to the local cluster and plain old GIC register access to the GIC in the local cluster should be used.

It is possible to access the local cluster's GIC registers via the redirect block, but keeping the special case for them is both good for performance (because we avoid the locking & indirection overhead of using the redirect block) and necessary to maintain compatibility with systems using CM revisions prior to 3.5 which don't support the redirect block.

The gic_irq_lock_cluster() function relies upon an IRQs effective affinity in order to discover which cluster the IRQ is affine to. In order to track this & allow it to be updated at an appropriate point during gic_set_affinity() we select the generic support for effective affinity using CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK.

gic_set_affinity() is the one function which gains much complexity. It now deconfigures routing to any VP(E), ie. CPU, on the old cluster when moving affinity to a new cluster.

gic_shared_irq_domain_map() moves its update of the IRQs effective affinity to before its use of gic_irq_lock_cluster(), to ensure that operation is on the cluster the IRQ is affine to.

The remaining changes are straightforward use of the gic_irq_lock_cluster() function to select between local cluster & remote cluster code-paths when configuring interrupts.

---
 drivers/irqchip/Kconfig        |   1 +
 drivers/irqchip/irq-mips-gic.c | 161 +++++++++++++++++++++++++++++----
 2 files changed, 143 insertions(+), 19 deletions(-)
drivers/irqchip/Kconfig +1 -0
index d82bcab233a1..deaafbfea169 100644
@@ -338,6 +338,7 @@ config KEYSTONE_IRQ
 
 config MIPS_GIC
 	bool
+	select GENERIC_IRQ_EFFECTIVE_AFF_MASK
 	select GENERIC_IRQ_IPI if SMP
 	select IRQ_DOMAIN_HIERARCHY
 	select MIPS_CM
drivers/irqchip/irq-mips-gic.c +142 -19

227 lines not on this page · raw message

Signature · 1 line
2.25.1
#10 lore raw

PATCH v8 5/13 clocksource: mips-gic-timer: Always use cluster 0 counter as clocksource

In reply to Aleksandar Rikalo

From: Paul Burton <[email protected]>

In a multi-cluster MIPS system, there are multiple GICs - one in each cluster - each of which has its independent counter. The counters in each GIC are not synchronized in any way, so they can drift relative to one another through the lifetime of the system. This is problematic for a clock source which ought to be global.

Avoid problems by always accessing cluster 0's counter, using cross-cluster register access. This adds overhead so it is applied only on multi-cluster systems.

---
 drivers/clocksource/mips-gic-timer.c | 39 +++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)
drivers/clocksource/mips-gic-timer.c +38 -1
index 110347707ff9..7907b740497a 100644
@@ -166,6 +166,37 @@ static u64 gic_hpt_read(struct clocksource *cs)
 	return gic_read_count();
 }
 
+static u64 gic_hpt_read_multicluster(struct clocksource *cs)
+{
+	unsigned int hi, hi2, lo;
+	u64 count;
+
+	mips_cm_lock_other(0, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL);
+
+	if (mips_cm_is64) {
+		count = read_gic_redir_counter();
+		goto out;
+	}
+
+	hi = read_gic_redir_counter_32h();
+	while (true) {
+		lo = read_gic_redir_counter_32l();
+
+		/* If hi didn't change then lo didn't wrap & we're done */
+		hi2 = read_gic_redir_counter_32h();
+		if (hi2 == hi)
+			break;
+
+		/* Otherwise, repeat with the latest hi value */
+		hi = hi2;
+	}
+
+	count = (((u64)hi) << 32) + lo;
+out:
+	mips_cm_unlock_other();
+	return count;
+}
+
 static struct clocksource gic_clocksource = {
 	.name			= "GIC",
 	.read			= gic_hpt_read,
@@ -203,6 +234,11 @@ static int __init __gic_clocksource_init(void)
 		gic_clocksource.rating = 200;
 	gic_clocksource.rating += clamp(gic_frequency / 10000000, 0, 99);
 
+	if (mips_cps_multicluster_cpus()) {
+		gic_clocksource.read = &gic_hpt_read_multicluster;
+		gic_clocksource.vdso_clock_mode = VDSO_CLOCKMODE_NONE;
+	}
+
 	ret = clocksource_register_hz(&gic_clocksource, gic_frequency);
 	if (ret < 0)
 		pr_warn("Unable to register clocksource\n");
@@ -261,7 +297,8 @@ static int __init gic_clocksource_of_init(struct device_node *node)
 	 * stable CPU frequency or on the platforms with CM3 and CPU frequency
 	 * change performed by the CPC core clocks divider.
 	 */
-	if (mips_cm_revision() >= CM_REV_CM3 || !IS_ENABLED(CONFIG_CPU_FREQ)) {
+	if ((mips_cm_revision() >= CM_REV_CM3 || !IS_ENABLED(CONFIG_CPU_FREQ)) &&
+	     !mips_cps_multicluster_cpus()) {
 		sched_clock_register(mips_cm_is64 ?
 				     gic_read_count_64 : gic_read_count_2x32,
 				     gic_count_width, gic_frequency);
Signature · 1 line
2.25.1
#11 lore raw

PATCH v8 6/13 clocksource: mips-gic-timer: Enable counter when CPUs start

In reply to Aleksandar Rikalo

From: Paul Burton <[email protected]>

In multi-cluster MIPS I6500 systems there is a GIC in each cluster, each with its own counter. When a cluster powers up the counter will be stopped, with the COUNTSTOP bit set in the GIC_CONFIG register.

In single cluster systems, it has been fine to clear COUNTSTOP once in gic_clocksource_of_init() to start the counter. In multi-cluster systems, this will only have started the counter in the boot cluster, and any CPUs in other clusters will find their counter stopped which will break the GIC clock_event_device.

Resolve this by having CPUs clear the COUNTSTOP bit when they come online, using the existing gic_starting_cpu() CPU hotplug callback. This will allow CPUs in secondary clusters to ensure that the cluster's GIC counter is running as expected.

---
 drivers/clocksource/mips-gic-timer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clocksource/mips-gic-timer.c +3 -3
index 7907b740497a..abb685a080a5 100644
@@ -115,6 +115,9 @@ static void gic_update_frequency(void *data)
 
 static int gic_starting_cpu(unsigned int cpu)
 {
+	/* Ensure the GIC counter is running */
+	clear_gic_config(GIC_CONFIG_COUNTSTOP);
+
 	gic_clockevent_cpu_init(cpu, this_cpu_ptr(&gic_clockevent_device));
 	return 0;
 }
@@ -288,9 +291,6 @@ static int __init gic_clocksource_of_init(struct device_node *node)
 			pr_warn("Unable to register clock notifier\n");
 	}
 
-	/* And finally start the counter */
-	clear_gic_config(GIC_CONFIG_COUNTSTOP);
-
 	/*
 	 * It's safe to use the MIPS GIC timer as a sched clock source only if
 	 * its ticks are stable, which is true on either the platforms with
Signature · 1 line
2.25.1
#12 lore raw

PATCH v8 7/13 MIPS: pm-cps: Use per-CPU variables as per-CPU, not per-core

In reply to Aleksandar Rikalo

From: Paul Burton <[email protected]>

The pm-cps code has up until now used per-CPU variables indexed by core, rather than CPU number, in order to share data amongst sibling CPUs (ie. VPs/threads in a core). This works fine for single cluster systems, but with multi-cluster systems a core number is no longer unique in the system, leading to sharing between CPUs that are not actually siblings.

Avoid this issue by using per-CPU variables as they are more generally used - ie. access them using CPU numbers rather than core numbers. Sharing between siblings is then accomplished by:
- Assigning the same pointer to entries for each sibling CPU for the nc_asm_enter & ready_count variables, which allow this by virtue of being per-CPU pointers.

- Indexing by the first CPU set in a CPUs cpu_sibling_map in the case of pm_barrier, for which we can't use the previous approach because the per-CPU variable is not a pointer.

---
 arch/mips/kernel/pm-cps.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)
arch/mips/kernel/pm-cps.c +17 -13
index d09ca77e624d..9369a8dc385e 100644
@@ -57,10 +57,7 @@ static DEFINE_PER_CPU_ALIGNED(u32*, ready_count);
 /* Indicates online CPUs coupled with the current CPU */
 static DEFINE_PER_CPU_ALIGNED(cpumask_t, online_coupled);
 
-/*
- * Used to synchronize entry to deep idle states. Actually per-core rather
- * than per-CPU.
- */
+/* Used to synchronize entry to deep idle states */
 static DEFINE_PER_CPU_ALIGNED(atomic_t, pm_barrier);
 
 /* Saved CPU state across the CPS_PM_POWER_GATED state */
@@ -112,9 +109,10 @@ int cps_pm_enter_state(enum cps_pm_state state)
 	cps_nc_entry_fn entry;
 	struct core_boot_config *core_cfg;
 	struct vpe_boot_config *vpe_cfg;
+	atomic_t *barrier;
 
 	/* Check that there is an entry function for this state */
-	entry = per_cpu(nc_asm_enter, core)[state];
+	entry = per_cpu(nc_asm_enter, cpu)[state];
 	if (!entry)
 		return -EINVAL;
 
@@ -150,7 +148,7 @@ int cps_pm_enter_state(enum cps_pm_state state)
 	smp_mb__after_atomic();
 
 	/* Create a non-coherent mapping of the core ready_count */
-	core_ready_count = per_cpu(ready_count, core);
+	core_ready_count = per_cpu(ready_count, cpu);
 	nc_addr = kmap_noncoherent(virt_to_page(core_ready_count),
 				   (unsigned long)core_ready_count);
 	nc_addr += ((unsigned long)core_ready_count & ~PAGE_MASK);
@@ -158,7 +156,8 @@ int cps_pm_enter_state(enum cps_pm_state state)
 
 	/* Ensure ready_count is zero-initialised before the assembly runs */
 	WRITE_ONCE(*nc_core_ready_count, 0);
-	coupled_barrier(&per_cpu(pm_barrier, core), online);
+	barrier = &per_cpu(pm_barrier, cpumask_first(&cpu_sibling_map[cpu]));
+	coupled_barrier(barrier, online);
 
 	/* Run the generated entry code */
 	left = entry(online, nc_core_ready_count);
@@ -629,12 +628,14 @@ static void *cps_gen_entry_code(unsigned cpu, enum cps_pm_state state)
 
 static int cps_pm_online_cpu(unsigned int cpu)
 {
-	enum cps_pm_state state;
-	unsigned core = cpu_core(&cpu_data[cpu]);
+	unsigned int sibling, core;
 	void *entry_fn, *core_rc;
+	enum cps_pm_state state;
+
+	core = cpu_core(&cpu_data[cpu]);
 
 	for (state = CPS_PM_NC_WAIT; state < CPS_PM_STATE_COUNT; state++) {
-		if (per_cpu(nc_asm_enter, core)[state])
+		if (per_cpu(nc_asm_enter, cpu)[state])
 			continue;
 		if (!test_bit(state, state_support))
 			continue;
@@ -646,16 +647,19 @@ static int cps_pm_online_cpu(unsigned int cpu)
 			clear_bit(state, state_support);
 		}
 
-		per_cpu(nc_asm_enter, core)[state] = entry_fn;
+		for_each_cpu(sibling, &cpu_sibling_map[cpu])
+			per_cpu(nc_asm_enter, sibling)[state] = entry_fn;
 	}
 
-	if (!per_cpu(ready_count, core)) {
+	if (!per_cpu(ready_count, cpu)) {
 		core_rc = kmalloc(sizeof(u32), GFP_KERNEL);
 		if (!core_rc) {
 			pr_err("Failed allocate core %u ready_count\n", core);
 			return -ENOMEM;
 		}
-		per_cpu(ready_count, core) = core_rc;
+
+		for_each_cpu(sibling, &cpu_sibling_map[cpu])
+			per_cpu(ready_count, sibling) = core_rc;
 	}
 
 	return 0;
Signature · 1 line
2.25.1
#13 lore raw

PATCH v8 8/13 MIPS: CPS: Introduce struct cluster_boot_config

In reply to Aleksandar Rikalo

From: Paul Burton <[email protected]>

In preparation for supporting multi-cluster systems, introduce a struct cluster_boot_config as an extra layer in the boot configuration maintained by the MIPS Coherent Processing System (CPS) SMP implementation. For now only one struct cluster_boot_config will be allocated & we'll simply defererence its core_config field to find the struct core_boot_config array which can be used to boot as usual.

---
 arch/mips/include/asm/smp-cps.h |  6 ++-
 arch/mips/kernel/asm-offsets.c  |  3 ++
 arch/mips/kernel/cps-vec.S      | 19 ++++++--
 arch/mips/kernel/pm-cps.c       |  5 +-
 arch/mips/kernel/smp-cps.c      | 82 +++++++++++++++++++++------------
 5 files changed, 81 insertions(+), 34 deletions(-)
arch/mips/include/asm/smp-cps.h +5 -1
index ab94e50f62b8..a629e948a6fd 100644
@@ -22,7 +22,11 @@ struct core_boot_config {
 	struct vpe_boot_config *vpe_config;
 };
 
-extern struct core_boot_config *mips_cps_core_bootcfg;
+struct cluster_boot_config {
+	struct core_boot_config *core_config;
+};
+
+extern struct cluster_boot_config *mips_cps_cluster_bootcfg;
 
 extern void mips_cps_core_boot(int cca, void __iomem *gcr_base);
 extern void mips_cps_core_init(void);
arch/mips/kernel/asm-offsets.c +3 -0
index cb1045ebab06..b29944160b28 100644
@@ -404,6 +404,9 @@ void output_cps_defines(void)
 {
 	COMMENT(" MIPS CPS offsets. ");
 
+	OFFSET(CLUSTERBOOTCFG_CORECONFIG, cluster_boot_config, core_config);
+	DEFINE(CLUSTERBOOTCFG_SIZE, sizeof(struct cluster_boot_config));
+
 	OFFSET(COREBOOTCFG_VPEMASK, core_boot_config, vpe_mask);
 	OFFSET(COREBOOTCFG_VPECONFIG, core_boot_config, vpe_config);
 	DEFINE(COREBOOTCFG_SIZE, sizeof(struct core_boot_config));
arch/mips/kernel/cps-vec.S +16 -3
index f876309130ad..2ae7034a3d5c 100644
@@ -19,6 +19,10 @@
 #define GCR_CPC_BASE_OFS	0x0088
 #define GCR_CL_COHERENCE_OFS	0x2008
 #define GCR_CL_ID_OFS		0x2028
+#define  CM3_GCR_Cx_ID_CLUSTER_SHF	8
+#define  CM3_GCR_Cx_ID_CLUSTER_MSK	(0xff << 8)
+#define  CM3_GCR_Cx_ID_CORENUM_SHF	0
+#define  CM3_GCR_Cx_ID_CORENUM_MSK	(0xff << 0)
 
 #define CPC_CL_VC_STOP_OFS	0x2020
 #define CPC_CL_VC_RUN_OFS	0x2028
@@ -271,12 +275,21 @@ LEAF(mips_cps_core_init)
  */
 LEAF(mips_cps_get_bootcfg)
 	/* Calculate a pointer to this cores struct core_boot_config */
+	PTR_LA	v0, mips_cps_cluster_bootcfg
+	PTR_L	v0, 0(v0)
 	lw	t0, GCR_CL_ID_OFS(s1)
+#ifdef CONFIG_CPU_MIPSR6
+	ext	t1, t0, CM3_GCR_Cx_ID_CLUSTER_SHF, 8
+	li	t2, CLUSTERBOOTCFG_SIZE
+	mul	t1, t1, t2
+	PTR_ADDU \
+		v0, v0, t1
+#endif
+	PTR_L	v0, CLUSTERBOOTCFG_CORECONFIG(v0)
+	andi	t0, t0, CM3_GCR_Cx_ID_CORENUM_MSK
 	li	t1, COREBOOTCFG_SIZE
 	mul	t0, t0, t1
-	PTR_LA	t1, mips_cps_core_bootcfg
-	PTR_L	t1, 0(t1)
-	PTR_ADDU v0, t0, t1
+	PTR_ADDU v0, v0, t0
 
 	/* Calculate this VPEs ID. If the core doesn't support MT use 0 */
 	li	t9, 0
arch/mips/kernel/pm-cps.c +4 -1
index 9369a8dc385e..3de0e05e0511 100644
@@ -101,12 +101,14 @@ static void coupled_barrier(atomic_t *a, unsigned online)
 int cps_pm_enter_state(enum cps_pm_state state)
 {
 	unsigned cpu = smp_processor_id();
+	unsigned int cluster = cpu_cluster(&current_cpu_data);
 	unsigned core = cpu_core(&current_cpu_data);
 	unsigned online, left;
 	cpumask_t *coupled_mask = this_cpu_ptr(&online_coupled);
 	u32 *core_ready_count, *nc_core_ready_count;
 	void *nc_addr;
 	cps_nc_entry_fn entry;
+	struct cluster_boot_config *cluster_cfg;
 	struct core_boot_config *core_cfg;
 	struct vpe_boot_config *vpe_cfg;
 	atomic_t *barrier;
@@ -136,7 +138,8 @@ int cps_pm_enter_state(enum cps_pm_state state)
 		if (!mips_cps_smp_in_use())
 			return -EINVAL;
 
-		core_cfg = &mips_cps_core_bootcfg[core];
+		cluster_cfg = &mips_cps_cluster_bootcfg[cluster];
+		core_cfg = &cluster_cfg->core_config[core];
 		vpe_cfg = &core_cfg->vpe_config[cpu_vpe_id(&current_cpu_data)];
 		vpe_cfg->pc = (unsigned long)mips_cps_pm_restore;
 		vpe_cfg->gp = (unsigned long)current_thread_info();
arch/mips/kernel/smp-cps.c +53 -29

137 lines not on this page · raw message

Signature · 1 line
2.25.1
#14 lore raw

PATCH v8 9/13 MIPS: CPS: Boot CPUs in secondary clusters

In reply to Aleksandar Rikalo

From: Paul Burton <[email protected]>

Probe for & boot CPUs (cores & VPs) in secondary clusters (ie. not the cluster that began booting Linux) when they are present in systems with CM 3.5 or higher.

---
 arch/mips/include/asm/mips-cm.h |  18 +++
 arch/mips/include/asm/smp-cps.h |   1 +
 arch/mips/kernel/mips-cm.c      |   4 +-
 arch/mips/kernel/smp-cps.c      | 205 ++++++++++++++++++++++++++++----
 4 files changed, 207 insertions(+), 21 deletions(-)
arch/mips/include/asm/mips-cm.h +18 -0
index 1e782275850a..4d47163647dd 100644
@@ -255,6 +255,12 @@ GCR_ACCESSOR_RW(32, 0x130, l2_config)
 GCR_ACCESSOR_RO(32, 0x150, sys_config2)
 #define CM_GCR_SYS_CONFIG2_MAXVPW		GENMASK(3, 0)
 
+/* GCR_L2-RAM_CONFIG - Configuration & status of L2 cache RAMs */
+GCR_ACCESSOR_RW(64, 0x240, l2_ram_config)
+#define CM_GCR_L2_RAM_CONFIG_PRESENT		BIT(31)
+#define CM_GCR_L2_RAM_CONFIG_HCI_DONE		BIT(30)
+#define CM_GCR_L2_RAM_CONFIG_HCI_SUPPORTED	BIT(29)
+
 /* GCR_L2_PFT_CONTROL - Controls hardware L2 prefetching */
 GCR_ACCESSOR_RW(32, 0x300, l2_pft_control)
 #define CM_GCR_L2_PFT_CONTROL_PAGEMASK		GENMASK(31, 12)
@@ -266,6 +272,18 @@ GCR_ACCESSOR_RW(32, 0x308, l2_pft_control_b)
 #define CM_GCR_L2_PFT_CONTROL_B_CEN		BIT(8)
 #define CM_GCR_L2_PFT_CONTROL_B_PORTID		GENMASK(7, 0)
 
+/* GCR_L2_TAG_ADDR - Access addresses in L2 cache tags */
+GCR_ACCESSOR_RW(64, 0x600, l2_tag_addr)
+
+/* GCR_L2_TAG_STATE - Access L2 cache tag state */
+GCR_ACCESSOR_RW(64, 0x608, l2_tag_state)
+
+/* GCR_L2_DATA - Access data in L2 cache lines */
+GCR_ACCESSOR_RW(64, 0x610, l2_data)
+
+/* GCR_L2_ECC - Access ECC information from L2 cache lines */
+GCR_ACCESSOR_RW(64, 0x618, l2_ecc)
+
 /* GCR_L2SM_COP - L2 cache op state machine control */
 GCR_ACCESSOR_RW(32, 0x620, l2sm_cop)
 #define CM_GCR_L2SM_COP_PRESENT			BIT(31)
arch/mips/include/asm/smp-cps.h +1 -0
index a629e948a6fd..10d3ebd890cb 100644
@@ -23,6 +23,7 @@ struct core_boot_config {
 };
 
 struct cluster_boot_config {
+	unsigned long *core_power;
 	struct core_boot_config *core_config;
 };
 
arch/mips/kernel/mips-cm.c +3 -1
index 3eb2cfb893e1..9854bc2b6895 100644
@@ -308,7 +308,9 @@ void mips_cm_lock_other(unsigned int cluster, unsigned int core,
 		      FIELD_PREP(CM3_GCR_Cx_OTHER_VP, vp);
 
 		if (cm_rev >= CM_REV_CM3_5) {
-			val |= CM_GCR_Cx_OTHER_CLUSTER_EN;
+			if (cluster != cpu_cluster(&current_cpu_data))
+				val |= CM_GCR_Cx_OTHER_CLUSTER_EN;
+			val |= CM_GCR_Cx_OTHER_GIC_EN;
 			val |= FIELD_PREP(CM_GCR_Cx_OTHER_CLUSTER, cluster);
 			val |= FIELD_PREP(CM_GCR_Cx_OTHER_BLOCK, block);
 		} else {
arch/mips/kernel/smp-cps.c +185 -20

299 lines not on this page · raw message

Signature · 1 line
2.25.1
#15 lore raw

PATCH v8 10/13 dt-bindings: mips: cpu: Add property for broken HCI information

In reply to Aleksandar Rikalo

From: Gregory CLEMENT <[email protected]>

Some CM3.5 reports show that Hardware Cache Initialization is complete, but in reality it's not the case. They also incorrectly indicate that Hardware Cache Initialization is supported. This optional property allows warning about this broken feature that cannot be detected at runtime.

---
 Documentation/devicetree/bindings/mips/cpus.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/mips/cpus.yaml +6 -0
index a85137add668..57e93c07ab1b 100644
@@ -47,6 +47,12 @@ properties:
   clocks:
     maxItems: 1
 
+  cm3-l2-config-hci-broken:
+    type: boolean
+    description:
+      If present, indicates that the HCI (Hardware Cache Initialization)
+      information for the L2 cache in multi-cluster configuration is broken.
+
   device_type: true
 
 allOf:
Signature · 1 line
2.25.1
#24 lore raw

PATCH v8 11/13 MIPS: CPS: Support broken HCI for multicluster

In reply to Aleksandar Rikalo

From: Gregory CLEMENT <[email protected]>

Some CM3.5 devices incorrectly report that hardware cache initialization has completed, and also claim to support hardware cache initialization when they don't actually do so. This commit fixes this issue by retrieving the correct information from the device tree and allowing the system to bypass the hardware cache initialization step. Instead, it relies on manual operation. As a result, multi-user support is now possible for these CPUs.

---
 arch/mips/kernel/smp-cps.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
arch/mips/kernel/smp-cps.c +21 -1
index 4f344c890a23..265cf52c0dd1 100644
@@ -39,6 +39,7 @@ UASM_L_LA(_not_nmi)
 static uint32_t core_entry_reg;
 static phys_addr_t cps_vec_pa;
 
+static bool l2_hci_broken;
 struct cluster_boot_config *mips_cps_cluster_bootcfg;
 
 static void power_up_other_cluster(unsigned int cluster)
@@ -254,6 +255,22 @@ static void __init cps_smp_setup(void)
 #endif /* CONFIG_MIPS_MT_FPAFF */
 }
 
+static void __init check_hci_quirk(void)
+{
+	struct device_node *np;
+
+	np = of_cpu_device_node_get(0);
+	if (!np) {
+		pr_debug("%s: No cpu node in the device tree\n", __func__);
+		return;
+	}
+
+	if (of_property_read_bool(np, "cm3-l2-config-hci-broken")) {
+		pr_info("HCI (Hardware Cache Init for the L2 cache) in GCR_L2_RAM_CONFIG from the CM3 is broken");
+		l2_hci_broken = true;
+	}
+}
+
 static void __init cps_prepare_cpus(unsigned int max_cpus)
 {
 	unsigned int nclusters, ncores, core_vpes, c, cl, cca;
@@ -307,6 +324,9 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
 					   sizeof(*mips_cps_cluster_bootcfg),
 					   GFP_KERNEL);
 
+	if (nclusters > 1)
+		check_hci_quirk();
+
 	for (cl = 0; cl < nclusters; cl++) {
 		/* Allocate core boot configuration structs */
 		ncores = mips_cps_numcores(cl);
@@ -368,7 +388,7 @@ static void init_cluster_l2(void)
 {
 	u32 l2_cfg, l2sm_cop, result;
 
-	while (1) {
+	while (!l2_hci_broken) {
 		l2_cfg = read_gcr_redir_l2_ram_config();
 
 		/* If HCI is not supported, use the state machine below */
Signature · 1 line
2.25.1
#25 lore raw

PATCH v8 12/13 MIPS: mobileye: dts: eyeq6h: Enable cluster support

In reply to Aleksandar Rikalo

From: Gregory CLEMENT <[email protected]>

The CM3.5 device used in EyeQ6H SoCs incorrectly reports the status for Hardware Cache Initialization (HCI). This commit adds a property to acknowledge this issue, which enables the use of the second CPU cluster.

---
 arch/mips/boot/dts/mobileye/eyeq6h.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/mips/boot/dts/mobileye/eyeq6h.dtsi +1 -0
index 1db3c3cda2e3..4ea85dfd4eed 100644
@@ -18,6 +18,7 @@ cpu@0 {
 			compatible = "img,i6500";
 			reg = <0>;
 			clocks = <&occ_cpu>;
+			cm3-l2-config-hci-broken;
 		};
 	};
 
Signature · 1 line
2.25.1
#26 lore raw

PATCH v8 13/13 irqchip: mips-gic: Handle case with cluster without CPU cores

In reply to Aleksandar Rikalo

From: Gregory CLEMENT <[email protected]>

It is possible to have no CPU cores in a cluster; in such cases, it is not possible to access the GIC, and any indirect access leads to an exception. This patch dynamically skips the indirect access in such situations.

---
 drivers/irqchip/irq-mips-gic.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/irqchip/irq-mips-gic.c +16 -4
index f42f69bbd6fb..bca8053864b2 100644
@@ -141,7 +141,8 @@ static bool gic_irq_lock_cluster(struct irq_data *d)
 	cl = cpu_cluster(&cpu_data[cpu]);
 	if (cl == cpu_cluster(&current_cpu_data))
 		return false;
-
+	if (mips_cps_numcores(cl) == 0)
+		return false;
 	mips_cm_lock_other(cl, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL);
 	return true;
 }
@@ -507,6 +508,9 @@ static void gic_mask_local_irq_all_vpes(struct irq_data *d)
 	struct gic_all_vpes_chip_data *cd;
 	int intr, cpu;
 
+	if (!mips_cps_multicluster_cpus())
+		return;
+
 	intr = GIC_HWIRQ_TO_LOCAL(d->hwirq);
 	cd = irq_data_get_irq_chip_data(d);
 	cd->mask = false;
@@ -520,6 +524,9 @@ static void gic_unmask_local_irq_all_vpes(struct irq_data *d)
 	struct gic_all_vpes_chip_data *cd;
 	int intr, cpu;
 
+	if (!mips_cps_multicluster_cpus())
+		return;
+
 	intr = GIC_HWIRQ_TO_LOCAL(d->hwirq);
 	cd = irq_data_get_irq_chip_data(d);
 	cd->mask = true;
@@ -687,8 +694,10 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,
 	if (!gic_local_irq_is_routable(intr))
 		return -EPERM;
 
-	for_each_online_cpu_gic(cpu, &gic_lock)
-		write_gic_vo_map(mips_gic_vx_map_reg(intr), map);
+	if (mips_cps_multicluster_cpus()) {
+		for_each_online_cpu_gic(cpu, &gic_lock)
+			write_gic_vo_map(mips_gic_vx_map_reg(intr), map);
+	}
 
 	return 0;
 }
@@ -982,7 +991,7 @@ static int __init gic_of_init(struct device_node *node,
 				change_gic_trig(i, GIC_TRIG_LEVEL);
 				write_gic_rmask(i);
 			}
-		} else {
+		} else if (mips_cps_numcores(cl) != 0) {
 			mips_cm_lock_other(cl, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL);
 			for (i = 0; i < gic_shared_intrs; i++) {
 				change_gic_redir_pol(i, GIC_POL_ACTIVE_HIGH);
@@ -990,6 +999,9 @@ static int __init gic_of_init(struct device_node *node,
 				write_gic_redir_rmask(i);
 			}
 			mips_cm_unlock_other();
+
+		} else {
+			pr_warn("No CPU cores on the cluster %d skip it\n", cl);
 		}
 	}
 
Signature · 1 line
2.25.1
#8 lore raw

Re: [PATCH v8 04/13] irqchip/mips-gic: Multi-cluster support

In reply to Aleksandar Rikalo
Quoted 7 lines · Aleksandar Rikalo

+ * In summary, if this function returns true then the caller should access GIC
+ * registers using redirect register block accessors & then call
+ * mips_cm_unlock_other() when done. If this function returns false then the
+ * caller should trivially access GIC registers in the local cluster.
+ *
+ * Returns true if locking performed, else false.
+ */

drivers/irqchip/irq-mips-gic.c static inline void gic_unlock_cluster(void) · line 143

Quoted 10 lines
drivers/irqchip/irq-mips-gic.c +10 -0
+static bool gic_irq_lock_cluster(struct irq_data *d)
+{
+	unsigned int cpu, cl;
+
+	cpu = cpumask_first(irq_data_get_effective_affinity_mask(d));
+	BUG_ON(cpu >= NR_CPUS);
+
+	cl = cpu_cluster(&cpu_data[cpu]);
+	if (cl == cpu_cluster(&current_cpu_data))
+		return false;

Not that I personally care much about the performance of this. But why aren't you caching the cluster or at least the target CPU in irq_data somewhere? cpumask_first() is not cheap on a large system when the cpu is at the very end of the bitmask. AFAICT nothing here uses chip_data, so you can do:

       unsigned long cl = (unsigned long)irq_data_get_irq_chip_data(d);

which is a single load operation and you can update it in the set_affinity() callback and during setup. No?

I'll take the irqchip bits as is if nobody complains within the next days and you can optimize on top if you care.

Thanks,

tglx

#16 lore raw

Re: [PATCH v8 10/13] dt-bindings: mips: cpu: Add property for broken HCI information

In reply to Aleksandar Rikalo
Quoted 8 lines · Aleksandar Rikalo

From: Gregory CLEMENT <[email protected]>

Some CM3.5 reports show that Hardware Cache Initialization is complete, but in reality it's not the case. They also incorrectly indicate that Hardware Cache Initialization is supported. This optional property allows warning about this broken feature that cannot be detected at runtime.

Quoted 7 lines
---
 Documentation/devicetree/bindings/mips/cpus.yaml | 6 ++++++
 1 file changed, 6 insertions(+)

I cannot find this patch in v6, nothing in changelog explaining what happened here.

Documentation/devicetree/bindings/mips/cpus.yaml properties: · line 50

Quoted 9 lines
Documentation/devicetree/bindings/mips/cpus.yaml +1 -0
index a85137add668..57e93c07ab1b 100644
@@ -47,6 +47,12 @@ properties:
   clocks:
     maxItems: 1
 
+  cm3-l2-config-hci-broken:

Are these names - cm3, l2, hci - obvious and known in MIPS? HCI usually means something else - see drivers/bluetooth/ and drivers/nfc/

Is this property applicable for all MIPS vendors? There is no vendor prefix here, so this is generic for this architecture, right?

Best regards,
Krzysztof

#17 lore raw

Re: [PATCH v8 10/13] dt-bindings: mips: cpu: Add property for broken HCI information

Quoted 8 lines · Krzysztof Kozlowski
Quoted 8 lines
Documentation/devicetree/bindings/mips/cpus.yaml +0 -0
index a85137add668..57e93c07ab1b 100644
@@ -47,6 +47,12 @@ properties:
   clocks:
     maxItems: 1
 
Quoted 4 lines

Documentation/devicetree/bindings/mips/cpus.yaml properties: · line 50

Quoted 1 line
Documentation/devicetree/bindings/mips/cpus.yaml +1 -0
+  cm3-l2-config-hci-broken:

Are these names - cm3, l2, hci - obvious and known in MIPS? HCI usually means something else - see drivers/bluetooth/ and drivers/nfc/

I would say yes. At least the name "CM3" (Coherence Manager 3) is common knowledge.
L2 HCI (L2 Hardware Cache Initialization) is a feature of CM3 that is non-functional on some systems.

Quoted 2 lines

Is this property applicable for all MIPS vendors? There is no vendor prefix here, so this is generic for this architecture, right?

I'm honestly not sure if this is something that only one vendor will use. Theoretically, there could be more. Perhaps Gregory CLEMENT can give a more precise answer.

Best Regards,
Aleksandar

maintainer
#18 lore raw

Re: [PATCH v8 10/13] dt-bindings: mips: cpu: Add property for broken HCI information

Hi,

Quoted 20 lines · Krzysztof Kozlowski
Quoted 9 lines
Quoted 9 lines
Documentation/devicetree/bindings/mips/cpus.yaml +0 -0
index a85137add668..57e93c07ab1b 100644
@@ -47,6 +47,12 @@ properties:
   clocks:
     maxItems: 1
 
Quoted 4 lines

Documentation/devicetree/bindings/mips/cpus.yaml properties: · line 50

Quoted 1 line
Documentation/devicetree/bindings/mips/cpus.yaml +1 -0
+  cm3-l2-config-hci-broken:

Are these names - cm3, l2, hci - obvious and known in MIPS? HCI usually means something else - see drivers/bluetooth/ and drivers/nfc/

I would say yes. At least the name "CM3" (Coherence Manager 3) is common knowledge.
L2 HCI (L2 Hardware Cache Initialization) is a feature of CM3 that is non-functional on some systems.

Quoted 6 lines
Quoted 2 lines

Is this property applicable for all MIPS vendors? There is no vendor prefix here, so this is generic for this architecture, right?

I'm honestly not sure if this is something that only one vendor will use. Theoretically, there could be more. Perhaps Gregory CLEMENT can give a more precise answer.

All I know is that this property is needed because of an issue in this CPU designed by Imagination. So, to my knowledge, it is present at least on some Imagination CPUs, but since it is an issue, I think any other MIPS designer could encounter the same problem.

Gregory

Quoted 3 lines

Best Regards,
Aleksandar

Signature · 3 lines
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#19 lore raw

Re: [PATCH v8 10/13] dt-bindings: mips: cpu: Add property for broken HCI information

In reply to Aleksandar Rikalo

在2024年10月29日十月 下午12:21,Aleksandar Rikalo写道:
[...]

Quoted 3 lines
Quoted 3 lines

Is this property applicable for all MIPS vendors? There is no vendor prefix here, so this is generic for this architecture, right?

I'd say the best vendor prefix is mti in this case.

CM3 IP block is supplied by MIPS Technology, it is not a part of MIPS architecture spec.

Thanks

Signature · 1 line
- Jiaxun
#20 lore raw

Re: [PATCH v8 10/13] dt-bindings: mips: cpu: Add property for broken HCI information

Quoted 10 lines · 在2024年10月29日十月 下午4:11,Jiaxun Yang写道:

在2024年10月29日十月 下午12:21,Aleksandar Rikalo写道:
[...]

Quoted 3 lines
Quoted 3 lines

Is this property applicable for all MIPS vendors? There is no vendor prefix here, so this is generic for this architecture, right?

I'd say the best vendor prefix is mti in this case.

CM3 IP block is supplied by MIPS Technology, it is not a part of MIPS architecture spec.

I just tried to revise this problem and I think a better approach would be picking my CM binding [1] patch and add this as a property to CM binding.

You don't need to pick rest of that series, this binding alone is sufficient, and it's already being reviewed.

Thanks
[1]: https://lore.kernel.org/all/[email protected]/

Quoted 4 lines

Thanks

Signature · 1 line
- Jiaxun
Signature · 1 line
- Jiaxun
Tested-by on the v8 series
#28 lore raw
In reply to Aleksandar Rikalo
Quoted 3 lines · 在2024年10月28日十月 下午5:59,Aleksandar Rikalo写道:

Taken from Paul Burton MIPS repo with minor changes from Chao-ying Fu. Tested with 64r6el_defconfig on Boston board in 2 cluster/2 VPU and 1 cluster/4 VPU configurations.

For the whole series (despite pending dt-binding discussion):

Thanks.
- Jiaxun

Quoted 77 lines

v8:
- irqchip: mips-gic: Handle case with cluster without CPU cores.
- Add Tested-by: Gregory CLEMENT <[email protected]> for the
entire series.
- Re-base onto the master branch, with no functionality impact.

v7:
- Add fixes for specific CM3.5 which is used in EyeQ6H SoCs, suggested
by Gregory Clement.
- Re-base onto the master branch, with no functionality impact.

v6:
- Re-base onto the master branch, with no functionality impact.
- Correct the issue reported by the kernel test robot.

v5:
- Drop FDC related changes (patches 12, 13, and 14).
- Apply changes suggested by Thomas Gleixner (patches 3 and 4).
- Add #include <linux/cpumask.h> to patch 1, suggested by Thomas
Bogendoerfer.
- Add Reviewed-by: Philippe Mathieu-Daudé <[email protected]> for the
patch 08/11.
- Add Tested-by: Serge Semin <[email protected]> for the entire
series.
- Correct some commit messages.

v4:
- Re-base onto the master branch, with no functionality impact.
- Refactor MIPS FDC driver in the context of multicluster support.

v3:
- Add Reviewed-by: Jiaxun Yang <[email protected]> for the patch 02/12.
- Add the changes requested by Marc Zyngier for the 3/12 patch.
- Remove the patch 11/12 (a consequence of a discussion between Jiaxun Yang and Marc Zyngier.
- Re-base onto the master branch, with no functionality impact.

v2:
- Apply correct Signed-off-by to avoid confusion.

Chao-ying Fu (1):
irqchip/mips-gic: Setup defaults in each cluster

Gregory CLEMENT (4):
dt-bindings: mips: cpu: Add property for broken HCI information
MIPS: CPS: Support broken HCI for multicluster
MIPS: mobileye: dts: eyeq6h: Enable cluster support
irqchip: mips-gic: Handle case with cluster without CPU cores

Paul Burton (8):
irqchip/mips-gic: Introduce for_each_online_cpu_gic() irqchip/mips-gic: Support multi-cluster in for_each_online_cpu_gic() irqchip/mips-gic: Multi-cluster support
clocksource: mips-gic-timer: Always use cluster 0 counter as
clocksource
clocksource: mips-gic-timer: Enable counter when CPUs start
MIPS: pm-cps: Use per-CPU variables as per-CPU, not per-core
MIPS: CPS: Introduce struct cluster_boot_config
MIPS: CPS: Boot CPUs in secondary clusters

 .../devicetree/bindings/mips/cpus.yaml        |   6 +
 arch/mips/boot/dts/mobileye/eyeq6h.dtsi       |   1 +
 arch/mips/include/asm/mips-cm.h               |  18 ++
 arch/mips/include/asm/smp-cps.h               |   7 +-
 arch/mips/kernel/asm-offsets.c                |   3 +
 arch/mips/kernel/cps-vec.S                    |  19 +-
 arch/mips/kernel/mips-cm.c                    |   4 +-
 arch/mips/kernel/pm-cps.c                     |  35 +-
 arch/mips/kernel/smp-cps.c                    | 305 +++++++++++++++---
 drivers/clocksource/mips-gic-timer.c          |  45 ++-
 drivers/irqchip/Kconfig                       |   1 +
 drivers/irqchip/irq-mips-gic.c                | 269 ++++++++++++---
 12 files changed, 599 insertions(+), 114 deletions(-)
Signature · 1 line
2.25.1
Signature · 1 line
- Jiaxun
merge bot Applied
#9 lore raw

[tip: irq/core] irqchip/mips-gic: Multi-cluster support

In reply to Aleksandar Rikalo
The following commit has been merged into the irq/core branch of tip:

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     322a9063876890895cb8308cc6f59de312e8aad5
Gitweb:        https://git.kernel.org/tip/322a9063876890895cb8308cc6f59de312e8aad5
Author:        Paul Burton <[email protected]>
AuthorDate:    Mon, 28 Oct 2024 18:59:26 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Wed, 30 Oct 2024 15:41:18 +01:00

irqchip/mips-gic: Multi-cluster support

The MIPS I6500 CPU & CM (Coherence Manager) 3.5 introduce the concept of multiple clusters to the system. In these systems, each cluster contains its own GIC, so the GIC isn't truly global any longer. Access to registers in the GICs of remote clusters is possible using a redirect register block much like the redirect register blocks provided by the CM & CPC, and configured through the same GCR_REDIRECT register that mips_cm_lock_other() abstraction builds upon.

It is expected that external interrupts are connected identically on all clusters. That is, if there is a device providing an interrupt connected to GIC interrupt pin 0 then it should be connected to pin 0 of every GIC in the system. For the most part, the GIC can be treated as though it is still truly global, so long as interrupts in the cluster are configured properly.

Introduce support for such multi-cluster systems in the MIPS GIC irqchip driver. A newly introduced gic_irq_lock_cluster() function allows:

1) Configure access to a GIC in a remote cluster via the redirect register block, using mips_cm_lock_other().

Or:

2) Detect that the interrupt in question is affine to the local cluster and plain old GIC register access to the GIC in the local cluster should be used.

It is possible to access the local cluster's GIC registers via the redirect block, but keeping the special case for them is both good for performance (because we avoid the locking & indirection overhead of using the redirect block) and necessary to maintain compatibility with systems using CM revisions prior to 3.5 which don't support the redirect block.

The gic_irq_lock_cluster() function relies upon an IRQs effective affinity in order to discover which cluster the IRQ is affine to. In order to track this & allow it to be updated at an appropriate point during gic_set_affinity() select the generic support for effective affinity using CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK.

gic_set_affinity() is the one function which gains much complexity. It now deconfigures routing to any VP(E), ie. CPU, on the old cluster when moving affinity to a new cluster.

gic_shared_irq_domain_map() moves its update of the IRQs effective affinity to before its use of gic_irq_lock_cluster(), to ensure that operation is on the cluster the IRQ is affine to.

The remaining changes are straightforward use of the gic_irq_lock_cluster() function to select between local cluster & remote cluster code-paths when configuring interrupts.

---
 drivers/irqchip/Kconfig        |   1 +-
 drivers/irqchip/irq-mips-gic.c | 161 ++++++++++++++++++++++++++++----
 2 files changed, 143 insertions(+), 19 deletions(-)
drivers/irqchip/Kconfig +1 -0
index 006a47a..f20adf7 100644
@@ -352,6 +352,7 @@ config KEYSTONE_IRQ
 
 config MIPS_GIC
 	bool
+	select GENERIC_IRQ_EFFECTIVE_AFF_MASK
 	select GENERIC_IRQ_IPI if SMP
 	select IRQ_DOMAIN_HIERARCHY
 	select MIPS_CM
drivers/irqchip/irq-mips-gic.c +142 -19

227 lines not on this page · raw message

#27 lore raw

[tip: irq/core] irqchip/mips-gic: Prevent indirect access to clusters without CPU cores

In reply to Aleksandar Rikalo
The following commit has been merged into the irq/core branch of tip:

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     d1cb1437b785f312d63f447e2e79ff768e7ccc29
Gitweb:        https://git.kernel.org/tip/d1cb1437b785f312d63f447e2e79ff768e7ccc29
Author:        Gregory CLEMENT <[email protected]>
AuthorDate:    Mon, 28 Oct 2024 18:59:35 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Wed, 30 Oct 2024 15:41:32 +01:00

irqchip/mips-gic: Prevent indirect access to clusters without CPU cores

It is possible to have zero CPU cores in a cluster; in such cases, it is not possible to access the GIC, and any indirect access leads to an exception.

Prevent access to such clusters by checking the number of cores in the cluster at all places which issue indirect cluster access.

---
 drivers/irqchip/irq-mips-gic.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/irqchip/irq-mips-gic.c +16 -4
index f42f69b..bca8053 100644
@@ -141,7 +141,8 @@ static bool gic_irq_lock_cluster(struct irq_data *d)
 	cl = cpu_cluster(&cpu_data[cpu]);
 	if (cl == cpu_cluster(&current_cpu_data))
 		return false;
-
+	if (mips_cps_numcores(cl) == 0)
+		return false;
 	mips_cm_lock_other(cl, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL);
 	return true;
 }
@@ -507,6 +508,9 @@ static void gic_mask_local_irq_all_vpes(struct irq_data *d)
 	struct gic_all_vpes_chip_data *cd;
 	int intr, cpu;
 
+	if (!mips_cps_multicluster_cpus())
+		return;
+
 	intr = GIC_HWIRQ_TO_LOCAL(d->hwirq);
 	cd = irq_data_get_irq_chip_data(d);
 	cd->mask = false;
@@ -520,6 +524,9 @@ static void gic_unmask_local_irq_all_vpes(struct irq_data *d)
 	struct gic_all_vpes_chip_data *cd;
 	int intr, cpu;
 
+	if (!mips_cps_multicluster_cpus())
+		return;
+
 	intr = GIC_HWIRQ_TO_LOCAL(d->hwirq);
 	cd = irq_data_get_irq_chip_data(d);
 	cd->mask = true;
@@ -687,8 +694,10 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,
 	if (!gic_local_irq_is_routable(intr))
 		return -EPERM;
 
-	for_each_online_cpu_gic(cpu, &gic_lock)
-		write_gic_vo_map(mips_gic_vx_map_reg(intr), map);
+	if (mips_cps_multicluster_cpus()) {
+		for_each_online_cpu_gic(cpu, &gic_lock)
+			write_gic_vo_map(mips_gic_vx_map_reg(intr), map);
+	}
 
 	return 0;
 }
@@ -982,7 +991,7 @@ static int __init gic_of_init(struct device_node *node,
 				change_gic_trig(i, GIC_TRIG_LEVEL);
 				write_gic_rmask(i);
 			}
-		} else {
+		} else if (mips_cps_numcores(cl) != 0) {
 			mips_cm_lock_other(cl, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL);
 			for (i = 0; i < gic_shared_intrs; i++) {
 				change_gic_redir_pol(i, GIC_POL_ACTIVE_HIGH);
@@ -990,6 +999,9 @@ static int __init gic_of_init(struct device_node *node,
 				write_gic_redir_rmask(i);
 			}
 			mips_cm_unlock_other();
+
+		} else {
+			pr_warn("No CPU cores on the cluster %d skip it\n", cl);
 		}
 	}
 
merge bot Applied
#6 lore raw

[tip: irq/core] irqchip/mips-gic: Setup defaults in each cluster

In reply to Aleksandar Rikalo
The following commit has been merged into the irq/core branch of tip:

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     c7c0d13d1d308b6e2a3d69274b38fca0167081df
Gitweb:        https://git.kernel.org/tip/c7c0d13d1d308b6e2a3d69274b38fca0167081df
Author:        Chao-ying Fu <[email protected]>
AuthorDate:    Mon, 28 Oct 2024 18:59:25 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Wed, 30 Oct 2024 15:41:18 +01:00

irqchip/mips-gic: Setup defaults in each cluster

In multi-cluster MIPS I6500 systems, there is a GIC per cluster.

The default shared interrupt setup configured in gic_of_init() applies only to the GIC in the cluster containing the boot CPU, leaving the GICs of other clusters unconfigured.

Configure the other clusters as well.

---
 drivers/irqchip/irq-mips-gic.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)
drivers/irqchip/irq-mips-gic.c +24 -6
index 29bdfdc..d93a076 100644
@@ -764,7 +764,7 @@ static int gic_cpu_startup(unsigned int cpu)
 static int __init gic_of_init(struct device_node *node,
 			      struct device_node *parent)
 {
-	unsigned int cpu_vec, i, gicconfig;
+	unsigned int cpu_vec, i, gicconfig, cl, nclusters;
 	unsigned long reserved;
 	phys_addr_t gic_base;
 	struct resource res;
@@ -845,11 +845,29 @@ static int __init gic_of_init(struct device_node *node,
 
 	board_bind_eic_interrupt = &gic_bind_eic_interrupt;
 
-	/* Setup defaults */
-	for (i = 0; i < gic_shared_intrs; i++) {
-		change_gic_pol(i, GIC_POL_ACTIVE_HIGH);
-		change_gic_trig(i, GIC_TRIG_LEVEL);
-		write_gic_rmask(i);
+	/*
+	 * Initialise each cluster's GIC shared registers to sane default
+	 * values.
+	 * Otherwise, the IPI set up will be erased if we move code
+	 * to gic_cpu_startup for each cpu.
+	 */
+	nclusters = mips_cps_numclusters();
+	for (cl = 0; cl < nclusters; cl++) {
+		if (cl == cpu_cluster(&current_cpu_data)) {
+			for (i = 0; i < gic_shared_intrs; i++) {
+				change_gic_pol(i, GIC_POL_ACTIVE_HIGH);
+				change_gic_trig(i, GIC_TRIG_LEVEL);
+				write_gic_rmask(i);
+			}
+		} else {
+			mips_cm_lock_other(cl, 0, 0, CM_GCR_Cx_OTHER_BLOCK_GLOBAL);
+			for (i = 0; i < gic_shared_intrs; i++) {
+				change_gic_redir_pol(i, GIC_POL_ACTIVE_HIGH);
+				change_gic_redir_trig(i, GIC_TRIG_LEVEL);
+				write_gic_redir_rmask(i);
+			}
+			mips_cm_unlock_other();
+		}
 	}
 
 	return cpuhp_setup_state(CPUHP_AP_IRQ_MIPS_GIC_STARTING,
merge bot Applied
#4 lore raw

[tip: irq/core] irqchip/mips-gic: Support multi-cluster in for_each_online_cpu_gic()

In reply to Aleksandar Rikalo
The following commit has been merged into the irq/core branch of tip:

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     d9e2ed610a6094534d13ea347c7b7a5bd7ce4ee5
Gitweb:        https://git.kernel.org/tip/d9e2ed610a6094534d13ea347c7b7a5bd7ce4ee5
Author:        Paul Burton <[email protected]>
AuthorDate:    Mon, 28 Oct 2024 18:59:24 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Wed, 30 Oct 2024 15:41:18 +01:00

irqchip/mips-gic: Support multi-cluster in for_each_online_cpu_gic()

Use CM's GCR_CL_REDIRECT register to access registers in remote clusters, so that users of gic_with_each_online_cpu() gains support for multi-cluster without further changes.

---
 drivers/irqchip/irq-mips-gic.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/irqchip/irq-mips-gic.c +7 -0
index 6c7a7d2..29bdfdc 100644
@@ -88,6 +88,12 @@ static int __gic_with_next_online_cpu(int prev)
 	return cpu;
 }
 
+static inline void gic_unlock_cluster(void)
+{
+	if (mips_cps_multicluster_cpus())
+		mips_cm_unlock_other();
+}
+
 /**
  * for_each_online_cpu_gic() - Iterate over online CPUs, access local registers
  * @cpu: An integer variable to hold the current CPU number
@@ -102,6 +108,7 @@ static int __gic_with_next_online_cpu(int prev)
 	guard(raw_spinlock_irqsave)(gic_lock);		\
 	for ((cpu) = __gic_with_next_online_cpu(-1);	\
 	     (cpu) < nr_cpu_ids;			\
+	     gic_unlock_cluster(),			\
 	     (cpu) = __gic_with_next_online_cpu(cpu))
 
 static void gic_clear_pcpu_masks(unsigned int intr)
merge bot Applied
#2 lore raw

[tip: irq/core] irqchip/mips-gic: Replace open coded online CPU iterations

In reply to Aleksandar Rikalo
The following commit has been merged into the irq/core branch of tip:

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     496461050b74d44a2adb39511403a36c9a555bc7
Gitweb:        https://git.kernel.org/tip/496461050b74d44a2adb39511403a36c9a555bc7
Author:        Paul Burton <[email protected]>
AuthorDate:    Mon, 28 Oct 2024 18:59:23 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Wed, 30 Oct 2024 15:41:18 +01:00

irqchip/mips-gic: Replace open coded online CPU iterations

Several places in the MIPS GIC driver iterate over the online CPUs to operate on the CPU's GIC local register block, accessed via the GIC's other/redirect register block.

Abstract the process of iterating over online CPUs & configuring the other/redirect region to access their registers through a new for_each_online_cpu_gic() macro and convert all usage sites over.

---
 drivers/irqchip/irq-mips-gic.c | 59 ++++++++++++++++++++++-----------
 1 file changed, 41 insertions(+), 18 deletions(-)
drivers/irqchip/irq-mips-gic.c +41 -18
index 76253e8..6c7a7d2 100644
@@ -66,6 +66,44 @@ static struct gic_all_vpes_chip_data {
 	bool	mask;
 } gic_all_vpes_chip_data[GIC_NUM_LOCAL_INTRS];
 
+static int __gic_with_next_online_cpu(int prev)
+{
+	unsigned int cpu;
+
+	/* Discover the next online CPU */
+	cpu = cpumask_next(prev, cpu_online_mask);
+
+	/* If there isn't one, we're done */
+	if (cpu >= nr_cpu_ids)
+		return cpu;
+
+	/*
+	 * Move the access lock to the next CPU's GIC local register block.
+	 *
+	 * Set GIC_VL_OTHER. Since the caller holds gic_lock nothing can
+	 * clobber the written value.
+	 */
+	write_gic_vl_other(mips_cm_vp_id(cpu));
+
+	return cpu;
+}
+
+/**
+ * for_each_online_cpu_gic() - Iterate over online CPUs, access local registers
+ * @cpu: An integer variable to hold the current CPU number
+ * @gic_lock: A pointer to raw spin lock used as a guard
+ *
+ * Iterate over online CPUs & configure the other/redirect register region to
+ * access each CPUs GIC local register block, which can be accessed from the
+ * loop body using read_gic_vo_*() or write_gic_vo_*() accessor functions or
+ * their derivatives.
+ */
+#define for_each_online_cpu_gic(cpu, gic_lock)		\
+	guard(raw_spinlock_irqsave)(gic_lock);		\
+	for ((cpu) = __gic_with_next_online_cpu(-1);	\
+	     (cpu) < nr_cpu_ids;			\
+	     (cpu) = __gic_with_next_online_cpu(cpu))
+
 static void gic_clear_pcpu_masks(unsigned int intr)
 {
 	unsigned int i;
@@ -350,37 +388,27 @@ static struct irq_chip gic_local_irq_controller = {
 static void gic_mask_local_irq_all_vpes(struct irq_data *d)
 {
 	struct gic_all_vpes_chip_data *cd;
-	unsigned long flags;
 	int intr, cpu;
 
 	intr = GIC_HWIRQ_TO_LOCAL(d->hwirq);
 	cd = irq_data_get_irq_chip_data(d);
 	cd->mask = false;
 
-	raw_spin_lock_irqsave(&gic_lock, flags);
-	for_each_online_cpu(cpu) {
-		write_gic_vl_other(mips_cm_vp_id(cpu));
+	for_each_online_cpu_gic(cpu, &gic_lock)
 		write_gic_vo_rmask(BIT(intr));
-	}
-	raw_spin_unlock_irqrestore(&gic_lock, flags);
 }
 
 static void gic_unmask_local_irq_all_vpes(struct irq_data *d)
 {
 	struct gic_all_vpes_chip_data *cd;
-	unsigned long flags;
 	int intr, cpu;
 
 	intr = GIC_HWIRQ_TO_LOCAL(d->hwirq);
 	cd = irq_data_get_irq_chip_data(d);
 	cd->mask = true;
 
-	raw_spin_lock_irqsave(&gic_lock, flags);
-	for_each_online_cpu(cpu) {
-		write_gic_vl_other(mips_cm_vp_id(cpu));
+	for_each_online_cpu_gic(cpu, &gic_lock)
 		write_gic_vo_smask(BIT(intr));
-	}
-	raw_spin_unlock_irqrestore(&gic_lock, flags);
 }
 
 static void gic_all_vpes_irq_cpu_online(void)
@@ -469,7 +497,6 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,
 			      irq_hw_number_t hwirq)
 {
 	struct gic_all_vpes_chip_data *cd;
-	unsigned long flags;
 	unsigned int intr;
 	int err, cpu;
 	u32 map;
@@ -533,12 +560,8 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,
 	if (!gic_local_irq_is_routable(intr))
 		return -EPERM;
 
-	raw_spin_lock_irqsave(&gic_lock, flags);
-	for_each_online_cpu(cpu) {
-		write_gic_vl_other(mips_cm_vp_id(cpu));
+	for_each_online_cpu_gic(cpu, &gic_lock)
 		write_gic_vo_map(mips_gic_vx_map_reg(intr), map);
-	}
-	raw_spin_unlock_irqrestore(&gic_lock, flags);
 
 	return 0;
 }
maintainer
#21 lore raw

Re: [PATCH v8 10/13] dt-bindings: mips: cpu: Add property for broken HCI information

In reply to Jiaxun Yang

Hi Jiaxun,

Quoted 15 lines
Quoted 10 lines · 在2024年10月29日十月 下午4:11,Jiaxun Yang写道:

在2024年10月29日十月 下午12:21,Aleksandar Rikalo写道:
[...]

Quoted 3 lines
Quoted 3 lines

Is this property applicable for all MIPS vendors? There is no vendor prefix here, so this is generic for this architecture, right?

I'd say the best vendor prefix is mti in this case.

CM3 IP block is supplied by MIPS Technology, it is not a part of MIPS architecture spec.

I just tried to revise this problem and I think a better approach would be picking my CM binding [1] patch and add this as a property to CM binding.

Quoted 6 lines

You don't need to pick rest of that series, this binding alone is sufficient, and it's already being reviewed.

Thanks
[1]:
https://lore.kernel.org/all/[email protected]/

I had a look at your series and it seems that all the issues raised were solved, so why wasn't it merged?

Regarding the binding in particular: If we add the property "cm3-l2-config-hci-broken", then it should be optional. However, the reg property also should be optional. Indeed, if we can detect the CM address, we shouldn't use a reg property.

If we go in this direction, not only will the binding be modified but also code in arch/mips/kernel/mips-cm.c to handle this new property and manage the case where the reg is not needed. Additionally, we'll need to modify code in arch/mips/kernel/smp-cps.c to retrieve information about the HCI.

I can write a series to illustrate it, if needed.

Gregory

Quoted 7 lines
Quoted 4 lines

Thanks

Signature · 1 line
- Jiaxun
Signature · 1 line
- Jiaxun
Signature · 3 lines
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#22 lore raw

Re: [PATCH v8 10/13] dt-bindings: mips: cpu: Add property for broken HCI information

Quoted 20 lines · Gregory CLEMENT

Hi Jiaxun,

Quoted 18 lines
Quoted 10 lines · 在2024年10月29日十月 下午4:11,Jiaxun Yang写道:

在2024年10月29日十月 下午12:21,Aleksandar Rikalo写道:
[...]

Quoted 3 lines
Quoted 3 lines

Is this property applicable for all MIPS vendors? There is no vendor prefix here, so this is generic for this architecture, right?

I'd say the best vendor prefix is mti in this case.

CM3 IP block is supplied by MIPS Technology, it is not a part of MIPS architecture spec.

I just tried to revise this problem and I think a better approach would be picking my CM binding [1] patch and add this as a property to CM binding.

You don't need to pick rest of that series, this binding alone is sufficient, and it's already being reviewed.

Quoted 6 lines
Quoted 3 lines

Thanks
[1]:
https://lore.kernel.org/all/[email protected]/

I had a look at your series and it seems that all the issues raised were solved, so why wasn't it merged?

https://lore.kernel.org/all/2xkut5pyzk4b4ugl4ku72y4rfqrfsoxj4aww2jwlgkc3lmd464@zwf773fr7fpq/

so it's still unclear to me, whether there is something to fix or not.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#23 lore raw

Re: [PATCH v8 10/13] dt-bindings: mips: cpu: Add property for broken HCI information

Quoted 21 lines · 在2024年10月31日十月 下午2:42,Thomas Bogendoerfer写道:
Quoted 20 lines · Gregory CLEMENT

Hi Jiaxun,

Quoted 18 lines
Quoted 10 lines · 在2024年10月29日十月 下午4:11,Jiaxun Yang写道:

在2024年10月29日十月 下午12:21,Aleksandar Rikalo写道:
[...]

Quoted 3 lines
Quoted 3 lines

Is this property applicable for all MIPS vendors? There is no vendor prefix here, so this is generic for this architecture, right?

I'd say the best vendor prefix is mti in this case.

CM3 IP block is supplied by MIPS Technology, it is not a part of MIPS architecture spec.

I just tried to revise this problem and I think a better approach would be picking my CM binding [1] patch and add this as a property to CM binding.

You don't need to pick rest of that series, this binding alone is sufficient, and it's already being reviewed.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Thanks
[1]:
https://lore.kernel.org/all/[email protected]/

I had a look at your series and it seems that all the issues raised were solved, so why wasn't it merged?

https://lore.kernel.org/all/2xkut5pyzk4b4ugl4ku72y4rfqrfsoxj4aww2jwlgkc3lmd464@zwf773fr7fpq/

Yes this is still pending.

My FPGA boards are constantly breaking down so I’m on radio silence recently.

Sorry for the confusion.

Thanks

Quoted 8 lines

so it's still unclear to me, whether there is something to fix or not.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
Signature · 1 line
- Jiaxun
maintainer Tested-by Serge Semin Tested-by on the v8 series
#30 lore raw
In reply to Aleksandar Rikalo

Hello Aleksandar,

Quoted 3 lines

Taken from Paul Burton MIPS repo with minor changes from Chao-ying Fu. Tested with 64r6el_defconfig on Boston board in 2 cluster/2 VPU and 1 cluster/4 VPU configurations.

I tested your series on top of v6.13, with some patches already merged. Only the patch "[PATCH v8 09/13] MIPS: CPS: Boot CPUs in secondary clusters" encountered a merge issue. You can review the fixed version I created as an attachment.

With the v2 series I sent a few days ago, cluster support continued to work on EyeQ5 and EyeQ6. However, for specific needs requiring support of EyeQ6, I will send a new version that takes into account the feedback received.

Gregory

From 2246af47a5046fb383a071eb9b002a9afc8d6717 Mon Sep 17 00:00:00 2001
From: Paul Burton <[email protected]>
Date: Sat, 19 Oct 2024 09:10:34 +0200
Subject: [PATCH] MIPS: CPS: Boot CPUs in secondary clusters

Probe for & boot CPUs (cores & VPs) in secondary clusters (ie. not the cluster that began booting Linux) when they are present in systems with CM 3.5 or higher.

---
 arch/mips/include/asm/mips-cm.h |  18 +++
 arch/mips/include/asm/smp-cps.h |   1 +
 arch/mips/kernel/mips-cm.c      |   4 +-
 arch/mips/kernel/smp-cps.c      | 205 ++++++++++++++++++++++++++++----
 4 files changed, 207 insertions(+), 21 deletions(-)
arch/mips/include/asm/mips-cm.h +18 -0
index 23ce951f445bb..1afa85db1fb37 100644
@@ -255,6 +255,12 @@ GCR_ACCESSOR_RW(32, 0x130, l2_config)
 GCR_ACCESSOR_RO(32, 0x150, sys_config2)
 #define CM_GCR_SYS_CONFIG2_MAXVPW		GENMASK(3, 0)
 
+/* GCR_L2-RAM_CONFIG - Configuration & status of L2 cache RAMs */
+GCR_ACCESSOR_RW(64, 0x240, l2_ram_config)
+#define CM_GCR_L2_RAM_CONFIG_PRESENT		BIT(31)
+#define CM_GCR_L2_RAM_CONFIG_HCI_DONE		BIT(30)
+#define CM_GCR_L2_RAM_CONFIG_HCI_SUPPORTED	BIT(29)
+
 /* GCR_L2_PFT_CONTROL - Controls hardware L2 prefetching */
 GCR_ACCESSOR_RW(32, 0x300, l2_pft_control)
 #define CM_GCR_L2_PFT_CONTROL_PAGEMASK		GENMASK(31, 12)
@@ -266,6 +272,18 @@ GCR_ACCESSOR_RW(32, 0x308, l2_pft_control_b)
 #define CM_GCR_L2_PFT_CONTROL_B_CEN		BIT(8)
 #define CM_GCR_L2_PFT_CONTROL_B_PORTID		GENMASK(7, 0)
 
+/* GCR_L2_TAG_ADDR - Access addresses in L2 cache tags */
+GCR_ACCESSOR_RW(64, 0x600, l2_tag_addr)
+
+/* GCR_L2_TAG_STATE - Access L2 cache tag state */
+GCR_ACCESSOR_RW(64, 0x608, l2_tag_state)
+
+/* GCR_L2_DATA - Access data in L2 cache lines */
+GCR_ACCESSOR_RW(64, 0x610, l2_data)
+
+/* GCR_L2_ECC - Access ECC information from L2 cache lines */
+GCR_ACCESSOR_RW(64, 0x618, l2_ecc)
+
 /* GCR_L2SM_COP - L2 cache op state machine control */
 GCR_ACCESSOR_RW(32, 0x620, l2sm_cop)
 #define CM_GCR_L2SM_COP_PRESENT			BIT(31)
arch/mips/include/asm/smp-cps.h +1 -0
index a629e948a6fda..10d3ebd890cb2 100644
@@ -23,6 +23,7 @@ struct core_boot_config {
 };
 
 struct cluster_boot_config {
+	unsigned long *core_power;
 	struct core_boot_config *core_config;
 };
 
arch/mips/kernel/mips-cm.c +3 -1
index 3eb2cfb893e19..9854bc2b6895d 100644
@@ -308,7 +308,9 @@ void mips_cm_lock_other(unsigned int cluster, unsigned int core,
 		      FIELD_PREP(CM3_GCR_Cx_OTHER_VP, vp);
 
 		if (cm_rev >= CM_REV_CM3_5) {
-			val |= CM_GCR_Cx_OTHER_CLUSTER_EN;
+			if (cluster != cpu_cluster(&current_cpu_data))
+				val |= CM_GCR_Cx_OTHER_CLUSTER_EN;
+			val |= CM_GCR_Cx_OTHER_GIC_EN;
 			val |= FIELD_PREP(CM_GCR_Cx_OTHER_CLUSTER, cluster);
 			val |= FIELD_PREP(CM_GCR_Cx_OTHER_BLOCK, block);
 		} else {
arch/mips/kernel/smp-cps.c +185 -20

299 lines not on this page · raw message

Signature · 1 line
2.45.2
Quoted 75 lines

v8:
- irqchip: mips-gic: Handle case with cluster without CPU cores.
- Add Tested-by: Gregory CLEMENT <[email protected]> for the entire series.
- Re-base onto the master branch, with no functionality impact.

v7:
- Add fixes for specific CM3.5 which is used in EyeQ6H SoCs, suggested by Gregory Clement.
- Re-base onto the master branch, with no functionality impact.

v6:
- Re-base onto the master branch, with no functionality impact.
- Correct the issue reported by the kernel test robot.

v5:
- Drop FDC related changes (patches 12, 13, and 14).
- Apply changes suggested by Thomas Gleixner (patches 3 and 4).
- Add #include <linux/cpumask.h> to patch 1, suggested by Thomas Bogendoerfer.
- Add Reviewed-by: Philippe Mathieu-Daudé <[email protected]> for the patch 08/11.
- Add Tested-by: Serge Semin <[email protected]> for the entire series.
- Correct some commit messages.

v4:
- Re-base onto the master branch, with no functionality impact.
- Refactor MIPS FDC driver in the context of multicluster support.

v3:
- Add Reviewed-by: Jiaxun Yang <[email protected]> for the patch 02/12.
- Add the changes requested by Marc Zyngier for the 3/12 patch.
- Remove the patch 11/12 (a consequence of a discussion between Jiaxun Yang and Marc Zyngier.
- Re-base onto the master branch, with no functionality impact.

v2:
- Apply correct Signed-off-by to avoid confusion.

Chao-ying Fu (1):
irqchip/mips-gic: Setup defaults in each cluster

Gregory CLEMENT (4):
dt-bindings: mips: cpu: Add property for broken HCI information
MIPS: CPS: Support broken HCI for multicluster
MIPS: mobileye: dts: eyeq6h: Enable cluster support
irqchip: mips-gic: Handle case with cluster without CPU cores

Paul Burton (8):
irqchip/mips-gic: Introduce for_each_online_cpu_gic() irqchip/mips-gic: Support multi-cluster in for_each_online_cpu_gic() irqchip/mips-gic: Multi-cluster support
clocksource: mips-gic-timer: Always use cluster 0 counter as
clocksource
clocksource: mips-gic-timer: Enable counter when CPUs start
MIPS: pm-cps: Use per-CPU variables as per-CPU, not per-core
MIPS: CPS: Introduce struct cluster_boot_config
MIPS: CPS: Boot CPUs in secondary clusters

 .../devicetree/bindings/mips/cpus.yaml        |   6 +
 arch/mips/boot/dts/mobileye/eyeq6h.dtsi       |   1 +
 arch/mips/include/asm/mips-cm.h               |  18 ++
 arch/mips/include/asm/smp-cps.h               |   7 +-
 arch/mips/kernel/asm-offsets.c                |   3 +
 arch/mips/kernel/cps-vec.S                    |  19 +-
 arch/mips/kernel/mips-cm.c                    |   4 +-
 arch/mips/kernel/pm-cps.c                     |  35 +-
 arch/mips/kernel/smp-cps.c                    | 305 +++++++++++++++---
 drivers/clocksource/mips-gic-timer.c          |  45 ++-
 drivers/irqchip/Kconfig                       |   1 +
 drivers/irqchip/irq-mips-gic.c                | 269 ++++++++++++---
 12 files changed, 599 insertions(+), 114 deletions(-)
Signature · 1 line
2.25.1
Signature · 3 lines
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#31 lore raw
Quoted 12 lines · Gregory CLEMENT

Hello Aleksandar,

Quoted 3 lines

Taken from Paul Burton MIPS repo with minor changes from Chao-ying Fu. Tested with 64r6el_defconfig on Boston board in 2 cluster/2 VPU and 1 cluster/4 VPU configurations.

I tested your series on top of v6.13, with some patches already merged. Only the patch "[PATCH v8 09/13] MIPS: CPS: Boot CPUs in secondary clusters" encountered a merge issue. You can review the fixed version I created as an attachment.

Quoted 6 lines

With the v2 series I sent a few days ago, cluster support continued to work on EyeQ5 and EyeQ6. However, for specific needs requiring support of EyeQ6, I will send a new version that takes into account the feedback received.

Gregory

Hello Gregory,

Thank you for your time.

I agree with the change in the attachment. Will you send it to the list or should I do it as a v9 version of the series?

Aleksandar

maintainer
#32 lore raw

Hello Aleksandar,

Quoted 19 lines
Quoted 17 lines · Gregory CLEMENT

Hello Aleksandar,

Quoted 3 lines

Taken from Paul Burton MIPS repo with minor changes from Chao-ying Fu. Tested with 64r6el_defconfig on Boston board in 2 cluster/2 VPU and 1 cluster/4 VPU configurations.

I tested your series on top of v6.13, with some patches already merged. Only the patch "[PATCH v8 09/13] MIPS: CPS: Boot CPUs in secondary clusters" encountered a merge issue. You can review the fixed version I created as an attachment.

With the v2 series I sent a few days ago, cluster support continued to work on EyeQ5 and EyeQ6. However, for specific needs requiring support of EyeQ6, I will send a new version that takes into account the feedback received.

Quoted 8 lines
Quoted 1 line

Gregory

Hello Gregory,

Thank you for your time.

I agree with the change in the attachment. Will you send it to the list or should I do it as a v9 version of the series?

I will let you send a v9 version. Feel free to merge my series [1] with yours, as some of my patches depend on your series.

[1]: https://lore.kernel.org/lkml/[email protected]/

Thanks,

Gregory

Signature · 3 lines
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#33 lore raw

Hello everyone,

The new version, v9, is here:
https://lore.kernel.org/linux-mips/[email protected]/

-- Aleksandar

Quoted 43 lines

Hello Aleksandar,

Quoted 19 lines
Quoted 17 lines · Gregory CLEMENT

Hello Aleksandar,

Quoted 3 lines

Taken from Paul Burton MIPS repo with minor changes from Chao-ying Fu. Tested with 64r6el_defconfig on Boston board in 2 cluster/2 VPU and 1 cluster/4 VPU configurations.

I tested your series on top of v6.13, with some patches already merged. Only the patch "[PATCH v8 09/13] MIPS: CPS: Boot CPUs in secondary clusters" encountered a merge issue. You can review the fixed version I created as an attachment.

With the v2 series I sent a few days ago, cluster support continued to work on EyeQ5 and EyeQ6. However, for specific needs requiring support of EyeQ6, I will send a new version that takes into account the feedback received.

Quoted 8 lines
Quoted 1 line

Gregory

Hello Gregory,

Thank you for your time.

I agree with the change in the attachment. Will you send it to the list or should I do it as a v9 version of the series?

I will let you send a v9 version. Feel free to merge my series [1] with yours, as some of my patches depend on your series.

[1]: https://lore.kernel.org/lkml/[email protected]/

Thanks,

Gregory

--
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com