linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	James P Michels III <james.p.michels@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3.12 05/56] usb-core bInterval quirk
Date: Wed,  3 Sep 2014 11:26:24 +0200	[thread overview]
Message-ID: <c877de31fe78ee82855a2c1049c7b755128f481c.1409735865.git.jslaby@suse.cz> (raw)
In-Reply-To: <b4839e6cd4a236a81725e422b2e05c26fe36048a.1409735865.git.jslaby@suse.cz>
In-Reply-To: <cover.1409735865.git.jslaby@suse.cz>

From: James P Michels III <james.p.michels@gmail.com>

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

===============

commit cd83ce9e6195aa3ea15ab4db92892802c20df5d0 upstream.

This patch adds a usb quirk to support devices with interupt endpoints
and bInterval values expressed as microframes. The quirk causes the
parse endpoint function to modify the reported bInterval to a standards
conforming value.

There is currently code in the endpoint parser that checks for
bIntervals that are outside of the valid range (1-16 for USB 2+ high
speed and super speed interupt endpoints). In this case, the code assumes
the bInterval is being reported in 1ms frames. As well, the correction
is only applied if the original bInterval value is out of the 1-16 range.

With this quirk applied to the device, the bInterval will be
accurately adjusted from microframes to an exponent.

Signed-off-by: James P Michels III <james.p.michels@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/usb/core/config.c  | 11 +++++++++++
 drivers/usb/core/quirks.c  |  4 ++++
 include/linux/usb/quirks.h | 11 +++++++++++
 3 files changed, 26 insertions(+)

diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 652438325197..98cb09617b20 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -201,6 +201,17 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
 			if (n == 0)
 				n = 9;	/* 32 ms = 2^(9-1) uframes */
 			j = 16;
+
+			/*
+			 * Adjust bInterval for quirked devices.
+			 * This quirk fixes bIntervals reported in
+			 * linear microframes.
+			 */
+			if (to_usb_device(ddev)->quirks &
+				USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL) {
+				n = clamp(fls(d->bInterval), i, j);
+				i = j = n;
+			}
 			break;
 		default:		/* USB_SPEED_FULL or _LOW */
 			/* For low-speed, 10 ms is the official minimum.
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 31f7ebf55868..6fd22252273c 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -147,6 +147,10 @@ static const struct usb_device_id usb_quirk_list[] = {
 	/* SKYMEDI USB_DRIVE */
 	{ USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME },
 
+	/* Razer - Razer Blade Keyboard */
+	{ USB_DEVICE(0x1532, 0x0116), .driver_info =
+			USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
+
 	/* BUILDWIN Photo Frame */
 	{ USB_DEVICE(0x1908, 0x1315), .driver_info =
 			USB_QUIRK_HONOR_BNUMINTERFACES },
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
index 52f944dfe2fd..55a17b188daa 100644
--- a/include/linux/usb/quirks.h
+++ b/include/linux/usb/quirks.h
@@ -30,4 +30,15 @@
    descriptor */
 #define USB_QUIRK_DELAY_INIT		0x00000040
 
+/*
+ * For high speed and super speed interupt endpoints, the USB 2.0 and
+ * USB 3.0 spec require the interval in microframes
+ * (1 microframe = 125 microseconds) to be calculated as
+ * interval = 2 ^ (bInterval-1).
+ *
+ * Devices with this quirk report their bInterval as the result of this
+ * calculation instead of the exponent variable used in the calculation.
+ */
+#define USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL	0x00000080
+
 #endif /* __LINUX_USB_QUIRKS_H */
-- 
2.1.0


  parent reply	other threads:[~2014-09-03 10:13 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-03  9:26 [PATCH 3.12 00/56] 3.12.28-stable review Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 01/56] bcache: Minor journal fix Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 02/56] usb: musb: cppi41: fire hrtimer according to programmed channel length Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 03/56] USB: serial: cp210x: Removing unncessary `usb_reset_device` on startup Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 04/56] USB: add reset resume quirk for usb3503 Jiri Slaby
