Revert "i2s: guarantee safety of memcpy from being interrupted by uart logging"

This reverts commit 646fd5e15a.
This commit is contained in:
laokaiyao 2023-02-27 11:59:58 +08:00 committed by morris
parent 754aa7d128
commit 40f1709a1f
2 changed files with 3 additions and 19 deletions

View File

@ -1086,11 +1086,8 @@ esp_err_t i2s_channel_preload_data(i2s_chan_handle_t tx_handle, const void *src,
if (bytes_can_load == 0) {
break;
}
/* Add spinlock in case memcpy be interrupted */
portENTER_CRITICAL_SAFE(&g_i2s.spinlock);
/* Load the data from the last loaded position */
memcpy((uint8_t *)(desc_ptr->buf + tx_handle->dma.rw_pos), data_ptr, bytes_can_load);
portEXIT_CRITICAL_SAFE(&g_i2s.spinlock);
data_ptr += bytes_can_load; // Move forward the data pointer
total_loaded_bytes += bytes_can_load; // Add to the total loaded bytes
remain_bytes -= bytes_can_load; // Update the remaining bytes to be loaded
@ -1146,10 +1143,7 @@ esp_err_t i2s_channel_write(i2s_chan_handle_t handle, const void *src, size_t si
if (bytes_can_write > size) {
bytes_can_write = size;
}
/* Add spinlock in case memcpy be interrupted */
portENTER_CRITICAL_SAFE(&g_i2s.spinlock);
memcpy(data_ptr, src_byte, bytes_can_write);
portEXIT_CRITICAL_SAFE(&g_i2s.spinlock);
size -= bytes_can_write;
src_byte += bytes_can_write;
handle->dma.rw_pos += bytes_can_write;
@ -1191,10 +1185,7 @@ esp_err_t i2s_channel_read(i2s_chan_handle_t handle, void *dest, size_t size, si
if (bytes_can_read > (int)size) {
bytes_can_read = size;
}
/* Add spinlock in case memcpy be interrupted */
portENTER_CRITICAL_SAFE(&g_i2s.spinlock);
memcpy(dest_byte, data_ptr, bytes_can_read);
portEXIT_CRITICAL_SAFE(&g_i2s.spinlock);
size -= bytes_can_read;
dest_byte += bytes_can_read;
handle->dma.rw_pos += bytes_can_read;

View File

@ -215,21 +215,14 @@ esp_err_t sdm_new_channel(const sdm_config_t *config, sdm_channel_handle_t *ret_
#if CONFIG_PM_ENABLE
esp_pm_lock_type_t pm_type = ESP_PM_NO_LIGHT_SLEEP;
#if SOC_SDM_CLK_SUPPORT_XTAL
if (config->clk_src == SDM_CLK_SRC_XTAL) {
pm_type = -1;
}
#endif // SOC_SDM_CLK_SUPPORT_XTAL
#if SOC_SDM_CLK_SUPPORT_APB
if (config->clk_src == SDM_CLK_SRC_APB) {
pm_type = ESP_PM_APB_FREQ_MAX;
}
#endif // SOC_SDM_CLK_SUPPORT_APB
if (pm_type >= 0) {
sprintf(chan->pm_lock_name, "sdm_%d_%d", group->group_id, chan_id); // e.g. sdm_0_0
ret = esp_pm_lock_create(pm_type, 0, chan->pm_lock_name, &chan->pm_lock);
ESP_RETURN_ON_ERROR(ret, TAG, "create %s lock failed", chan->pm_lock_name);
}
sprintf(chan->pm_lock_name, "sdm_%d_%d", group->group_id, chan_id); // e.g. sdm_0_0
ret = esp_pm_lock_create(pm_type, 0, chan->pm_lock_name, &chan->pm_lock);
ESP_GOTO_ON_ERROR(ret, err, TAG, "create %s lock failed", chan->pm_lock_name);
#endif // CONFIG_PM_ENABLE
group->clk_src = config->clk_src;