You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/03/18 14:47:36 UTC

[incubator-nuttx] branch master updated: risc-v/mpfs: usb: fix ep0 read done

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new ec2352a  risc-v/mpfs: usb: fix ep0 read done
ec2352a is described below

commit ec2352a4f9c9e988879c2ff0cc0fbab85ce99abe
Author: Eero Nurkkala <ee...@offcode.fi>
AuthorDate: Fri Mar 18 15:05:03 2022 +0200

    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 <ee...@offcode.fi>
---
 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 dc8a422..b82951d 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 */