Merge branch 'bugfix/spinlocks_misused_as_critical_sections' into 'master'

esp_hw_support: Fix misuse of spinlocks as critical sections

See merge request espressif/esp-idf!19282
This commit is contained in:
Darian
2022-07-29 11:57:28 +08:00
2 changed files with 5 additions and 5 deletions

View File

@@ -53,7 +53,7 @@ static esp_usb_console_cb_t s_tx_cb;
static void *s_cb_arg; static void *s_cb_arg;
#ifdef CONFIG_ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF #ifdef CONFIG_ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF
static spinlock_t s_write_lock = SPINLOCK_INITIALIZER; static portMUX_TYPE s_write_lock = portMUX_INITIALIZER_UNLOCKED;
void esp_usb_console_write_char(char c); void esp_usb_console_write_char(char c);
#define ISR_FLAG ESP_INTR_FLAG_IRAM #define ISR_FLAG ESP_INTR_FLAG_IRAM
#else #else
@@ -399,11 +399,11 @@ void esp_usb_console_write_char(char c)
} }
static inline void write_lock_acquire(void) static inline void write_lock_acquire(void)
{ {
spinlock_acquire(&s_write_lock, SPINLOCK_WAIT_FOREVER); portENTER_CRITICAL_SAFE(&s_write_lock);
} }
static inline void write_lock_release(void) static inline void write_lock_release(void)
{ {
spinlock_release(&s_write_lock); portEXIT_CRITICAL_SAFE(&s_write_lock);
} }
#else // CONFIG_ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF #else // CONFIG_ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF

View File

@@ -61,7 +61,7 @@ typedef struct {
event_select_args_t *select_args; event_select_args_t *select_args;
_lock_t lock; _lock_t lock;
// only for event fds that support ISR. // only for event fds that support ISR.
spinlock_t data_spin_lock; portMUX_TYPE data_spin_lock;
} event_context_t; } event_context_t;
esp_vfs_id_t s_eventfd_vfs_id = -1; esp_vfs_id_t s_eventfd_vfs_id = -1;
@@ -421,7 +421,7 @@ int eventfd(unsigned int initval, int flags)
fd = i; fd = i;
s_events[i].fd = i; s_events[i].fd = i;
s_events[i].support_isr = support_isr; s_events[i].support_isr = support_isr;
spinlock_initialize(&s_events[i].data_spin_lock); portMUX_INITIALIZE(&s_events[i].data_spin_lock);
if (support_isr) { if (support_isr) {
portENTER_CRITICAL(&s_events[i].data_spin_lock); portENTER_CRITICAL(&s_events[i].data_spin_lock);