2014-09-03  9:26 ` Jiri Slaby [this message]
2014-09-03  9:26 ` [PATCH 3.12 06/56] USB: core: hcd-pci: free IRQ before disabling PCI device when shutting down Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 07/56] HID: add quirk for 0x04d9:0xa096 device Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 08/56] PM / hibernate: avoid unsafe pages in e820 reserved regions Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 09/56] bio-integrity: add "bip_max_vcnt" into struct bio_integrity_payload Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 10/56] PCI: Add pci_upstream_bridge() Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 11/56] HID: logitech: perform bounds checking on device_id early enough Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 12/56] HID: fix a couple of off-by-ones Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 13/56] isofs: Fix unbounded recursion when processing relocated directories Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 14/56] USB: OHCI: fix bugs in debug routines Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 15/56] USB: OHCI: don't lose track of EDs when a controller dies Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 16/56] USB: devio: fix issue with log flooding Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 17/56] USB: serial: ftdi_sio: Annotate the current Xsens PID assignments Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 18/56] USB: serial: ftdi_sio: Add support for new Xsens devices Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 19/56] USB: ehci-pci: USB host controller support for Intel Quark X1000 Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 20/56] USB: Fix persist resume of some SS USB devices Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 21/56] ALSA: hda - fix an external mic jack problem on a HP machine Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 22/56] ALSA: virtuoso: add Xonar Essence STX II support Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 23/56] ALSA: hda/ca0132 - Don't try loading firmware at resume when already failed Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 24/56] ALSA: usb-audio: fix BOSS ME-25 MIDI regression Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 25/56] ALSA: hda - restore the gpio led after resume Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 26/56] ALSA: hda/realtek - Avoid setting wrong COEF on ALC269 & co Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 27/56] mei: start disconnect request timer consistently Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 28/56] ARM: OMAP3: Fix choice of omap3_restore_es function in OMAP34XX rev3.1.2 case Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 29/56] drm: omapdrm: fix compiler errors Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 30/56] hwmon: (sis5595) Prevent overflow problem when writing large limits Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 31/56] hwmon: (amc6821) Fix possible race condition bug Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 32/56] hwmon: (lm78) Fix overflow problems seen when writing large temperature limits Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 33/56] hwmon: (gpio-fan) Prevent overflow problem when writing large limits Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 34/56] hwmon: (ads1015) Fix off-by-one for valid channel index checking Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 35/56] hwmon: (lm85) Fix various errors on attribute writes Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 36/56] hwmon: (ads1015) Fix out-of-bounds array access Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 37/56] hwmon: (dme1737) Prevent overflow problem when writing large limits Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 38/56] tpm: Add missing tpm_do_selftest to ST33 I2C driver Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 39/56] drivers/i2c/busses: use correct type for dma_map/unmap Jiri Slaby
2014-09-03  9:26 ` [PATCH 3.12 40/56] ext4: fix ext4_discard_allocated_blocks() if we can't allocate the pa struct Jiri Slaby
2014-09-15  2:46   ` Ben Hutchings
2014-09-15  7:40     ` Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 41/56] serial: core: Preserve termios c_cflag for console resume Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 42/56] crypto: ux500 - make interrupt mode plausible Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 43/56] debugfs: Fix corrupted loop in debugfs_remove_recursive Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 44/56] KVM: x86: Inter-privilege level ret emulation is not implemeneted Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 45/56] KVM: x86: always exit on EOIs for interrupts listed in the IOAPIC redir table Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 46/56] Revert "KVM: x86: Increase the number of fixed MTRR regs to 10" Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 47/56] kvm: iommu: fix the third parameter of kvm_iommu_put_pages (CVE-2014-3601) Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 48/56] drm/radeon: add new KV pci id Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 49/56] drm/radeon: add new bonaire pci ids Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 50/56] drm/radeon: add additional SI " Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 51/56] PCI: Configure ASPM when enabling device Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 52/56] x86: don't exclude low BIOS area when allocating address space for non-PCI cards Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 53/56] x86_64/vsyscall: Fix warn_bad_vsyscall log output Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 54/56] x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 55/56] x86/xen: resume timer irqs early Jiri Slaby
2014-09-03  9:27 ` [PATCH 3.12 56/56] hpsa: fix bad -ENOMEM return value in hpsa_big_passthru_ioctl Jiri Slaby
2014-09-03 13:26 ` [PATCH 3.12 00/56] 3.12.28-stable review Guenter Roeck
2014-09-03 19:32   ` Jiri Slaby
2014-09-03 19:55     ` Guenter Roeck
2014-09-03 21:08     ` Guenter Roeck
2014-09-05  7:28       ` Jiri Slaby
2014-09-04 13:33 ` Shuah Khan

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=c877de31fe78ee82855a2c1049c7b755128f481c.1409735865.git.jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=gregkh@linuxfoundation.org \
    --cc=james.p.michels@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).