Skip to contentSkip to conversation

linux-ti33x-psp: Check if scheduling is required after DMA

PATCH In review Joel A Fernandes 2 participants 3 messages Nov 13, 2011

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 linux-ti33x-psp: Check if scheduling is required after DMA

After processing one DMA completion, checking if rescheduling is required instead of scheduling another completion request if the FIFO is non empty.

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:
* Corrected commit title

 ...pi41_dma-Check-if-scheduling-is-required-.patch |   42 ++++++++++++++++++++
 recipes-kernel/linux/linux-ti33x-psp_3.1.bb        |    3 +-
 2 files changed, 44 insertions(+), 1 deletions(-)
 create mode 100644 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/0006-usb-musb-cppi41_dma-Check-if-scheduling-is-required-.patch new file +42 -0
new file mode 100644
index 0000000..701c09d
@@ -0,0 +1,42 @@
+From b564457d26931a00f8c5645981a00c1eb78e9a90 Mon Sep 17 00:00:00 2001
+From: Joel A Fernandes <[email protected]>
+Date: Sat, 12 Nov 2011 23:42:26 -0600
+Subject: [PATCH] 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
+of CPU if the controller was slow to respond. We check if rescheduling
+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.
+
+Signed-off-by: Joel A Fernandes <[email protected]>
+---
+ drivers/usb/musb/cppi41_dma.c |   10 ++++++++++
+ 1 files changed, 10 insertions(+), 0 deletions(-)
+
+diff --git a/drivers/usb/musb/cppi41_dma.c b/drivers/usb/musb/cppi41_dma.c
+index a24707c..e68c5d7 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)
+ 	struct musb *musb = cppi->musb;
+ 	unsigned long flags;
+ 
++	/*
++	 * txdma worker thread can call schedule_work on itself and cause
++	 * itself to be scheduled immediately and because the data might still
++	 * be in FIFO if it hasn't been pushed out after DMA, it is possible for
++	 * 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);
+-- 
+1.7.4.1
+
recipes-kernel/linux/linux-ti33x-psp_3.1.bb +2 -1
index c4cdfea..37f59ca 100644
@@ -11,7 +11,7 @@ MULTI_CONFIG_BASE_SUFFIX = ""
 
 BRANCH = "v3.1-staging"
 SRCREV = "1d84d8853fa30cf3db2571a5aec572accca4e29d"
-MACHINE_KERNEL_PR_append = "q+gitr${SRCREV}"
+MACHINE_KERNEL_PR_append = "r+gitr${SRCREV}"
 
 COMPATIBLE_MACHINE = "(ti33x)"
 
@@ -35,6 +35,7 @@ PATCHES_OVER_PSP = " \
 	file://0003-arm-omap-mcspi-correct-memory-range-when-requesting-.patch \
 	file://0004-arm-omap-mcspi-follow-proper-pm_runtime-enable-disab.patch \
 	file://0005-arm-omap-mcspi-follow-proper-probe-remove-steps.patch \
+	file://0006-usb-musb-cppi41_dma-Check-if-scheduling-is-required-.patch \
 	file://can/0001-can-d_can-Added-support-for-Bosch-D_CAN-controller.patch \
 	file://can/0002-can-d_can-Added-platform-data-for-am33xx-device.patch \
 	file://can/0003-can-d_can-DCAN-config-added-to-am335x_evm_defconfig.patch \
Signature · 1 line
1.7.0.4
#1 lore raw

Op 13 nov. 2011, om 16:11 heeft Joel A Fernandes het volgende geschreven:

Quoted 8 lines

After processing one DMA completion, checking if rescheduling is required instead of scheduling another completion request if the FIFO is non empty.

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

I stil get the 100% cpu load after ejecting the drive even after applying this patch.

regards,

Koen

#2 lore raw
Quoted 19 lines

-----Original Message-----
From: Koen Kooi [mailto:[email protected]]
Sent: Sunday, November 13, 2011 11:09 AM
To: Fernandes, Joel A
Cc: [email protected]; Maupin, Chase
Subject: Re: [meta-ti] [PATCH v2] linux-ti33x-psp: Check if scheduling is required after DMA

Op 13 nov. 2011, om 16:11 heeft Joel A Fernandes het volgende geschreven:

Quoted 8 lines

After processing one DMA completion, checking if rescheduling is required instead of scheduling another completion request if the FIFO is non empty.

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

Quoted 5 lines
Quoted 1 line

I stil get the 100% cpu load after ejecting the drive even after applying this patch.

There might be more than one issue here, the other issue was with "rcu_kthread" taking up 100% CPU which was consistently reproducible with g_ether on a MAC host, does this process still give a high CPU load and have similar symptoms?

With node not running, do you see the high CPU load with any other application using g_ether?

Regards,
Joel