From: Seung-Woo Kim Date: Thu, 24 Aug 2023 08:02:26 +0000 (+0900) Subject: WORKAROUND: usb: cdns3: Restore onchip memory reservation X-Git-Tag: accepted/tizen/unified/riscv/20230828.003411^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F88%2F297788%2F1;p=platform%2Fkernel%2Flinux-starfive.git WORKAROUND: usb: cdns3: Restore onchip memory reservation 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 --- diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c index 1dcadef933e3..ede4935826f3 100644 --- a/drivers/usb/cdns3/cdns3-gadget.c +++ b/drivers/usb/cdns3/cdns3-gadget.c @@ -2452,6 +2452,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);