diff mbox series

[RESEND,3/3] irqchip/apple-aic: Add a new "Global fast IPIs only" feature level

Message ID 20240829110436.46052-4-towinchenmi@gmail.com (mailing list archive)
State Superseded, archived
Headers show
Series Add AIC support for A7-A11 SoCs | expand

Commit Message

Nick Chan Aug. 29, 2024, 11:02 a.m. UTC
Starting with the A11 (T8015) SoC, Apple began using arm64 sysregs for
fast IPIs. However, on A11, there is no such things as "Local" fast IPIs,
as the SYS_IMP_APL_IPI_RR_LOCAL_EL1 register does not seem to exist.

Add a new feature level, used by the compatible "apple,t8015-aic",
controlled by a static branch key named use_local_fast_ipi. When
use_fast_ipi is true and use_local_fast_ipi is false, fast IPIs are used
but all IPIs goes through the register SYS_IMP_APL_IPI_RR_GLOBAL_EL1, as
"global" IPIs.

Signed-off-by: Nick Chan <towinchenmi@gmail.com>
---
 drivers/irqchip/irq-apple-aic.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

Comments

Thomas Gleixner Aug. 29, 2024, 1:12 p.m. UTC | #1
On Thu, Aug 29 2024 at 19:02, Nick Chan wrote:
>  
> +	if (irqc->info.local_fast_ipi)
> +		static_branch_enable(&use_local_fast_ipi);
> +	else
> +		static_branch_disable(&use_local_fast_ipi);

As you define the key to be true by default there is no point to enable
the branch some more. Copy & pasta ...

Thanks,

        tglx
