arch/xtensa/esp32: Disable the CPU interrupt right when it's alloacted.
At this point we are in a critical section and have all the necessary information to disable the interrupt properly (CPU, and CPU interrupt). Leaving it to the drivers will complicate things as converting from IRQs to CPU interrupts could be tricky in SMP mode. Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
parent
97dca8fe10
commit
5be9f24fe5
@ -221,7 +221,7 @@ static inline void xtensa_disable_all(void)
|
||||
* be allocated from free interrupts within this set
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, the allocated level-sensitive, CPU interrupt numbr is
|
||||
* On success, the allocated level-sensitive, CPU interrupt number is
|
||||
* returned. A negated errno is returned on failure. The only possible
|
||||
* failure is that all level-sensitive CPU interrupts have already been
|
||||
* allocated.
|
||||
@ -236,6 +236,7 @@ static int esp32_alloc_cpuint(uint32_t intmask)
|
||||
uint32_t intset;
|
||||
int cpuint;
|
||||
int ret = -ENOMEM;
|
||||
int cpu = 0;
|
||||
|
||||
/* Check if there are CPU interrupts with the requested properties
|
||||
* available.
|
||||
@ -243,8 +244,9 @@ static int esp32_alloc_cpuint(uint32_t intmask)
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
cpu = up_cpu_index();
|
||||
#ifdef CONFIG_SMP
|
||||
if (this_cpu() != 0)
|
||||
if (cpu != 0)
|
||||
{
|
||||
freeints = &g_cpu1_freeints;
|
||||
}
|
||||
@ -287,6 +289,13 @@ static int esp32_alloc_cpuint(uint32_t intmask)
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure the CPU interrupt is disabled. */
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
xtensa_disable_cpuint(&g_intenable[cpu], (1ul << ret));
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
@ -97,7 +97,6 @@ static inline void xtensa_attach_fromcpu0_interrupt(void)
|
||||
|
||||
/* Connect all CPU peripheral source to allocated CPU interrupt */
|
||||
|
||||
up_disable_irq(cpuint);
|
||||
esp32_attach_peripheral(1, ESP32_PERIPH_CPU_CPU0, cpuint);
|
||||
|
||||
/* Attach the inter-CPU interrupt. */
|
||||
|
@ -2196,7 +2196,6 @@ int esp32_emac_init(void)
|
||||
goto error;
|
||||
}
|
||||
|
||||
up_disable_irq(priv->cpuint);
|
||||
esp32_attach_peripheral(0, ESP32_PERIPH_EMAC, priv->cpuint);
|
||||
|
||||
ret = irq_attach(ESP32_IRQ_EMAC, emac_interrupt, priv);
|
||||
|
@ -421,7 +421,6 @@ void esp32_gpioirqinitialize(void)
|
||||
|
||||
/* Attach the GPIO peripheral to the allocated CPU interrupt */
|
||||
|
||||
up_disable_irq(g_gpio_cpuint);
|
||||
esp32_attach_peripheral(cpu, ESP32_PERIPH_CPU_GPIO, g_gpio_cpuint);
|
||||
|
||||
/* Attach and enable the interrupt handler */
|
||||
|
@ -1567,7 +1567,6 @@ FAR struct i2c_master_s *esp32_i2cbus_initialize(int port)
|
||||
/* Set up to receive peripheral interrupts on the current CPU */
|
||||
|
||||
priv->cpu = up_cpu_index();
|
||||
up_disable_irq(priv->cpuint);
|
||||
esp32_attach_peripheral(priv->cpu, config->periph, priv->cpuint);
|
||||
|
||||
ret = irq_attach(config->irq, esp32_i2c_irq, priv);
|
||||
|
@ -139,7 +139,6 @@ static inline void xtensa_attach_fromcpu1_interrupt(void)
|
||||
|
||||
/* Connect all CPU peripheral source to allocated CPU interrupt */
|
||||
|
||||
up_disable_irq(cpuint);
|
||||
esp32_attach_peripheral(0, ESP32_PERIPH_CPU_CPU1, cpuint);
|
||||
|
||||
/* Attach the inter-CPU interrupt. */
|
||||
|
@ -1029,7 +1029,6 @@ static int esp32_attach(struct uart_dev_s *dev)
|
||||
|
||||
/* Attach the GPIO peripheral to the allocated CPU interrupt */
|
||||
|
||||
up_disable_irq(priv->cpuint);
|
||||
esp32_attach_peripheral(priv->cpu, priv->config->periph,
|
||||
priv->cpuint);
|
||||
|
||||
@ -1158,8 +1157,6 @@ static void dma_attach(uint8_t dma_chan)
|
||||
* and attach and enable the IRQ.
|
||||
*/
|
||||
|
||||
up_disable_irq(dma_cpuint);
|
||||
|
||||
if (dma_chan == 0)
|
||||
{
|
||||
esp32_attach_peripheral(cpu, ESP32_PERIPH_UHCI0, dma_cpuint);
|
||||
|
@ -1474,7 +1474,6 @@ FAR struct spi_dev_s *esp32_spibus_initialize(int port)
|
||||
/* Set up to receive peripheral interrupts on the current CPU */
|
||||
|
||||
priv->cpu = up_cpu_index();
|
||||
up_disable_irq(priv->cpuint);
|
||||
esp32_attach_peripheral(priv->cpu,
|
||||
priv->config->periph,
|
||||
priv->cpuint);
|
||||
|
@ -1307,7 +1307,6 @@ FAR struct spi_slave_ctrlr_s *esp32_spislv_ctrlr_initialize(int port)
|
||||
/* Set up to receive peripheral interrupts on the current CPU */
|
||||
|
||||
priv->cpu = up_cpu_index();
|
||||
up_disable_irq(priv->cpuint);
|
||||
esp32_attach_peripheral(priv->cpu,
|
||||
priv->config->periph,
|
||||
priv->cpuint);
|
||||
|
@ -752,10 +752,6 @@ static int esp32_wdt_setisr(FAR struct esp32_wdt_dev_s *dev, xcpt_t handler,
|
||||
|
||||
wdt->cpu = up_cpu_index();
|
||||
|
||||
/* Disable the provided CPU Interrupt to configure it */
|
||||
|
||||
up_disable_irq(wdt->cpuint);
|
||||
|
||||
/* Attach a peripheral interrupt to the available CPU interrupt in
|
||||
* the current core
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user