linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hardik Gajjar <hgajjar@de.adit-jv.com>
To: <gregkh@linuxfoundation.org>, <stern@rowland.harvard.edu>,
	<corbet@lwn.net>
Cc: <tj@kernel.org>, <rdunlap@infradead.org>, <paulmck@kernel.org>,
	<linux-doc@vger.kernel.org>, <linux-usb@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <erosca@de.adit-jv.com>,
	<hgajjar@de.adit-jv.com>, <Martin.Mueller5@de.bosch.com>
Subject: [PATCH] usb: hubs: Decrease IN-endpoint poll interval for Microchip USB491x hub
Date: Thu, 23 Nov 2023 09:19:48 +0100	[thread overview]
Message-ID: <20231123081948.58776-1-hgajjar@de.adit-jv.com> (raw)

There is a potential delay in announcing downstream USB bus activity to
Linux USB drivers due to the default interrupt endpoint having a poll
interval of 256ms.

Microchip has recommended ignoring the device descriptor and reducing
that value to 32ms, as it was too late to modify it in silicon.

This patch aims to speed up the USB enumeration process, facilitating
the successful completion of Apple CarPlay certifications and enhancing
user experience when utilizing USB devices through the Microchip Multihost
Hub.

A new quirk, USB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL, accelerates the
notification process by changing the Endpoint interrupt poll interval
from 256ms to 32ms.

Signed-off-by: Hardik Gajjar <hgajjar@de.adit-jv.com>
---
 Documentation/admin-guide/kernel-parameters.txt |  4 ++++
 drivers/usb/core/config.c                       |  8 ++++++++
 drivers/usb/core/quirks.c                       | 11 +++++++++++
 include/linux/usb/quirks.h                      |  5 +++++
 4 files changed, 28 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 65731b060e3f..6b0a66f0e6bf 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -6908,6 +6908,10 @@
 					pause after every control message);
 				o = USB_QUIRK_HUB_SLOW_RESET (Hub needs extra
 					delay after resetting its port);
+				p = USB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL (Set
+					bInterval to a Maximum of 9 to Reduce
+					default Poll Rate from 256 ms to
+					32 ms);
 			Example: quirks=0781:5580:bk,0a5c:5834:gij
 
 	usbhid.mousepoll=
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index b19e38d5fd10..4edbb5922872 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -355,6 +355,14 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
 				n = clamp(fls(d->bInterval), i, j);
 				i = j = n;
 			}
+
+			/*
+			 * This quirk limits bInterval to 9 (32 ms).
+			 */
+			if (udev->quirks & USB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL) {
+				n = clamp(fls(d->bInterval), i, min(j, 9));
+				i = j = n;
+			}
 			break;
 		default:		/* USB_SPEED_FULL or _LOW */
 			/*
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 15e9bd180a1d..243ae5981cc8 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -138,6 +138,9 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
 			case 'o':
 				flags |= USB_QUIRK_HUB_SLOW_RESET;
 				break;
+			case 'p':
+				flags |= USB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL;
+				break;
 			/* Ignore unrecognized flag characters */
 			}
 		}
@@ -211,6 +214,14 @@ static const struct usb_device_id usb_quirk_list[] = {
 	/* USB3503 */
 	{ USB_DEVICE(0x0424, 0x3503), .driver_info = USB_QUIRK_RESET_RESUME },
 
+	/* USB491x hubs need 32ms instead of 256ms bInterval */
+	{ USB_DEVICE(0x0424, 0x4913), .driver_info =
+			USB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL},
+	{ USB_DEVICE(0x0424, 0x4914), .driver_info =
+			USB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL},
+	{ USB_DEVICE(0x0424, 0x4915), .driver_info =
+			USB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL},
+
 	/* Microsoft Wireless Laser Mouse 6000 Receiver */
 	{ USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME },
 
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
index eeb7c2157c72..8fbcca4432bf 100644
--- a/include/linux/usb/quirks.h
+++ b/include/linux/usb/quirks.h
@@ -72,4 +72,9 @@
 /* device has endpoints that should be ignored */
 #define USB_QUIRK_ENDPOINT_IGNORE		BIT(15)
 
+/*
+ * Limits the bInterval value to 9 instead of default value 16
+ */
+#define USB_QUIRK_REDUCE_FRAME_INTR_BINTERVAL	BIT(16)
+
 #endif /* __LINUX_USB_QUIRKS_H */
-- 
2.17.1


             reply	other threads:[~2023-11-23  8:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-23  8:19 Hardik Gajjar [this message]
2023-11-23 18:17 ` [PATCH] usb: hubs: Decrease IN-endpoint poll interval for Microchip USB491x hub Alan Stern
2023-11-24 14:50   ` Hardik Gajjar
2023-11-24 14:57     ` Alan Stern

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=20231123081948.58776-1-hgajjar@de.adit-jv.com \
    --to=hgajjar@de.adit-jv.com \
    --cc=Martin.Mueller5@de.bosch.com \
    --cc=corbet@lwn.net \
    --cc=erosca@de.adit-jv.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tj@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).