linux-ti33x-psp: Refresh musb patch
authorJoel A Fernandes <joelagnel@ti.com>
Tue, 15 Nov 2011 03:34:23 +0000 (21:34 -0600)
committerKoen Kooi <koen@dominion.thruhere.net>
Tue, 15 Nov 2011 07:53:06 +0000 (08:53 +0100)
This patch is rewritten to poll for the channel FIFO state without depending on a worker thread.

The v2 version fixes all the previous issues, and remains to be seen if it also fixes the issue of
100% CPU usage with a mac.

Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
recipes-kernel/linux/linux-ti33x-psp-3.1/0006-usb-musb-cppi41_dma-Check-if-scheduling-is-required-.patch
recipes-kernel/linux/linux-ti33x-psp_3.1.bb

index 701c09d8c3df49702a7346456a54635caa938cd8..db7a7f22b0befef5108b23d9e7ba8aa93d3ecbf4 100644 (file)
@@ -1,7 +1,7 @@
-From b564457d26931a00f8c5645981a00c1eb78e9a90 Mon Sep 17 00:00:00 2001
+From c5a0664fa68a8541c1400bf7330a072581b12c38 Mon Sep 17 00:00:00 2001
 From: Joel A Fernandes <joelagnel@ti.com>
 Date: Sat, 12 Nov 2011 23:42:26 -0600
-Subject: [PATCH] usb::musb::cppi41_dma: Check if scheduling is required after DMA
+Subject: [PATCH v2] usb::musb::cppi41_dma: Check if scheduling is required after DMA
 
 Even after TX DMA, data can still be in the FIFO and we would keep
 rescheduling the worker thread in a polling fashion taking up a lot
@@ -11,19 +11,64 @@ is required and sleep if so.
 This fixes high CPU load issue seen with g_mass_storage on a BeagleBone
 and could potentially fix similar issues seen with other gadget drivers.
 
+v2 changes:
+Avoid rescheduling a "worker", this process involves a lot of workqueue
+related crunching that is unnecessary. If we're polling, we might as well
+do it with minimum overhead, and giving other processes CPU time at the
+same time.
+
 Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
 ---
- drivers/usb/musb/cppi41_dma.c |   10 ++++++++++
- 1 files changed, 10 insertions(+), 0 deletions(-)
+ drivers/usb/musb/cppi41_dma.c |   30 ++++++++++++++++++------------
+ 1 files changed, 18 insertions(+), 12 deletions(-)
 
 diff --git a/drivers/usb/musb/cppi41_dma.c b/drivers/usb/musb/cppi41_dma.c
-index a24707c..e68c5d7 100644
+index a24707c..3ac58b1 100644
 --- a/drivers/usb/musb/cppi41_dma.c
 +++ b/drivers/usb/musb/cppi41_dma.c
-@@ -1319,6 +1319,16 @@ void txdma_completion_work(struct work_struct *data)
+@@ -1283,6 +1283,7 @@ void cppi41_check_fifo_empty(struct cppi41 *cppi)
+       for (index = 0; index < USB_CPPI41_NUM_CH; index++) {
+               void __iomem *epio;
+               u16 csr;
++              unsigned long flags;
+               tx_ch = &cppi->tx_cppi_ch[index];
+               if (tx_ch->tx_complete) {
+@@ -1299,29 +1300,34 @@ void cppi41_check_fifo_empty(struct cppi41 *cppi)
+                       epio = tx_ch->end_pt->regs;
+                       csr = musb_readw(epio, MUSB_TXCSR);
+-                      if (csr & (MUSB_TXCSR_TXPKTRDY |
+-                              MUSB_TXCSR_FIFONOTEMPTY))
+-                              resched = 1;
+-                      else {
+-                              tx_ch->tx_complete = 0;
+-                              musb_dma_completion(musb, index+1, 1);
++                      while (1) {
++                              csr = musb_readw(epio, MUSB_TXCSR);
++                              if(!(csr & (MUSB_TXCSR_TXPKTRDY |
++                                      MUSB_TXCSR_FIFONOTEMPTY)))
++                              break;
++                              cond_resched();
+                       }
++                      tx_ch->tx_complete = 0;
++                      spin_lock_irqsave(&musb->lock, flags);
++                      musb_dma_completion(musb, index+1, 1);
++                      spin_unlock_irqrestore(&musb->lock, flags);
+               }
+       }
+-
+-      if (resched)
+-              schedule_work(&cppi->txdma_work);
+ }
+ void txdma_completion_work(struct work_struct *data)
+ {
+       struct cppi41 *cppi = container_of(data, struct cppi41, txdma_work);
        struct musb *musb = cppi->musb;
-       unsigned long flags;
+-      unsigned long flags;
  
+-      spin_lock_irqsave(&musb->lock, flags);
 +      /*
 +       * txdma worker thread can call schedule_work on itself and cause
 +       * itself to be scheduled immediately and because the data might still
@@ -31,12 +76,11 @@ index a24707c..e68c5d7 100644
 +       * the worker to consume lot of CPU when the controller is slow, so we
 +       * reschedule if necessary.
 +       */
-+      if (need_resched())
-+              cond_resched();
-+
-       spin_lock_irqsave(&musb->lock, flags);
        cppi41_check_fifo_empty(cppi);
-       spin_unlock_irqrestore(&musb->lock, flags);
+-      spin_unlock_irqrestore(&musb->lock, flags);
+ }
+ /**
 -- 
 1.7.4.1
 
index 37f59cad635fc457bab5506d1c180610d2107d59..556ad5abeed6b0ef314c0a0ad01bf689f49e9ee5 100644 (file)
@@ -11,7 +11,7 @@ MULTI_CONFIG_BASE_SUFFIX = ""
 
 BRANCH = "v3.1-staging"
 SRCREV = "1d84d8853fa30cf3db2571a5aec572accca4e29d"
-MACHINE_KERNEL_PR_append = "r+gitr${SRCREV}"
+MACHINE_KERNEL_PR_append = "s+gitr${SRCREV}"
 
 COMPATIBLE_MACHINE = "(ti33x)"