diff options
| author | zelong_666 <[email protected]> | 2026-10-08 20:01:10 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2026-10-08 22:05:44 +0800 |
| commit | 379b6a2cdb58b90ac2d338d18bdbb911fef4fafd (patch) | |
| tree | 58f84a3a5ab22afd09c00aa2dd4bbd03b766268c | |
| parent | 17ff1f0045d3ee28a604c66bebeab3a9bb7f653e (diff) | |
fix(port/musb): Use the mapped channel in usbh_kill_urb on SiFli 52/56
usbh_kill_urb() derived both the channel to mask and the channel to flush from
the endpoint number ((urb->ep->bEndpointAddress & 0x0f) and bEndpointAddress
itself), which only holds when the channel number equals the endpoint number.
When MUSB_SIFLI_EP_MAP is in use the channel is assigned by
sifli_ep_map_alloc(): the SiFli 52/56 host channels are pooled per direction
(IN ch1..ch4, OUT ch5..ch7), so e.g. EP1 OUT lives on ch5 and EP2 OUT on ch6.
Masking by endpoint number therefore clears the interrupt enable of an
unrelated channel and leaves the aborted channel's interrupt armed, and
musb_fifo_flush() is asked to clean the FIFO of a different endpoint than the
one the URB was using.
Take the channel from pipe->chidx, which is the channel the URB was submitted
on, and rebuild the byte musb_fifo_flush() expects (direction in bit7, channel
in bits 6:0). Non-mapped MUSB ports keep their previous behaviour.
EP0 is unaffected either way: with chidx 0 and bEndpointAddress 0 both forms
resolve to bit 0 and byte 0.
| -rw-r--r-- | port/musb/usb_hc_musb.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/port/musb/usb_hc_musb.c b/port/musb/usb_hc_musb.c index 50e16c02..259c3dbc 100644 --- a/port/musb/usb_hc_musb.c +++ b/port/musb/usb_hc_musb.c @@ -954,15 +954,23 @@ int usbh_kill_urb(struct usbh_urb *urb) urb->errorcode = -USB_ERR_SHUTDOWN; +#ifdef MUSB_SIFLI_EP_MAP + uint8_t chidx = pipe->chidx; + uint8_t fifo_ep = (urb->ep->bEndpointAddress & 0x80) | chidx; +#else + uint8_t chidx = (urb->ep->bEndpointAddress & 0x0f); + uint8_t fifo_ep = urb->ep->bEndpointAddress; +#endif + if (urb->ep->bEndpointAddress & 0x80) { - HWREGH(USB_BASE + MUSB_RXIE_OFFSET) &= ~(1 << (urb->ep->bEndpointAddress & 0x0f)); - HWREGH(USB_BASE + MUSB_RXIS_OFFSET) = (1 << (urb->ep->bEndpointAddress & 0x0f)); + HWREGH(USB_BASE + MUSB_RXIE_OFFSET) &= ~(1 << chidx); + HWREGH(USB_BASE + MUSB_RXIS_OFFSET) = (1 << chidx); } else { - HWREGH(USB_BASE + MUSB_TXIE_OFFSET) &= ~(1 << (urb->ep->bEndpointAddress & 0x0f)); - HWREGH(USB_BASE + MUSB_TXIS_OFFSET) = (1 << (urb->ep->bEndpointAddress & 0x0f)); + HWREGH(USB_BASE + MUSB_TXIE_OFFSET) &= ~(1 << chidx); + HWREGH(USB_BASE + MUSB_TXIS_OFFSET) = (1 << chidx); } - musb_fifo_flush(bus, urb->ep->bEndpointAddress); + musb_fifo_flush(bus, fifo_ep); usb_osal_leave_critical_section(flags); |
