You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/08/09 17:01:15 UTC

[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #4304: esp32: Re-organize the interrupt handling process to correctly handle the SMP case

gustavonihei commented on a change in pull request #4304:
URL: https://github.com/apache/incubator-nuttx/pull/4304#discussion_r685367716



##########
File path: arch/xtensa/src/common/xtensa_cpupause.c
##########
@@ -308,4 +395,65 @@ int up_cpu_resume(int cpu)
   return OK;
 }
 
+/****************************************************************************
+ * Name: up_send_irqreq()
+ *
+ * Description:
+ *   Send up_enable_irq() / up_disable_irq() request to the specified cpu
+ *
+ *   This function is called from up_enable_irq() or up_disable_irq()
+ *   to be handled on specified CPU. Locking protocol in the sequence is
+ *   the same as up_pause_cpu() plus up_resume_cpu().
+ *
+ * Input Parameters:
+ *   idx - The request index (0: enable, 1: disable)
+ *   irq - The IRQ number to be handled
+ *   cpu - The index of the CPU which will handle the request
+ *
+ ****************************************************************************/
+
+void up_send_irqreq(int idx, int irq, int cpu)
+{
+  int ret;
+  DEBUGASSERT(cpu >= 0 && cpu < CONFIG_SMP_NCPUS && cpu != this_cpu());
+
+  /* Wait for the spinlocks to be released */
+
+  spin_lock(&g_cpu_wait[cpu]);
+  spin_lock(&g_cpu_paused[cpu]);
+
+  /* Set irq for the cpu */
+
+  g_irq_to_handle[cpu][idx] = irq;
+
+  /* Execute the intercpu interrupt */
+
+  ret = xtensa_intercpu_interrupt(cpu, CPU_INTCODE_NONE);
+  if (ret < 0)
+    {
+      /* What happened?  Unlock the g_cpu_wait spinlock */
+
+      spin_unlock(&g_cpu_wait[cpu]);
+    }
+  else
+    {
+      /* Wait for the other CPU to unlock g_cpu_paused meaning that
+       * it is fully paused and ready for up_cpu_resume();
+       */
+
+      spin_lock(&g_cpu_paused[cpu]);
+    }
+
+  /* Wait for the handler is executed on cpu */
+
+  spin_lock(&g_cpu_paused[cpu]);
+  spin_unlock(&g_cpu_paused[cpu]);
+
+  /* Finally unlock the spinlock to proceed the handler */
+
+  spin_unlock(&g_cpu_wait[cpu]);
+
+  return;

Review comment:
       ```suggestion
   ```
   This may be removed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org