summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiddharth Vadapalli <s-vadapalli@ti.com>2024-10-07 17:49:27 +0530
committerMattijs Korpershoek <mkorpershoek@baylibre.com>2024-10-11 14:32:38 +0200
commitc54c72dec7948093b200ae1290575a1e9abbbb40 (patch)
treeb92ae3ed74cc64c08d855fd9fdb9bb7cbce0c196
parentce1023de730ffa37beae46a5276061a74a041a09 (diff)
usb: gadget: cdns3: Fix cdns3_ep_config() by setting ep.maxpacket
The function cdns3_ep_config() calculates the maximum packet size based on the Endpoint Type and the Gadget Speed and stores it in the variable "max_packet_size". This value is then programmed in the USB Controller for the corresponding Endpoint. This may result in a mismatch between the maximum packet size programmed in the USB controller and the maximum packet size seen by the UDC Core via "maxpacket" member of "struct usb_ep". Additionally, since TD_SIZE is calculated in cdns3_ep_run_transfer() on the basis of the maximum packet size stored in the "maxpacket" member of "struct usb_ep", it may lead to an incorrect value of TD_SIZE when compared with what the USB controller actually expects (max_packet_size). Fix this. Fixes: 7e91f6ccdc84 ("usb: Add Cadence USB3 host and gadget driver") Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> Reviewed-by: Roger Quadros <rogerq@kernel.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Link: https://lore.kernel.org/r/20241007121927.1680039-1-s-vadapalli@ti.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
-rw-r--r--drivers/usb/cdns3/gadget.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index ac7e469469a..a30c40ef80e 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -1637,6 +1637,14 @@ void cdns3_ep_config(struct cdns3_endpoint *priv_ep)
else
priv_ep->trb_burst_size = 16;
+ /*
+ * The Endpoint is configured to handle a maximum packet size of
+ * max_packet_size. Hence, set priv_ep->endpoint.maxpacket to
+ * max_packet_size. This is necessary to ensure that the TD_SIZE
+ * is calculated correctly in cdns3_ep_run_transfer().
+ */
+ priv_ep->endpoint.maxpacket = max_packet_size;
+
ret = cdns3_ep_onchip_buffer_reserve(priv_dev, buffering + 1,
!!priv_ep->dir);
if (ret) {