All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param
@ 2014-11-28 13:50 Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 01/17] net2280: Remove obsolete module param use_dma_chaining Ricardo Ribalda Delgado
                   ` (16 more replies)
  0 siblings, 17 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

This set of patches removes broken parameter use_dma_chaining, and the
unneeded full_speed,use_dma and use_msi.

Then does some code cleanout by removing duplicated and dead code.

Finally it removes the unconditional removed debug messages, since
they can be enabled by the user via dynamic printk.

Due to the fact that I am implementing the scather gatter on the top of
this tree I would like to get this merged/reviewed before continuing.

Ricardo Ribalda Delgado (17):
  net2280: Remove obsolete module param use_dma_chaining
  net2280: remove full_speed module parameter
  net2280: Remove module parameter use_msi
  net2280: Remove use_dma module parameter
  net2280: Remove dma_started field
  net2280: Remove restart_dma inline function definition
  net2280: Code cleanout remove ep_stdrsp function
  net2280: Remove field is_halt
  net2280: Remove function ep_stall
  net2280: Merge abort_dma for 228x and 338x
  net2280: Clean function net2280_queue
  net2280: Improve patching of defect 7374
  net2280: Remove function resume_dma
  net2280: Declare allow_status_338x as inline
  net2280: Simplify scan_dma_completions
  net2280: Move ASSERT_OUT_NAKING into out_flush
  net2280: Re-enable dynamic debug messages

 drivers/usb/gadget/udc/net2280.c | 525 ++++++++++-----------------------------
 drivers/usb/gadget/udc/net2280.h |  23 +-
 2 files changed, 129 insertions(+), 419 deletions(-)

-- 
2.1.3


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

* [PATCH 01/17] net2280: Remove obsolete module param use_dma_chaining
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 02/17] net2280: remove full_speed module parameter Ricardo Ribalda Delgado
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

use_dma_chaining module parameter was designed to avoid creating one irq
per package on a group of packages (with the help of the driver's flag
no_interrupt).

Unfortunately, when this parameter is enabled, the driver fails to work
on both net2280 and 3380 chips.

This patch removes this parameter, which was disabled by default.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 147 ++++-----------------------------------
 1 file changed, 13 insertions(+), 134 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index d6411e0..08c16ee 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -12,11 +12,7 @@
  * the Mass Storage, Serial, and Ethernet/RNDIS gadget drivers
  * as well as Gadget Zero and Gadgetfs.
  *
- * DMA is enabled by default.  Drivers using transfer queues might use
- * DMA chaining to remove IRQ latencies between transfers.  (Except when
- * short OUT transfers happen.)  Drivers can use the req->no_interrupt
- * hint to completely eliminate some IRQs, if a later IRQ is guaranteed
- * and DMA chaining is enabled.
+ * DMA is enabled by default.
  *
  * MSI is enabled by default.  The legacy IRQ is used if MSI couldn't
  * be enabled.
@@ -85,7 +81,6 @@ static const char *const ep_name[] = {
 };
 
 /* use_dma -- general goodness, fewer interrupts, less cpu load (vs PIO)
- * use_dma_chaining -- dma descriptor queueing gives even more irq reduction
  *
  * The net2280 DMA engines are not tightly integrated with their FIFOs;
  * not all cases are (yet) handled well in this driver or the silicon.
@@ -93,12 +88,10 @@ static const char *const ep_name[] = {
  * These two parameters let you use PIO or more aggressive DMA.
  */
 static bool use_dma = true;
-static bool use_dma_chaining;
 static bool use_msi = true;
 
 /* "modprobe net2280 use_dma=n" etc */
 module_param(use_dma, bool, 0444);
-module_param(use_dma_chaining, bool, 0444);
 module_param(use_msi, bool, 0444);
 
 /* mode 0 == ep-{a,b,c,d} 1K fifo each
@@ -202,15 +195,6 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
 	/* set speed-dependent max packet; may kick in high bandwidth */
 	set_max_speed(ep, max);
 
-	/* FIFO lines can't go to different packets.  PIO is ok, so
-	 * use it instead of troublesome (non-bulk) multi-packet DMA.
-	 */
-	if (ep->dma && (max % 4) != 0 && use_dma_chaining) {
-		ep_dbg(ep->dev, "%s, no dma for maxpacket %d\n",
-			ep->ep.name, ep->ep.maxpacket);
-		ep->dma = NULL;
-	}
-
 	/* set type, direction, address; reset fifo counters */
 	writel(BIT(FIFO_FLUSH), &ep->regs->ep_stat);
 	tmp = (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK);
@@ -747,8 +731,7 @@ static void fill_dma_desc(struct net2280_ep *ep,
 	req->valid = valid;
 	if (valid)
 		dmacount |= BIT(VALID_BIT);
-	if (likely(!req->req.no_interrupt || !use_dma_chaining))
-		dmacount |= BIT(DMA_DONE_INTERRUPT_ENABLE);
+	dmacount |= BIT(DMA_DONE_INTERRUPT_ENABLE);
 
 	/* td->dmadesc = previously set by caller */
 	td->dmaaddr = cpu_to_le32 (req->req.dma);
@@ -862,8 +845,7 @@ static void start_dma(struct net2280_ep *ep, struct net2280_request *req)
 	req->td->dmadesc = cpu_to_le32 (ep->td_dma);
 	fill_dma_desc(ep, req, 1);
 
-	if (!use_dma_chaining)
-		req->td->dmacount |= cpu_to_le32(BIT(END_OF_CHAIN));
+	req->td->dmacount |= cpu_to_le32(BIT(END_OF_CHAIN));
 
 	start_queue(ep, tmp, req->td_dma);
 }
@@ -1150,64 +1132,12 @@ static void scan_dma_completions(struct net2280_ep *ep)
 static void restart_dma(struct net2280_ep *ep)
 {
 	struct net2280_request	*req;
-	u32			dmactl = dmactl_default;
 
 	if (ep->stopped)
 		return;
 	req = list_entry(ep->queue.next, struct net2280_request, queue);
 
-	if (!use_dma_chaining) {
-		start_dma(ep, req);
-		return;
-	}
-
-	/* the 2280 will be processing the queue unless queue hiccups after
-	 * the previous transfer:
-	 *  IN:   wanted automagic zlp, head doesn't (or vice versa)
-	 *        DMA_FIFO_VALIDATE doesn't init from dma descriptors.
-	 *  OUT:  was "usb-short", we must restart.
-	 */
-	if (ep->is_in && !req->valid) {
-		struct net2280_request	*entry, *prev = NULL;
-		int			reqmode, done = 0;
-
-		ep_dbg(ep->dev, "%s dma hiccup td %p\n", ep->ep.name, req->td);
-		ep->in_fifo_validate = likely(req->req.zero ||
-				(req->req.length % ep->ep.maxpacket) != 0);
-		if (ep->in_fifo_validate)
-			dmactl |= BIT(DMA_FIFO_VALIDATE);
-		list_for_each_entry(entry, &ep->queue, queue) {
-			__le32		dmacount;
-
-			if (entry == req)
-				continue;
-			dmacount = entry->td->dmacount;
-			if (!done) {
-				reqmode = likely(entry->req.zero ||
-				   (entry->req.length % ep->ep.maxpacket));
-				if (reqmode == ep->in_fifo_validate) {
-					entry->valid = 1;
-					dmacount |= valid_bit;
-					entry->td->dmacount = dmacount;
-					prev = entry;
-					continue;
-				} else {
-					/* force a hiccup */
-					prev->td->dmacount |= dma_done_ie;
-					done = 1;
-				}
-			}
-
-			/* walk the rest of the queue so unlinks behave */
-			entry->valid = 0;
-			dmacount &= ~valid_bit;
-			entry->td->dmacount = dmacount;
-			prev = entry;
-		}
-	}
-
-	writel(0, &ep->dma->dmactl);
-	start_queue(ep, dmactl, req->td_dma);
+	start_dma(ep, req);
 }
 
 static void abort_dma_228x(struct net2280_ep *ep)
@@ -1306,25 +1236,6 @@ static int net2280_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 			done(ep, req, -ECONNRESET);
 		}
 		req = NULL;
-
-	/* patch up hardware chaining data */
-	} else if (ep->dma && use_dma_chaining) {
-		if (req->queue.prev == ep->queue.next) {
-			writel(le32_to_cpu(req->td->dmadesc),
-				&ep->dma->dmadesc);
-			if (req->td->dmacount & dma_done_ie)
-				writel(readl(&ep->dma->dmacount) |
-						le32_to_cpu(dma_done_ie),
-					&ep->dma->dmacount);
-		} else {
-			struct net2280_request	*prev;
-
-			prev = list_entry(req->queue.prev,
-				struct net2280_request, queue);
-			prev->td->dmadesc = req->td->dmadesc;
-			if (req->td->dmacount & dma_done_ie)
-				prev->td->dmacount |= dma_done_ie;
-		}
 	}
 
 	if (req)
@@ -1609,9 +1520,7 @@ static ssize_t registers_show(struct device *_dev,
 			"pci irqenb0 %02x irqenb1 %08x "
 			"irqstat0 %04x irqstat1 %08x\n",
 			driver_name, dev->chiprev,
-			use_dma
-				? (use_dma_chaining ? "chaining" : "enabled")
-				: "disabled",
+			use_dma ? "enabled" : "disabled",
 			readl(&dev->regs->devinit),
 			readl(&dev->regs->fifoctl),
 			s,
@@ -3423,17 +3332,12 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
 				continue;
 		}
 
-		/* chaining should stop on abort, short OUT from fifo,
-		 * or (stat0 codepath) short OUT transfer.
-		 */
-		if (!use_dma_chaining) {
-			if (!(tmp & BIT(DMA_TRANSACTION_DONE_INTERRUPT))) {
-				ep_dbg(ep->dev, "%s no xact done? %08x\n",
-					ep->ep.name, tmp);
-				continue;
-			}
-			stop_dma(ep->dma);
+		if (!(tmp & BIT(DMA_TRANSACTION_DONE_INTERRUPT))) {
+			ep_dbg(ep->dev, "%s no xact done? %08x\n",
+				ep->ep.name, tmp);
+			continue;
 		}
+		stop_dma(ep->dma);
 
 		/* OUT transfers terminate when the data from the
 		 * host is in our memory.  Process whatever's done.
@@ -3448,30 +3352,9 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
 		scan_dma_completions(ep);
 
 		/* disable dma on inactive queues; else maybe restart */
-		if (list_empty(&ep->queue)) {
-			if (use_dma_chaining)
-				stop_dma(ep->dma);
-		} else {
+		if (!list_empty(&ep->queue)) {
 			tmp = readl(&dma->dmactl);
-			if (!use_dma_chaining || (tmp & BIT(DMA_ENABLE)) == 0)
-				restart_dma(ep);
-			else if (ep->is_in && use_dma_chaining) {
-				struct net2280_request	*req;
-				__le32			dmacount;
-
-				/* the descriptor at the head of the chain
-				 * may still have VALID_BIT clear; that's
-				 * used to trigger changing DMA_FIFO_VALIDATE
-				 * (affects automagic zlp writes).
-				 */
-				req = list_entry(ep->queue.next,
-						struct net2280_request, queue);
-				dmacount = req->td->dmacount;
-				dmacount &= cpu_to_le32(BIT(VALID_BIT) |
-						DMA_BYTE_COUNT_MASK);
-				if (dmacount && (dmacount & valid_bit) == 0)
-					restart_dma(ep);
-			}
+			restart_dma(ep);
 		}
 		ep->irqs++;
 	}
@@ -3581,9 +3464,6 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	void			__iomem *base = NULL;
 	int			retval, i;
 
-	if (!use_dma)
-		use_dma_chaining = 0;
-
 	/* alloc, and start init */
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (dev == NULL) {
@@ -3742,8 +3622,7 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	ep_info(dev, "irq %d, pci mem %p, chip rev %04x\n",
 			pdev->irq, base, dev->chiprev);
 	ep_info(dev, "version: " DRIVER_VERSION "; dma %s %s\n",
-		use_dma	? (use_dma_chaining ? "chaining" : "enabled")
-			: "disabled",
+		use_dma	? "enabled" : "disabled",
 		dev->enhanced_mode ? "enhanced mode" : "legacy mode");
 	retval = device_create_file(&pdev->dev, &dev_attr_registers);
 	if (retval)
-- 
2.1.3


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

* [PATCH 02/17] net2280: remove full_speed module parameter
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 01/17] net2280: Remove obsolete module param use_dma_chaining Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 03/17] net2280: Remove module parameter use_msi Ricardo Ribalda Delgado
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

This patch removes the full_speed parameter used force full-speed
operation.

It was designed exclusively for testing purposes, and there is no
reason to maintain this in a production kernel.

Reverts: 2f0760774711c957c395b31131b848043af98edf
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 08c16ee..27b94c6 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -113,11 +113,6 @@ static bool enable_suspend;
 /* "modprobe net2280 enable_suspend=1" etc */
 module_param(enable_suspend, bool, 0444);
 
-/* force full-speed operation */
-static bool full_speed;
-module_param(full_speed, bool, 0444);
-MODULE_PARM_DESC(full_speed, "force full-speed mode -- for testing only!");
-
 #define	DIR_STRING(bAddress) (((bAddress) & USB_DIR_IN) ? "in" : "out")
 
 static char *type_string(u8 bmAttributes)
@@ -2291,11 +2286,7 @@ static int net2280_start(struct usb_gadget *_gadget,
 	if (retval)
 		goto err_func;
 
-	/* Enable force-full-speed testing mode, if desired */
-	if (full_speed && (dev->quirks & PLX_LEGACY))
-		writel(BIT(FORCE_FULL_SPEED_MODE), &dev->usb->xcvrdiag);
-
-	/* ... then enable host detection and ep0; and we're ready
+	/* enable host detection and ep0; and we're ready
 	 * for set_configuration as well as eventual disconnect.
 	 */
 	net2280_led_active(dev, 1);
@@ -2353,10 +2344,6 @@ static int net2280_stop(struct usb_gadget *_gadget)
 
 	net2280_led_active(dev, 0);
 
-	/* Disable full-speed test mode */
-	if (dev->quirks & PLX_LEGACY)
-		writel(0, &dev->usb->xcvrdiag);
-
 	device_remove_file(&dev->pdev->dev, &dev_attr_function);
 	device_remove_file(&dev->pdev->dev, &dev_attr_queues);
 
@@ -3655,9 +3642,6 @@ static void net2280_shutdown(struct pci_dev *pdev)
 	/* disable the pullup so the host will think we're gone */
 	writel(0, &dev->usb->usbctl);
 
-	/* Disable full-speed test mode */
-	if (dev->quirks & PLX_LEGACY)
-		writel(0, &dev->usb->xcvrdiag);
 }
 
 
-- 
2.1.3


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

* [PATCH 03/17] net2280: Remove module parameter use_msi
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 01/17] net2280: Remove obsolete module param use_dma_chaining Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 02/17] net2280: remove full_speed module parameter Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 04/17] net2280: Remove use_dma module parameter Ricardo Ribalda Delgado
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

Parameter use_msi was used to enable msi irq on usb338x chips, it was
enabled by default.

There is no reason to prefer non-msi irq on usb338x, and it falls back
to non msi on error.

Therefore remove this option.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 27b94c6..fc5c0a2 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -88,11 +88,9 @@ static const char *const ep_name[] = {
  * These two parameters let you use PIO or more aggressive DMA.
  */
 static bool use_dma = true;
-static bool use_msi = true;
 
 /* "modprobe net2280 use_dma=n" etc */
 module_param(use_dma, bool, 0444);
-module_param(use_msi, bool, 0444);
 
 /* mode 0 == ep-{a,b,c,d} 1K fifo each
  * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable
@@ -3426,7 +3424,7 @@ static void net2280_remove(struct pci_dev *pdev)
 	}
 	if (dev->got_irq)
 		free_irq(pdev->irq, dev);
-	if (use_msi && dev->quirks & PLX_SUPERSPEED)
+	if (dev->quirks & PLX_SUPERSPEED)
 		pci_disable_msi(pdev);
 	if (dev->regs)
 		iounmap(dev->regs);
@@ -3549,7 +3547,7 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		goto done;
 	}
 
-	if (use_msi && (dev->quirks & PLX_SUPERSPEED))
+	if (dev->quirks & PLX_SUPERSPEED)
 		if (pci_enable_msi(pdev))
 			ep_err(dev, "Failed to enable MSI mode\n");
 
-- 
2.1.3


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

* [PATCH 04/17] net2280: Remove use_dma module parameter
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (2 preceding siblings ...)
  2014-11-28 13:50 ` [PATCH 03/17] net2280: Remove module parameter use_msi Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 05/17] net2280: Remove dma_started field Ricardo Ribalda Delgado
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

