net2280: Code cleanout, improve debug and remove broken param
cover net2280: Code cleanout, improve debug and remove broken param
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(-)
Signature · 1 line
2.1.3
PATCH 1/17 net2280: Remove obsolete module param use_dma_chaining
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.
--- drivers/usb/gadget/udc/net2280.c | 147 ++++----------------------------------- 1 file changed, 13 insertions(+), 134 deletions(-)
drivers/usb/gadget/udc/net2280.c +13 -134
@@ -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)
Signature · 1 line
2.1.3
PATCH 2/17 net2280: remove full_speed module parameter
In reply to Ricardo Ribalda DelgadoThis 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
--- drivers/usb/gadget/udc/net2280.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-)
drivers/usb/gadget/udc/net2280.c +1 -17
@@ -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); }
Signature · 1 line
2.1.3
PATCH 3/17 net2280: Remove module parameter use_msi
In reply to Ricardo Ribalda DelgadoParameter 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.
--- drivers/usb/gadget/udc/net2280.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/gadget/udc/net2280.c +2 -4
@@ -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" );
Signature · 1 line
2.1.3
PATCH 4/17 net2280: Remove use_dma module parameter
In reply to Ricardo Ribalda Delgadouse_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.
--- drivers/usb/gadget/udc/net2280.c | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-)
drivers/usb/gadget/udc/net2280.c +5 -28
@@ -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)
Signature · 1 line
2.1.3
PATCH 5/17 net2280: Remove dma_started field
In reply to Ricardo Ribalda DelgadoRemove dma_started field from net2280_ep structure, since it is not used by any function.
--- drivers/usb/gadget/udc/net2280.c | 4 ---- drivers/usb/gadget/udc/net2280.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-)
drivers/usb/gadget/udc/net2280.c +0 -4
@@ -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
drivers/usb/gadget/udc/net2280.h +1 -1
@@ -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;
Signature · 1 line
2.1.3
PATCH 6/17 net2280: Remove restart_dma inline function definition
In reply to Ricardo Ribalda Delgadorestart_dma is not used before it is declaration. Therefore we can remove this definition.
--- drivers/usb/gadget/udc/net2280.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/gadget/udc/net2280.c +0 -2
@@ -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,
Signature · 1 line
2.1.3
Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition
Hello.
Quoted 1 line · Ricardo Ribalda Delgado
restart_dmais not used before it is declaration. Therefore we can
s/it is/its/.
Quoted 1 line
remove this definition.
You're removing the declaration, not definition.
Quoted 10 lines
Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/usb/gadget/udc/net2280.c | 2 -- 1 file changed, 2 deletions(-)drivers/usb/gadget/udc/net2280.c +0
-0
drivers/usb/gadget/udc/net2280.c dma_done(struct net2280_ep *ep, struct net2280_request *req, u32 dmacount, · line 1048
Quoted 8 lines
drivers/usb/gadget/udc/net2280.c +0
-2@@ -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
Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition
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!
Quoted 39 lines · Sergei Shtylyov
Hello.
Quoted 1 line · Ricardo Ribalda Delgado
restart_dmais not used before it is declaration. Therefore we cans/it is/its/.Quoted 1 line
remove this definition.
You're removing the declaration, not definition.
Quoted 20 lines
Signed-off-by Ricardo Ribalda Delgado <[email protected]>--- drivers/usb/gadget/udc/net2280.c | 2 -- 1 file changed, 2 deletions(-)drivers/usb/gadget/udc/net2280.c +0
-2@@ -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) {Quoted 1 line
/* only look at descriptors that were "naturally" retired,WBR, Sergei
Signature · 1 line
Ricardo Ribalda
Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition
Quoted 4 lines · Ricardo Ribalda Delgado
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.
Quoted 1 line
Thanks!
Not at all. :-)
[...]
Quoted 5 lines
Quoted 5 lines · Ricardo Ribalda Delgado
Quoted 2 lines
restart_dmais not used before it is declaration. Therefore we cans/it is/its/.
Also s/declaration/definition/.
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
remove this definition.
You're removing the declaration, not definition.
WBR, Sergei
Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition
Quoted 15 lines · Sergei Shtylyov
Quoted 4 lines · Ricardo Ribalda Delgado
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.
Quoted 1 line
Thanks!
Not at all. :-)[...]
Quoted 11 lines
Quoted 5 lines
Quoted 5 lines · Ricardo Ribalda Delgado
Quoted 2 lines
restart_dmais not used before it is declaration. Therefore we cans/it is/its/.Also s/declaration/definition/.
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
remove this definition.
You're removing the declaration, not definition.
do I get a new version of this patch ?
Signature · 1 line
balbi
Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition
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!!!
Quoted 32 lines · Felipe Balbi
Quoted 15 lines · Sergei Shtylyov
Quoted 4 lines · Ricardo Ribalda Delgado
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.
Quoted 1 line
Thanks!
Not at all. :-)[...]
Quoted 11 lines
Quoted 5 lines
Quoted 5 lines · Ricardo Ribalda Delgado
Quoted 2 lines
restart_dmais not used before it is declaration. Therefore we cans/it is/its/.Also s/declaration/definition/.
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
remove this definition.
You're removing the declaration, not definition.
do I get a new version of this patch ?
--
balbi
Signature · 1 line
Ricardo Ribalda
Re: [PATCH 06/17] net2280: Remove restart_dma inline function definition
Hi,
(top-post :-)
Quoted 5 lines · Ricardo Ribalda Delgado
Hello Felipe
I was waiting for more comments for the other patches and I forgot to resend this patch.
Quoted 7 lines
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
Signature · 1 line
balbi
PATCH 7/17 net2280: Code cleanout remove ep_stdrsp function
In reply to Ricardo Ribalda Delgadoep_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.
--- drivers/usb/gadget/udc/net2280.c | 49 +++++++--------------------------------- 1 file changed, 8 insertions(+), 41 deletions(-)
drivers/usb/gadget/udc/net2280.c +8 -41
@@ -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 ;
Signature · 1 line
2.1.3
PATCH 8/17 net2280: Remove field is_halt
In reply to Ricardo Ribalda DelgadoField is_halt is never used by any function.
--- drivers/usb/gadget/udc/net2280.c | 6 +----- drivers/usb/gadget/udc/net2280.h | 1 - 2 files changed, 1 insertion(+), 6 deletions(-)
drivers/usb/gadget/udc/net2280.c +1 -5
@@ -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 );
drivers/usb/gadget/udc/net2280.h +0 -1
@@ -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;
Signature · 1 line
2.1.3
PATCH 9/17 net2280: Remove function ep_stall
In reply to Ricardo Ribalda Delgadoirqs_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.
--- drivers/usb/gadget/udc/net2280.c | 44 ++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 29 deletions(-)
drivers/usb/gadget/udc/net2280.c +15 -29
@@ -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:
Signature · 1 line
2.1.3
PATCH 10/17 net2280: Merge abort_dma for 228x and 338x
In reply to Ricardo Ribalda DelgadoWe can use the same function for both families of chips and also remove the ep_stop_dma() function.
--- drivers/usb/gadget/udc/net2280.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)
drivers/usb/gadget/udc/net2280.c +2 -21
@@ -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);
Signature · 1 line
2.1.3
PATCH 11/17 net2280: Clean function net2280_queue
In reply to Ricardo Ribalda DelgadoDo not duplicate the code for the else branch of the condition.
--- drivers/usb/gadget/udc/net2280.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-)
drivers/usb/gadget/udc/net2280.c +5 -17
@@ -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 */
Signature · 1 line
2.1.3
PATCH 12/17 net2280: Improve patching of defect 7374
In reply to Ricardo Ribalda DelgadoOnce 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.
--- drivers/usb/gadget/udc/net2280.c | 153 +++++++++++++++++---------------------- drivers/usb/gadget/udc/net2280.h | 3 +- 2 files changed, 68 insertions(+), 88 deletions(-)
drivers/usb/gadget/udc/net2280.c +66 -87
@@ -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 */
drivers/usb/gadget/udc/net2280.h +2 -1
@@ -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;
Signature · 1 line
2.1.3
PATCH 13/17 net2280: Remove function resume_dma
In reply to Ricardo Ribalda DelgadoFunction resume_dma is not used, remove it.
The reason the compiler did not catch this dead code is the inline modifier.
--- drivers/usb/gadget/udc/net2280.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/usb/gadget/udc/net2280.c +0 -5
@@ -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) {
Signature · 1 line
2.1.3
PATCH 14/17 net2280: Declare allow_status_338x as inline
In reply to Ricardo Ribalda DelgadoThe 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.
--- drivers/usb/gadget/udc/net2280.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/net2280.h +1 -1
@@ -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
Signature · 1 line
2.1.3
PATCH 15/17 net2280: Simplify scan_dma_completions
In reply to Ricardo Ribalda DelgadoAfter 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.
--- drivers/usb/gadget/udc/net2280.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/usb/gadget/udc/net2280.c +2 -3
@@ -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
Signature · 1 line
2.1.3
PATCH 16/17 net2280: Move ASSERT_OUT_NAKING into out_flush
In reply to Ricardo Ribalda DelgadoASSERT_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
--- drivers/usb/gadget/udc/net2280.c | 10 ++++++++-- drivers/usb/gadget/udc/net2280.h | 17 ----------------- 2 files changed, 8 insertions(+), 19 deletions(-)
drivers/usb/gadget/udc/net2280.c +8 -2
@@ -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);
drivers/usb/gadget/udc/net2280.h +0 -17
@@ -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;
Signature · 1 line
2.1.3
PATCH 17/17 net2280: Re-enable dynamic debug messages
In reply to Ricardo Ribalda DelgadoSome 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.
--- drivers/usb/gadget/udc/net2280.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/gadget/udc/net2280.c +2 -4
@@ -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
Signature · 1 line
2.1.3