1
0
Fork 0
alistair23-linux/drivers/hid
Daniel Kurtz f0befcd64b HID: usbhid: hid-core: submit queued urbs before suspend
If any userspace program has opened a keyboard device, the input core
de-activates the keyboard's LEDs upon suspend().  It does this by sending
individual EV_LED[LED_X]=0 events to the underlying device driver by
directly calling the driver's registered event() handler.

The usb-hid driver event() handler processes each request by immediately
attempting to submit a CTRL URB to turn off the LED.  USB URB submission
is asynchronous.  First the URB is added to the head of the ctrl queue.
Then, if the CTRL_RUNNING flag is false, the URB is submitted immediately
(and CTRL_RUNNING is set).  If the CTRL_RUNNING flag was already true,
then the newly queued URB is submitted in the ctrl completion handler when
all previously submitted URBs have completed.  When all queued URBs have
been submitted, the completion handler clears the CTRL_RUNNING flag.

In the 2-LED suspend case, at input suspend(), 2 LED event CTRL URBs get
queued, with only the first actually submitted.  Soon after input
suspend() handler finishes, the usb-hid suspend() handler gets called.
Since this is NOT a PM_EVENT_AUTO suspend, the handler sets
REPORTED_IDLE, then waits for io to complete.

Unfortunately, this usually happens while the first LED request is
actually still being processed.  Thus when the completion handler tries
to submit the second LED request it fails, since REPORTED_IDLE is
already set!  This REPORTED_IDLE check failure causes the completion
handler to complete, however without clearing the CTRL_RUNNING flag.
This, in turn, means that the suspend() handler's wait_io() condition
is never satisfied, and instead it times out after 10 seconds, aborting
the original system suspend.

This patch changes the behavior to the following:
  (1) allow completion handler to finish submitting all queued URBs, even if
      REPORTED_IDLE is set.  This guarantees that all URBs queued before the
      hid-core suspend() call will be submitted before the system is
      suspended.
  (2) if REPORTED_IDLE is set and the URB queue is empty, queue, but
      don't submit, new URB submission requests.  These queued requests get
      submitted when resume() flushes the URB queue. This is similar to the
      existing behavior, however, any requests that arrive while the queue is
      not yet empty will still get submitted before suspend.
  (3) set the RUNNING flag when flushing the URB queue in resume().
      This keeps URBs that were queued in (2) from colliding with any new
      URBs that are being submitted during the resume process.  The new URB
      submission requests upon resume get properly queued behind the ones
      being flushed instead of the current situation where they collide,
      causing memory corruption and oopses.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-12-21 11:18:35 +01:00
