From: Sudeep Holla <sudeep.holla@kernel.org>
To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: Jens Wiklander <jens.wiklander@linaro.org>,
Sudeep Holla <sudeep.holla@kernel.org>
Subject: [PATCH v2 03/11] firmware: arm_ffa: Avoid collapsing NPI work from different CPUs
Date: Tue, 28 Apr 2026 19:33:27 +0100 [thread overview]
Message-ID: <20260428-ffa_fixes-v2-3-8595ae450034@kernel.org> (raw)
In-Reply-To: <20260428-ffa_fixes-v2-0-8595ae450034@kernel.org>
Notification pending interrupts are registered as per-CPU IRQs, but the
driver queues all NPI handling through a single shared work_struct.
That allows queue_work_on() calls from different CPUs to collapse onto a
single pending work item even though the work function uses the CPU it
runs on to fetch and handle per-CPU notifications.
Move notif_pcpu_work into the per-CPU ffa_pcpu_irq state and initialize
one work item per CPU. This keeps NPI handling independent per CPU and
avoids losing notifications when multiple CPUs queue work concurrently.
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
---
drivers/firmware/arm_ffa/driver.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index e6a051b20cb7..4e66c7325a4e 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -87,6 +87,7 @@ static inline int ffa_to_linux_errno(int errno)
struct ffa_pcpu_irq {
struct ffa_drv_info *info;
+ struct work_struct notif_pcpu_work;
};
struct ffa_drv_info {
@@ -106,7 +107,6 @@ struct ffa_drv_info {
unsigned int cpuhp_state;
struct ffa_pcpu_irq __percpu *irq_pcpu;
struct workqueue_struct *notif_pcpu_wq;
- struct work_struct notif_pcpu_work;
struct work_struct sched_recv_irq_work;
struct xarray partition_info;
DECLARE_HASHTABLE(notifier_hash, ilog2(FFA_MAX_NOTIFICATIONS));
@@ -1539,8 +1539,9 @@ ffa_self_notif_handle(u16 vcpu, bool is_per_vcpu, void *cb_data)
static void notif_pcpu_irq_work_fn(struct work_struct *work)
{
- struct ffa_drv_info *info = container_of(work, struct ffa_drv_info,
+ struct ffa_pcpu_irq *pcpu = container_of(work, struct ffa_pcpu_irq,
notif_pcpu_work);
+ struct ffa_drv_info *info = pcpu->info;
ffa_self_notif_handle(smp_processor_id(), true, info);
}
@@ -1811,7 +1812,7 @@ static irqreturn_t notif_pend_irq_handler(int irq, void *irq_data)
struct ffa_drv_info *info = pcpu->info;
queue_work_on(smp_processor_id(), info->notif_pcpu_wq,
- &info->notif_pcpu_work);
+ &pcpu->notif_pcpu_work);
return IRQ_HANDLED;
}
@@ -1928,8 +1929,11 @@ static int ffa_init_pcpu_irq(void)
if (!irq_pcpu)
return -ENOMEM;
- for_each_present_cpu(cpu)
+ for_each_present_cpu(cpu) {
per_cpu_ptr(irq_pcpu, cpu)->info = drv_info;
+ INIT_WORK(&per_cpu_ptr(irq_pcpu, cpu)->notif_pcpu_work,
+ notif_pcpu_irq_work_fn);
+ }
drv_info->irq_pcpu = irq_pcpu;
@@ -1958,7 +1962,6 @@ static int ffa_init_pcpu_irq(void)
}
INIT_WORK(&drv_info->sched_recv_irq_work, ffa_sched_recv_irq_work_fn);
- INIT_WORK(&drv_info->notif_pcpu_work, notif_pcpu_irq_work_fn);
drv_info->notif_pcpu_wq = create_workqueue("ffa_pcpu_irq_notification");
if (!drv_info->notif_pcpu_wq)
return -EINVAL;
--
2.43.0
next prev parent reply other threads:[~2026-04-28 18:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 18:33 [PATCH v2 00/11] firmware: arm_ffa: Fix cleanup, notification, and discovery paths Sudeep Holla
2026-04-28 18:33 ` [PATCH v2 01/11] firmware: arm_ffa: Check for NULL FF-A ID table while driver registration Sudeep Holla
2026-04-28 18:33 ` [PATCH v2 02/11] firmware: arm_ffa: Skip free_pages on RX buffer alloc failure Sudeep Holla
2026-04-28 18:33 ` Sudeep Holla [this message]
2026-04-28 18:33 ` [PATCH v2 04/11] firmware: arm_ffa: Fix per-vcpu self notifications handling in workqueue Sudeep Holla
2026-04-28 18:33 ` [PATCH v2 05/11] firmware: arm_ffa: Unregister bus notifier on teardown for FF-A v1.0 Sudeep Holla
2026-04-28 18:33 ` [PATCH v2 06/11] firmware: arm_ffa: Bound PARTITION_INFO_GET_REGS copies Sudeep Holla
2026-04-28 18:33 ` [PATCH v2 07/11] firmware: arm_ffa: Keep framework RX release under lock Sudeep Holla
2026-04-28 18:33 ` [PATCH v2 08/11] firmware: arm_ffa: Validate framework notification message layout Sudeep Holla
2026-04-28 18:33 ` [PATCH v2 09/11] firmware: arm_ffa: Align RxTx buffer size before mapping Sudeep Holla
2026-04-28 18:33 ` [PATCH v2 10/11] firmware: arm_ffa: Snapshot notifier callbacks under lock Sudeep Holla
2026-04-28 18:33 ` [PATCH v2 11/11] firmware: arm_ffa: Fix sched-recv callback partition lookup Sudeep Holla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260428-ffa_fixes-v2-3-8595ae450034@kernel.org \
--to=sudeep.holla@kernel.org \
--cc=jens.wiklander@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox