Commit 9383e084 authored by Vardan Mikayelyan's avatar Vardan Mikayelyan Committed by Felipe Balbi

usb: dwc2: gadget: Fix DMA memory freeing

Remove DMA memory free from EP disable flow by replacing
dma_alloc_coherent with dmam_alloc_coherent.
Tested-by: default avatarJohn Stultz <john.stultz@linaro.org>
Signed-off-by: default avatarVardan Mikayelyan <mvardan@synopsys.com>
Signed-off-by: default avatarJohn Youn <johnyoun@synopsys.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 990758c5
...@@ -3749,8 +3749,8 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep, ...@@ -3749,8 +3749,8 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
__func__, epctrl, epctrl_reg); __func__, epctrl, epctrl_reg);
/* Allocate DMA descriptor chain for non-ctrl endpoints */ /* Allocate DMA descriptor chain for non-ctrl endpoints */
if (using_desc_dma(hsotg)) { if (using_desc_dma(hsotg) && !hs_ep->desc_list) {
hs_ep->desc_list = dma_alloc_coherent(hsotg->dev, hs_ep->desc_list = dmam_alloc_coherent(hsotg->dev,
MAX_DMA_DESC_NUM_GENERIC * MAX_DMA_DESC_NUM_GENERIC *
sizeof(struct dwc2_dma_desc), sizeof(struct dwc2_dma_desc),
&hs_ep->desc_list_dma, GFP_ATOMIC); &hs_ep->desc_list_dma, GFP_ATOMIC);
...@@ -3872,7 +3872,7 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep, ...@@ -3872,7 +3872,7 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
error2: error2:
if (ret && using_desc_dma(hsotg) && hs_ep->desc_list) { if (ret && using_desc_dma(hsotg) && hs_ep->desc_list) {
dma_free_coherent(hsotg->dev, MAX_DMA_DESC_NUM_GENERIC * dmam_free_coherent(hsotg->dev, MAX_DMA_DESC_NUM_GENERIC *
sizeof(struct dwc2_dma_desc), sizeof(struct dwc2_dma_desc),
hs_ep->desc_list, hs_ep->desc_list_dma); hs_ep->desc_list, hs_ep->desc_list_dma);
hs_ep->desc_list = NULL; hs_ep->desc_list = NULL;
...@@ -3902,14 +3902,6 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep) ...@@ -3902,14 +3902,6 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep)
return -EINVAL; return -EINVAL;
} }
/* Remove DMA memory allocated for non-control Endpoints */
if (using_desc_dma(hsotg)) {
dma_free_coherent(hsotg->dev, MAX_DMA_DESC_NUM_GENERIC *
sizeof(struct dwc2_dma_desc),
hs_ep->desc_list, hs_ep->desc_list_dma);
hs_ep->desc_list = NULL;
}
epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index); epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index);
spin_lock_irqsave(&hsotg->lock, flags); spin_lock_irqsave(&hsotg->lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment