All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Thinh.Nguyen@synopsys.com, linux-usb@vger.kernel.org,
	Mathias Nyman <mathias.nyman@intel.com>
Subject: [PATCH v3 6/8] usb: xhci: Fix port minor revision
Date: Wed, 10 Mar 2021 19:43:21 -0800	[thread overview]
Message-ID: <ed330e95a19dc367819c5b4d78bf7a541c35aa0a.1615432770.git.Thinh.Nguyen@synopsys.com> (raw)
In-Reply-To: <cover.1615432770.git.Thinh.Nguyen@synopsys.com>

Some hosts incorrectly use sub-minor version for minor version (i.e.
0x02 instead of 0x20 for bcdUSB 0x320 and 0x01 for bcdUSB 0x310).
Currently the xHCI driver works around this by just checking for minor
revision > 0x01 for USB 3.1 everywhere. With the addition of USB 3.2,
checking this gets a bit cumbersome. Since there is no USB release with
bcdUSB 0x301 to 0x309, we can assume that sub-minor version 01 to 09 is
incorrect. Let's try to fix this and use the minor revision that matches
with the USB/xHCI spec to help with the version checking within the
driver.

Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
Changes in v3:
- Use comparison operators > < instead of & operation for easier read
Changes in v2:
- Use <<= when shift and assign value instead

 drivers/usb/host/xhci-mem.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 7eb8c07c8418..34d95c006751 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2129,6 +2129,15 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
 
 	if (major_revision == 0x03) {
 		rhub = &xhci->usb3_rhub;
+		/*
+		 * Some hosts incorrectly use sub-minor version for minor
+		 * version (i.e. 0x02 instead of 0x20 for bcdUSB 0x320 and 0x01
+		 * for bcdUSB 0x310). Since there is no USB release with sub
+		 * minor version 0x301 to 0x309, we can assume that they are
+		 * incorrect and fix it here.
+		 */
+		if (minor_revision > 0x00 && minor_revision < 0x10)
+			minor_revision <<= 4;
 	} else if (major_revision <= 0x02) {
 		rhub = &xhci->usb2_rhub;
 	} else {
-- 
2.28.0


  parent reply	other threads:[~2021-03-11  3:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11  3:42 [PATCH v3 0/8] usb: Check for genXxY on host Thinh Nguyen
2021-03-11  3:42 ` [PATCH v3 1/8] usb: core: Track SuperSpeed Plus GenXxY Thinh Nguyen
2021-03-11  3:42 ` [PATCH v3 2/8] usb: core: hub: Remove port_speed_is_ssp() Thinh Nguyen
2021-03-11  3:43 ` [PATCH v3 3/8] usb: core: hub: Print speed name based on ssp rate Thinh Nguyen
2021-03-11  3:43 ` [PATCH v3 4/8] usb: core: sysfs: Check for SSP rate in speed attr Thinh Nguyen
2021-03-11  3:43 ` [PATCH v3 5/8] usb: xhci: Init root hub SSP rate Thinh Nguyen
2021-03-11  3:43 ` Thinh Nguyen [this message]
2021-03-11  3:43 ` [PATCH v3 7/8] usb: xhci: Rewrite xhci_create_usb3_bos_desc() Thinh Nguyen
2021-03-11  3:43 ` [PATCH v3 8/8] usb: xhci: Remove unused function Thinh Nguyen
2021-03-23 12:19 ` [PATCH v3 0/8] usb: Check for genXxY on host Greg Kroah-Hartman
2021-03-23 14:36   ` Mathias Nyman
2021-03-23 15:53     ` Greg Kroah-Hartman

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=ed330e95a19dc367819c5b4d78bf7a541c35aa0a.1615432770.git.Thinh.Nguyen@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.