public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] amd5536udc: fixed shared interrupt bug and warning oops
@ 2009-08-11 22:00 Thomas Dahlmann
  2009-08-12  3:05 ` Vadim Lobanov
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Thomas Dahlmann @ 2009-08-11 22:00 UTC (permalink / raw)
  To: dbrownell; +Cc: vlobanov, linux-kernel, linux-usb

>From 9654f85cbeabec4b8652f9785bea317cd7068edb Mon Sep 17 00:00:00 2001
From: Thomas <dahlmann.thomas@arcor.de>
Date: Tue, 11 Aug 2009 22:09:55 +0200
Subject: [PATCH] amd5536udc: fixed shared interrupt bug and warning oops
  - fixed shared interrupt bug reported by Vadim Lobanov
  - fixed possible warning oops on driver unload when connected
  - prevent interrupt flood in PIO mode ("modprobe amd5536udc use_dma=0")
    when using gadget ether
  - applied patch "Drop NULL test on list_entry result" submitted by Julia Lawall

Signed-off-by: Thomas <dahlmann.thomas@arcor.de>
---
 drivers/usb/gadget/amd5536udc.c |  103 ++++++++++++++++++++------------------
 1 files changed, 54 insertions(+), 49 deletions(-)

diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index 77352cc..78fd192 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -1213,6 +1213,11 @@ udc_queue(struct usb_ep *usbep, struct usb_request *usbreq, gfp_t gfp)
 				tmp &= AMD_UNMASK_BIT(ep->num);
 				writel(tmp, &dev->regs->ep_irqmsk);
 			}
+		} else if (ep->in) {
+				/* enable ep irq */
+				tmp = readl(&dev->regs->ep_irqmsk);
+				tmp &= AMD_UNMASK_BIT(ep->num);
+				writel(tmp, &dev->regs->ep_irqmsk);
 		}
 
 	} else if (ep->dma) {
@@ -2005,18 +2010,17 @@ __acquires(dev->lock)
 {
 	int tmp;
 
-	/* empty queues and init hardware */
-	udc_basic_init(dev);
-	for (tmp = 0; tmp < UDC_EP_NUM; tmp++) {
-		empty_req_queue(&dev->ep[tmp]);
-	}
-
 	if (dev->gadget.speed != USB_SPEED_UNKNOWN) {
 		spin_unlock(&dev->lock);
 		driver->disconnect(&dev->gadget);
 		spin_lock(&dev->lock);
 	}
-	/* init */
+
+	/* empty queues and init hardware */
+	udc_basic_init(dev);
+	for (tmp = 0; tmp < UDC_EP_NUM; tmp++)
+		empty_req_queue(&dev->ep[tmp]);
+
 	udc_setup_endpoints(dev);
 }
 
@@ -2378,40 +2382,34 @@ static irqreturn_t udc_data_in_isr(struct udc *dev, int ep_ix)
 		if (!ep->cancel_transfer && !list_empty(&ep->queue)) {
 			req = list_entry(ep->queue.next,
 					struct udc_request, queue);
-			if (req) {
-				/*
-				 * length bytes transfered
-				 * check dma done of last desc. in PPBDU mode
-				 */
-				if (use_dma_ppb_du) {
-					td = udc_get_last_dma_desc(req);
-					if (td) {
-						dma_done =
-							AMD_GETBITS(td->status,
-							UDC_DMA_IN_STS_BS);
-						/* don't care DMA done */
-						req->req.actual =
-							req->req.length;
-					}
-				} else {
-					/* assume all bytes transferred */
+			/*
+			 * length bytes transfered
+			 * check dma done of last desc. in PPBDU mode
+			 */
+			if (use_dma_ppb_du) {
+				td = udc_get_last_dma_desc(req);
+				if (td) {
+					dma_done =
+						AMD_GETBITS(td->status,
+						UDC_DMA_IN_STS_BS);
+					/* don't care DMA done */
 					req->req.actual = req->req.length;
 				}
+			} else {
+				/* assume all bytes transferred */
+				req->req.actual = req->req.length;
+			}
 
-				if (req->req.actual == req->req.length) {
-					/* complete req */
-					complete_req(ep, req, 0);
-					req->dma_going = 0;
-					/* further request available ? */
-					if (list_empty(&ep->queue)) {
-						/* disable interrupt */
-						tmp = readl(
-							&dev->regs->ep_irqmsk);
-						tmp |= AMD_BIT(ep->num);
-						writel(tmp,
-							&dev->regs->ep_irqmsk);
-					}
-
+			if (req->req.actual == req->req.length) {
+				/* complete req */
+				complete_req(ep, req, 0);
+				req->dma_going = 0;
+				/* further request available ? */
+				if (list_empty(&ep->queue)) {
+					/* disable interrupt */
+					tmp = readl(&dev->regs->ep_irqmsk);
+					tmp |= AMD_BIT(ep->num);
+					writel(tmp, &dev->regs->ep_irqmsk);
 				}
 			}
 		}
@@ -2478,6 +2476,13 @@ static irqreturn_t udc_data_in_isr(struct udc *dev, int ep_ix)
 				}
 			}
 
+		} else if (!use_dma && ep->in) {
+			/* disable interrupt */
+			tmp = readl(
+				&dev->regs->ep_irqmsk);
+			tmp |= AMD_BIT(ep->num);
+			writel(tmp,
+				&dev->regs->ep_irqmsk);
 		}
 	}
 	/* clear status bits */
@@ -3285,6 +3290,17 @@ static int udc_pci_probe(
 		goto finished;
 	}
 
+	spin_lock_init(&dev->lock);
+	/* udc csr registers base */
+	dev->csr = dev->virt_addr + UDC_CSR_ADDR;
+	/* dev registers base */
+	dev->regs = dev->virt_addr + UDC_DEVCFG_ADDR;
+	/* ep registers base */
+	dev->ep_regs = dev->virt_addr + UDC_EPREGS_ADDR;
+	/* fifo's base */
+	dev->rxfifo = (u32 __iomem *)(dev->virt_addr + UDC_RXFIFO_ADDR);
+	dev->txfifo = (u32 __iomem *)(dev->virt_addr + UDC_TXFIFO_ADDR);
+
 	if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) {
 		dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq);
 		kfree(dev);
@@ -3337,7 +3353,6 @@ static int udc_probe(struct udc *dev)
 	udc_pollstall_timer.data = 0;
 
 	/* device struct setup */
-	spin_lock_init(&dev->lock);
 	dev->gadget.ops = &udc_ops;
 
 	dev_set_name(&dev->gadget.dev, "gadget");
@@ -3346,16 +3361,6 @@ static int udc_probe(struct udc *dev)
 	dev->gadget.name = name;
 	dev->gadget.is_dualspeed = 1;
 
-	/* udc csr registers base */
-	dev->csr = dev->virt_addr + UDC_CSR_ADDR;
-	/* dev registers base */
-	dev->regs = dev->virt_addr + UDC_DEVCFG_ADDR;
-	/* ep registers base */
-	dev->ep_regs = dev->virt_addr + UDC_EPREGS_ADDR;
-	/* fifo's base */
-	dev->rxfifo = (u32 __iomem *)(dev->virt_addr + UDC_RXFIFO_ADDR);
-	dev->txfifo = (u32 __iomem *)(dev->virt_addr + UDC_TXFIFO_ADDR);
-
 	/* init registers, interrupts, ... */
 	startup_registers(dev);
 
-- 
1.5.6.3




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] amd5536udc: fixed shared interrupt bug and warning oops
  2009-08-11 22:00 [PATCH] amd5536udc: fixed shared interrupt bug and warning oops Thomas Dahlmann
@ 2009-08-12  3:05 ` Vadim Lobanov
  2009-08-14  3:04 ` Vadim Lobanov
  2009-08-18 22:06 ` Andrew Morton
  2 siblings, 0 replies; 5+ messages in thread
