This is an automated email from the ASF dual-hosted git repository.
GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new fc8039db077 arch/arm64: gicv2: implement up_trigger_irq
fc8039db077 is described below
commit fc8039db077f238e7cb02eb70f4a18696f66b66a
Author: lipengfei28 <[email protected]>
AuthorDate: Wed Dec 25 16:49:02 2024 +0800
arch/arm64: gicv2: implement up_trigger_irq
Replace the GICv2-private arm_cpu_sgi() and arm64_gic_raise_sgi()
helpers with the generic up_trigger_irq() entry point already used by
the other architectures, so that the GICv2 and GICv3 back ends expose
the same SMP call interface.
Both SGI and ordinary IRQ triggering go through one function now:
SGIs are issued via ICC_SGIR, and non-SGI interrupts are made pending
through the distributor ISPENDR register.
Signed-off-by: lipengfei28 <[email protected]>
---
arch/arm64/src/common/arm64_gicv2.c | 144 ++++++++++++----------------------
arch/arm64/src/common/arm64_smpcall.c | 2 +-
2 files changed, 51 insertions(+), 95 deletions(-)
diff --git a/arch/arm64/src/common/arm64_gicv2.c
b/arch/arm64/src/common/arm64_gicv2.c
index 169800167ac..abddfdc12c3 100644
--- a/arch/arm64/src/common/arm64_gicv2.c
+++ b/arch/arm64/src/common/arm64_gicv2.c
@@ -702,57 +702,6 @@ void up_secure_irq_all(bool secure)
* Private Functions
****************************************************************************/
-/****************************************************************************
- * Name: arm_cpu_sgi
- *
- * Description:
- * Perform a Software Generated Interrupt (SGI). If CONFIG_SMP is
- * selected, then the SGI is sent to all CPUs specified in the CPU set.
- * That set may include the current CPU.
- *
- * If CONFIG_SMP is not selected, the cpuset is ignored and SGI is sent
- * only to the current CPU.
- *
- * Input Parameters:
- * sgi - The SGI interrupt ID (0-15)
- * cpuset - The set of CPUs to receive the SGI
- *
- * Returned Value:
- * OK is always returned at present.
- *
- ****************************************************************************/
-
-static inline void arm_cpu_sgi(int sgi, unsigned int cpuset)
-{
- uint32_t regval;
-
-#ifdef CONFIG_SMP
- regval = GIC_ICDSGIR_INTID(sgi) | GIC_ICDSGIR_CPUTARGET(cpuset) |
- GIC_ICDSGIR_TGTFILTER_LIST;
-#else
- regval = GIC_ICDSGIR_INTID(sgi) | GIC_ICDSGIR_CPUTARGET(0) |
- GIC_ICDSGIR_TGTFILTER_THIS;
-#endif
-
-#if defined(CONFIG_ARCH_TRUSTZONE_SECURE)
- if (sgi >= GIC_IRQ_SGI0 && sgi <= GIC_IRQ_SGI7)
-#endif
- {
- /* Set NSATT be 1: forward the SGI specified in the SGIINTID field to a
- * specified CPU interfaces only if the SGI is configured as Group 1 on
- * that interface.
- * For non-secure context, the configuration of GIC_ICDSGIR_NSATT_GRP1
- * is not mandatory in the GICv2 specification, but for SMP scenarios,
- * this value needs to be configured, otherwise issues may occur in the
- * SMP scenario.
- */
-
- regval |= GIC_ICDSGIR_NSATT_GRP1;
- }
-
- putreg32(regval, GIC_ICDSGIR);
-}
-
/****************************************************************************
* Name: gic_validate_dist_version
*
@@ -1273,42 +1222,6 @@ void up_affinity_irq(int irq, cpu_set_t cpuset)
}
}
-/****************************************************************************
- * Name: up_trigger_irq
- *
- * Description:
- * Perform a Software Generated Interrupt (SGI). If CONFIG_SMP is
- * selected, then the SGI is sent to all CPUs specified in the CPU set.
- * That set may include the current CPU.
- *
- * If CONFIG_SMP is not selected, the cpuset is ignored and SGI is sent
- * only to the current CPU.
- *
- * Input Parameters
- * irq - The SGI interrupt ID (0-15)
- * cpuset - The set of CPUs to receive the SGI
- *
- ****************************************************************************/
-
-void up_trigger_irq(int irq, cpu_set_t cpuset)
-{
- if (irq >= 0 && irq <= GIC_IRQ_SGI15)
- {
- arm_cpu_sgi(irq, cpuset);
- }
- else if (irq >= 0 && irq < NR_IRQS)
- {
- uintptr_t regaddr;
-
- /* Write '1' to the corresponding bit in the distributor Interrupt
- * Set-Pending (ICDISPR)
- */
-
- regaddr = GIC_ICDISPR(irq);
- putreg32(GIC_ICDISPR_INT(irq), regaddr);
- }
-}
-
/****************************************************************************
* Name: up_set_irq_type
*
@@ -1430,23 +1343,66 @@ void arm64_gic_secondary_init(void)
}
/****************************************************************************
- * Name: arm64_gic_raise_sgi
+ * Name: up_trigger_irq
*
* Description:
- * Raise software generated interrupt to the target
+ * Perform a Software Generated Interrupt (SGI). If CONFIG_SMP is
+ * selected, then the SGI is sent to all CPUs specified in the CPU set.
+ * That set may include the current CPU.
*
- * Input Parameters
- * sgi - The SGI interrupt ID (0-15)
+ * If CONFIG_SMP is not selected, the cpuset is ignored and SGI is sent
+ * only to the current CPU.
+ *
+ * Input Parameters:
+ * irq - The SGI interrupt ID (0-15)
* cpuset - The set of CPUs to receive the SGI
*
* Returned Value:
- * None
+ * OK is always returned at present.
*
****************************************************************************/
-void arm64_gic_raise_sgi(unsigned int sgi, uint16_t cpuset)
+void up_trigger_irq(int irq, cpu_set_t cpuset)
{
- arm_cpu_sgi(sgi, cpuset);
+ uint32_t regval;
+
+ if (irq >= 0 && irq <= GIC_IRQ_SGI15)
+ {
+#ifdef CONFIG_SMP
+ regval = GIC_ICDSGIR_INTID(irq) | GIC_ICDSGIR_CPUTARGET(cpuset) |
+ GIC_ICDSGIR_TGTFILTER_LIST;
+#else
+ regval = GIC_ICDSGIR_INTID(irq) | GIC_ICDSGIR_CPUTARGET(0) |
+ GIC_ICDSGIR_TGTFILTER_THIS;
+#endif
+
+#if defined(CONFIG_ARCH_TRUSTZONE_SECURE)
+ if (irq >= GIC_IRQ_SGI0 && irq <= GIC_IRQ_SGI7)
+#endif
+ {
+ /* Set NSATT be 1: forward the SGI specified in the SGIINTID field
+ * to a specified CPU interfaces only if the SGI is configured as
+ * Group 1 on that interface.
+ * For non-secure context, the configuration of
+ * GIC_ICDSGIR_NSATT_GRP1 is not mandatory in the GICv2
+ * specification, but for SMP scenarios,
+ * this value needs to be configured, otherwise issues may occur
+ * in the SMP scenario.
+ */
+
+ regval |= GIC_ICDSGIR_NSATT_GRP1;
+ }
+
+ putreg32(regval, GIC_ICDSGIR);
+ }
+ else if (irq >= 0 && irq < NR_IRQS)
+ {
+ /* Write '1' to the corresponding bit in the distributor Interrupt
+ * Set-Pending (ICDISPR)
+ */
+
+ putreg32(GIC_ICDISPR_INT(irq), GIC_ICDISPR(irq));
+ }
}
#endif /* CONFIG_SMP */
diff --git a/arch/arm64/src/common/arm64_smpcall.c
b/arch/arm64/src/common/arm64_smpcall.c
index 11e95658cd3..fdd6fe0a727 100644
--- a/arch/arm64/src/common/arm64_smpcall.c
+++ b/arch/arm64/src/common/arm64_smpcall.c
@@ -96,7 +96,7 @@ int up_send_smp_sched(int cpu)
{
/* Execute SGI2 */
- arm64_gic_raise_sgi(GIC_SMP_SCHED, (1 << cpu));
+ up_trigger_irq(GIC_SMP_SCHED, (1 << cpu));
return OK;
}