use_dma parameter was designed to enable the dma on the chip. It was
enabled by default.

It comes from the time when the dma was not reliable. Now it has been
working ok in production.

This patch removes this parameter.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 33 +++++----------------------------
 1 file changed, 5 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index fc5c0a2..230b8d4 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -80,18 +80,6 @@ static const char *const ep_name[] = {
 	"ep-e", "ep-f", "ep-g", "ep-h",
 };
 
-/* use_dma -- general goodness, fewer interrupts, less cpu load (vs PIO)
- *
- * The net2280 DMA engines are not tightly integrated with their FIFOs;
- * not all cases are (yet) handled well in this driver or the silicon.
- * Some gadget drivers work better with the dma support here than others.
- * These two parameters let you use PIO or more aggressive DMA.
- */
-static bool use_dma = true;
-
-/* "modprobe net2280 use_dma=n" etc */
-module_param(use_dma, bool, 0444);
-
 /* mode 0 == ep-{a,b,c,d} 1K fifo each
  * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable
  * mode 2 == ep-a 2K fifo, ep-{b,c} 1K each, ep-d unavailable
@@ -455,7 +443,7 @@ static int net2280_disable(struct usb_ep *_ep)
 	/* synch memory views with the device */
 	(void)readl(&ep->cfg->ep_cfg);
 
