Skip to contentSkip to conversation

patch to remove kernel thread for runtime pm from usbhid

RFT Applied Oliver Neukum 4 participants 10 messages Oct 12, 2010 3 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Hi,

this patch saves a kernel thread. It works with my mouse. Please test.

Regards
Oliver

Quoted 1 line

From 89cb25b186e336c04f74165f08bca6c934ebdfad Mon Sep 17 00:00:00 2001

From: Oliver Neukum <[email protected]>
Date: Tue, 12 Oct 2010 09:28:11 +0200
Subject: [PATCH] Input: usbhid: convert runtime pm to async API

This patch removes the dedicated work queue and thus the kernel thread used to wake up USB HID devices. It is replaced with the use of the async API which didn't exist when runtime pm was introduced to usbhid.

---
 Makefile                      |    2 +-
 drivers/hid/usbhid/hid-core.c |   57 +++++++++++++---------------------------
 drivers/hid/usbhid/usbhid.h   |    1 -
 drivers/usb/core/usb.h        |   13 +++++++++
 4 files changed, 33 insertions(+), 40 deletions(-)
Makefile +1 -1
index 77b5c6e..f610e8c 100644
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 6
 SUBLEVEL = 36
-EXTRAVERSION = -rc7
+EXTRAVERSION = -rc7hid
 NAME = Sheep on Meth
 
 # *DOCUMENTATION*
drivers/hid/usbhid/hid-core.c +19 -38

169 lines not on this page · raw message

drivers/hid/usbhid/usbhid.h +0 -1
index 89d2e84..1673cac 100644
@@ -95,7 +95,6 @@ struct usbhid_device {
 	unsigned long stop_retry;                                       /* Time to give up, in jiffies */
 	unsigned int retry_delay;                                       /* Delay length in ms */
 	struct work_struct reset_work;                                  /* Task context for resets */
-	struct work_struct restart_work;				/* waking up for output to be done in a task */
 	wait_queue_head_t wait;						/* For sleeping */
 	int ledcount;							/* counting the number of active leds */
 };
drivers/usb/core/usb.h +13 -0
index cd88220..fbb988a 100644
@@ -124,6 +124,19 @@ static inline int is_usb_device_driver(struct device_driver *drv)
 			for_devices;
 }
 
+/* translate USB error codes to codes user space understands */
+static inline int usb_translate_errors(int error_code)
+{
+	switch (error_code) {
+	case 0:
+	case -ENOMEM:
+	case -ENODEV:
+		return error_code;
+	default:
+		return -EIO;
+	}
+}
+
 
 /* for labeling diagnostics */
 extern const char *usbcore_name;
Signature · 1 line
1.7.1
#2 lore raw
In reply to a message not in the archive
Quoted 12 lines · Oliver Neukum

Hi,

this patch saves a kernel thread. It works with my mouse. Please test.

       Regards
               Oliver

From 89cb25b186e336c04f74165f08bca6c934ebdfad Mon Sep 17 00:00:00 2001
From: Oliver Neukum <[email protected]>
Date: Tue, 12 Oct 2010 09:28:11 +0200
Subject: [PATCH] Input: usbhid: convert runtime pm to async API

Quoted 7 lines

This patch removes the dedicated work queue and thus the kernel thread used to wake up USB HID devices. It is replaced with the use of the async API which didn't exist when runtime pm was introduced to usbhid.

---

Tested on OMAP4 SDP with USB Keyboard and USB Mouse using 'evtest' program.

Works fine.

Regards,
Maulik
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to a message not in the archive

Am Dienstag, 12. Oktober 2010, 13:34:33 schrieb Maulik Mankad:

Quoted 11 lines · Oliver Neukum
Quoted 8 lines

This patch removes the dedicated work queue and thus the kernel thread used to wake up USB HID devices. It is replaced with the use of the async API which didn't exist when runtime pm was introduced to usbhid.

---

Tested on OMAP4 SDP with USB Keyboard and USB Mouse using 'evtest' program.

Thank you. Do both devices support remote wakeup? How much sleep time was generated?

Regards
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 8 lines · Oliver Neukum

