From 8c3d609275f7f39d308e5c40a6220c67454f7a28 Mon Sep 17 00:00:00 2001 From: Vahram Aharonyan Date: Wed, 27 Apr 2016 20:20:46 -0700 Subject: usb: dwc2: gadget: Check for ep0 in enable Replaced the WARN_ON with a check and return of -EINVAL in the dwc2_hsotg_ep_enable function if ep0 is passed in. Signed-off-by: Vahram Aharonyan Signed-off-by: John Youn Signed-off-by: Felipe Balbi --- drivers/usb/dwc2/gadget.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/usb/dwc2') diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 818f158232bb..d330190f58ef 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2631,7 +2631,10 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep, desc->wMaxPacketSize, desc->bInterval); /* not to be called for EP0 */ - WARN_ON(index == 0); + if (index == 0) { + dev_err(hsotg->dev, "%s: called for EP 0\n", __func__); + return -EINVAL; + } dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0; if (dir_in != hs_ep->dir_in) { -- cgit 1.4.1 From ee3de8d750134703c702534173cd8623d1b32c38 Mon Sep 17 00:00:00 2001 From: Vardan Mikayelyan Date: Wed, 27 Apr 2016 20:20:48 -0700 Subject: usb: dwc2: gadget: Prevent handling of host interrupts In host slave mode, the core asserts the rxready, txfifoempty interrupts that get serviced in the gadget irq handler. Prevent servicing of these when not in the gadget mode of operation. Signed-off-by: Vardan Mikayelyan Signed-off-by: John Youn Signed-off-by: Felipe Balbi --- drivers/usb/dwc2/gadget.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/usb/dwc2') diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index d330190f58ef..4c5e3005e1dc 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2425,6 +2425,9 @@ static irqreturn_t dwc2_hsotg_irq(int irq, void *pw) u32 gintsts; u32 gintmsk; + if (!dwc2_is_device_mode(hsotg)) + return IRQ_NONE; + spin_lock(&hsotg->lock); irq_retry: gintsts = dwc2_readl(hsotg->regs + GINTSTS); -- cgit 1.4.1 From b0d659022e5c96ee5c4bd62d22d3da2d66de306b Mon Sep 17 00:00:00 2001 From: Vardan Mikayelyan Date: Wed, 27 Apr 2016 20:20:51 -0700 Subject: usb: dwc2: host: Setting qtd to NULL after freeing it This is safety change added while doing slub debugging. Affected functions: dwc2_hcd_qtd_unlink_and_free() _dwc2_hcd_urb_enqueue() Signed-off-by: Vardan Mikayelyan Signed-off-by: John Youn Signed-off-by: Felipe Balbi --- drivers/usb/dwc2/hcd.c | 1 + drivers/usb/dwc2/hcd.h | 1 + 2 files changed, 2 insertions(+) (limited to 'drivers/usb/dwc2') diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 1f6255131857..2df3d04d26f5 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4703,6 +4703,7 @@ fail2: spin_unlock_irqrestore(&hsotg->lock, flags); urb->hcpriv = NULL; kfree(qtd); + qtd = NULL; fail1: if (qh_allocated) { struct dwc2_qtd *qtd2, *qtd2_tmp; diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h index 89fa26cb25f4..7758bfb644ff 100644 --- a/drivers/usb/dwc2/hcd.h +++ b/drivers/usb/dwc2/hcd.h @@ -552,6 +552,7 @@ static inline void dwc2_hcd_qtd_unlink_and_free(struct dwc2_hsotg *hsotg, { list_del(&qtd->qtd_list_entry); kfree(qtd); + qtd = NULL; } /* Descriptor DMA support functions */ -- cgit 1.4.1 From 907a444718b8f93956acac1c944d880c54ab900d Mon Sep 17 00:00:00 2001 From: Sevak Arakelyan Date: Wed, 27 Apr 2016 20:20:53 -0700 Subject: usb: dwc2: Fixed SOF interrupt enabling/disabling In case of DDMA mode we don't need to get an SOF interrupt so disable the unmasking of SOF interrupt in DDMA mode. Signed-off-by: Sevak Arakelyan Signed-off-by: John Youn Signed-off-by: Felipe Balbi --- drivers/usb/dwc2/hcd_queue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/usb/dwc2') diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c index 7f634fd771c7..b5c7793a2df2 100644 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c @@ -1709,7 +1709,8 @@ void dwc2_hcd_qh_unlink(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) dwc2_deschedule_periodic(hsotg, qh); hsotg->periodic_qh_count--; - if (!hsotg->periodic_qh_count) { + if (!hsotg->periodic_qh_count && + hsotg->core_params->dma_desc_enable <= 0) { intr_mask = dwc2_readl(hsotg->regs + GINTMSK); intr_mask &= ~GINTSTS_SOF; dwc2_writel(intr_mask, hsotg->regs + GINTMSK); -- cgit 1.4.1 From a6ef3e02542a33fb705e6977221deb0292b27398 Mon Sep 17 00:00:00 2001 From: John Youn Date: Wed, 27 Apr 2016 20:20:56 -0700 Subject: usb: dwc2: Proper cleanup on dr_mode failure Cleanup in probe if we fail to get dr_mode. Signed-off-by: John Youn Signed-off-by: Felipe Balbi --- drivers/usb/dwc2/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/dwc2') diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 88629bed6614..fc6f5251de5d 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -562,7 +562,7 @@ static int dwc2_driver_probe(struct platform_device *dev) retval = dwc2_get_dr_mode(hsotg); if (retval) - return retval; + goto error; /* * Reset before dwc2_get_hwparams() then it could get power-on real -- cgit 1.4.1