summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorboa-z <[email protected]>2026-11-08 08:21:56 -0800
committerRbb666 <[email protected]>2026-11-09 10:30:27 +0800
commitbd6c9fbfc9c5ae2e60f47cd58bbbc2171176cad9 (patch)
tree19be8582fa7b8182459166bb097b0f42945eb8df
parentcc533832d3b6596e3d3964f557e52cb8cd1fee30 (diff)
[cherryusb][ehci] Fix missing SETUP buffer cache clean
Backport cherry-embedded/CherryUSB@41f5796: https://github.com/cherry-embedded/CherryUSB/commit/41f57964cc442145099250f0190eb71e9d1d9d5a The fix is already merged in CherryUSB upstream but is not included in the v1.6.1 copy integrated in RT-Thread. The EHCI port cleans qTD/QH descriptors and the transfer buffer for DMA, but not the SETUP packet, so on a non-coherent platform the controller can read a stale packet and a device may never enumerate. Apply the upstream change: clean the SETUP buffer in ehci_qh_add_head() before the QH is linked into the asynchronous or periodic list.
-rw-r--r--components/drivers/usb/cherryusb/port/ehci/usb_hc_ehci.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/components/drivers/usb/cherryusb/port/ehci/usb_hc_ehci.c b/components/drivers/usb/cherryusb/port/ehci/usb_hc_ehci.c
index fd72907f89..a95b8bc675 100644
--- a/components/drivers/usb/cherryusb/port/ehci/usb_hc_ehci.c
+++ b/components/drivers/usb/cherryusb/port/ehci/usb_hc_ehci.c
@@ -137,6 +137,10 @@ static inline void ehci_qh_add_head(struct ehci_qh_hw *head, struct ehci_qh_hw *
n->hw.hlp = head->hw.hlp;
usb_ehci_qh_qtd_flush(n);
+ if (n->urb->setup) {
+ usb_dcache_clean((uintptr_t)n->urb->setup, USB_ALIGN_UP(8, CONFIG_USB_ALIGN_SIZE));
+ }
+
usb_dcache_flush((uintptr_t)n->urb->transfer_buffer, USB_ALIGN_UP(n->urb->transfer_buffer_length, CONFIG_USB_ALIGN_SIZE));
head->hw.hlp = QH_HLP_QH(n);