..
usbhid HID: usbhid: hid-core: submit queued urbs before suspend 2011-12-21 11:18:35 +01:00
Kconfig HID: Kconfig: fix syntax 2011-12-19 09:16:29 +01:00
Makefile Merge branch 'upstream' into for-linus 2011-10-25 09:59:04 +02:00
hid-a4tech.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-apple.c HID: hid-apple: add device ID of another wireless aluminium 2011-10-28 18:54:56 +02:00
hid-axff.c HID: ACRUX - handle gamepads with different report layout 2011-08-04 15:25:34 +02:00
hid-belkin.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-cherry.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-chicony.c HID: adding __init/__exit macros to module init/exit functions 2009-07-23 01:28:01 +02:00
hid-core.c HID: make parser more verbose about parsing errors by default 2011-12-15 11:00:38 +01:00
hid-cypress.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-debug.c HID: debugfs: decode Generic Device Controls Usage Page 2011-11-19 12:19:00 +01:00
hid-dr.c HID: add support for DragonRise PID 0011 gamepad 2011-02-01 11:01:06 +01:00
hid-elecom.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-emsff.c HID: emsff: use symbolic name instead of hardcoded PID constant 2011-12-21 00:29:19 +01:00
hid-ezkey.c HID: adding __init/__exit macros to module init/exit functions 2009-07-23 01:28:01 +02:00
hid-gaff.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-gyration.c HID: Add teletext/color keys - gyration remote - EU version (GYAR3101CKDE) 2011-02-15 10:29:57 +01:00
hid-holtekff.c HID: add FF support for Holtek On Line Grip based gamepads 2011-06-27 12:40:00 +02:00
hid-ids.h HID: hid-apple: add device ID of another wireless aluminium 2011-10-28 18:54:56 +02:00
hid-input.c HID: hid-input: fix compile for !HID_BATTERY_STRENGTH 2011-11-30 14:42:08 +01:00
hid-kensington.c HID: adding __init/__exit macros to module init/exit functions 2009-07-23 01:28:01 +02:00
hid-keytouch.c HID: add support for Keytouch IEC 60945 2011-02-17 15:12:45 +01:00
hid-kye.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-lcpower.c HID: hid-lcpower: fix key mapping 2011-02-13 15:04:51 +01:00
hid-lg.c HID: lg4ff - Add range setting support and sysfs interface 2011-08-04 16:45:55 +02:00
hid-lg.h HID: lg4ff - Fix misleading info in Kconfig 2011-08-04 16:45:55 +02:00
hid-lg2ff.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-lg3ff.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-lg4ff.c HID: hid-lg4ff: Casting (void *) value returned by kmalloc is useless 2011-11-11 15:09:29 +01:00
hid-lgff.c HID: lg4ff - Move handling of Logitech wheels to lg4ff driver 2011-08-04 16:45:55 +02:00
hid-logitech-dj.c HID: hid-logitech-dj: fix off by one 2011-09-20 16:09:22 +02:00
hid-logitech-dj.h HID: hid-logitech-dj: fix off by one 2011-09-20 16:09:22 +02:00
hid-magicmouse.c HID: hid-magicmouse: Magic Trackpad has 1 button, not 2 2011-10-21 10:13:55 +02:00
hid-microsoft.c HID: fix horizontal wheel for ms comfort mouse 4500 2011-07-12 10:31:56 +02:00
hid-monterey.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-multitouch.c HID: multitouch: make struct mt_classess static 2011-11-22 23:23:37 +01:00
hid-ntrig.c HID: hid-ntrig: init settle and mode check 2011-03-14 13:10:13 +01:00
hid-ortek.c HID: add support for Skycable 0x3f07 wireless presenter 2011-03-21 16:12:23 +01:00
hid-petalynx.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-picolcd.c HID: picolcd: make fb_pending_lock and picolcd_fb_cleanup static 2011-11-22 23:25:28 +01:00
hid-pl.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-primax.c HID: support primax keyboards violating USB HID spec 2011-10-17 17:04:41 +02:00
hid-prodikeys.c HID: prodikeys: kfree() NULL pointer cleanup 2011-08-04 23:51:29 +02:00
hid-quanta.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-roccat-arvo.c HID: roccat: fix NULL pointer dereference, add range checks 2011-06-13 13:06:23 +02:00
hid-roccat-arvo.h HID: roccat: correction and cleanup of HID feature reports 2011-06-13 12:52:57 +02:00
hid-roccat-common.c HID: roccat: Use kmemdup rather than duplicating its implementation 2011-11-20 00:42:42 +01:00
hid-roccat-common.h HID: roccat: correction and cleanup of HID feature reports 2011-06-13 12:52:57 +02:00
hid-roccat-kone.c HID: roccat: Use kmemdup rather than duplicating its implementation 2011-11-20 00:42:42 +01:00
hid-roccat-kone.h HID: roccat: correction and cleanup of HID feature reports 2011-06-13 12:52:57 +02:00
hid-roccat-koneplus.c HID: roccat: fix NULL pointer dereference, add range checks 2011-06-13 13:06:23 +02:00
hid-roccat-koneplus.h HID: roccat: correction and cleanup of HID feature reports 2011-06-13 12:52:57 +02:00
hid-roccat-kovaplus.c HID: roccat: Kovaplus now reports external profile changes via roccat device 2011-09-07 13:38:27 +02:00
hid-roccat-kovaplus.h HID: roccat: correction and cleanup of HID feature reports 2011-06-13 12:52:57 +02:00
hid-roccat-pyra.c HID: roccat: Pyra now reports external profile changes via roccat device 2011-09-07 13:38:27 +02:00
hid-roccat-pyra.h HID: roccat: correction and cleanup of HID feature reports 2011-06-13 12:52:57 +02:00
hid-roccat.c HID: drivers/hid/hid-roccat.c: eliminate a null pointer dereference 2011-11-01 15:13:08 +01:00
hid-samsung.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-sjoy.c HID: Add device IDs for more SJOY adapters 2011-10-21 01:01:45 +02:00
hid-sony.c HID: hid-sony: fix endiannes of Sixaxis accel/gyro values 2011-06-13 13:21:30 +02:00
hid-speedlink.c HID: Add driver to fix Speedlink VAD Cezanne support 2011-06-08 09:45:37 +02:00
hid-sunplus.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-tmff.c Merge branch 'master' into upstream 2010-12-10 15:19:18 +01:00
hid-topseed.c HID: Add support for Perixx PERIBOARD-707 (Plus) 2010-11-25 15:59:02 +01:00
hid-twinhan.c HID: add __init/__exit macros to twinhan.c 2009-09-29 13:58:20 +02:00
hid-uclogic.c HID: uclogic: Add support for UC-Logic WP1062 2011-07-11 14:37:24 +02:00
hid-wacom.c Merge branch 'upstream-fixes' into for-linus 2011-10-25 09:58:12 +02:00
hid-waltop.c HID: waltop: add support for Waltop Slim Tablet 12.1 inch 2010-10-01 15:34:05 +02:00
hid-wiimote.c HID: wiimote: Add MAINTAINERS entry 2011-09-07 13:25:18 +02:00
hid-zpff.c HID: Add and use hid_<level>: dev_<level> equivalents 2010-12-10 15:10:38 +01:00
hid-zydacron.c HID: zydacron: kfree() NULL pointer cleanup 2011-08-04 23:51:29 +02:00
hidraw.c Merge branch 'upstream' into for-linus 2011-10-25 09:59:04 +02:00