mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Oliver Neukum <oliver@neukum.org>, David Fries <david@fries.net>,
	Jiri Kosina <jkosina@suse.cz>
Subject: [patch 008/123] HID: usbhid: introduce timeout for stuck ctrl/out URBs
Date: Fri, 12 Mar 2010 16:11:46 -0800	[thread overview]
Message-ID: <20100313001505.873349402@kvm.kroah.org> (raw)
In-Reply-To: <20100313001618.GA9811@kroah.com>
In-Reply-To: <20100313001618.GA9811@kroah.com>

2.6.33-stable review patch.  If anyone has any objections, please let me know.

-----------------

From: Oliver Neukum <oliver@neukum.org>

commit 858155fbcc0cd713f6382c527bb1c3abc0ed6d00 upstream.

Some devices do not react to a control request (seen on APC UPS's) resulting in
a slow stream of messages, "generic-usb ... control queue full".  Therefore
request needs a timeout.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: David Fries <david@fries.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/hid/usbhid/hid-core.c |   28 ++++++++++++++++++++++++++--
 drivers/hid/usbhid/usbhid.h   |    2 ++
 2 files changed, 28 insertions(+), 2 deletions(-)

--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -316,6 +316,7 @@ static int hid_submit_out(struct hid_dev
 			err_hid("usb_submit_urb(out) failed");
 			return -1;
 		}
+		usbhid->last_out = jiffies;
 	} else {
 		/*
 		 * queue work to wake up the device.
@@ -377,6 +378,7 @@ static int hid_submit_ctrl(struct hid_de
 			err_hid("usb_submit_urb(ctrl) failed");
 			return -1;
 		}
+		usbhid->last_ctrl = jiffies;
 	} else {
 		/*
 		 * queue work to wake up the device.
@@ -512,9 +514,20 @@ static void __usbhid_submit_report(struc
 		usbhid->out[usbhid->outhead].report = report;
 		usbhid->outhead = head;
 
-		if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl))
+		if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl)) {
 			if (hid_submit_out(hid))
 				clear_bit(HID_OUT_RUNNING, &usbhid->iofl);
+		} else {
+			/*
+			 * the queue is known to run
+			 * but an earlier request may be stuck
+			 * we may need to time out
+			 * no race because this is called under
+			 * spinlock
+			 */
+			if (time_after(jiffies, usbhid->last_out + HZ * 5))
+				usb_unlink_urb(usbhid->urbout);
+		}
 		return;
 	}
 
@@ -535,9 +548,20 @@ static void __usbhid_submit_report(struc
 	usbhid->ctrl[usbhid->ctrlhead].dir = dir;
 	usbhid->ctrlhead = head;
 
-	if (!test_and_set_bit(HID_CTRL_RUNNING, &usbhid->iofl))
+	if (!test_and_set_bit(HID_CTRL_RUNNING, &usbhid->iofl)) {
 		if (hid_submit_ctrl(hid))
 			clear_bit(HID_CTRL_RUNNING, &usbhid->iofl);
+	} else {
+		/*
+		 * the queue is known to run
+		 * but an earlier request may be stuck
+		 * we may need to time out
+		 * no race because this is called under
+		 * spinlock
+		 */
+		if (time_after(jiffies, usbhid->last_ctrl + HZ * 5))
+			usb_unlink_urb(usbhid->urbctrl);
+	}
 }
 
 void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir)
--- a/drivers/hid/usbhid/usbhid.h
+++ b/drivers/hid/usbhid/usbhid.h
@@ -80,12 +80,14 @@ struct usbhid_device {
 	unsigned char ctrlhead, ctrltail;                               /* Control fifo head & tail */
 	char *ctrlbuf;                                                  /* Control buffer */
 	dma_addr_t ctrlbuf_dma;                                         /* Control buffer dma */
+	unsigned long last_ctrl;						/* record of last output for timeouts */
 
 	struct urb *urbout;                                             /* Output URB */
 	struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE];              /* Output pipe fifo */
 	unsigned char outhead, outtail;                                 /* Output pipe fifo head & tail */
 	char *outbuf;                                                   /* Output buffer */
 	dma_addr_t outbuf_dma;                                          /* Output buffer dma */