Am Dienstag, 12. Oktober 2010, 13:34:33 schrieb Maulik Mankad:

Quoted 7 lines · Oliver Neukum
Quoted 6 lines

This patch removes the dedicated work queue and thus the kernel thread used to wake up USB HID devices. It is replaced with the use of the async API which didn't exist when runtime pm was introduced to usbhid.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

---

Tested on OMAP4 SDP with USB Keyboard and USB Mouse using 'evtest' program.

Thank you. Do both devices support remote wakeup? How much sleep time was generated?

Reading the wakeup node (as below) shows that its enabled.

cat /sys/bus/usb/devices/1-1/manufacturer
Dell

# cat /sys/bus/usb/devices/1-1/power/wakeup
enabled

My test was basically using the HID device post enumeration, and make sure that data transfers work reliably.

I can test more if you provide steps as per your need.

Regards,
Maulik

#6 lore raw

Am Dienstag, 12. Oktober 2010, 14:10:42 schrieb Maulik Mankad:

Quoted 11 lines · Oliver Neukum
Quoted 4 lines

Thank you. Do both devices support remote wakeup? How much sleep time was generated?

Reading the wakeup node (as below) shows that its enabled.

cat /sys/bus/usb/devices/1-1/manufacturer
Dell

Quoted 7 lines
# cat /sys/bus/usb/devices/1-1/power/wakeup
enabled

My test was basically using the HID device post enumeration, and make sure that data transfers work reliably.

I can test more if you provide steps as per your need.

Very good! Please do a
echo "auto" >/sys/bus/usb/devices/1-1/power/level
and do the test. After that I'd like to have the content of
active_duration connected_duration runtime_active_time runtime_enabled runtime_status runtime_suspended_time runtime_usage wakeup_count in /sys/bus/usb/devices/1-1/power/

Regards
Oliver

#7 lore raw
Quoted 18 lines · Oliver Neukum

Am Dienstag, 12. Oktober 2010, 14:10:42 schrieb Maulik Mankad:

Quoted 17 lines · Oliver Neukum
Quoted 4 lines

Thank you. Do both devices support remote wakeup? How much sleep time was generated?

Reading the wakeup node (as below) shows that its enabled.

cat /sys/bus/usb/devices/1-1/manufacturer
Dell

# cat /sys/bus/usb/devices/1-1/power/wakeup
enabled

My test was basically using the HID device post enumeration, and make sure that data transfers work reliably.

Quoted 7 lines
Quoted 1 line

I can test more if you provide steps as per your need.

Very good! Please do a
echo "auto" >/sys/bus/usb/devices/1-1/power/level
and do the test. After that I'd like to have the content of
active_duration  connected_duration  runtime_active_time  runtime_enabled  runtime_status  runtime_suspended_time  runtime_usage  wakeup_count in /sys/bus/usb/devices/1-1/power/

Below are some logs from my tests. I gave below two commands to suspend the bus.

(1) echo 0 > /sys/bus/usb/devices/1-1/power/autosuspend

(2) echo auto > /sys/bus/usb/devices/1-1/power/control
==========================================
usb usb1: usb wakeup-resume
usb usb1: usb auto-resume
hub 1-0:1.0: hub_resume
hub 1-0:1.0: port 1: status 0303 change 0004
hub 1-0:1.0: state 7 ports 1 chg 0002 evt 0000
usb 1-1: usb wakeup-resume
usb 1-1: finish resume
usb 1-1: usb auto-suspend
hub 1-0:1.0: resume on port 1, status 0
hub 1-0:1.0: port 1, status 0303, change 0004, 1.5 Mb/s hub 1-0:1.0: hub_suspend
usb usb1: bus auto-suspend
musb_bus_suspend 2311: trying to suspend as a_host while active usb usb1: bus suspend fail, err -16
hub 1-0:1.0: hub_resume
hub 1-0:1.0: port 1: status 0303 change 0004
hub 1-0:1.0: state 7 ports 1 chg 0002 evt 0000
usb 1-1: usb wakeup-resume
usb 1-1: finish resume
usb 1-1: usb auto-suspend
hub 1-0:1.0: resume on port 1, status 0
hub 1-0:1.0: port 1, status 0303, change 0004, 1.5 Mb/s hub 1-0:1.0: hub_suspend
usb usb1: bus auto-suspend
musb_bus_suspend 2311: trying to suspend as a_host while active usb usb1: bus suspend fail, err -16
hub 1-0:1.0: hub_resume
hub 1-0:1.0: port 1: status 0303 change 0004
hub 1-0:1.0: state 7 ports 1 chg 0002 evt 0000
usb 1-1: usb wakeup-resume
usb 1-1: finish resume
usb 1-1: usb auto-suspend
hub 1-0:1.0: resume on port 1, status 0
hub 1-0:1.0: port 1, status 0303, change 0004, 1.5 Mb/s
========================================================

