WORKAROUND: usb: cdns3: Restore onchip memory reservation
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 24 Aug 2023 08:02:26 +0000 (17:02 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 19 Feb 2024 00:13:55 +0000 (09:13 +0900)
Restore onchip meory reservation of disable in_ep when hw
configuration is not done as a workaround.
Without restoring, disabling and re-enabling eps causes
check failure of onchip memory reseration size.

This fixes usb communication failure of ffs_func_set_alt()
calling usb_ep_disable() and usb_ep_enable() for all ep.

Note: for non workaround, it should calculate exact reservation
size from ep type and usb speed and should restore out_ep memory
reservation when there is no more enabled out_ep.

Change-Id: Ifca0052f96fd777036e01b9ddb7ae6af54bba911
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
drivers/usb/cdns3/cdns3-gadget.c

index d140010..325fbaa 100644 (file)
@@ -2508,6 +2508,16 @@ static int cdns3_gadget_ep_disable(struct usb_ep *ep)
 
        trace_cdns3_gadget_ep_disable(priv_ep);
 
+       /*
+        * WORKAROUND: before hw configuration, restore onchip memory
+        * reservation for each disabled in_ep with ep_buf_size
+        *
+        * for out_ep, only one onchip buffer is reused.
+        */
+       if (!priv_dev->hw_configured_flag)
+               if (!!priv_ep->dir)
+                       priv_dev->onchip_used_size -= priv_dev->ep_buf_size;
+
        cdns3_select_ep(priv_dev, ep->desc->bEndpointAddress);
 
        ep_cfg = readl(&priv_dev->regs->ep_cfg);