From: Vadim Lobanov @ 2009-08-12  3:05 UTC (permalink / raw)
  To: Thomas Dahlmann; +Cc: dbrownell, linux-kernel, linux-usb

On Wed, 2009-08-12 at 00:00 +0200, Thomas Dahlmann wrote:
> >From 9654f85cbeabec4b8652f9785bea317cd7068edb Mon Sep 17 00:00:00 2001
> From: Thomas <dahlmann.thomas@arcor.de>
> Date: Tue, 11 Aug 2009 22:09:55 +0200
> Subject: [PATCH] amd5536udc: fixed shared interrupt bug and warning oops
>   - fixed shared interrupt bug reported by Vadim Lobanov
>   - fixed possible warning oops on driver unload when connected
>   - prevent interrupt flood in PIO mode ("modprobe amd5536udc use_dma=0")
>     when using gadget ether
>   - applied patch "Drop NULL test on list_entry result" submitted by Julia Lawall

I'll give this patch a spin on our boxes as soon as I get a chance to do
so. Thanks for sending it out. :)



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] amd5536udc: fixed shared interrupt bug and warning oops
  2009-08-11 22:00 [PATCH] amd5536udc: fixed shared interrupt bug and warning oops Thomas Dahlmann
  2009-08-12  3:05 ` Vadim Lobanov
@ 2009-08-14  3:04 ` Vadim Lobanov
  2009-08-18 22:06 ` Andrew Morton
  2 siblings, 0 replies; 5+ messages in thread
From: Vadim Lobanov @ 2009-08-14  3:04 UTC (permalink / raw)
  To: Thomas Dahlmann; +Cc: dbrownell, linux-kernel, linux-usb

On Wed, 2009-08-12 at 00:00 +0200, Thomas Dahlmann wrote:
> >From 9654f85cbeabec4b8652f9785bea317cd7068edb Mon Sep 17 00:00:00 2001
> From: Thomas <dahlmann.thomas@arcor.de>
> Date: Tue, 11 Aug 2009 22:09:55 +0200
> Subject: [PATCH] amd5536udc: fixed shared interrupt bug and warning oops
>   - fixed shared interrupt bug reported by Vadim Lobanov
>   - fixed possible warning oops on driver unload when connected
>   - prevent interrupt flood in PIO mode ("modprobe amd5536udc use_dma=0")
>     when using gadget ether
>   - applied patch "Drop NULL test on list_entry result" submitted by Julia Lawall
> 
> Signed-off-by: Thomas <dahlmann.thomas@arcor.de>

Looks good.

Tested-by: Vadim Lobanov <vlobanov@speakeasy.net>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] amd5536udc: fixed shared interrupt bug and warning oops
  2009-08-11 22:00 [PATCH] amd5536udc: fixed shared interrupt bug and warning oops Thomas Dahlmann
  2009-08-12  3:05 ` Vadim Lobanov
  2009-08-14  3:04 ` Vadim Lobanov
@ 2009-08-18 22:06 ` Andrew Morton
  2 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2009-08-18 22:06 UTC (permalink / raw)
  To: Thomas Dahlmann; +Cc: dbrownell, vlobanov, linux-kernel, linux-usb

