diff options
| author | sakumisu <[email protected]> | 2025-07-26 16:11:47 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2025-07-26 16:11:47 +0800 |
| commit | 6702ab922553f0438c029f44a5152f3b3e637dbc (patch) | |
| tree | 447f690ca17840f6e56ca90fb0b49df812960259 | |
| parent | ecb98f399d0a64296f42a75b65cfe36b9d7a39b0 (diff) | |
update(port/dwc2): invalid data before start read
Signed-off-by: sakumisu <[email protected]>
| -rw-r--r-- | port/dwc2/usb_dc_dwc2.c | 2 | ||||
| -rw-r--r-- | port/dwc2/usb_hc_dwc2.c | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/port/dwc2/usb_dc_dwc2.c b/port/dwc2/usb_dc_dwc2.c index e9de2602..098ef350 100644 --- a/port/dwc2/usb_dc_dwc2.c +++ b/port/dwc2/usb_dc_dwc2.c @@ -777,6 +777,7 @@ int usbd_ep_set_stall(uint8_t busid, const uint8_t ep) } if ((ep_idx == 0) && g_dwc2_udc[busid].user_params.device_dma_enable) { + usb_dcache_invalidate((uintptr_t)&g_dwc2_udc[busid].setup, USB_ALIGN_UP(8, CONFIG_USB_ALIGN_SIZE)); dwc2_ep0_start_read_setup(busid, (uint8_t *)&g_dwc2_udc[busid].setup); } @@ -947,6 +948,7 @@ int usbd_ep_start_read(uint8_t busid, const uint8_t ep, uint8_t *data, uint32_t } if (g_dwc2_udc[busid].user_params.device_dma_enable) { + usb_dcache_invalidate((uintptr_t)data, USB_ALIGN_UP(data_len, CONFIG_USB_ALIGN_SIZE)); USB_OTG_OUTEP(ep_idx)->DOEPDMA = (uint32_t)data; } if (g_dwc2_udc[busid].out_ep[ep_idx].ep_type == USB_ENDPOINT_TYPE_ISOCHRONOUS) { diff --git a/port/dwc2/usb_hc_dwc2.c b/port/dwc2/usb_hc_dwc2.c index b28ad954..5a19ace5 100644 --- a/port/dwc2/usb_hc_dwc2.c +++ b/port/dwc2/usb_hc_dwc2.c @@ -20,7 +20,6 @@ struct dwc2_chan { uint32_t xferlen; uint8_t chidx; bool inuse; - bool dir_in; bool do_ssplit; bool do_csplit; uint8_t hub_addr; @@ -317,12 +316,13 @@ static inline void dwc2_chan_transfer(struct usbh_bus *bus, uint8_t ch_num, uint (((uint32_t)pid << 29) & USB_OTG_HCTSIZ_DPID); if (!(ep_addr & 0x80)) { - chan->dir_in = false; if (buf) { usb_dcache_clean((uintptr_t)buf, USB_ALIGN_UP(size, CONFIG_USB_ALIGN_SIZE)); } } else { - chan->dir_in = true; + if (buf) { + usb_dcache_invalidate((uintptr_t)buf, USB_ALIGN_UP(size, CONFIG_USB_ALIGN_SIZE)); + } } /* xfer_buff MUST be 32-bits aligned */ |
