git: 33cbbf268f7d - main - xhci(4): Add quirk for "TUSB73x0 USB3.0 xHCI Controller".

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Thu, 03 Mar 2022 17:15:18 UTC
The branch main has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=33cbbf268f7d0f3daff0c2aa06836d932faf56a9

commit 33cbbf268f7d0f3daff0c2aa06836d932faf56a9
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-03-03 16:32:20 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-03-03 17:14:21 +0000

    xhci(4): Add quirk for "TUSB73x0 USB3.0 xHCI Controller".
    
    Tested by:      br@
    MFC after:      1 week
    Sponsored by:   NVIDIA Networking
---
 sys/dev/usb/controller/xhci.c     | 11 +++++++++--
 sys/dev/usb/controller/xhci.h     |  5 ++++-
 sys/dev/usb/controller/xhci_pci.c |  7 ++++++-
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c
index febb5f3d82cb..f95996b7ab32 100644
--- a/sys/dev/usb/controller/xhci.c
+++ b/sys/dev/usb/controller/xhci.c
@@ -2,7 +2,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
- * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2010-2022 Hans Petter Selasky
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -104,6 +104,10 @@ static int xhcictlquirk = 1;
 SYSCTL_INT(_hw_usb_xhci, OID_AUTO, ctlquirk, CTLFLAG_RWTUN,
     &xhcictlquirk, 0, "Set to enable control endpoint quirk");
 
+static int xhcidcepquirk;
+SYSCTL_INT(_hw_usb_xhci, OID_AUTO, dcepquirk, CTLFLAG_RWTUN,
+    &xhcidcepquirk, 0, "Set to disable endpoint deconfigure command");
+
 #ifdef USB_DEBUG
 static int xhcidebug;
 static int xhciroute;
@@ -1477,8 +1481,11 @@ xhci_cmd_configure_ep(struct xhci_softc *sc, uint64_t input_ctx,
 	temp = XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_CONFIGURE_EP) |
 	    XHCI_TRB_3_SLOT_SET(slot_id);
 
-	if (deconfigure)
+	if (deconfigure) {
+		if (sc->sc_no_deconfigure != 0 || xhcidcepquirk != 0)
+			return (0);	/* Success */
 		temp |= XHCI_TRB_3_DCEP_BIT;
+	}
 
 	trb.dwTrb3 = htole32(temp);
 
diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h
index ff7ec23ca5f2..e5c189697067 100644
--- a/sys/dev/usb/controller/xhci.h
+++ b/sys/dev/usb/controller/xhci.h
@@ -3,7 +3,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
- * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2010-2022 Hans Petter Selasky
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -555,6 +555,9 @@ struct xhci_softc {
 	/* size of context */
 	uint8_t			sc_ctx_is_64_byte;
 
+	/* deconfiguring USB device is not fully supported */
+	uint8_t			sc_no_deconfigure;
+
 	/* Isochronous Scheduling Threshold */
 	uint8_t			sc_ist;
 
diff --git a/sys/dev/usb/controller/xhci_pci.c b/sys/dev/usb/controller/xhci_pci.c
index bb9baee6800d..be12d8c33382 100644
--- a/sys/dev/usb/controller/xhci_pci.c
+++ b/sys/dev/usb/controller/xhci_pci.c
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
- * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2010-2022 Hans Petter Selasky
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -287,6 +287,9 @@ xhci_pci_attach(device_t self)
 	sc->sc_io_size = rman_get_size(sc->sc_io_res);
 
 	switch (pci_get_devid(self)) {
+	case 0x8241104c:	/* TUSB73x0 USB3.0 xHCI Controller */
+		sc->sc_no_deconfigure = 1;
+		break;
 	case 0x01941033:	/* NEC uPD720200 USB 3.0 controller */
 	case 0x00141912:	/* NEC uPD720201 USB 3.0 controller */
 		/* Don't use 64-bit DMA on these controllers. */
@@ -310,6 +313,8 @@ xhci_pci_attach(device_t self)
 		sc->sc_imod_default = XHCI_IMOD_DEFAULT_LP;
 		sc->sc_ctlstep = 1;
 		break;
+	default:
+		break;
 	}
 
 	if (xhci_init(sc, self, usedma32)) {