-	if (use_dma && !ep->dma && ep->num >= 1 && ep->num <= 4)
+	if (!ep->dma && ep->num >= 1 && ep->num <= 4)
 		ep->dma = &ep->dev->dma[ep->num - 1];
 
 	spin_unlock_irqrestore(&ep->dev->lock, flags);
@@ -1508,12 +1496,11 @@ static ssize_t registers_show(struct device *_dev,
 
 	/* Main Control Registers */
 	t = scnprintf(next, size, "%s version " DRIVER_VERSION
-			", chiprev %04x, dma %s\n\n"
+			", chiprev %04x\n\n"
 			"devinit %03x fifoctl %08x gadget '%s'\n"
 			"pci irqenb0 %02x irqenb1 %08x "
 			"irqstat0 %04x irqstat1 %08x\n",
 			driver_name, dev->chiprev,
-			use_dma ? "enabled" : "disabled",
 			readl(&dev->regs->devinit),
 			readl(&dev->regs->fifoctl),
 			s,
@@ -1995,10 +1982,6 @@ static void usb_reset(struct net2280 *dev)
 static void usb_reinit_228x(struct net2280 *dev)
 {
 	u32	tmp;
-	int	init_dma;
-
-	/* use_dma changes are ignored till next device re-init */
-	init_dma = use_dma;
 
 	/* basic endpoint init */
 	for (tmp = 0; tmp < 7; tmp++) {
@@ -2010,8 +1993,7 @@ static void usb_reinit_228x(struct net2280 *dev)
 
 		if (tmp > 0 && tmp <= 4) {
 			ep->fifo_size = 1024;
-			if (init_dma)
-				ep->dma = &dev->dma[tmp - 1];
+			ep->dma = &dev->dma[tmp - 1];
 		} else
 			ep->fifo_size = 64;
 		ep->regs = &dev->epregs[tmp];
@@ -2035,7 +2017,6 @@ static void usb_reinit_228x(struct net2280 *dev)
 
 static void usb_reinit_338x(struct net2280 *dev)
 {
-	int init_dma;
 	int i;
 	u32 tmp, val;
 	u32 fsmvalue;
@@ -2043,9 +2024,6 @@ static void usb_reinit_338x(struct net2280 *dev)
 	static const u32 ep_reg_addr[9] = { 0x00, 0xC0, 0x00, 0xC0, 0x00,
 						0x00, 0xC0, 0x00, 0xC0 };
 
-	/* use_dma changes are ignored till next device re-init */
-	init_dma = use_dma;
-
 	/* basic endpoint init */
 	for (i = 0; i < dev->n_ep; i++) {
 		struct net2280_ep *ep = &dev->ep[i];
@@ -2054,7 +2032,7 @@ static void usb_reinit_338x(struct net2280 *dev)
 		ep->dev = dev;
 		ep->num = i;
 
-		if (i > 0 && i <= 4 && init_dma)
+		if (i > 0 && i <= 4)
 			ep->dma = &dev->dma[i - 1];
 
 		if (dev->enhanced_mode) {
@@ -3606,8 +3584,7 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	ep_info(dev, "%s\n", driver_desc);
 	ep_info(dev, "irq %d, pci mem %p, chip rev %04x\n",
 			pdev->irq, base, dev->chiprev);
-	ep_info(dev, "version: " DRIVER_VERSION "; dma %s %s\n",
-		use_dma	? "enabled" : "disabled",
+	ep_info(dev, "version: " DRIVER_VERSION "; %s\n",
 		dev->enhanced_mode ? "enhanced mode" : "legacy mode");
 	retval = device_create_file(&pdev->dev, &dev_attr_registers);
 	if (retval)
-- 
2.1.3


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

* [PATCH 05/17] net2280: Remove dma_started field
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (3 preceding siblings ...)
  2014-11-28 13:50 ` [PATCH 04/17] net2280: Remove use_dma module parameter Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 06/17] net2280: Remove restart_dma inline function definition Ricardo Ribalda Delgado
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

Remove dma_started field from net2280_ep structure, since it is not used
by any function.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 4 ----
 drivers/usb/gadget/udc/net2280.h | 2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 230b8d4..0340462 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -834,16 +834,12 @@ static void start_dma(struct net2280_ep *ep, struct net2280_request *req)
 static inline void resume_dma(struct net2280_ep *ep)
 {
 	writel(readl(&ep->dma->dmactl) | BIT(DMA_ENABLE), &ep->dma->dmactl);
-
-	ep->dma_started = true;
 }
 
 static inline void ep_stop_dma(struct net2280_ep *ep)
 {
 	writel(readl(&ep->dma->dmactl) & ~BIT(DMA_ENABLE), &ep->dma->dmactl);
 	spin_stop_dma(ep->dma);
-
-	ep->dma_started = false;
 }
 
 static inline void
diff --git a/drivers/usb/gadget/udc/net2280.h b/drivers/usb/gadget/udc/net2280.h
index 03f1524..4c53b83 100644
--- a/drivers/usb/gadget/udc/net2280.h
+++ b/drivers/usb/gadget/udc/net2280.h
@@ -100,7 +100,7 @@ struct net2280_ep {
 	dma_addr_t				td_dma;	/* of dummy */
 	struct net2280				*dev;
 	unsigned long				irqs;
-	unsigned is_halt:1, dma_started:1;
+	unsigned is_halt:1;
 
 	/* analogous to a host-side qh */
 	struct list_head			queue;
-- 
2.1.3


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

* [PATCH 06/17] net2280: Remove restart_dma inline function definition
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (4 preceding siblings ...)
  2014-11-28 13:50 ` [PATCH 05/17] net2280: Remove dma_started field Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 14:46   ` Sergei Shtylyov
  2014-11-28 13:50 ` [PATCH 07/17] net2280: Code cleanout remove ep_stdrsp function Ricardo Ribalda Delgado
                   ` (10 subsequent siblings)
  16 siblings, 1 reply; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

restart_dma is not used before it is declaration. Therefore we can
remove this definition.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 0340462..e8c36db 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -1043,8 +1043,6 @@ dma_done(struct net2280_ep *ep,	struct net2280_request *req, u32 dmacount,
 	done(ep, req, status);
 }
 
-static void restart_dma(struct net2280_ep *ep);
-
 static void scan_dma_completions(struct net2280_ep *ep)
 {
 	/* only look at descriptors that were "naturally" retired,
-- 
2.1.3


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

* [PATCH 07/17] net2280: Code cleanout remove ep_stdrsp function
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (5 preceding siblings ...)
  2014-11-28 13:50 ` [PATCH 06/17] net2280: Remove restart_dma inline function definition Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 08/17] net2280: Remove field is_halt Ricardo Ribalda Delgado
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

ep_stdrsp was only called by handle_stat0_irqs_superspeed and with
always the same flags.

Remove the function and replace the call by the code inside the
function, since it is very simple once the dead code is removed.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 49 +++++++---------------------------------
 1 file changed, 8 insertions(+), 41 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index e8c36db..653a8a2 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -2668,46 +2668,6 @@ static void ep_stall(struct net2280_ep *ep, int stall)
 	}
 }
 
-static void ep_stdrsp(struct net2280_ep *ep, int value, int wedged)
-{
-	/* set/clear, then synch memory views with the device */
-	if (value) {
-		ep->stopped = 1;
-		if (ep->num == 0)
-			ep->dev->protocol_stall = 1;
-		else {
-			if (ep->dma)
-				ep_stop_dma(ep);
-			ep_stall(ep, true);
-		}
-
-		if (wedged)
-			ep->wedged = 1;
-	} else {
-		ep->stopped = 0;
-		ep->wedged = 0;
-
-		ep_stall(ep, false);
-
-		/* Flush the queue */
-		if (!list_empty(&ep->queue)) {
-			struct net2280_request *req =
-			    list_entry(ep->queue.next, struct net2280_request,
-				       queue);
-			if (ep->dma)
-				resume_dma(ep);
-			else {
-				if (ep->is_in)
-					write_fifo(ep, &req->req);
-				else {
-					if (read_fifo(ep, req))
-						done(ep, req, 0);
-				}
-			}
-		}
-	}
-}
-
 static void handle_stat0_irqs_superspeed(struct net2280 *dev,
 		struct net2280_ep *ep, struct usb_ctrlrequest r)
 {
@@ -2864,7 +2824,14 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
 			e = get_ep_by_addr(dev,	w_index);
 			if (!e || (w_value != USB_ENDPOINT_HALT))
 				goto do_stall3;
-			ep_stdrsp(e, true, false);
+			ep->stopped = 1;
+			if (ep->num == 0)
+				ep->dev->protocol_stall = 1;
+			else {
+				if (ep->dma)
+					ep_stop_dma(ep);
+				ep_stall(ep, true);
+			}
 			allow_status_338x(ep);
 			break;
 
-- 
2.1.3


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

* [PATCH 08/17] net2280: Remove field is_halt
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (6 preceding siblings ...)
  2014-11-28 13:50 ` [PATCH 07/17] net2280: Code cleanout remove ep_stdrsp function Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 09/17] net2280: Remove function ep_stall Ricardo Ribalda Delgado
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

Field is_halt is never used by any function.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 6 +-----
 drivers/usb/gadget/udc/net2280.h | 1 -
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 653a8a2..48e8d82 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -2643,7 +2643,6 @@ static void ep_stall(struct net2280_ep *ep, int stall)
 		       /* BIT(SET_NAK_PACKETS) | */
 		       BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE),
 		       &ep->regs->ep_rsp);
-		ep->is_halt = 1;
 	} else {
 		if (dev->gadget.speed == USB_SPEED_SUPER) {
 			/*
@@ -2663,7 +2662,6 @@ static void ep_stall(struct net2280_ep *ep, int stall)
 		writel(val,
 		       /* | BIT(CLEAR_NAK_PACKETS),*/
 		       &ep->regs->ep_rsp);
-		ep->is_halt = 0;
 		val = readl(&ep->regs->ep_rsp);
 	}
 }
@@ -2924,9 +2922,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
 		}
 		ep->stopped = 0;
 		dev->protocol_stall = 0;
-		if (dev->quirks & PLX_SUPERSPEED)
-			ep->is_halt = 0;
-		else{
+		if (!(dev->quirks & PLX_SUPERSPEED)) {
 			if (ep->dev->quirks & PLX_2280)
 				tmp = BIT(FIFO_OVERFLOW) |
 				    BIT(FIFO_UNDERFLOW);
diff --git a/drivers/usb/gadget/udc/net2280.h b/drivers/usb/gadget/udc/net2280.h
index 4c53b83..a16494a 100644
--- a/drivers/usb/gadget/udc/net2280.h
+++ b/drivers/usb/gadget/udc/net2280.h
@@ -100,7 +100,6 @@ struct net2280_ep {
 	dma_addr_t				td_dma;	/* of dummy */
 	struct net2280				*dev;
 	unsigned long				irqs;
-	unsigned is_halt:1;
 
 	/* analogous to a host-side qh */
 	struct list_head			queue;
-- 
2.1.3


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

* [PATCH 09/17] net2280: Remove function ep_stall
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (7 preceding siblings ...)
  2014-11-28 13:50 ` [PATCH 08/17] net2280: Remove field is_halt Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 10/17] net2280: Merge abort_dma for 228x and 338x Ricardo Ribalda Delgado
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

irqs_superspeed calls ep_stall instead of set/clear_halt, due to a
workaround for SS seqnum. Create a function with the workaround and
call set/clear_halt instead.

This way we can compare the code of super/normal speed and it is easier
to follow the code.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 44 ++++++++++++++--------------------------
 1 file changed, 15 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 48e8d82..5ba5132 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -2632,38 +2632,19 @@ restore_data_eps:
 	return;
 }
 
-static void ep_stall(struct net2280_ep *ep, int stall)
+static void ep_clear_seqnum(struct net2280_ep *ep)
 {
 	struct net2280 *dev = ep->dev;
 	u32 val;
 	static const u32 ep_pl[9] = { 0, 3, 4, 7, 8, 2, 5, 6, 9 };
 
-	if (stall) {
-		writel(BIT(SET_ENDPOINT_HALT) |
-		       /* BIT(SET_NAK_PACKETS) | */
-		       BIT(CLEAR_CONTROL_STATUS_PHASE_HANDSHAKE),
-		       &ep->regs->ep_rsp);
-	} else {
-		if (dev->gadget.speed == USB_SPEED_SUPER) {
-			/*
-			 * Workaround for SS SeqNum not cleared via
-			 * Endpoint Halt (Clear) bit. select endpoint
-			 */
-			val = readl(&dev->plregs->pl_ep_ctrl);
-			val = (val & ~0x1f) | ep_pl[ep->num];
-			writel(val, &dev->plregs->pl_ep_ctrl);
+	val = readl(&dev->plregs->pl_ep_ctrl) & ~0x1f;
+	val |= ep_pl[ep->num];
+	writel(val, &dev->plregs->pl_ep_ctrl);
+	val |= BIT(SEQUENCE_NUMBER_RESET);
+	writel(val, &dev->plregs->pl_ep_ctrl);
 
-			val |= BIT(SEQUENCE_NUMBER_RESET);
-			writel(val, &dev->plregs->pl_ep_ctrl);
-		}
-		val = readl(&ep->regs->ep_rsp);
-		val |= BIT(CLEAR_ENDPOINT_HALT) |
-			BIT(CLEAR_ENDPOINT_TOGGLE);
-		writel(val,
-		       /* | BIT(CLEAR_NAK_PACKETS),*/
-		       &ep->regs->ep_rsp);
-		val = readl(&ep->regs->ep_rsp);
-	}
+	return;
 }
 
 static void handle_stat0_irqs_superspeed(struct net2280 *dev,
@@ -2764,7 +2745,12 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
 			if (w_value != USB_ENDPOINT_HALT)
 				goto do_stall3;
 			ep_vdbg(dev, "%s clear halt\n", e->ep.name);
-			ep_stall(e, false);
+			/*
+			 * Workaround for SS SeqNum not cleared via
+			 * Endpoint Halt (Clear) bit. select endpoint
+			 */
+			ep_clear_seqnum(e);
+			clear_halt(e);
 			if (!list_empty(&e->queue) && e->td_dma)
 				restart_dma(e);
 			allow_status(ep);
@@ -2828,7 +2814,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
 			else {
 				if (ep->dma)
 					ep_stop_dma(ep);
-				ep_stall(ep, true);
+				set_halt(ep);
 			}
 			allow_status_338x(ep);
 			break;
@@ -2857,7 +2843,7 @@ do_stall3:
 				r.bRequestType, r.bRequest, tmp);
 		dev->protocol_stall = 1;
 		/* TD 9.9 Halt Endpoint test. TD 9.22 Set feature test */
-		ep_stall(ep, true);
+		set_halt(ep);
 	}
 
 next_endpoints3:
-- 
2.1.3


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

* [PATCH 10/17] net2280: Merge abort_dma for 228x and 338x
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (8 preceding siblings ...)
  2014-11-28 13:50 ` [PATCH 09/17] net2280: Remove function ep_stall Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 11/17] net2280: Clean function net2280_queue Ricardo Ribalda Delgado
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

We can use the same function for both families of chips and also remove
the ep_stop_dma() function.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 23 ++---------------------
 1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 5ba5132..46b66b3 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -836,12 +836,6 @@ static inline void resume_dma(struct net2280_ep *ep)
 	writel(readl(&ep->dma->dmactl) | BIT(DMA_ENABLE), &ep->dma->dmactl);
 }
 
-static inline void ep_stop_dma(struct net2280_ep *ep)
-{
-	writel(readl(&ep->dma->dmactl) & ~BIT(DMA_ENABLE), &ep->dma->dmactl);
-	spin_stop_dma(ep->dma);
-}
-
 static inline void
 queue_dma(struct net2280_ep *ep, struct net2280_request *req, int valid)
 {
@@ -1115,7 +1109,7 @@ static void restart_dma(struct net2280_ep *ep)
 	start_dma(ep, req);
 }
 
-static void abort_dma_228x(struct net2280_ep *ep)
+static void abort_dma(struct net2280_ep *ep)
 {
 	/* abort the current transfer */
 	if (likely(!list_empty(&ep->queue))) {
@@ -1127,19 +1121,6 @@ static void abort_dma_228x(struct net2280_ep *ep)
 	scan_dma_completions(ep);
 }
 
-static void abort_dma_338x(struct net2280_ep *ep)
-{
-	writel(BIT(DMA_ABORT), &ep->dma->dmastat);
-	spin_stop_dma(ep->dma);
-}
-
-static void abort_dma(struct net2280_ep *ep)
-{
-	if (ep->dev->quirks & PLX_LEGACY)
-		return abort_dma_228x(ep);
-	return abort_dma_338x(ep);
-}
-
 /* dequeue ALL requests */
 static void nuke(struct net2280_ep *ep)
 {
@@ -2813,7 +2794,7 @@ static void handle_stat0_irqs_superspeed(struct net2280 *dev,
 				ep->dev->protocol_stall = 1;
 			else {
 				if (ep->dma)
-					ep_stop_dma(ep);
+					abort_dma(ep);
 				set_halt(ep);
 			}
 			allow_status_338x(ep);
-- 
2.1.3


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

* [PATCH 11/17] net2280: Clean function net2280_queue
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (9 preceding siblings ...)
  2014-11-28 13:50 ` [PATCH 10/17] net2280: Merge abort_dma for 228x and 338x Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 12/17] net2280: Improve patching of defect 7374 Ricardo Ribalda Delgado
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

Do not duplicate the code for the else branch of the condition.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 46b66b3..ade4693 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -937,24 +937,12 @@ net2280_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
 	_req->actual = 0;
 
 	/* kickstart this i/o queue? */
-	if (list_empty(&ep->queue) && !ep->stopped) {
-		/* DMA request while EP halted */
-		if (ep->dma &&
-		    (readl(&ep->regs->ep_rsp) & BIT(CLEAR_ENDPOINT_HALT)) &&
-			(dev->quirks & PLX_SUPERSPEED)) {
-			int valid = 1;
-			if (ep->is_in) {
-				int expect;
-				expect = likely(req->req.zero ||
-						((req->req.length %
-						  ep->ep.maxpacket) != 0));
-				if (expect != ep->in_fifo_validate)
-					valid = 0;
-			}
-			queue_dma(ep, req, valid);
-		}
+	if  (list_empty(&ep->queue) && !ep->stopped &&
+		!((dev->quirks & PLX_SUPERSPEED) && ep->dma &&
+		  (readl(&ep->regs->ep_rsp) & BIT(CLEAR_ENDPOINT_HALT)))) {
+
 		/* use DMA if the endpoint supports it, else pio */
-		else if (ep->dma)
+		if (ep->dma)
 			start_dma(ep, req);
 		else {
 			/* maybe there's no control data, just status ack */
-- 
2.1.3


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

* [PATCH 12/17] net2280: Improve patching of defect 7374
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (10 preceding siblings ...)
  2014-11-28 13:50 ` [PATCH 11/17] net2280: Clean function net2280_queue Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 13/17] net2280: Remove function resume_dma Ricardo Ribalda Delgado
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

Once the defect 7374 is patched, there is no reason the keep reading the
idx scratch register.

Cache the content of the scratch idx register on device flag.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 153 +++++++++++++++++----------------------
 drivers/usb/gadget/udc/net2280.h |   3 +-
 2 files changed, 68 insertions(+), 88 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index ade4693..d4255f9 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -1765,76 +1765,73 @@ static void defect7374_disable_data_eps(struct net2280 *dev)
 static void defect7374_enable_data_eps_zero(struct net2280 *dev)
 {
 	u32 tmp = 0, tmp_reg;
-	u32 fsmvalue, scratch;
+	u32 scratch;
 	int i;
 	unsigned char ep_sel;
 
 	scratch = get_idx_reg(dev->regs, SCRATCH);
-	fsmvalue = scratch & (0xf << DEFECT7374_FSM_FIELD);
+
+	WARN_ON((scratch & (0xf << DEFECT7374_FSM_FIELD))
+		== DEFECT7374_FSM_SS_CONTROL_READ);
+
 	scratch &= ~(0xf << DEFECT7374_FSM_FIELD);
 
-	/*See if firmware needs to set up for workaround*/
-	if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ) {
-		ep_warn(dev, "Operate Defect 7374 workaround soft this time");
-		ep_warn(dev, "It will operate on cold-reboot and SS connect");
-
-		/*GPEPs:*/
-		tmp = ((0 << ENDPOINT_NUMBER) | BIT(ENDPOINT_DIRECTION) |
-		       (2 << OUT_ENDPOINT_TYPE) | (2 << IN_ENDPOINT_TYPE) |
-		       ((dev->enhanced_mode) ?
-		       BIT(OUT_ENDPOINT_ENABLE) : BIT(ENDPOINT_ENABLE)) |
-		       BIT(IN_ENDPOINT_ENABLE));
-
-		for (i = 1; i < 5; i++)
-			writel(tmp, &dev->ep[i].cfg->ep_cfg);
-
-		/* CSRIN, PCIIN, STATIN, RCIN*/
-		tmp = ((0 << ENDPOINT_NUMBER) | BIT(ENDPOINT_ENABLE));
-		writel(tmp, &dev->dep[1].dep_cfg);
-		writel(tmp, &dev->dep[3].dep_cfg);
-		writel(tmp, &dev->dep[4].dep_cfg);
-		writel(tmp, &dev->dep[5].dep_cfg);
-
-		/*Implemented for development and debug.
-		 * Can be refined/tuned later.*/
-		for (ep_sel = 0; ep_sel <= 21; ep_sel++) {
-			/* Select an endpoint for subsequent operations: */
-			tmp_reg = readl(&dev->plregs->pl_ep_ctrl);
-			writel(((tmp_reg & ~0x1f) | ep_sel),
-			       &dev->plregs->pl_ep_ctrl);
-
-			if (ep_sel == 1) {
-				tmp =
-				    (readl(&dev->plregs->pl_ep_ctrl) |
-				     BIT(CLEAR_ACK_ERROR_CODE) | 0);
-				writel(tmp, &dev->plregs->pl_ep_ctrl);
-				continue;
-			}
+	ep_warn(dev, "Operate Defect 7374 workaround soft this time");
+	ep_warn(dev, "It will operate on cold-reboot and SS connect");
 
-			if (ep_sel == 0 || (ep_sel > 9 && ep_sel < 14) ||
-					ep_sel == 18  || ep_sel == 20)
-				continue;
+	/*GPEPs:*/
+	tmp = ((0 << ENDPOINT_NUMBER) | BIT(ENDPOINT_DIRECTION) |
+			(2 << OUT_ENDPOINT_TYPE) | (2 << IN_ENDPOINT_TYPE) |
+			((dev->enhanced_mode) ?
+			 BIT(OUT_ENDPOINT_ENABLE) : BIT(ENDPOINT_ENABLE)) |
+			BIT(IN_ENDPOINT_ENABLE));
 
-			tmp = (readl(&dev->plregs->pl_ep_cfg_4) |
-				 BIT(NON_CTRL_IN_TOLERATE_BAD_DIR) | 0);
-			writel(tmp, &dev->plregs->pl_ep_cfg_4);
+	for (i = 1; i < 5; i++)
+		writel(tmp, &dev->ep[i].cfg->ep_cfg);
 
-			tmp = readl(&dev->plregs->pl_ep_ctrl) &
-				~BIT(EP_INITIALIZED);
-			writel(tmp, &dev->plregs->pl_ep_ctrl);
+	/* CSRIN, PCIIN, STATIN, RCIN*/
+	tmp = ((0 << ENDPOINT_NUMBER) | BIT(ENDPOINT_ENABLE));
+	writel(tmp, &dev->dep[1].dep_cfg);
+	writel(tmp, &dev->dep[3].dep_cfg);
+	writel(tmp, &dev->dep[4].dep_cfg);
+	writel(tmp, &dev->dep[5].dep_cfg);
 
+	/*Implemented for development and debug.
+	 * Can be refined/tuned later.*/
+	for (ep_sel = 0; ep_sel <= 21; ep_sel++) {
+		/* Select an endpoint for subsequent operations: */
+		tmp_reg = readl(&dev->plregs->pl_ep_ctrl);
+		writel(((tmp_reg & ~0x1f) | ep_sel),
+				&dev->plregs->pl_ep_ctrl);
+
+		if (ep_sel == 1) {
+			tmp =
+				(readl(&dev->plregs->pl_ep_ctrl) |
+				 BIT(CLEAR_ACK_ERROR_CODE) | 0);
+			writel(tmp, &dev->plregs->pl_ep_ctrl);
+			continue;
 		}
 
-		/* Set FSM to focus on the first Control Read:
-		 * - Tip: Connection speed is known upon the first
-		 * setup request.*/
-		scratch |= DEFECT7374_FSM_WAITING_FOR_CONTROL_READ;
-		set_idx_reg(dev->regs, SCRATCH, scratch);
+		if (ep_sel == 0 || (ep_sel > 9 && ep_sel < 14) ||
+				ep_sel == 18  || ep_sel == 20)
+			continue;
+
+		tmp = (readl(&dev->plregs->pl_ep_cfg_4) |
+				BIT(NON_CTRL_IN_TOLERATE_BAD_DIR) | 0);
+		writel(tmp, &dev->plregs->pl_ep_cfg_4);
+
+		tmp = readl(&dev->plregs->pl_ep_ctrl) &
+			~BIT(EP_INITIALIZED);
+		writel(tmp, &dev->plregs->pl_ep_ctrl);
 
-	} else{
-		ep_warn(dev, "Defect 7374 workaround soft will NOT operate");
-		ep_warn(dev, "It will operate on cold-reboot and SS connect");
 	}
+
+	/* Set FSM to focus on the first Control Read:
+	 * - Tip: Connection speed is known upon the first
+	 * setup request.*/
+	scratch |= DEFECT7374_FSM_WAITING_FOR_CONTROL_READ;
+	set_idx_reg(dev->regs, SCRATCH, scratch);
+
 }
 
 /* keeping it simple:
@@ -1885,21 +1882,13 @@ static void usb_reset_228x(struct net2280 *dev)
 static void usb_reset_338x(struct net2280 *dev)
 {
 	u32 tmp;
-	u32 fsmvalue;
 
 	dev->gadget.speed = USB_SPEED_UNKNOWN;
 	(void)readl(&dev->usb->usbctl);
 
 	net2280_led_init(dev);
 
-	fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
-			(0xf << DEFECT7374_FSM_FIELD);
-
-	/* See if firmware needs to set up for workaround: */
-	if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ) {
-		ep_info(dev, "%s: Defect 7374 FsmValue 0x%08x\n", __func__,
-		     fsmvalue);
-	} else {
+	if (dev->bug7734_patched) {
 		/* disable automatic responses, and irqs */
 		writel(0, &dev->usb->stdrsp);
 		writel(0, &dev->regs->pciirqenb0);
@@ -1916,7 +1905,7 @@ static void usb_reset_338x(struct net2280 *dev)
 
 	writel(~0, &dev->regs->irqstat0), writel(~0, &dev->regs->irqstat1);
 
-	if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ) {
+	if (dev->bug7734_patched) {
 		/* reset, and enable pci */
 		tmp = readl(&dev->regs->devinit) |
 		    BIT(PCI_ENABLE) |
@@ -1982,7 +1971,6 @@ static void usb_reinit_338x(struct net2280 *dev)
 {
 	int i;
 	u32 tmp, val;
-	u32 fsmvalue;
 	static const u32 ne[9] = { 0, 1, 2, 3, 4, 1, 2, 3, 4 };
 	static const u32 ep_reg_addr[9] = { 0x00, 0xC0, 0x00, 0xC0, 0x00,
 						0x00, 0xC0, 0x00, 0xC0 };
@@ -2020,14 +2008,7 @@ static void usb_reinit_338x(struct net2280 *dev)
 	dev->ep[0].stopped = 0;
 
 	/* Link layer set up */
-	fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
-				(0xf << DEFECT7374_FSM_FIELD);
-
-	/* See if driver needs to set up for workaround: */
-	if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ)
-		ep_info(dev, "%s: Defect 7374 FsmValue %08x\n",
-						__func__, fsmvalue);
-	else {
+	if (dev->bug7734_patched) {
 		tmp = readl(&dev->usb_ext->usbctl2) &
 		    ~(BIT(U1_ENABLE) | BIT(U2_ENABLE) | BIT(LTM_ENABLE));
 		writel(tmp, &dev->usb_ext->usbctl2);
@@ -2134,15 +2115,8 @@ static void ep0_start_228x(struct net2280 *dev)
 
 static void ep0_start_338x(struct net2280 *dev)
 {
-	u32 fsmvalue;
 
-	fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
-			(0xf << DEFECT7374_FSM_FIELD);
-
-	if (fsmvalue != DEFECT7374_FSM_SS_CONTROL_READ)
-		ep_info(dev, "%s: Defect 7374 FsmValue %08x\n", __func__,
-		     fsmvalue);
-	else
+	if (dev->bug7734_patched)
 		writel(BIT(CLEAR_NAK_OUT_PACKETS_MODE) |
 		       BIT(SET_EP_HIDE_STATUS_PHASE),
 		       &dev->epregs[0].ep_rsp);
@@ -2230,7 +2204,7 @@ static int net2280_start(struct usb_gadget *_gadget,
 	 */
 	net2280_led_active(dev, 1);
 
-	if (dev->quirks & PLX_SUPERSPEED)
+	if ((dev->quirks & PLX_SUPERSPEED) && !dev->bug7734_patched)
 		defect7374_enable_data_eps_zero(dev);
 
 	ep0_start(dev);
@@ -2552,6 +2526,7 @@ static void defect7374_workaround(struct net2280 *dev, struct usb_ctrlrequest r)
 		 * run after the next USB connection.
 		 */
 		scratch |= DEFECT7374_FSM_NON_SS_CONTROL_READ;
+		dev->bug7734_patched = 1;
 		goto restore_data_eps;
 	}
 
@@ -2565,6 +2540,7 @@ static void defect7374_workaround(struct net2280 *dev, struct usb_ctrlrequest r)
 		if ((state >= (ACK_GOOD_NORMAL << STATE)) &&
 			(state <= (ACK_GOOD_MORE_ACKS_TO_COME << STATE))) {
 			scratch |= DEFECT7374_FSM_SS_CONTROL_READ;
+			dev->bug7734_patched = 1;
 			break;
 		}
 
@@ -2904,7 +2880,7 @@ static void handle_stat0_irqs(struct net2280 *dev, u32 stat)
 		cpu_to_le32s(&u.raw[0]);
 		cpu_to_le32s(&u.raw[1]);
 
-		if (dev->quirks & PLX_SUPERSPEED)
+		if ((dev->quirks & PLX_SUPERSPEED) && !dev->bug7734_patched)
 			defect7374_workaround(dev, u.r);
 
 		tmp = 0;
@@ -3418,9 +3394,12 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		fsmvalue = get_idx_reg(dev->regs, SCRATCH) &
 					(0xf << DEFECT7374_FSM_FIELD);
 		/* See if firmware needs to set up for workaround: */
-		if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ)
+		if (fsmvalue == DEFECT7374_FSM_SS_CONTROL_READ) {
+			dev->bug7734_patched = 1;
 			writel(0, &dev->usb->usbctl);
-	} else{
+		} else
+			dev->bug7734_patched = 0;
+	} else {
 		dev->enhanced_mode = 0;
 		dev->n_ep = 7;
 		/* put into initial config, link up all endpoints */
diff --git a/drivers/usb/gadget/udc/net2280.h b/drivers/usb/gadget/udc/net2280.h
index a16494a..c7c7981 100644
--- a/drivers/usb/gadget/udc/net2280.h
+++ b/drivers/usb/gadget/udc/net2280.h
@@ -165,7 +165,8 @@ struct net2280 {
 					ltm_enable:1,
 					wakeup_enable:1,
 					selfpowered:1,
-					addressed_state:1;
+					addressed_state:1,
+					bug7734_patched:1;
 	u16				chiprev;
 	int enhanced_mode;
 	int n_ep;
-- 
2.1.3


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

* [PATCH 13/17] net2280: Remove function resume_dma
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (11 preceding siblings ...)
  2014-11-28 13:50 ` [PATCH 12/17] net2280: Improve patching of defect 7374 Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:50 ` [PATCH 14/17] net2280: Declare allow_status_338x as inline Ricardo Ribalda Delgado
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

Function resume_dma is not used, remove it.

The reason the compiler did not catch this dead code is the inline
modifier.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index d4255f9..cc76181 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -831,11 +831,6 @@ static void start_dma(struct net2280_ep *ep, struct net2280_request *req)
 	start_queue(ep, tmp, req->td_dma);
 }
 
-static inline void resume_dma(struct net2280_ep *ep)
-{
-	writel(readl(&ep->dma->dmactl) | BIT(DMA_ENABLE), &ep->dma->dmactl);
-}
-
 static inline void
 queue_dma(struct net2280_ep *ep, struct net2280_request *req, int valid)
 {
-- 
2.1.3


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

* [PATCH 14/17] net2280: Declare allow_status_338x as inline
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (12 preceding siblings ...)
  2014-11-28 13:50 ` [PATCH 13/17] net2280: Remove function resume_dma Ricardo Ribalda Delgado
@ 2014-11-28 13:50 ` Ricardo Ribalda Delgado
  2014-11-28 13:51 ` [PATCH 15/17] net2280: Simplify scan_dma_completions Ricardo Ribalda Delgado
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:50 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

The function is very simple, does not declare any variable and it is
called in the irq path.

The counterpart for net228x is already declared as inline.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/net2280.h b/drivers/usb/gadget/udc/net2280.h
index c7c7981..b31deb0 100644
--- a/drivers/usb/gadget/udc/net2280.h
+++ b/drivers/usb/gadget/udc/net2280.h
@@ -125,7 +125,7 @@ static inline void allow_status(struct net2280_ep *ep)
 	ep->stopped = 1;
 }
 
-static void allow_status_338x(struct net2280_ep *ep)
+static inline void allow_status_338x(struct net2280_ep *ep)
 {
 	/*
 	 * Control Status Phase Handshake was set by the chip when the setup
-- 
2.1.3


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

* [PATCH 15/17] net2280: Simplify scan_dma_completions
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (13 preceding siblings ...)
  2014-11-28 13:50 ` [PATCH 14/17] net2280: Declare allow_status_338x as inline Ricardo Ribalda Delgado
@ 2014-11-28 13:51 ` Ricardo Ribalda Delgado
  2014-11-28 13:51 ` [PATCH 16/17] net2280: Move ASSERT_OUT_NAKING into out_flush Ricardo Ribalda Delgado
  2014-11-28 13:51 ` [PATCH 17/17] net2280: Re-enable dynamic debug messages Ricardo Ribalda Delgado
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:51 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

After fix superspeed dma_done was applied we can simplify the code by
removing the duplicated dma_done and letting the function check if there
are more completed dma transactions.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index cc76181..a978e6e 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -1051,9 +1051,8 @@ static void scan_dma_completions(struct net2280_ep *ep)
 			dma_done(ep, req, tmp, 0);
 			break;
 		} else if (!ep->is_in &&
-				(req->req.length % ep->ep.maxpacket) != 0) {
-			if (ep->dev->quirks & PLX_SUPERSPEED)
-				return dma_done(ep, req, tmp, 0);
+			   (req->req.length % ep->ep.maxpacket) &&
+			   !(ep->dev->quirks & PLX_SUPERSPEED)) {
 
 			tmp = readl(&ep->regs->ep_stat);
 			/* AVOID TROUBLE HERE by not issuing short reads from
-- 
2.1.3


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

* [PATCH 16/17] net2280: Move ASSERT_OUT_NAKING into out_flush
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (14 preceding siblings ...)
  2014-11-28 13:51 ` [PATCH 15/17] net2280: Simplify scan_dma_completions Ricardo Ribalda Delgado
@ 2014-11-28 13:51 ` Ricardo Ribalda Delgado
  2014-11-28 13:51 ` [PATCH 17/17] net2280: Re-enable dynamic debug messages Ricardo Ribalda Delgado
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:51 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

ASSERT_OUT_NAKING was only called by out_flush and was hidden behind a
ifdef.

This patch moves the inline function into out_flush and remove the
ifdef. The user can decide to print the debug message or not via dynamic
printk

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 10 ++++++++--
 drivers/usb/gadget/udc/net2280.h | 17 -----------------
 2 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index a978e6e..b1c253e 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -575,9 +575,15 @@ static void out_flush(struct net2280_ep *ep)
 	u32	__iomem *statp;
 	u32	tmp;
 
-	ASSERT_OUT_NAKING(ep);
-
 	statp = &ep->regs->ep_stat;
+
+	tmp = readl(statp);
+	if (tmp & BIT(NAK_OUT_PACKETS)) {
+		ep_dbg(ep->dev, "%s %s %08x !NAK\n",
+			ep->ep.name, __func__, tmp);
+		writel(BIT(SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
+	}
+
 	writel(BIT(DATA_OUT_PING_TOKEN_INTERRUPT) |
 		BIT(DATA_PACKET_RECEIVED_INTERRUPT),
 		statp);
diff --git a/drivers/usb/gadget/udc/net2280.h b/drivers/usb/gadget/udc/net2280.h
index b31deb0..a307dce 100644
--- a/drivers/usb/gadget/udc/net2280.h
+++ b/drivers/usb/gadget/udc/net2280.h
@@ -356,23 +356,6 @@ static inline void start_out_naking(struct net2280_ep *ep)
 	readl(&ep->regs->ep_rsp);
 }
 
-#ifdef DEBUG
-static inline void assert_out_naking(struct net2280_ep *ep, const char *where)
-{
-	u32	tmp = readl(&ep->regs->ep_stat);
-
-	if ((tmp & BIT(NAK_OUT_PACKETS)) == 0) {
-		ep_dbg(ep->dev, "%s %s %08x !NAK\n",
-				ep->ep.name, where, tmp);
-		writel(BIT(SET_NAK_OUT_PACKETS),
-			&ep->regs->ep_rsp);
-	}
-}
-#define ASSERT_OUT_NAKING(ep) assert_out_naking(ep, __func__)
-#else
-#define ASSERT_OUT_NAKING(ep) do {} while (0)
-#endif
-
 static inline void stop_out_naking(struct net2280_ep *ep)
 {
 	u32	tmp;
-- 
2.1.3


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

* [PATCH 17/17] net2280: Re-enable dynamic debug messages
  2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
                   ` (15 preceding siblings ...)
  2014-11-28 13:51 ` [PATCH 16/17] net2280: Move ASSERT_OUT_NAKING into out_flush Ricardo Ribalda Delgado
@ 2014-11-28 13:51 ` Ricardo Ribalda Delgado
  16 siblings, 0 replies; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 13:51 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Ricardo Ribalda Delgado,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

Some debug messages were not build due to unconditional #if 0.

These messages are very useful for debugging and the user can enable
them on demand via dynamic debug.

If they are not enabled the performance is not affected.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/usb/gadget/udc/net2280.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index b1c253e..d2fabdc 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -927,10 +927,8 @@ net2280_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
 			return ret;
 	}
 
-#if 0
 	ep_vdbg(dev, "%s queue req %p, len %d buf %p\n",
 			_ep->name, _req, _req->length, _req->buf);
-#endif
 
 	spin_lock_irqsave(&dev->lock, flags);
 
@@ -2287,10 +2285,10 @@ static void handle_ep_small(struct net2280_ep *ep)
 	/* ack all, and handle what we care about */
 	t = readl(&ep->regs->ep_stat);
 	ep->irqs++;
-#if 0
+
 	ep_vdbg(ep->dev, "%s ack ep_stat %08x, req %p\n",
 			ep->ep.name, t, req ? &req->req : 0);
-#endif
+
 	if (!ep->is_in || (ep->dev->quirks & PLX_2280))
 		writel(t & ~BIT(NAK_OUT_PACKETS), &ep->regs->ep_stat);
 	else
-- 
2.1.3


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

* Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition
  2014-11-28 13:50 ` [PATCH 06/17] net2280: Remove restart_dma inline function definition Ricardo Ribalda Delgado
@ 2014-11-28 14:46   ` Sergei Shtylyov
  2014-11-28 15:21     ` Ricardo Ribalda Delgado
  0 siblings, 1 reply; 24+ messages in thread
From: Sergei Shtylyov @ 2014-11-28 14:46 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado, Felipe Balbi, Greg Kroah-Hartman,
	Peter Chen, Andrzej Pietrasiewicz, linux-usb, linux-kernel

Hello.

On 11/28/2014 04:50 PM, Ricardo Ribalda Delgado wrote:

> restart_dma is not used before it is declaration. Therefore we can

    s/it is/its/.

> remove this definition.

    You're removing the declaration, not definition.

> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
>   drivers/usb/gadget/udc/net2280.c | 2 --
>   1 file changed, 2 deletions(-)

> diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
> index 0340462..e8c36db 100644
> --- a/drivers/usb/gadget/udc/net2280.c
> +++ b/drivers/usb/gadget/udc/net2280.c
> @@ -1043,8 +1043,6 @@ dma_done(struct net2280_ep *ep,	struct net2280_request *req, u32 dmacount,
>   	done(ep, req, status);
>   }
>
> -static void restart_dma(struct net2280_ep *ep);
> -
>   static void scan_dma_completions(struct net2280_ep *ep)
>   {
>   	/* only look at descriptors that were "naturally" retired,

WBR, Sergei


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

* Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition
  2014-11-28 14:46   ` Sergei Shtylyov
@ 2014-11-28 15:21     ` Ricardo Ribalda Delgado
  2014-11-28 20:16       ` Sergei Shtylyov
  0 siblings, 1 reply; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-11-28 15:21 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Felipe Balbi, Greg Kroah-Hartman, Peter Chen,
	Andrzej Pietrasiewicz, Linux USB Mailing List, LKML

Hello

Thanks for reviewing. I will fix it and resend it on the next version
of the patchset to avoid spamming the ML

I guess it is ok to add your Reviewed-by

Thanks!


On Fri, Nov 28, 2014 at 3:46 PM, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
> Hello.
>
> On 11/28/2014 04:50 PM, Ricardo Ribalda Delgado wrote:
>
>> restart_dma is not used before it is declaration. Therefore we can
>
>
>    s/it is/its/.
>
>> remove this definition.
>
>
>    You're removing the declaration, not definition.
>
>> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
>> ---
>>   drivers/usb/gadget/udc/net2280.c | 2 --
>>   1 file changed, 2 deletions(-)
>
>
>> diff --git a/drivers/usb/gadget/udc/net2280.c
>> b/drivers/usb/gadget/udc/net2280.c
>> index 0340462..e8c36db 100644
>> --- a/drivers/usb/gadget/udc/net2280.c
>> +++ b/drivers/usb/gadget/udc/net2280.c
>> @@ -1043,8 +1043,6 @@ dma_done(struct net2280_ep *ep,   struct
>> net2280_request *req, u32 dmacount,
>>         done(ep, req, status);
>>   }
>>
>> -static void restart_dma(struct net2280_ep *ep);
>> -
>>   static void scan_dma_completions(struct net2280_ep *ep)
>>   {
>>         /* only look at descriptors that were "naturally" retired,
>
>
> WBR, Sergei
>



-- 
Ricardo Ribalda

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

* Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition
  2014-11-28 15:21     ` Ricardo Ribalda Delgado
@ 2014-11-28 20:16       ` Sergei Shtylyov
  2014-12-23 18:44         ` Felipe Balbi
  0 siblings, 1 reply; 24+ messages in thread
From: Sergei Shtylyov @ 2014-11-28 20:16 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado
  Cc: Felipe Balbi, Greg Kroah-Hartman, Peter Chen,
	Andrzej Pietrasiewicz, Linux USB Mailing List, LKML

On 11/28/2014 06:21 PM, Ricardo Ribalda Delgado wrote:

> Thanks for reviewing. I will fix it and resend it on the next version
> of the patchset to avoid spamming the ML

> I guess it is ok to add your Reviewed-by

    Yes, if you like.

> Thanks!

    Not at all. :-)

[...]

>> On 11/28/2014 04:50 PM, Ricardo Ribalda Delgado wrote:

>>> restart_dma is not used before it is declaration. Therefore we can

>>     s/it is/its/.

    Also s/declaration/definition/.

>>> remove this definition.

>>     You're removing the declaration, not definition.

WBR, Sergei


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

* Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition
  2014-11-28 20:16       ` Sergei Shtylyov
@ 2014-12-23 18:44         ` Felipe Balbi
  2014-12-23 20:20           ` Ricardo Ribalda Delgado
  0 siblings, 1 reply; 24+ messages in thread
From: Felipe Balbi @ 2014-12-23 18:44 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Ricardo Ribalda Delgado, Felipe Balbi, Greg Kroah-Hartman,
	Peter Chen, Andrzej Pietrasiewicz, Linux USB Mailing List, LKML

[-- Attachment #1: Type: text/plain, Size: 741 bytes --]

On Fri, Nov 28, 2014 at 11:16:16PM +0300, Sergei Shtylyov wrote:
> On 11/28/2014 06:21 PM, Ricardo Ribalda Delgado wrote:
> 
> >Thanks for reviewing. I will fix it and resend it on the next version
> >of the patchset to avoid spamming the ML
> 
> >I guess it is ok to add your Reviewed-by
> 
>    Yes, if you like.
> 
> >Thanks!
> 
>    Not at all. :-)
> 
> [...]
> 
> >>On 11/28/2014 04:50 PM, Ricardo Ribalda Delgado wrote:
> 
> >>>restart_dma is not used before it is declaration. Therefore we can
> 
> >>    s/it is/its/.
> 
>    Also s/declaration/definition/.
> 
> >>>remove this definition.
> 
> >>    You're removing the declaration, not definition.

do I get a new version of this patch ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition
  2014-12-23 18:44         ` Felipe Balbi
@ 2014-12-23 20:20           ` Ricardo Ribalda Delgado
  2014-12-23 23:44             ` Felipe Balbi
  0 siblings, 1 reply; 24+ messages in thread
From: Ricardo Ribalda Delgado @ 2014-12-23 20:20 UTC (permalink / raw)
  To: balbi
  Cc: Sergei Shtylyov, Greg Kroah-Hartman, Peter Chen,
	Andrzej Pietrasiewicz, Linux USB Mailing List, LKML

Hello Felipe

I was waiting for more comments for the other patches and I forgot to
resend this patch.

I am on holidays and without access to a computer with the right
tools, nevertheless , since the changes are only on the commit message
I have modified the patch with vi.

I have been very careful, but I cannot try to apply it. If it does not
work, please feel free to modify it yourself (if you want) or wait
until I am back


Thanks!!!

On Tue, Dec 23, 2014 at 7:44 PM, Felipe Balbi <balbi@ti.com> wrote:
> On Fri, Nov 28, 2014 at 11:16:16PM +0300, Sergei Shtylyov wrote:
>> On 11/28/2014 06:21 PM, Ricardo Ribalda Delgado wrote:
>>
>> >Thanks for reviewing. I will fix it and resend it on the next version
>> >of the patchset to avoid spamming the ML
>>
>> >I guess it is ok to add your Reviewed-by
>>
>>    Yes, if you like.
>>
>> >Thanks!
>>
>>    Not at all. :-)
>>
>> [...]
>>
>> >>On 11/28/2014 04:50 PM, Ricardo Ribalda Delgado wrote:
>>
>> >>>restart_dma is not used before it is declaration. Therefore we can
>>
>> >>    s/it is/its/.
>>
>>    Also s/declaration/definition/.
>>
>> >>>remove this definition.
>>
>> >>    You're removing the declaration, not definition.
>
> do I get a new version of this patch ?
>
> --
> balbi



-- 
Ricardo Ribalda

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

* Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition
  2014-12-23 20:20           ` Ricardo Ribalda Delgado
@ 2014-12-23 23:44             ` Felipe Balbi
  0 siblings, 0 replies; 24+ messages in thread
From: Felipe Balbi @ 2014-12-23 23:44 UTC (permalink / raw)
  To: Ricardo Ribalda Delgado
  Cc: balbi, Sergei Shtylyov, Greg Kroah-Hartman, Peter Chen,
	Andrzej Pietrasiewicz, Linux USB Mailing List, LKML

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

Hi,

(top-post :-)

On Tue, Dec 23, 2014 at 09:20:23PM +0100, Ricardo Ribalda Delgado wrote:
> Hello Felipe
> 
> I was waiting for more comments for the other patches and I forgot to
> resend this patch.
> 
> I am on holidays and without access to a computer with the right
> tools, nevertheless , since the changes are only on the commit message
> I have modified the patch with vi.
> 
> I have been very careful, but I cannot try to apply it. If it does not
> work, please feel free to modify it yourself (if you want) or wait
> until I am back

I very much like this series, quite a bit of code removed and things
which were already default are now only option. Very good work. It's now
all on my testing/next

cheers

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2014-12-23 23:45 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-28 13:50 [PATCH 00/17] net2280: Code cleanout, improve debug and remove broken param Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 01/17] net2280: Remove obsolete module param use_dma_chaining Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 02/17] net2280: remove full_speed module parameter Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 03/17] net2280: Remove module parameter use_msi Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 04/17] net2280: Remove use_dma module parameter Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 05/17] net2280: Remove dma_started field Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 06/17] net2280: Remove restart_dma inline function definition Ricardo Ribalda Delgado
2014-11-28 14:46   ` Sergei Shtylyov
2014-11-28 15:21     ` Ricardo Ribalda Delgado
2014-11-28 20:16       ` Sergei Shtylyov
2014-12-23 18:44         ` Felipe Balbi
2014-12-23 20:20           ` Ricardo Ribalda Delgado
2014-12-23 23:44             ` Felipe Balbi
2014-11-28 13:50 ` [PATCH 07/17] net2280: Code cleanout remove ep_stdrsp function Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 08/17] net2280: Remove field is_halt Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 09/17] net2280: Remove function ep_stall Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 10/17] net2280: Merge abort_dma for 228x and 338x Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 11/17] net2280: Clean function net2280_queue Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 12/17] net2280: Improve patching of defect 7374 Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 13/17] net2280: Remove function resume_dma Ricardo Ribalda Delgado
2014-11-28 13:50 ` [PATCH 14/17] net2280: Declare allow_status_338x as inline Ricardo Ribalda Delgado
2014-11-28 13:51 ` [PATCH 15/17] net2280: Simplify scan_dma_completions Ricardo Ribalda Delgado
2014-11-28 13:51 ` [PATCH 16/17] net2280: Move ASSERT_OUT_NAKING into out_flush Ricardo Ribalda Delgado
2014-11-28 13:51 ` [PATCH 17/17] net2280: Re-enable dynamic debug messages Ricardo Ribalda Delgado

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.