From ec2352a4f9c9e988879c2ff0cc0fbab85ce99abe Mon Sep 17 00:00:00 2001 From: Eero Nurkkala Date: Fri, 18 Mar 2022 15:05:03 +0200 Subject: [PATCH] risc-v/mpfs: usb: fix ep0 read done USB EP0 reads data from the fifo but doesn't mark the read done which adds significant delays. Fix this unnecessary slowdown due to operation timeouts by finishing the read properly. Also add a missing function description to the function mpfs_ep_set_fifo_size(). Signed-off-by: Eero Nurkkala --- arch/risc-v/src/mpfs/mpfs_usb.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/risc-v/src/mpfs/mpfs_usb.c b/arch/risc-v/src/mpfs/mpfs_usb.c index dc8a4226073..b82951d1eba 100755 --- a/arch/risc-v/src/mpfs/mpfs_usb.c +++ b/arch/risc-v/src/mpfs/mpfs_usb.c @@ -1086,6 +1086,22 @@ static int mpfs_req_read(struct mpfs_usbdev_s *priv, return OK; } +/**************************************************************************** + * Name: mpfs_ep_set_fifo_size + * + * Description: + * Sets the fifo size for the endpoint. + * + * Input Parameters: + * epno - Endpoint number + * in - Device to host (TX) fifo if set, RX fifo if unset + * fifo_size - Desired fifo size + * + * Returned Value: + * None + * + ****************************************************************************/ + static void mpfs_ep_set_fifo_size(uint8_t epno, uint8_t in, uint16_t fifo_size) { @@ -3093,6 +3109,12 @@ static void mpfs_ctrl_ep_interrupt(struct mpfs_usbdev_s *priv, int epno) if (count0 > 0) { mpfs_read_rx_fifo((uint8_t *)&priv->ctrl, count0, EP0); + + /* Mark the read finished */ + + mpfs_putreg16(CSR0L_DEV_SERVICED_RX_PKT_RDY_MASK | + CSR0L_DEV_DATA_END_MASK, + MPFS_USB_INDEXED_CSR_EP0_CSR0); } /* SETUP data is ready */