From f5c3dd417fa3309ca2eef23a65d6287ee5e1904f Mon Sep 17 00:00:00 2001 From: William Wu Date: Fri, 30 Mar 2018 14:26:11 +0800 Subject: [PATCH] usb: dwc_otg_310: hcd: avoid to free dma mem if irqs disabled This patch fix the following warning when plug out a dm9601 usb ethernet: WARNING: at include/asm-generic/dma-mapping-common.h:274 Modules linked in: drmboot(P) CPU: 5 PID: 1501 Comm: kworker/5:2 Tainted: P 4.4.103 #5 Hardware name: Rockchip rk3368 xkp board (DT) Workqueue: usb_hub_wq hub_event task: ffffffc0326d4100 task.stack: ffffffc0389fc000 PC is at __DWC_DMA_FREE+0x38/0xa0 LR is at dwc_otg_hcd_qh_free+0xe0/0x120 pc : [] lr : [] pstate: 204001c5 sp : ffffffc0389ffab0 ... Call trace: [] __DWC_DMA_FREE+0x38/0xa0 [] dwc_otg_hcd_qh_free+0xe0/0x120 [] dwc_otg_hcd_endpoint_disable+0xa4/0xd [] endpoint_disable+0x20/0x30 [] usb_hcd_disable_endpoint+0x1c/0x24 [] usb_disable_endpoint+0x80/0x8c [] usb_disable_device+0x1f4/0x210 [] usb_disconnect+0x9c/0x1cc [] hub_event+0x740/0xe50 [] process_one_work+0x254/0x3f0 [] worker_thread+0x304/0x418 [] kthread+0xe8/0xf0 [] ret_from_fork+0x10/0x40 Change-Id: I8958bb2a43307d214f7aaaecd337da30b645d8e1 Signed-off-by: William Wu --- drivers/usb/dwc_otg_310/dwc_otg_hcd_queue.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/dwc_otg_310/dwc_otg_hcd_queue.c b/drivers/usb/dwc_otg_310/dwc_otg_hcd_queue.c index a291ff127eba..1aae0beef392 100644 --- a/drivers/usb/dwc_otg_310/dwc_otg_hcd_queue.c +++ b/drivers/usb/dwc_otg_310/dwc_otg_hcd_queue.c @@ -71,8 +71,11 @@ void dwc_otg_hcd_qh_free(dwc_otg_hcd_t *hcd, dwc_otg_qh_t *qh) buf_size = hcd->core_if->core_params->max_transfer_size; buf_size = buf_size > 65536 ? 65536 : buf_size; } + + DWC_SPINUNLOCK_IRQRESTORE(hcd->lock, flags); DWC_DEV_DMA_FREE(buf_size, qh->dw_align_buf, qh->dw_align_buf_dma); + DWC_SPINLOCK_IRQSAVE(hcd->lock, &flags); } DWC_FREE(qh);