bdk: bpmp: do not use full maintenance

Instead use proper clean/invalidation of dcache.
This commit is contained in:
CTCaer 2022-02-15 00:14:14 +02:00
parent 70ee61f0da
commit 7c74391754
4 changed files with 22 additions and 14 deletions

View file

@ -144,7 +144,8 @@ static int _se_execute(u32 op, void *dst, u32 dst_size, const void *src, u32 src
SE(SE_ERR_STATUS_REG) = SE(SE_ERR_STATUS_REG); SE(SE_ERR_STATUS_REG) = SE(SE_ERR_STATUS_REG);
SE(SE_INT_STATUS_REG) = SE(SE_INT_STATUS_REG); SE(SE_INT_STATUS_REG) = SE(SE_INT_STATUS_REG);
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false); // Flush data before starting OP.
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLEAN_WAY, false);
SE(SE_OPERATION_REG) = op; SE(SE_OPERATION_REG) = op;
@ -152,7 +153,8 @@ static int _se_execute(u32 op, void *dst, u32 dst_size, const void *src, u32 src
{ {
int res = _se_wait(); int res = _se_wait();
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false); // Invalidate data after OP is done.
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, false);
if (src) if (src)
{ {
@ -175,7 +177,8 @@ static int _se_execute_finalize()
{ {
int res = _se_wait(); int res = _se_wait();
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false); // Invalidate data after OP is done.
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, false);
if (ll_src) if (ll_src)
{ {

View file

@ -983,6 +983,7 @@ static int _sdmmc_update_dma(sdmmc_t *sdmmc)
sdmmc->dma_addr_next += 0x80000; sdmmc->dma_addr_next += 0x80000;
} }
} }
if (result != SDMMC_MASKINT_NOERROR) if (result != SDMMC_MASKINT_NOERROR)
{ {
#ifdef ERROR_EXTRA_PRINTING #ifdef ERROR_EXTRA_PRINTING
@ -1017,7 +1018,7 @@ static int _sdmmc_execute_cmd_inner(sdmmc_t *sdmmc, sdmmc_cmd_t *cmd, sdmmc_req_
} }
// Flush cache before starting the transfer. // Flush cache before starting the transfer.
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false); bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLEAN_WAY, false);
is_data_present = true; is_data_present = true;
} }
@ -1066,8 +1067,8 @@ DPRINTF("rsp(%d): %08X, %08X, %08X, %08X\n", result,
{ {
if (req) if (req)
{ {
// Flush cache after transfer. // Invalidate cache after transfer.
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false); bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, false);
if (blkcnt_out) if (blkcnt_out)
*blkcnt_out = blkcnt; *blkcnt_out = blkcnt;

View file

@ -787,7 +787,7 @@ static int _usbd_ep_operation(usb_ep_t endpoint, u8 *buf, u32 len, u32 sync_time
if (direction == USB_DIR_IN) if (direction == USB_DIR_IN)
{ {
prime_bit = USB2D_ENDPT_STATUS_TX_OFFSET << actual_ep; prime_bit = USB2D_ENDPT_STATUS_TX_OFFSET << actual_ep;
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false); bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLEAN_WAY, false);
} }
else else
prime_bit = USB2D_ENDPT_STATUS_RX_OFFSET << actual_ep; prime_bit = USB2D_ENDPT_STATUS_RX_OFFSET << actual_ep;
@ -826,7 +826,7 @@ out:
res = USB_ERROR_XFER_ERROR; res = USB_ERROR_XFER_ERROR;
if (direction == USB_DIR_OUT) if (direction == USB_DIR_OUT)
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false); bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, false);
} }
return res; return res;
@ -1470,7 +1470,7 @@ int usb_device_ep1_out_reading_finish(u32 *pending_bytes, u32 sync_timeout)
*pending_bytes = _usbd_get_ep1_out_bytes_read(); *pending_bytes = _usbd_get_ep1_out_bytes_read();
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false); bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, false);
if (ep_status == USB_EP_STATUS_IDLE) if (ep_status == USB_EP_STATUS_IDLE)
return USB_RES_OK; return USB_RES_OK;

View file

@ -993,7 +993,8 @@ static int _xusb_queue_trb(u32 ep_idx, void *trb, bool ring_doorbell)
// Ring doorbell. // Ring doorbell.
if (ring_doorbell) if (ring_doorbell)
{ {
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false); // Flush data before transfer.
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLEAN_WAY, false);
u32 target_id = (ep_idx << 8) & 0xFFFF; u32 target_id = (ep_idx << 8) & 0xFFFF;
if (ep_idx == XUSB_EP_CTRL_IN) if (ep_idx == XUSB_EP_CTRL_IN)
target_id |= usbd_xotg->ctrl_seq_num << 16; target_id |= usbd_xotg->ctrl_seq_num << 16;
@ -1947,10 +1948,11 @@ int xusb_device_ep1_out_read(u8 *buf, u32 len, u32 *bytes_read, u32 sync_tries)
if (bytes_read) if (bytes_read)
*bytes_read = res ? 0 : usbd_xotg->tx_bytes[USB_DIR_OUT]; *bytes_read = res ? 0 : usbd_xotg->tx_bytes[USB_DIR_OUT];
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false);
} }
// Invalidate data after transfer.
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, false);
return res; return res;
} }
@ -1988,7 +1990,8 @@ int xusb_device_ep1_out_reading_finish(u32 *pending_bytes, u32 sync_tries)
if (pending_bytes) if (pending_bytes)
*pending_bytes = res ? 0 : usbd_xotg->tx_bytes[USB_DIR_OUT]; *pending_bytes = res ? 0 : usbd_xotg->tx_bytes[USB_DIR_OUT];
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false); // Invalidate data after transfer.
bpmp_mmu_maintenance(BPMP_MMU_MAINT_INVALID_WAY, false);
return res; return res;
} }
@ -1998,7 +2001,8 @@ int xusb_device_ep1_in_write(u8 *buf, u32 len, u32 *bytes_written, u32 sync_trie
if (len > USB_EP_BUFFER_MAX_SIZE) if (len > USB_EP_BUFFER_MAX_SIZE)
len = USB_EP_BUFFER_MAX_SIZE; len = USB_EP_BUFFER_MAX_SIZE;
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLN_INV_WAY, false); // Flush data before transfer.
bpmp_mmu_maintenance(BPMP_MMU_MAINT_CLEAN_WAY, false);
int res = USB_RES_OK; int res = USB_RES_OK;
usbd_xotg->tx_count[USB_DIR_IN] = 0; usbd_xotg->tx_count[USB_DIR_IN] = 0;