summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2022-08-14 12:42:37 +0800
committersakumisu <[email protected]>2022-08-14 12:42:37 +0800
commitce848a21df63fd3646f4cd3dcb1a539d2c424074 (patch)
tree8e4ec4e5a53d128d4266561c95ddcbd9cfb491d9
parent18afd80c7fe90babb43f95ac2ca9bb1f0514fbb9 (diff)
add dcache invalidate for async transfer
-rw-r--r--port/dwc2/usb_hc_dwc2.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/port/dwc2/usb_hc_dwc2.c b/port/dwc2/usb_hc_dwc2.c
index cae495c9..53fea5c8 100644
--- a/port/dwc2/usb_hc_dwc2.c
+++ b/port/dwc2/usb_hc_dwc2.c
@@ -48,6 +48,7 @@ struct dwc2_pipe {
uint8_t ep_interval; /* Interrupt/isochronous EP polling interval */
uint16_t num_packets; /* for HCTSIZx*/
uint32_t xferlen; /* for HCTSIZx*/
+ uint8_t *buffer; /* for dcache invalidate */
volatile int result; /* The result of the transfer */
volatile uint32_t xfrd; /* Bytes transferred (at end of transfer) */
volatile bool waiter; /* True: Thread is waiting for a channel event */
@@ -566,7 +567,11 @@ static void dwc2_pipe_wakeup(struct dwc2_pipe *chan)
if (chan->result < 0) {
nbytes = chan->result;
}
-
+#ifdef CONFIG_USB_DCACHE_ENABLE
+ if (((chan->ep_addr & 0x80) == 0x80) && (nbytes > 0)) {
+ usb_dcache_invalidate((uint32_t)chan->buffer, nbytes);
+ }
+#endif
callback(arg, nbytes);
}
#endif
@@ -1043,6 +1048,7 @@ int usbh_ep_bulk_async_transfer(usbh_epinfo_t ep, uint8_t *buffer, uint32_t bufl
usb_dcache_clean((uintptr_t)buffer, buflen);
}
#endif
+ chan->buffer = buffer;
dwc2_pipe_transfer(chidx, chan->ep_addr, (uint32_t *)buffer, chan->xferlen, chan->num_packets, chan->data_pid);
return 0;