diff options
author | Joel A Fernandes <joelagnel@ti.com> | 2011-11-14 21:34:23 -0600 |
---|---|---|
committer | Koen Kooi <koen@dominion.thruhere.net> | 2011-11-15 08:53:06 +0100 |
commit | 59e00aecf2740048b03364f0c41b15da686d254f (patch) | |
tree | 298a073e07bcce75133fd546a293b4abd39b9cfd | |
parent | a0b13fc0e549390c8e2e24004117d0275a0bb966 (diff) | |
download | meta-ti-59e00aecf2740048b03364f0c41b15da686d254f.tar.gz |
linux-ti33x-psp: Refresh musb patch
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>
-rw-r--r-- | recipes-kernel/linux/linux-ti33x-psp-3.1/0006-usb-musb-cppi41_dma-Check-if-scheduling-is-required-.patch | 68 | ||||
-rw-r--r-- | recipes-kernel/linux/linux-ti33x-psp_3.1.bb | 2 |
2 files changed, 57 insertions, 13 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.1/0006-usb-musb-cppi41_dma-Check-if-scheduling-is-required-.patch b/recipes-kernel/linux/linux-ti33x-psp-3.1/0006-usb-musb-cppi41_dma-Check-if-scheduling-is-required-.patch index 701c09d8..db7a7f22 100644 --- a/recipes-kernel/linux/linux-ti33x-psp-3.1/0006-usb-musb-cppi41_dma-Check-if-scheduling-is-required-.patch +++ b/recipes-kernel/linux/linux-ti33x-psp-3.1/0006-usb-musb-cppi41_dma-Check-if-scheduling-is-required-.patch | |||
@@ -1,7 +1,7 @@ | |||
1 | From b564457d26931a00f8c5645981a00c1eb78e9a90 Mon Sep 17 00:00:00 2001 | 1 | From c5a0664fa68a8541c1400bf7330a072581b12c38 Mon Sep 17 00:00:00 2001 |
2 | From: Joel A Fernandes <joelagnel@ti.com> | 2 | From: Joel A Fernandes <joelagnel@ti.com> |
3 | Date: Sat, 12 Nov 2011 23:42:26 -0600 | 3 | Date: Sat, 12 Nov 2011 23:42:26 -0600 |
4 | Subject: [PATCH] usb::musb::cppi41_dma: Check if scheduling is required after DMA | 4 | Subject: [PATCH v2] usb::musb::cppi41_dma: Check if scheduling is required after DMA |
5 | 5 | ||
6 | Even after TX DMA, data can still be in the FIFO and we would keep | 6 | Even after TX DMA, data can still be in the FIFO and we would keep |
7 | rescheduling the worker thread in a polling fashion taking up a lot | 7 | rescheduling the worker thread in a polling fashion taking up a lot |
@@ -11,19 +11,64 @@ is required and sleep if so. | |||
11 | This fixes high CPU load issue seen with g_mass_storage on a BeagleBone | 11 | This fixes high CPU load issue seen with g_mass_storage on a BeagleBone |
12 | and could potentially fix similar issues seen with other gadget drivers. | 12 | and could potentially fix similar issues seen with other gadget drivers. |
13 | 13 | ||
14 | v2 changes: | ||
15 | Avoid rescheduling a "worker", this process involves a lot of workqueue | ||
16 | related crunching that is unnecessary. If we're polling, we might as well | ||
17 | do it with minimum overhead, and giving other processes CPU time at the | ||
18 | same time. | ||
19 | |||
14 | Signed-off-by: Joel A Fernandes <joelagnel@ti.com> | 20 | Signed-off-by: Joel A Fernandes <joelagnel@ti.com> |
15 | --- | 21 | --- |
16 | drivers/usb/musb/cppi41_dma.c | 10 ++++++++++ | 22 | drivers/usb/musb/cppi41_dma.c | 30 ++++++++++++++++++------------ |
17 | 1 files changed, 10 insertions(+), 0 deletions(-) | 23 | 1 files changed, 18 insertions(+), 12 deletions(-) |
18 | 24 | ||
19 | diff --git a/drivers/usb/musb/cppi41_dma.c b/drivers/usb/musb/cppi41_dma.c | 25 | diff --git a/drivers/usb/musb/cppi41_dma.c b/drivers/usb/musb/cppi41_dma.c |
20 | index a24707c..e68c5d7 100644 | 26 | index a24707c..3ac58b1 100644 |
21 | --- a/drivers/usb/musb/cppi41_dma.c | 27 | --- a/drivers/usb/musb/cppi41_dma.c |
22 | +++ b/drivers/usb/musb/cppi41_dma.c | 28 | +++ b/drivers/usb/musb/cppi41_dma.c |
23 | @@ -1319,6 +1319,16 @@ void txdma_completion_work(struct work_struct *data) | 29 | @@ -1283,6 +1283,7 @@ void cppi41_check_fifo_empty(struct cppi41 *cppi) |
30 | for (index = 0; index < USB_CPPI41_NUM_CH; index++) { | ||
31 | void __iomem *epio; | ||
32 | u16 csr; | ||
33 | + unsigned long flags; | ||
34 | |||
35 | tx_ch = &cppi->tx_cppi_ch[index]; | ||
36 | if (tx_ch->tx_complete) { | ||
37 | @@ -1299,29 +1300,34 @@ void cppi41_check_fifo_empty(struct cppi41 *cppi) | ||
38 | epio = tx_ch->end_pt->regs; | ||
39 | csr = musb_readw(epio, MUSB_TXCSR); | ||
40 | |||
41 | - if (csr & (MUSB_TXCSR_TXPKTRDY | | ||
42 | - MUSB_TXCSR_FIFONOTEMPTY)) | ||
43 | - resched = 1; | ||
44 | - else { | ||
45 | - tx_ch->tx_complete = 0; | ||
46 | - musb_dma_completion(musb, index+1, 1); | ||
47 | + while (1) { | ||
48 | + csr = musb_readw(epio, MUSB_TXCSR); | ||
49 | + if(!(csr & (MUSB_TXCSR_TXPKTRDY | | ||
50 | + MUSB_TXCSR_FIFONOTEMPTY))) | ||
51 | + break; | ||
52 | + cond_resched(); | ||
53 | } | ||
54 | + tx_ch->tx_complete = 0; | ||
55 | + spin_lock_irqsave(&musb->lock, flags); | ||
56 | + musb_dma_completion(musb, index+1, 1); | ||
57 | + spin_unlock_irqrestore(&musb->lock, flags); | ||
58 | } | ||
59 | } | ||
60 | - | ||
61 | - if (resched) | ||
62 | - schedule_work(&cppi->txdma_work); | ||
63 | } | ||
64 | |||
65 | void txdma_completion_work(struct work_struct *data) | ||
66 | { | ||
67 | struct cppi41 *cppi = container_of(data, struct cppi41, txdma_work); | ||
24 | struct musb *musb = cppi->musb; | 68 | struct musb *musb = cppi->musb; |
25 | unsigned long flags; | 69 | - unsigned long flags; |
26 | 70 | ||
71 | - spin_lock_irqsave(&musb->lock, flags); | ||
27 | + /* | 72 | + /* |
28 | + * txdma worker thread can call schedule_work on itself and cause | 73 | + * txdma worker thread can call schedule_work on itself and cause |
29 | + * itself to be scheduled immediately and because the data might still | 74 | + * itself to be scheduled immediately and because the data might still |
@@ -31,12 +76,11 @@ index a24707c..e68c5d7 100644 | |||
31 | + * the worker to consume lot of CPU when the controller is slow, so we | 76 | + * the worker to consume lot of CPU when the controller is slow, so we |
32 | + * reschedule if necessary. | 77 | + * reschedule if necessary. |
33 | + */ | 78 | + */ |
34 | + if (need_resched()) | ||
35 | + cond_resched(); | ||
36 | + | ||
37 | spin_lock_irqsave(&musb->lock, flags); | ||
38 | cppi41_check_fifo_empty(cppi); | 79 | cppi41_check_fifo_empty(cppi); |
39 | spin_unlock_irqrestore(&musb->lock, flags); | 80 | - spin_unlock_irqrestore(&musb->lock, flags); |
81 | } | ||
82 | |||
83 | /** | ||
40 | -- | 84 | -- |
41 | 1.7.4.1 | 85 | 1.7.4.1 |
42 | 86 | ||
diff --git a/recipes-kernel/linux/linux-ti33x-psp_3.1.bb b/recipes-kernel/linux/linux-ti33x-psp_3.1.bb index 37f59cad..556ad5ab 100644 --- a/recipes-kernel/linux/linux-ti33x-psp_3.1.bb +++ b/recipes-kernel/linux/linux-ti33x-psp_3.1.bb | |||
@@ -11,7 +11,7 @@ MULTI_CONFIG_BASE_SUFFIX = "" | |||
11 | 11 | ||
12 | BRANCH = "v3.1-staging" | 12 | BRANCH = "v3.1-staging" |
13 | SRCREV = "1d84d8853fa30cf3db2571a5aec572accca4e29d" | 13 | SRCREV = "1d84d8853fa30cf3db2571a5aec572accca4e29d" |
14 | MACHINE_KERNEL_PR_append = "r+gitr${SRCREV}" | 14 | MACHINE_KERNEL_PR_append = "s+gitr${SRCREV}" |
15 | 15 | ||
16 | COMPATIBLE_MACHINE = "(ti33x)" | 16 | COMPATIBLE_MACHINE = "(ti33x)" |
17 | 17 | ||