On Wed, 12 Aug 2009 00:00:56 +0200
Thomas Dahlmann <dahlmann.thomas@arcor.de> wrote:

> Subject: [PATCH] amd5536udc: fixed shared interrupt bug and warning oops
>   - fixed shared interrupt bug reported by Vadim Lobanov
>   - fixed possible warning oops on driver unload when connected
>   - prevent interrupt flood in PIO mode ("modprobe amd5536udc use_dma=0")
>     when using gadget ether
>   - applied patch "Drop NULL test on list_entry result" submitted by Julia Lawall


Julia's patch is already in linux-next, so I can't apply this.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] amd5536udc: fixed shared interrupt bug and warning oops
@ 2009-10-06 14:23 Thomas Dahlmann
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Dahlmann @ 2009-10-06 14:23 UTC (permalink / raw)
  To: akpm; +Cc: dbrownell, linux-kernel, robert.richter

>From 38b535f604befaf16c6a3a1fc9fc80bcb56b8498 Mon Sep 17 00:00:00 2001
From: Thomas Dahlmann <dahlmann.thomas@arcor.de>
Date: Tue, 6 Oct 2009 16:01:04 +0200
Subject: [PATCH] amd5536udc: fixed shared interrupt bug and warning oops
 - fixed shared interrupt bug reported by Vadim Lobanov
 - fixed possible warning oops on driver unload when connected
 - prevent interrupt flood in PIO mode ("modprobe amd5536udc use_dma=0")
   when using gadget ether

Signed-off-by: Thomas Dahlmann <dahlmann.thomas@arcor.de>
---
 drivers/usb/gadget/amd5536udc.c |   49 +++++++++++++++++++++++---------------
 1 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index d5b6596..731150d 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -1213,7 +1213,12 @@ udc_queue(struct usb_ep *usbep, struct usb_request *usbreq, gfp_t gfp)
 				tmp &= AMD_UNMASK_BIT(ep->num);
 				writel(tmp, &dev->regs->ep_irqmsk);
 			}
