[PATCH] firmware: arm_ffa: Fix kernel warning about incorrect SRI/NPI

Sudeep Holla sudeep.holla at arm.com
Thu Apr 18 03:29:32 PDT 2024


If the firmware returns incorrect SRI/NRI number, we fail to set it up
in the kernel which is absolutely fine.

However, we don't reset the stashed value of sched_recv or notif_pend
IRQs. When we call ffa_notifications_cleanup() in case of failures to
setup the notifications, we end up calling free_percpu_irq() from
ffa_uninit_pcpu_irq() which results in the following warning:

  |  genirq: Flags mismatch irq 6. 00004401 (ARM-FFA-NPI) vs. 00004400 (IPI)
  |  ARM FF-A: Error registering percpu NPI nIRQ 6 : -16
  |  ARM FF-A: Notification setup failed -16, not enabled
  |  ------------[ cut here ]------------
  |  Trying to free already-free IRQ 6
  |  WARNING: CPU: 2 PID: 1 at kernel/irq/manage.c:2476 __free_percpu_irq+0x6c/0x138
  |  Modules linked in:
  |  CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.9.0-rc3 #211
  |  Hardware name: FVP Base RevC (DT)
  |  pstate: 614000c9 (nZCv daIF +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
  |  pc : __free_percpu_irq+0x6c/0x138
  |  lr : __free_percpu_irq+0x6c/0x138
  |  Call trace:
  |   __free_percpu_irq+0x6c/0x138
  |   free_percpu_irq+0x48/0x84
  |   ffa_notifications_cleanup+0x78/0x164
  |   ffa_notifications_setup+0x368/0x3c0
  |   ffa_init+0x2b4/0x36c
  |   do_one_initcall+0xe0/0x258
  |   do_initcall_level+0x8c/0xac
  |   do_initcalls+0x54/0x94
  |   do_basic_setup+0x1c/0x28
  |   kernel_init_freeable+0x108/0x174
  |   kernel_init+0x20/0x1a4
  |   ret_from_fork+0x10/0x20

Fix the same by resetting the stashed copy of IRQ values to 0 in case
of any failure to set them up properly.

Cc: Jens Wiklander <jens.wiklander at linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla at arm.com>
---
 drivers/firmware/arm_ffa/driver.c | 2 ++
 1 file changed, 2 insertions(+)

Hi,

I just rushed to officially respond to [1] as applied before testing it.
Though this is issue with firmware, it exposed an issue in the cleanup
path in the driver. Currently SPMC in hafnium returns 6 as NPI which is
already used as IPI by the non-secure Linux world.

Regards,
Sudeep

diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 018eddf40ca2..b64e8ee64bc2 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -1435,6 +1435,7 @@ static int ffa_init_pcpu_irq(void)
 		if (ret) {
 			pr_err("Error registering percpu SRI nIRQ %d : %d\n",
 			       drv_info->sched_recv_irq, ret);
+			drv_info->sched_recv_irq = 0;
 			return ret;
 		}
 	}
@@ -1446,6 +1447,7 @@ static int ffa_init_pcpu_irq(void)
 		if (ret) {
 			pr_err("Error registering percpu NPI nIRQ %d : %d\n",
 			       drv_info->notif_pend_irq, ret);
+			drv_info->notif_pend_irq = 0;
 			return ret;
 		}
 	}
-- 
2.43.2




More information about the linux-arm-kernel mailing list