cache: Fix libraries and drivers

Fix the usage to be compliant to the new cache API.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This commit is contained in:
Carlo Caione 2022-10-05 18:54:56 +02:00 committed by Anas Nashif
commit cc427b4bb0
6 changed files with 27 additions and 37 deletions

View file

@ -517,7 +517,7 @@ int can_mcan_init(const struct device *dev)
can->txbtie = CAN_MCAN_TXBTIE_TIE;
memset32_volatile(msg_ram, 0, sizeof(struct can_mcan_msg_sram));
sys_cache_data_range(msg_ram, sizeof(struct can_mcan_msg_sram), K_CACHE_WB);
sys_cache_data_flush_range(msg_ram, sizeof(struct can_mcan_msg_sram));
return 0;
}
@ -550,9 +550,8 @@ static void can_mcan_tc_event_handler(const struct device *dev)
while (can->txefs & CAN_MCAN_TXEFS_EFFL) {
event_idx = (can->txefs & CAN_MCAN_TXEFS_EFGI) >>
CAN_MCAN_TXEFS_EFGI_POS;
sys_cache_data_range((void *)&msg_ram->tx_event_fifo[event_idx],
sizeof(struct can_mcan_tx_event_fifo),
K_CACHE_INVD);
sys_cache_data_invd_range((void *)&msg_ram->tx_event_fifo[event_idx],
sizeof(struct can_mcan_tx_event_fifo));
tx_event = &msg_ram->tx_event_fifo[event_idx];
tx_idx = tx_event->mm.idx;
/* Acknowledge TX event */
@ -624,9 +623,8 @@ static void can_mcan_get_message(const struct device *dev,
get_idx = (*fifo_status_reg & CAN_MCAN_RXF0S_F0GI) >>
CAN_MCAN_RXF0S_F0GI_POS;
sys_cache_data_range((void *)&fifo[get_idx].hdr,
sizeof(struct can_mcan_rx_fifo_hdr),
K_CACHE_INVD);
sys_cache_data_invd_range((void *)&fifo[get_idx].hdr,
sizeof(struct can_mcan_rx_fifo_hdr));
memcpy32_volatile(&hdr, &fifo[get_idx].hdr,
sizeof(struct can_mcan_rx_fifo_hdr));
@ -670,9 +668,8 @@ static void can_mcan_get_message(const struct device *dev,
data_length = can_dlc_to_bytes(frame.dlc);
if (data_length <= sizeof(frame.data)) {
/* Data needs to be written in 32 bit blocks! */
sys_cache_data_range((void *)fifo[get_idx].data_32,
ROUND_UP(data_length, sizeof(uint32_t)),
K_CACHE_INVD);
sys_cache_data_invd_range((void *)fifo[get_idx].data_32,
ROUND_UP(data_length, sizeof(uint32_t)));
memcpy32_volatile(frame.data_32, fifo[get_idx].data_32,
ROUND_UP(data_length, sizeof(uint32_t)));
@ -898,9 +895,9 @@ int can_mcan_send(const struct device *dev,
memcpy32_volatile(&msg_ram->tx_buffer[put_idx].hdr, &tx_hdr, sizeof(tx_hdr));
memcpy32_volatile(msg_ram->tx_buffer[put_idx].data_32, frame->data_32,
ROUND_UP(data_length, 4));
sys_cache_data_range((void *)&msg_ram->tx_buffer[put_idx].hdr, sizeof(tx_hdr), K_CACHE_WB);
sys_cache_data_range((void *)&msg_ram->tx_buffer[put_idx].data_32, ROUND_UP(data_length, 4),
K_CACHE_WB);
sys_cache_data_flush_range((void *)&msg_ram->tx_buffer[put_idx].hdr, sizeof(tx_hdr));
sys_cache_data_flush_range((void *)&msg_ram->tx_buffer[put_idx].data_32,
ROUND_UP(data_length, 4));
data->tx_fin_cb[put_idx] = callback;
data->tx_fin_cb_arg[put_idx] = user_data;
@ -971,9 +968,8 @@ int can_mcan_add_rx_filter_std(const struct device *dev,
memcpy32_volatile(&msg_ram->std_filt[filter_id], &filter_element,
sizeof(struct can_mcan_std_filter));
sys_cache_data_range((void *)&msg_ram->std_filt[filter_id],
sizeof(struct can_mcan_std_filter),
K_CACHE_WB);
sys_cache_data_flush_range((void *)&msg_ram->std_filt[filter_id],
sizeof(struct can_mcan_std_filter));
k_mutex_unlock(&data->inst_mutex);
@ -1036,9 +1032,8 @@ static int can_mcan_add_rx_filter_ext(const struct device *dev,
memcpy32_volatile(&msg_ram->ext_filt[filter_id], &filter_element,
sizeof(struct can_mcan_ext_filter));
sys_cache_data_range((void *)&msg_ram->ext_filt[filter_id],
sizeof(struct can_mcan_ext_filter),
K_CACHE_WB);
sys_cache_data_flush_range((void *)&msg_ram->ext_filt[filter_id],
sizeof(struct can_mcan_ext_filter));
k_mutex_unlock(&data->inst_mutex);
@ -1100,15 +1095,13 @@ void can_mcan_remove_rx_filter(const struct device *dev, int filter_id)
memset32_volatile(&msg_ram->ext_filt[filter_id], 0,
sizeof(struct can_mcan_ext_filter));
sys_cache_data_range((void *)&msg_ram->ext_filt[filter_id],
sizeof(struct can_mcan_ext_filter),
K_CACHE_WB);
sys_cache_data_flush_range((void *)&msg_ram->ext_filt[filter_id],
sizeof(struct can_mcan_ext_filter));
} else {
memset32_volatile(&msg_ram->std_filt[filter_id], 0,
sizeof(struct can_mcan_std_filter));
sys_cache_data_range((void *)&msg_ram->std_filt[filter_id],
sizeof(struct can_mcan_std_filter),
K_CACHE_WB);
sys_cache_data_flush_range((void *)&msg_ram->std_filt[filter_id],
sizeof(struct can_mcan_std_filter));
}
k_mutex_unlock(&data->inst_mutex);