+	unsigned long last_out;							/* record of last output for timeouts */
 
 	spinlock_t lock;						/* fifo spinlock */
 	unsigned long iofl;                                             /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */



  parent reply	other threads:[~2010-03-13  1:35 UTC|newest]

Thread overview: 137+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-13  0:16 [patch 000/123] 2.6.33.1-stable review Greg KH
2010-03-13  0:11 ` [patch 001/123] ahci: disable FPDMA auto-activate optimization on NVIDIA AHCI Greg KH
2010-03-13  0:11 ` [patch 002/123] netlabel: fix export of SELinux categories > 127 Greg KH
2010-03-13  0:11 ` [patch 003/123] PCI hotplug: ibmphp: read the length of ebda and map entire ebda region Greg KH
2010-03-13  0:11 ` [patch 004/123] PCI hotplug: check ioremap() return value in ibmphp_ebda.c Greg KH
2010-03-13  0:11 ` [patch 005/123] security: fix error return path in ima_inode_alloc Greg KH
2010-03-13  0:11 ` [patch 006/123] airo: fix setting zero length WEP key Greg KH
2010-03-13  0:11 ` [patch 007/123] HID: remove TENX iBuddy from blacklist Greg KH
2010-03-13  0:11 ` Greg KH [this message]
2010-03-13  0:11 ` [patch 009/123] mac80211: quit addba_resp_timer if Tx BA session is torn down Greg KH
2010-03-13  0:11 ` [patch 010/123] mac80211: Reset dynamic ps timer in Rx path Greg KH
2010-03-13  0:11 ` [patch 011/123] [SCSI] mpt2sas: Delete volume before HBA detach Greg KH
2010-03-13  0:11 ` [patch 012/123] readahead: introduce FMODE_RANDOM for POSIX_FADV_RANDOM Greg KH
2010-03-13  0:11 ` [patch 013/123] slab: initialize unused alien cache entry as NULL at alloc_alien_cache() Greg KH
2010-03-13  0:11 ` [patch 014/123] V4L/DVB (13991): gspca_mr973010a: Fix cif type 1 cameras not streaming on UHCI controllers Greg KH
2010-03-13  0:11 ` [patch 015/123] vfs: take f_lock on modifying f_mode after open time Greg KH
2010-03-13  0:11 ` [patch 016/123] x86, uv: uv_global_gru_mmr_address() macro fix Greg KH
2010-03-13  0:11 ` [patch 017/123] drm/i915: give up on 8xx lid status Greg KH
2010-03-13  0:11 ` [patch 018/123] ath9k: fix keycache leak in split tkip case Greg KH
2010-03-13  0:11 ` [patch 019/123] rtc-core: fix memory leak Greg KH
2010-03-13  0:11 ` [patch 020/123] x86/PCI: Prevent mmconfig memory corruption Greg KH
2010-03-13  0:11 ` [patch 021/123] clocksource: Fix up a registration/IRQ race in the sh drivers Greg KH
2010-03-13  0:12 ` [patch 022/123] SCSI: qla1280: Drop host_lock while requesting firmware Greg KH
2010-03-13  0:12 ` [patch 023/123] Staging: hv: add a pci device table Greg KH
2010-03-13  0:12 ` [patch 024/123] Staging: hv: match on DMI values to know if we should run Greg KH
2010-03-13  0:12 ` [patch 025/123] Staging: Fixed pohmelfs regression because of per-bdi writeback Greg KH
2010-03-13  0:12 ` [patch 026/123] Staging: wlan-ng: Add select WEXT_PRIV to Kconfig to prevent build failure Greg KH
2010-03-13  0:12 ` [patch 027/123] Staging: mimio: remove the mimio driver Greg KH
2010-03-13  0:12 ` [patch 028/123] dvb-core: Fix DoS bug in ULE decapsulation code that can be triggered by an invalid Payload Pointer Greg KH
2010-03-13  0:12 ` [patch 029/123] V4L/DVB: v4l: soc_camera: fix bound checking of mbus_fmt[] index Greg KH
2010-03-13  0:12 ` [patch 030/123] PM / Hibernate: Fix preallocating of memory Greg KH
2010-03-13  0:12 ` [patch 031/123] macintosh/therm_adt746x: Fix sysfs attributes lifetime Greg KH
2010-03-13  0:12 ` [patch 032/123] macintosh/hwmon/ams: Fix device removal sequence Greg KH
2010-03-13  0:12 ` [patch 033/123] oprofile/x86: fix perfctr nmi reservation for mulitplexing Greg KH
2010-03-13  0:12 ` [patch 034/123] perf symbols: Check the right return variable Greg KH
2010-03-13  0:12 ` [patch 035/123] perf_event: Fix preempt warning in perf_clock() Greg KH
2010-03-13  0:12 ` [patch 036/123] oprofile: remove tracing build dependency Greg KH
2010-03-13  0:12 ` [patch 037/123] oprofile/x86: remove node check in AMD IBS initialization Greg KH
2010-03-13  0:12 ` [patch 038/123] oprofile/x86: use kzalloc() instead of kmalloc() Greg KH
2010-03-13  0:12 ` [patch 039/123] oprofile/x86: fix msr access to reserved counters Greg KH
2010-03-13  0:12 ` [patch 040/123] perf: Reimplement frequency driven sampling Greg KH
2010-03-13  0:12 ` [patch 041/123] tracing: Fix ftrace_event_call alignment for use with gcc 4.5 Greg KH
2010-03-13  0:12 ` [patch 042/123] ALSA: hda: Use 3stack quirk for Toshiba Satellite L40-10Q Greg KH
2010-03-13  0:12 ` [patch 043/123] ALSA: via82xx: add quirk for D1289 motherboard Greg KH
2010-03-13  0:12 ` [patch 044/123] ALSA: pcm core - fix fifo_size channels interval check Greg KH
2010-03-13  0:12 ` [patch 045/123] ALSA: usb-audio: reduce MIDI packet size to work around broken firmware Greg KH
2010-03-13  0:12 ` [patch 046/123] ALSA: USB MIDI support for Access Music VirusTI Greg KH
2010-03-13  0:12 ` [patch 047/123] thinkpad-acpi: fix ALSA callback return status Greg KH
2010-03-13  0:12 ` [patch 048/123] ALSA: hda: Use LPIB for Dell Latitude 131L Greg KH
2010-03-13  0:12 ` [patch 049/123] ALSA: hda: Use LPIB for a Biostar Microtech board Greg KH
2010-03-13  0:12 ` [patch 050/123] ALSA: hda-intel: Add position_fix quirk for ASUS M2V-MX SE Greg KH
2010-03-13  0:12 ` [patch 051/123] ASoC: fix ak4104 register array access Greg KH
2010-03-13  0:12 ` [patch 052/123] driver-core: fix race condition in get_device_parent() Greg KH
2010-03-13  0:12 ` [patch 053/123] Driver-Core: devtmpfs - reset inode permissions before unlinking Greg KH
2010-03-13  0:12 ` [patch 054/123] sysfs: Cache the last sysfs_dirent to improve readdir scalability v2 Greg KH
2010-03-13  0:12 ` [patch 055/123] tty: Fix the ldisc hangup race Greg KH
2010-03-13  0:12 ` [patch 056/123] serial: imx: fix NULL dereference Oops when pdata == NULL Greg KH
2010-03-13  0:12 ` [patch 057/123] USB: serial: sierra driver indat_callback fix Greg KH
2010-03-13  0:12 ` [patch 058/123] USB: fix I2C API usage in ohci-pnx4008 Greg KH
2010-03-13  0:12 ` [patch 059/123] p54usb: Add the USB ID for Belkin (Accton) FD7050E ver 1010ec Greg KH
2010-03-13  0:12 ` [patch 060/123] p54pci: handle dma mapping errors Greg KH
2010-03-13  0:12 ` [patch 061/123] gpiolib: Actually set output state in wm831x_gpio_direction_output() Greg KH
2010-03-13  0:12 ` [patch 062/123] gpio: cs5535-gpio: fix input direction Greg KH
2010-03-13  0:12 ` [patch 063/123] hwmon: (tmp421) Fix temperature conversions Greg KH
2010-03-13  0:12 ` [patch 064/123] hwmon: (tmp421) Restore missing inputs Greg KH
2010-03-13  0:12 ` [patch 065/123] hwmon: Fix off-by-one kind values Greg KH
2010-03-13  0:12 ` [patch 066/123] pata_hpt3x2n: always stretch UltraDMA timing Greg KH
2010-03-13  0:12 ` [patch 067/123] scm: Only support SCM_RIGHTS on unix domain sockets Greg KH
2010-03-13  0:12 ` [patch 068/123] skbuff: align sk_buff::cb to 64 bit and close some potential holes Greg KH
2010-03-13  0:12 ` [patch 069/123] netdevice.h: check for CONFIG_WLAN instead of CONFIG_WLAN_80211 Greg KH
2010-03-13  0:12 ` [patch 070/123] ath9k: re-enable ps by default for new single chip families Greg KH
2010-03-16  1:04   ` [Stable-review] " Luis R. Rodriguez
2010-03-19  0:04     ` [stable] " Greg KH
2010-03-23 19:26       ` [Stable-review] [stable] " Luis R. Rodriguez
2010-04-02 17:37       ` [stable] [Stable-review] " Luis R. Rodriguez
2010-03-13  0:12 ` [patch 071/123] ath9k: fix beacon timer restart after a card reset Greg KH
2010-03-13  0:12 ` [patch 072/123] ath9k: fix rate control fallback rate selection Greg KH
2010-03-13  0:12 ` [patch 073/123] ath9k: disable RIFS search for AR91xx based chips Greg KH
2010-03-13  0:12 ` [patch 074/123] ath5k: use correct packet type when transmitting Greg KH
2010-03-13  0:12 ` [patch 075/123] b43/b43legacy: Wake queues in wireless_core_start Greg KH
2010-03-13  0:12 ` [patch 076/123] netfilter: xt_recent: fix buffer overflow Greg KH
2010-03-13  0:12 ` [patch 077/123] netfilter: xt_recent: fix false match Greg KH
2010-03-13  0:12 ` [patch 078/123] sunxvr500: Additional PCI id for sunxvr500 driver Greg KH
2010-03-13  0:12 ` [patch 079/123] mac80211: do not transmit frames on unconfigured 4-addr vlan interfaces Greg KH
2010-03-13  0:12 ` [patch 080/123] eeepc-laptop: disable wireless hotplug for 1005PE Greg KH
2010-03-13  0:12 ` [patch 081/123] thinkpad-acpi: fix poll thread auto-start Greg KH
2010-03-13  0:13 ` [patch 082/123] thinkpad-acpi: R52 brightness_mode has been confirmed Greg KH
2010-03-13  0:13 ` [patch 083/123] thinkpad-acpi: document HKEY event 3006 Greg KH
2010-03-13  0:13 ` [patch 084/123] thinkpad-acpi: make driver events work in NVRAM poll mode Greg KH
2010-03-13  0:13 ` [patch 085/123] thinkpad-acpi: fix bluetooth/wwan resume Greg KH
2010-03-13  0:13 ` [patch 086/123] thinkpad-acpi: lock down video output state access Greg KH
2010-03-13  0:13 ` [patch 087/123] ocfs2: Only bug out in direct io write for reflinked extent Greg KH
2010-03-13  0:13 ` [patch 088/123] x86, ia32_aout: do not kill argument mapping Greg KH
2010-03-13  0:13 ` [patch 089/123] x86: Add iMac9,1 to pci_reboot_dmi_table Greg KH
2010-03-13  0:13 ` [patch 090/123] x86, xen: Disable highmem PTE allocation even when CONFIG_HIGHPTE=y Greg KH
2010-03-13  0:13 ` [patch 091/123] x86: Avoid race condition in pci_enable_msix() Greg KH
2010-03-13  0:13 ` [patch 092/123] x86: Fix SCI on IOAPIC != 0 Greg KH
2010-03-13  0:13 ` [patch 093/123] USB: xhci: Fix finding extended capabilities registers Greg KH
2010-03-13  0:13 ` [patch 094/123] USB: fix the idProduct value for USB-3.0 root hubs Greg KH
2010-03-13  0:13 ` [patch 095/123] USB: fix crash in uhci_scan_schedule Greg KH
2010-03-13  0:13 ` [patch 096/123] USB: remove debugging message for uevent constructions Greg KH
2010-03-13  0:13 ` [patch 097/123] USB: Move hcd free_dev call into usb_disconnect to fix oops Greg KH
2010-03-13  0:13 ` [patch 098/123] USB: f_mass_storage: fix crash on bind() error Greg KH
2010-03-13  0:13 ` [patch 099/123] USB: add new ftdi_sio device ids Greg KH
2010-03-13  0:13 ` [patch 100/123] USB: serial: ftdi: add CONTEC vendor and product id Greg KH
2010-03-13  0:13 ` [patch 101/123] USB: cp210x: Add 81E8 (Zephyr Bioharness) Greg KH
2010-03-13  0:13 ` [patch 102/123] USB: unusual_devs: Add support for multiple Option 3G sticks Greg KH
2010-03-13  0:13 ` [patch 103/123] drm/i915: Use a dmi quirk to skip a broken SDVO TV output Greg KH
2010-03-13  0:13 ` [patch 104/123] drm/ttm: handle OOM in ttm_tt_swapout Greg KH
2010-03-13  0:13 ` [patch 105/123] drm/radeon/kms/atom: fix shr/shl ops Greg KH
2010-03-13  0:13 ` [patch 106/123] sunrpc: remove unnecessary svc_xprt_put Greg KH
2010-03-13  0:13 ` [patch 107/123] SUNRPC: Handle EINVAL error returns from the TCP connect operation Greg KH
2010-03-13  0:13 ` [patch 108/123] s3cmci: s3cmci_card_present: Use no_detect to decide whether there is a card detect pin Greg KH
2010-03-13  0:13 ` [patch 109/123] s3cmci: initialize default platform data no_wprotect and no_detect with 1 Greg KH
2010-03-15 16:16   ` [Stable-review] " Stefan Bader
2010-03-30 21:17     ` Greg KH
2010-03-13  0:13 ` [patch 110/123] scripts/get_maintainer.pl: fix possible infinite loop Greg KH
2010-03-13  0:13 ` [patch 111/123] rtc-coh901331: fix braces in resume code Greg KH
2010-03-13  0:13 ` [patch 112/123] NFS: Fix an allocation-under-spinlock bug Greg KH
2010-03-13  0:13 ` [patch 113/123] dm: free dm_io before bio_endio not after Greg KH
2010-03-13  0:13 ` [patch 114/123] dm ioctl: only issue uevent on resume if state changed Greg KH
2010-03-22 18:43   ` Mike Snitzer
2010-03-22 18:54     ` Alasdair G Kergon
2010-04-19 17:44       ` [stable] " Greg KH
2010-03-13  0:13 ` [patch 115/123] KVM: VMX: Trap and invalid MWAIT/MONITOR instruction Greg KH
2010-03-13  0:13 ` [patch 116/123] KVM: x86 emulator: Add group8 instruction decoding Greg KH
2010-03-13  0:13 ` [patch 117/123] KVM: x86 emulator: Forbid modifying CS segment register by mov instruction Greg KH
2010-03-13  0:13 ` [patch 118/123] KVM: x86 emulator: Add group9 instruction decoding Greg KH
2010-03-13  0:13 ` [patch 119/123] KVM: x86 emulator: Check CPL level during privilege instruction emulation Greg KH
2010-03-13  0:13 ` [patch 120/123] sched: Fix sched_mv_power_savings for !SMT Greg KH
2010-03-15  5:51   ` Vaidyanathan Srinivasan
2010-03-15 14:27     ` Greg KH
2010-03-13  0:13 ` [patch 121/123] sched: Fix SMT scheduler regression in find_busiest_queue() Greg KH
2010-03-13  0:13 ` [patch 122/123] sched: Dont use possibly stale sched_class Greg KH
2010-03-13  0:13 ` [patch 123/123] x86, mm: Allow highmem user page tables to be disabled at boot time Greg KH
2010-03-13  2:58 ` [patch 000/123] 2.6.33.1-stable review Grant Coady
2010-03-13  3:27   ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100313001505.873349402@kvm.kroah.org \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=david@fries.net \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver@neukum.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®