-		}
+		} else if (ep->in) {
+				/* enable ep irq */
+				tmp = readl(&dev->regs->ep_irqmsk);
+				tmp &= AMD_UNMASK_BIT(ep->num);
+				writel(tmp, &dev->regs->ep_irqmsk);
+			}
 
 	} else if (ep->dma) {
 
@@ -2005,18 +2010,17 @@ __acquires(dev->lock)
 {
 	int tmp;
 
-	/* empty queues and init hardware */
-	udc_basic_init(dev);
-	for (tmp = 0; tmp < UDC_EP_NUM; tmp++) {
-		empty_req_queue(&dev->ep[tmp]);
-	}
-
 	if (dev->gadget.speed != USB_SPEED_UNKNOWN) {
 		spin_unlock(&dev->lock);
 		driver->disconnect(&dev->gadget);
 		spin_lock(&dev->lock);
 	}
-	/* init */
+
+	/* empty queues and init hardware */
+	udc_basic_init(dev);
+	for (tmp = 0; tmp < UDC_EP_NUM; tmp++)
+		empty_req_queue(&dev->ep[tmp]);
+
 	udc_setup_endpoints(dev);
 }
 
@@ -2472,6 +2476,13 @@ static irqreturn_t udc_data_in_isr(struct udc *dev, int ep_ix)
 				}
 			}
 
+		} else if (!use_dma && ep->in) {
+			/* disable interrupt */
+			tmp = readl(
+				&dev->regs->ep_irqmsk);
+			tmp |= AMD_BIT(ep->num);
+			writel(tmp,
+				&dev->regs->ep_irqmsk);
 		}
 	}
 	/* clear status bits */
@@ -3279,6 +3290,17 @@ static int udc_pci_probe(
 		goto finished;
 	}
 
+	spin_lock_init(&dev->lock);
+	/* udc csr registers base */
+	dev->csr = dev->virt_addr + UDC_CSR_ADDR;
+	/* dev registers base */
+	dev->regs = dev->virt_addr + UDC_DEVCFG_ADDR;
+	/* ep registers base */
+	dev->ep_regs = dev->virt_addr + UDC_EPREGS_ADDR;
+	/* fifo's base */
+	dev->rxfifo = (u32 __iomem *)(dev->virt_addr + UDC_RXFIFO_ADDR);
+	dev->txfifo = (u32 __iomem *)(dev->virt_addr + UDC_TXFIFO_ADDR);
+
 	if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) {
 		dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq);
 		kfree(dev);
@@ -3331,7 +3353,6 @@ static int udc_probe(struct udc *dev)
 	udc_pollstall_timer.data = 0;
 
 	/* device struct setup */
-	spin_lock_init(&dev->lock);
 	dev->gadget.ops = &udc_ops;
 
 	dev_set_name(&dev->gadget.dev, "gadget");
@@ -3340,16 +3361,6 @@ static int udc_probe(struct udc *dev)
 	dev->gadget.name = name;
 	dev->gadget.is_dualspeed = 1;
 
-	/* udc csr registers base */
-	dev->csr = dev->virt_addr + UDC_CSR_ADDR;
-	/* dev registers base */
-	dev->regs = dev->virt_addr + UDC_DEVCFG_ADDR;
-	/* ep registers base */
-	dev->ep_regs = dev->virt_addr + UDC_EPREGS_ADDR;
-	/* fifo's base */
-	dev->rxfifo = (u32 __iomem *)(dev->virt_addr + UDC_RXFIFO_ADDR);
-	dev->txfifo = (u32 __iomem *)(dev->virt_addr + UDC_TXFIFO_ADDR);
-
 	/* init registers, interrupts, ... */
 	startup_registers(dev);
 
-- 
1.5.6.3




^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-10-06 14:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-11 22:00 [PATCH] amd5536udc: fixed shared interrupt bug and warning oops Thomas Dahlmann
2009-08-12  3:05 ` Vadim Lobanov
2009-08-14  3:04 ` Vadim Lobanov
2009-08-18 22:06 ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2009-10-06 14:23 Thomas Dahlmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox