update(port/dwc2/usb_hc_dwc2): only clean & invalid buffer in usbh_submit_urb, do not clean&invalid many times

Signed-off-by: sakumisu <1203593632@qq.com>
This commit is contained in:
sakumisu
2025-08-02 20:52:25 +08:00
parent 3905eff2f4
commit 7037fd0e8d

View File

@@ -311,16 +311,6 @@ static inline void dwc2_chan_transfer(struct usbh_bus *bus, uint8_t ch_num, uint
(((uint32_t)num_packets << 19) & USB_OTG_HCTSIZ_PKTCNT) |
(((uint32_t)pid << 29) & USB_OTG_HCTSIZ_DPID);
if (!(ep_addr & 0x80)) {
if (buf) {
usb_dcache_clean((uintptr_t)buf, USB_ALIGN_UP(size, CONFIG_USB_ALIGN_SIZE));
}
} else {
if (buf) {
usb_dcache_invalidate((uintptr_t)buf, USB_ALIGN_UP(size, CONFIG_USB_ALIGN_SIZE));
}
}
/* xfer_buff MUST be 32-bits aligned */
USB_OTG_HC(ch_num)->HCDMA = (uint32_t)buf;
@@ -1066,6 +1056,25 @@ int usbh_submit_urb(struct usbh_urb *urb)
usb_osal_leave_critical_section(flags);
if (urb->setup) {
usb_dcache_clean((uintptr_t)urb->setup, USB_ALIGN_UP(sizeof(struct usb_setup_packet), CONFIG_USB_ALIGN_SIZE));
if (urb->transfer_buffer) {
if (urb->setup->bmRequestType & 0x80) {
usb_dcache_invalidate((uintptr_t)urb->transfer_buffer, USB_ALIGN_UP(urb->transfer_buffer_length, CONFIG_USB_ALIGN_SIZE));
} else {
usb_dcache_clean((uintptr_t)urb->transfer_buffer, USB_ALIGN_UP(urb->transfer_buffer_length, CONFIG_USB_ALIGN_SIZE));
}
}
} else if (urb->transfer_buffer && (USB_GET_ENDPOINT_TYPE(urb->ep->bmAttributes) != USB_ENDPOINT_TYPE_ISOCHRONOUS)) {
if (urb->ep->bEndpointAddress & 0x80) {
usb_dcache_invalidate((uintptr_t)urb->transfer_buffer, USB_ALIGN_UP(urb->transfer_buffer_length, CONFIG_USB_ALIGN_SIZE));
} else {
usb_dcache_clean((uintptr_t)urb->transfer_buffer, USB_ALIGN_UP(urb->transfer_buffer_length, CONFIG_USB_ALIGN_SIZE));
}
} else {
}
switch (USB_GET_ENDPOINT_TYPE(urb->ep->bmAttributes)) {
case USB_ENDPOINT_TYPE_CONTROL:
chan->ep0_state = DWC2_EP0_STATE_SETUP;