Revert "Use small lock to protect resources related to irq in arch avr, hc, mips and or1k."

This reverts commit bed3bd0852.
This commit is contained in:
Xiang Xiao
2025-02-06 23:01:45 +08:00
committed by archer
parent 96093574fc
commit 9e687ca896
6 changed files with 28 additions and 55 deletions
+3 -7
View File
@@ -33,7 +33,7 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/spinlock.h>
#include <nuttx/irq.h>
#include "avr_internal.h"
#include "irq/irq.h"
@@ -60,10 +60,6 @@ struct g_gpiohandler_s
static struct g_gpiohandler_s g_gpiohandler[NR_GPIO_IRQS];
/* Spinlock */
static spinlock_t g_gpioirq_lock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -332,7 +328,7 @@ int gpio_irqattach(int irq, xcpt_t handler, void *arg)
* to the unexpected interrupt handler.
*/
flags = spin_lock_irqsave(&g_gpioirq_lock);
flags = enter_critical_section();
if (handler == NULL)
{
gpio_irqdisable(irq);
@@ -346,7 +342,7 @@ int gpio_irqattach(int irq, xcpt_t handler, void *arg)
g_gpiohandler[irq].handler = handler;
g_gpiohandler[irq].arg = arg;
spin_unlock_irqrestore(&g_gpioirq_lock, flags);
leave_critical_section(flags);
ret = OK;
}
+5 -11
View File
@@ -30,7 +30,7 @@
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/spinlock.h>
#include <nuttx/irq.h>
#include "hc_internal.h"
#include "m9s12.h"
@@ -49,12 +49,6 @@
* Private Data
****************************************************************************/
/* Spinlock */
#ifdef CONFIG_HCS12_GPIOIRQ
static spinlock_t g_gpioirq_lock = SP_UNLOCKED;
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -256,11 +250,11 @@ void hcs12_gpioirqenable(int irq)
if (hcs12_mapirq(irq, &regaddr, &pin) == OK)
{
irqstate_t flags = spin_lock_irqsave(&g_gpioirq_lock);
irqstate_t flags = enter_critical_section();
uint8_t regval = getreg8(regaddr);
regval |= (1 << pin);
putreg8(regval, regaddr);
spin_unlock_irqrestore(&g_gpioirq_lock, flags);
leave_critical_section(flags);
}
}
#endif /* CONFIG_HCS12_GPIOIRQ */
@@ -281,11 +275,11 @@ void hcs12_gpioirqdisable(int irq)
if (hcs12_mapirq(irq, &regaddr, &pin) == OK)
{
irqstate_t flags = spin_lock_irqsave(&g_gpioirq_lock);
irqstate_t flags = enter_critical_section();
uint8_t regval = getreg8(regaddr);
regval &= ~(1 << pin);
putreg8(regval, regaddr);
spin_unlock_irqrestore(&g_gpioirq_lock, flags);
leave_critical_section(flags);
}
}
#endif /* CONFIG_HCS12_GPIOIRQ */
+3 -7
View File
@@ -29,7 +29,7 @@
#include <stdint.h>
#include <assert.h>
#include <nuttx/spinlock.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <arch/board/board.h>
@@ -55,10 +55,6 @@ struct g_cnisrs_s
static struct g_cnisrs_s g_cnisrs[IOPORT_NUMCN];
/* Spinlock */
static spinlock_t g_gpioirq_lock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -207,7 +203,7 @@ int pic32mx_gpioattach(uint32_t pinset, unsigned int cn, xcpt_t handler,
{
/* Get the previously attached handler as the return value */
flags = spin_lock_irqsave(&g_gpioirq_lock);
flags = enter_critical_section();
/* Are we attaching or detaching? */
@@ -244,7 +240,7 @@ int pic32mx_gpioattach(uint32_t pinset, unsigned int cn, xcpt_t handler,
g_cnisrs[cn].handler = handler;
g_cnisrs[cn].arg = arg;
spin_unlock_irqrestore(&g_gpioirq_lock, flags);
leave_critical_section(flags);
}
return OK;
+3 -7
View File
@@ -29,7 +29,7 @@
#include <stdint.h>
#include <assert.h>
#include <nuttx/spinlock.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <arch/board/board.h>
#include <arch/pic32mz/irq.h>
@@ -152,10 +152,6 @@ static struct ioport_level2_s * const g_level2_handlers[CHIP_NPORTS] =
#endif
};
/* Spinlock */
static spinlock_t g_gpioirq_lock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -484,7 +480,7 @@ int pic32mz_gpioattach(pinset_t pinset, xcpt_t handler, void *arg)
{
/* Get the previously attached handler as the return value */
flags = spin_lock_irqsave(&g_gpioirq_lock);
flags = enter_critical_section();
/* Are we attaching or detaching? */
@@ -539,7 +535,7 @@ int pic32mz_gpioattach(pinset_t pinset, xcpt_t handler, void *arg)
handlers->handler[pin].entry = handler;
handlers->handler[pin].arg = arg;
spin_unlock_irqrestore(&g_gpioirq_lock, flags);
leave_critical_section(flags);
}
}
+6 -11
View File
@@ -30,23 +30,13 @@
#include <assert.h>
#include <debug.h>
#include <nuttx/spinlock.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <arch/irq.h>
#include <arch/spr.h>
#include "or1k_internal.h"
/****************************************************************************
* Private Data
****************************************************************************/
/* Spinlock */
#ifdef CONFIG_DEBUG_IRQ_INFO
static spinlock_t g_irq_lock = SP_UNLOCKED;
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -144,6 +134,11 @@ void or1k_ack_irq(int irq)
#ifdef CONFIG_DEBUG_IRQ_INFO
void or1k_dump_pic(const char *msg, int irq)
{
irqstate_t flags;
flags = enter_critical_section();
leave_critical_section(flags);
}
#else
+8 -12
View File
@@ -31,7 +31,7 @@
#include <assert.h>
#include <debug.h>
#include <nuttx/spinlock.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <arch/irq.h>
@@ -66,7 +66,7 @@
#define IRQ_MKMAP(c, i) (((c) << 0x05) | (i))
/****************************************************************************
* Private Data
* Public Data
****************************************************************************/
static volatile uint8_t g_irqmap[NR_IRQS];
@@ -99,10 +99,6 @@ uintptr_t g_cpu_intstack_top[CONFIG_SMP_NCPUS] =
};
#endif /* if CONFIG_ARCH_INTERRUPTSTACK > 7 */
/* Spinlock */
static spinlock_t g_irq_lock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -223,10 +219,10 @@ int s698pm_cpuint_initialize(void)
int s698pm_setup_irq(int cpu, int irq, int priority)
{
irqstate_t flags;
irqstate_t irqstate;
int cpuint;
flags = spin_lock_irqsave(&g_irq_lock);
irqstate = enter_critical_section();
if (irq >= S698PM_IRQ_FIRST_INT && irq <= S698PM_IRQ_LAST_INT)
{
@@ -255,7 +251,7 @@ int s698pm_setup_irq(int cpu, int irq, int priority)
g_irqmap[irq] = IRQ_MKMAP(cpu, cpuint);
(void)up_prioritize_irq(irq, priority);
spin_unlock_irqrestore(&g_irq_lock, flags);
leave_critical_section(irqstate);
return cpuint;
}
@@ -277,13 +273,13 @@ int s698pm_setup_irq(int cpu, int irq, int priority)
void s698pm_teardown_irq(int irq)
{
irqstate_t flags;
irqstate_t irqstate;
flags = spin_lock_irqsave(&g_irq_lock);
irqstate = enter_critical_section();
g_irqmap[irq] = IRQ_UNMAPPED;
spin_unlock_irqrestore(&g_irq_lock, flags);
leave_critical_section(irqstate);
}
/****************************************************************************