mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
freertos: Replace portSET_INTERRUPT_MASK_FROM_ISR() call for SMP
The behavior of portSET_INTERRUPT_MASK_FROM_ISR() has changed in SMP FreeRTOS. It's previous behavior is now implemented in portDISABLE_INTERRUPTS() and portRESTORE_INTERRUPTS(). This commit replaces all portSET_INTERRUPT_MASK_FROM_ISR() and portCLEAR_INTERRUPT_MASK_FROM_ISR() calls with portDISABLE_INTERRUPTS() and portRESTORE_INTERRUPTS() respectively
This commit is contained in:
@@ -62,13 +62,21 @@ esp_err_t esp_apptrace_lock_take(esp_apptrace_lock_t *lock, esp_apptrace_tmo_t *
|
||||
while (1) {
|
||||
//Todo: Replace the current locking mechanism and int_state with portTRY_ENTER_CRITICAL() instead.
|
||||
// do not overwrite lock->int_state before we actually acquired the mux
|
||||
#if CONFIG_FREERTOS_SMP
|
||||
unsigned int_state = portDISABLE_INTERRUPTS();
|
||||
#else
|
||||
unsigned int_state = portSET_INTERRUPT_MASK_FROM_ISR();
|
||||
#endif
|
||||
bool success = spinlock_acquire(&lock->mux, 0);
|
||||
if (success) {
|
||||
lock->int_state = int_state;
|
||||
return ESP_OK;
|
||||
}
|
||||
#if CONFIG_FREERTOS_SMP
|
||||
portRESTORE_INTERRUPTS(int_state);
|
||||
#else
|
||||
portCLEAR_INTERRUPT_MASK_FROM_ISR(int_state);
|
||||
#endif
|
||||
// we can be preempted from this place till the next call (above) to portSET_INTERRUPT_MASK_FROM_ISR()
|
||||
res = esp_apptrace_tmo_check(tmo);
|
||||
if (res != ESP_OK) {
|
||||
@@ -85,7 +93,11 @@ esp_err_t esp_apptrace_lock_give(esp_apptrace_lock_t *lock)
|
||||
// after call to the following func we can not be sure that lock->int_state
|
||||
// is not overwritten by other CPU who has acquired the mux just after we released it. See esp_apptrace_lock_take().
|
||||
spinlock_release(&lock->mux);
|
||||
#if CONFIG_FREERTOS_SMP
|
||||
portRESTORE_INTERRUPTS(int_state);
|
||||
#else
|
||||
portCLEAR_INTERRUPT_MASK_FROM_ISR(int_state);
|
||||
#endif
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user