Nick Chan Aug. 29, 2024, 2:06 p.m. UTC | #2
On 29/8/2024 19:02, Nick Chan wrote:
> Starting with the A11 (T8015) SoC, Apple began using arm64 sysregs for
> fast IPIs. However, on A11, there is no such things as "Local" fast IPIs,
> as the SYS_IMP_APL_IPI_RR_LOCAL_EL1 register does not seem to exist.
> 
> Add a new feature level, used by the compatible "apple,t8015-aic",
> controlled by a static branch key named use_local_fast_ipi. When
> use_fast_ipi is true and use_local_fast_ipi is false, fast IPIs are used
> but all IPIs goes through the register SYS_IMP_APL_IPI_RR_GLOBAL_EL1, as
> "global" IPIs.
> 
> Signed-off-by: Nick Chan <towinchenmi@gmail.com>
> ---
>  drivers/irqchip/irq-apple-aic.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c
> index 626aaeafa96c..1640074af2e1 100644
> --- a/drivers/irqchip/irq-apple-aic.c
> +++ b/drivers/irqchip/irq-apple-aic.c
> @@ -236,6 +236,8 @@ enum fiq_hwirq {
>  
>  /* True if UNCORE/UNCORE2 and Sn_... IPI registers are present and used (A11+) */
>  static DEFINE_STATIC_KEY_TRUE(use_fast_ipi);
> +/* True if SYS_IMP_APL_IPI_RR_LOCAL_EL1 exists (M1+) */
> +static DEFINE_STATIC_KEY_TRUE(use_local_fast_ipi);
>  
>  struct aic_info {
>  	int version;
> @@ -253,6 +255,7 @@ struct aic_info {
>  
>  	/* Features */
>  	bool fast_ipi;
> +	bool local_fast_ipi;
>  };
>  
>  static const struct aic_info aic1_info __initconst = {
> @@ -271,6 +274,16 @@ static const struct aic_info aic1_fipi_info __initconst = {
>  	.fast_ipi	= true,
>  };
>  
> +static const struct aic_info aic1_local_fipi_info __initconst = {
> +	.version	= 1,
> +
> +	.event		= AIC_EVENT,
> +	.target_cpu	= AIC_TARGET_CPU,
> +
> +	.fast_ipi	= true,
> +	.local_fast_ipi = true,
> +};
> +
>  static const struct aic_info aic2_info __initconst = {
This patch is incorrectly disabling local fast IPI on aic2, it will be
corrected in v2.

>  	.version	= 2,
>  
> @@ -282,6 +295,10 @@ static const struct aic_info aic2_info __initconst = {
>  static const struct of_device_id aic_info_match[] = {
>  	{
>  		.compatible = "apple,t8103-aic",
> +		.data = &aic1_local_fipi_info,
> +	},
> +	{
> +		.compatible = "apple,t8015-aic",
>  		.data = &aic1_fipi_info,
>  	},
>  	{
> @@ -748,7 +765,8 @@ static void aic_ipi_send_fast(int cpu)
>  	u64 cluster = MPIDR_CLUSTER(mpidr);
>  	u64 idx = MPIDR_CPU(mpidr);
>  
> -	if (MPIDR_CLUSTER(my_mpidr) == cluster)
> +	if (static_branch_likely(&use_local_fast_ipi) &&
> +	    MPIDR_CLUSTER(my_mpidr) == cluster)
>  		write_sysreg_s(FIELD_PREP(IPI_RR_CPU, idx),
>  			       SYS_IMP_APL_IPI_RR_LOCAL_EL1);
>  	else
> @@ -992,6 +1010,11 @@ static int __init aic_of_ic_init(struct device_node *node, struct device_node *p
>  	else
>  		static_branch_disable(&use_fast_ipi);
>  
> +	if (irqc->info.local_fast_ipi)
> +		static_branch_enable(&use_local_fast_ipi);
> +	else
> +		static_branch_disable(&use_local_fast_ipi);
> +
>  	irqc->info.die_stride = off - start_off;
>  
>  	irqc->hw_domain = irq_domain_create_tree(of_node_to_fwnode(node),

Nick Chan
diff mbox series

Patch

diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c
index 626aaeafa96c..1640074af2e1 100644
--- a/drivers/irqchip/irq-apple-aic.c
+++ b/drivers/irqchip/irq-apple-aic.c
@@ -236,6 +236,8 @@  enum fiq_hwirq {
 
 /* True if UNCORE/UNCORE2 and Sn_... IPI registers are present and used (A11+) */
 static DEFINE_STATIC_KEY_TRUE(use_fast_ipi);
+/* True if SYS_IMP_APL_IPI_RR_LOCAL_EL1 exists (M1+) */
+static DEFINE_STATIC_KEY_TRUE(use_local_fast_ipi);
 
 struct aic_info {
 	int version;
@@ -253,6 +255,7 @@  struct aic_info {
 
 	/* Features */
 	bool fast_ipi;
+	bool local_fast_ipi;
 };
 
 static const struct aic_info aic1_info __initconst = {
@@ -271,6 +274,16 @@  static const struct aic_info aic1_fipi_info __initconst = {
 	.fast_ipi	= true,
 };
 
+static const struct aic_info aic1_local_fipi_info __initconst = {
+	.version	= 1,
+
+	.event		= AIC_EVENT,
+	.target_cpu	= AIC_TARGET_CPU,
+
+	.fast_ipi	= true,
+	.local_fast_ipi = true,
+};
+
 static const struct aic_info aic2_info __initconst = {
 	.version	= 2,
 
@@ -282,6 +295,10 @@  static const struct aic_info aic2_info __initconst = {
 static const struct of_device_id aic_info_match[] = {
 	{
 		.compatible = "apple,t8103-aic",
+		.data = &aic1_local_fipi_info,
+	},
+	{
+		.compatible = "apple,t8015-aic",
 		.data = &aic1_fipi_info,
 	},
 	{
@@ -748,7 +765,8 @@  static void aic_ipi_send_fast(int cpu)
 	u64 cluster = MPIDR_CLUSTER(mpidr);
 	u64 idx = MPIDR_CPU(mpidr);
 
-	if (MPIDR_CLUSTER(my_mpidr) == cluster)
+	if (static_branch_likely(&use_local_fast_ipi) &&
+	    MPIDR_CLUSTER(my_mpidr) == cluster)
 		write_sysreg_s(FIELD_PREP(IPI_RR_CPU, idx),
 			       SYS_IMP_APL_IPI_RR_LOCAL_EL1);
 	else
@@ -992,6 +1010,11 @@  static int __init aic_of_ic_init(struct device_node *node, struct device_node *p
 	else
 		static_branch_disable(&use_fast_ipi);
 
+	if (irqc->info.local_fast_ipi)
+		static_branch_enable(&use_local_fast_ipi);
+	else
+		static_branch_disable(&use_local_fast_ipi);
+
 	irqc->info.die_stride = off - start_off;
 
 	irqc->hw_domain = irq_domain_create_tree(of_node_to_fwnode(node),