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

commit 453a1b5538e56efc921f497d43a6c32ec00bfa70
Author: hujun5 <[email protected]>
AuthorDate: Wed May 6 19:58:09 2026 +0800

    rptun/bmp: dispatch IRQ enable/disable to CPU0 via cpu_call
    
    On ARM GIC, up_enable_irq()/up_disable_irq() for SGI/PPI interrupts
    is per-CPU -- it only modifies the enable bit on the local core. The
    rptun_bmp doorbell IRQ is routed to CPU0, so the enable/disable must
    happen on CPU0 regardless of which core calls register_callback().
    
    Extract the IRQ enable/disable logic into rptun_bmp_set_irq() and
    use nxsched_cpu_call_single(0, ...) to ensure it always executes on
    CPU0 in SMP configurations. For non-SMP builds, call it directly.
    
    This is an alternative to pinning the rptun worker thread to CPU0,
    only constraining the IRQ operation rather than the full worker.
    
    Signed-off-by: hujun5 <[email protected]>
---
 drivers/rptun/rptun_bmp.c | 36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/rptun/rptun_bmp.c b/drivers/rptun/rptun_bmp.c
index d882a093f3f..c2334e8d94a 100644
--- a/drivers/rptun/rptun_bmp.c
+++ b/drivers/rptun/rptun_bmp.c
@@ -145,16 +145,11 @@ static int rptun_bmp_notify(FAR struct rptun_dev_s *dev, 
uint32_t vqid)
   return 0;
 }
 
-static int rptun_bmp_register_callback(FAR struct rptun_dev_s *dev,
-                                       rptun_callback_t callback,
-                                       FAR void *arg)
+static int rptun_bmp_set_irq(FAR void *arg)
 {
-  FAR struct rptun_bmp_dev_s *priv = (FAR struct rptun_bmp_dev_s *)dev;
-
-  priv->callback = callback;
-  priv->arg      = arg;
+  FAR struct rptun_bmp_dev_s *priv = arg;
 
-  if (callback)
+  if (priv->callback)
     {
       up_enable_irq(priv->irq_event);
     }
@@ -166,6 +161,31 @@ static int rptun_bmp_register_callback(FAR struct 
rptun_dev_s *dev,
   return 0;
 }
 
+static int rptun_bmp_register_callback(FAR struct rptun_dev_s *dev,
+                                       rptun_callback_t callback,
+                                       FAR void *arg)
+{
+  FAR struct rptun_bmp_dev_s *priv = (FAR struct rptun_bmp_dev_s *)dev;
+
+  priv->callback = callback;
+  priv->arg      = arg;
+
+#ifdef CONFIG_SMP
+  /* The doorbell IRQ (SGI/PPI) is routed to CPU0. On ARM GIC,
+   * up_enable_irq/up_disable_irq for per-CPU interrupts only
+   * affects the local core's enable bit. We must ensure the
+   * operation executes on CPU0; use nxsched_cpu_call_single()
+   * to dispatch it if we are running on another core.
+   */
+
+  nxsched_cpu_call_single(0, rptun_bmp_set_irq, priv);
+#else
+  rptun_bmp_set_irq(priv);
+#endif
+
+  return 0;
+}
+
 /****************************************************************************
  * Name: rptun_bmp_interrupt
  *

Reply via email to