You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2023/10/03 20:51:57 UTC

[nuttx] branch master updated: esp32/irq: Fix erroneous interrupt allocation for each CPU core

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new b8b0ae9238 esp32/irq: Fix erroneous interrupt allocation for each CPU core
b8b0ae9238 is described below

commit b8b0ae9238421b24d2ea9d1a6fba203d92340aad
Author: Tiago Medicci Serrano <ti...@espressif.com>
AuthorDate: Tue Oct 3 11:37:50 2023 -0300

    esp32/irq: Fix erroneous interrupt allocation for each CPU core
    
    When allocating a CPU interrupt, make sure to select the correct
    CPU core to query for it. Simply checking for the current CPU does
    not satisfy this requirement because the CPU allocation thread may
    be executed by the other core: it's necessary to stick with the
    intended CPU passed as an argument of the `esp32_setup_irq`.
---
 arch/xtensa/src/esp32/esp32_irq.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/xtensa/src/esp32/esp32_irq.c b/arch/xtensa/src/esp32/esp32_irq.c
index 2119ad07a1..56938edffb 100644
--- a/arch/xtensa/src/esp32/esp32_irq.c
+++ b/arch/xtensa/src/esp32/esp32_irq.c
@@ -262,6 +262,7 @@ static void esp32_intinfo(int cpu, int periphid,
  *   devices.
  *
  * Input Parameters:
+ *   cpu     - CPU core to query for CPU interrupt candidates
  *   intmask - mask of candidate CPU interrupts.  The CPU interrupt will be
  *             be allocated from free interrupts within this set
  *
@@ -271,20 +272,18 @@ static void esp32_intinfo(int cpu, int periphid,
  *
  ****************************************************************************/
 
-static int esp32_getcpuint(uint32_t intmask)
+static int esp32_getcpuint(int cpu, uint32_t intmask)
 {
   uint32_t *freeints;
   uint32_t bitmask;
   uint32_t intset;
   int cpuint;
   int ret = -ENOMEM;
-  int cpu = 0;
 
   /* Check if there are CPU interrupts with the requested properties
    * available.
    */
 
-  cpu = up_cpu_index();
 #ifdef CONFIG_SMP
   if (cpu != 0)
     {
@@ -348,6 +347,7 @@ static int esp32_getcpuint(uint32_t intmask)
  *   Allocate a level CPU interrupt
  *
  * Input Parameters:
+ *   cpu      - CPU core to query for CPU interrupt candidates
  *   priority - Priority of the CPU interrupt (1-5)
  *   type     - Interrupt type (level or edge).
  *
@@ -359,7 +359,7 @@ static int esp32_getcpuint(uint32_t intmask)
  *
  ****************************************************************************/
 
-static int esp32_alloc_cpuint(int priority, int type)
+static int esp32_alloc_cpuint(int cpu, int priority, int type)
 {
   uint32_t mask;
 
@@ -385,7 +385,7 @@ static int esp32_alloc_cpuint(int priority, int type)
       mask = g_priority[ESP32_PRIO_INDEX(priority)] & ESP32_CPUINT_EDGESET;
     }
 
-  return esp32_getcpuint(mask);
+  return esp32_getcpuint(cpu, mask);
 }
 
 /****************************************************************************
@@ -811,7 +811,7 @@ int esp32_setup_irq(int cpu, int periphid, int priority, int type)
    *    3. Map the CPU interrupt to the IRQ to ease searching later.
    */
 
-  cpuint = esp32_alloc_cpuint(priority, type);
+  cpuint = esp32_alloc_cpuint(cpu, priority, type);
   if (cpuint < 0)
     {
       irqerr("Unable to allocate CPU interrupt for priority=%d and type=%d",