Note that the bus keeps suspending and when I press a key on the keyboard I see logs related to wakeup-resume.

Also I see the below entries under /sys/bus/usb/devices/1-1/power/

ls /sys/bus/usb/devices/1-1/power/

active_duration  connected_duration  level    wakeup
autosuspend      control             persist

cat /sys/bus/usb/devices/1-1/power/active_duration 64289

cat /sys/bus/usb/devices/1-1/power/connected_duration 224015

cat /sys/bus/usb/devices/1-1/power/persist
1

cat /sys/bus/usb/devices/1-1/power/control
auto

I don't see the runtime entries. Any idea why is this so? I have applied your patch to 2.6.35 kernel where my device works.

Has this something to do with the kernel version I am using / some option to be turned on in menuconfig?

Regards,
Maulik
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw
Quoted 87 lines · Maulik Mankad
Quoted 18 lines · Oliver Neukum

Am Dienstag, 12. Oktober 2010, 14:10:42 schrieb Maulik Mankad:

Quoted 17 lines · Oliver Neukum
Quoted 4 lines

Thank you. Do both devices support remote wakeup? How much sleep time was generated?

Reading the wakeup node (as below) shows that its enabled.

cat /sys/bus/usb/devices/1-1/manufacturer
Dell

# cat /sys/bus/usb/devices/1-1/power/wakeup
enabled

My test was basically using the HID device post enumeration, and make sure that data transfers work reliably.

Quoted 7 lines
Quoted 1 line

I can test more if you provide steps as per your need.

Very good! Please do a
echo "auto" >/sys/bus/usb/devices/1-1/power/level
and do the test. After that I'd like to have the content of
active_duration  connected_duration  runtime_active_time  runtime_enabled  runtime_status  runtime_suspended_time  runtime_usage  wakeup_count in /sys/bus/usb/devices/1-1/power/

Below are some logs from my tests. I gave below two commands to suspend the bus.

(1) echo 0 > /sys/bus/usb/devices/1-1/power/autosuspend

(2) echo auto > /sys/bus/usb/devices/1-1/power/control
==========================================
usb usb1: usb wakeup-resume
usb usb1: usb auto-resume
hub 1-0:1.0: hub_resume
hub 1-0:1.0: port 1: status 0303 change 0004
hub 1-0:1.0: state 7 ports 1 chg 0002 evt 0000
usb 1-1: usb wakeup-resume
usb 1-1: finish resume
usb 1-1: usb auto-suspend
hub 1-0:1.0: resume on port 1, status 0
hub 1-0:1.0: port 1, status 0303, change 0004, 1.5 Mb/s hub 1-0:1.0: hub_suspend
usb usb1: bus auto-suspend
musb_bus_suspend 2311: trying to suspend as a_host while active usb usb1: bus suspend fail, err -16
hub 1-0:1.0: hub_resume
hub 1-0:1.0: port 1: status 0303 change 0004
hub 1-0:1.0: state 7 ports 1 chg 0002 evt 0000
usb 1-1: usb wakeup-resume
usb 1-1: finish resume
usb 1-1: usb auto-suspend
hub 1-0:1.0: resume on port 1, status 0
hub 1-0:1.0: port 1, status 0303, change 0004, 1.5 Mb/s hub 1-0:1.0: hub_suspend
usb usb1: bus auto-suspend
musb_bus_suspend 2311: trying to suspend as a_host while active usb usb1: bus suspend fail, err -16
hub 1-0:1.0: hub_resume
hub 1-0:1.0: port 1: status 0303 change 0004
hub 1-0:1.0: state 7 ports 1 chg 0002 evt 0000
usb 1-1: usb wakeup-resume
usb 1-1: finish resume
usb 1-1: usb auto-suspend
hub 1-0:1.0: resume on port 1, status 0
hub 1-0:1.0: port 1, status 0303, change 0004, 1.5 Mb/s
========================================================

Note that the bus keeps suspending and when I press a key on the keyboard I see logs related to wakeup-resume.

Also I see the below entries under /sys/bus/usb/devices/1-1/power/

 ls /sys/bus/usb/devices/1-1/power/ active_duration  connected_duration  level    wakeup autosuspend      control             persist

cat /sys/bus/usb/devices/1-1/power/active_duration 64289

cat /sys/bus/usb/devices/1-1/power/connected_duration 224015

cat /sys/bus/usb/devices/1-1/power/persist
1

Quoted 9 lines

cat /sys/bus/usb/devices/1-1/power/control
auto

I don't see the runtime entries. Any idea why is this so? I have applied your patch to 2.6.35 kernel where my device works.

Has this something to do with the kernel version I am using / some option to be turned on in menuconfig?

Seems like the below commit added that support to sysfs.

commit 8d4b9d1bfef117862a2889dec4dac227068544c9

Author: Arjan van de Ven <[email protected]>
Date:   Mon Jul 19 02:01:06 2010 +0200

PM / Runtime: Add runtime PM statistics (v3)

I will see if I can apply this to my kernel and provide the stats you need.

Regards,
Maulik
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw
In reply to a message not in the archive
Quoted 10 lines · Maulik Mankad

Seems like the below commit added that support to sysfs.

commit 8d4b9d1bfef117862a2889dec4dac227068544c9
Author: Arjan van de Ven <arjan-VuQAYsv1563Yd54FQh9/[email protected]>
Date:   Mon Jul 19 02:01:06 2010 +0200

   PM / Runtime: Add runtime PM statistics (v3)

I will see if I can apply this to my kernel and provide the stats you need.

I applied the relevant patches to 2.6.35 related to runtime PM and collected the below statistics.

cat /sys/bus/usb/devices/1-1/power/active_duration 120609

cat /sys/bus/usb/devices/1-1/power/autosuspend
0

cat /sys/bus/usb/devices/1-1/power/connected_duration 220398

cat /sys/bus/usb/devices/1-1/power/control
auto

cat /sys/bus/usb/devices/1-1/power/level
auto

cat /sys/bus/usb/devices/1-1/power/persist
1

cat /sys/bus/usb/devices/1-1/power/runtime_active_time 120523

cat /sys/bus/usb/devices/1-1/power/runtime_status
suspended

cat /sys/bus/usb/devices/1-1/power/runtime_suspended_time 159773

cat /sys/bus/usb/devices/1-1/power/wakeup
enabled

cat /sys/bus/usb/devices/1-1/power/wakeup_count
0

I am not familiar with the runtime pm statistics and can't interpret the above values.

Let me know if this information is helpful and if you need anything else.

Regards,
Maulik
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw

Am Dienstag, 12. Oktober 2010, 16:26:28 schrieb Maulik Mankad:

Quoted 5 lines

I am not familiar with the runtime pm statistics and can't interpret the above values.

Let me know if this information is helpful and if you need anything else.

Perfect. It works as it should. May I add your tested-by line?

Thank you
Oliver

Tested-by
#12 lore raw
Quoted 9 lines · Oliver Neukum

Am Dienstag, 12. Oktober 2010, 16:26:28 schrieb Maulik Mankad:

Quoted 5 lines

I am not familiar with the runtime pm statistics and can't interpret the above values.

Let me know if this information is helpful and if you need anything else.

Perfect. It works as it should. May I add your tested-by line?

Thanks.Yes please.