xhci: remove XHCI_TRUST_TX_LENGTH quirk
authorMathias Nyman <mathias.nyman@linux.intel.com>
Mon, 29 Apr 2024 14:02:36 +0000 (17:02 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 May 2024 06:47:14 +0000 (08:47 +0200)
If this quirk was set then driver would treat transfer events with
'Success' completion code as 'Short packet' if there were untransferred
bytes left.

This is so common that turn it into default behavior.

xhci_warn_ratelimited() is no longer used after this, so remove it.

A success event with untransferred bytes left doesn't always mean a
misbehaving controller. If there was an error mid a multi-TRB TD it's
allowed to issue a success event for the last TRB in that TD.

See xhci 1.2 spec 4.9.1 Transfer Descriptors

"Note: If an error is detected while processing a multi-TRB TD, the xHC
 shall generate a Transfer Event for the TRB that the error was detected
 on with the appropriate error Condition Code, then may advance to the
 next TD. If in the process of advancing to the next TD, a Transfer TRB
 is encountered with its IOC flag set, then the Condition Code of the
 Transfer Event generated for that Transfer TRB should be Success,
 because there was no error actually associated with the TRB that
 generated the Event. However, an xHC implementation may redundantly
 assert the original error Condition Code."

Co-developed-by: Niklas Neronin <niklas.neronin@linux.intel.com>
Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20240429140245.3955523-10-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-pci.c
drivers/usb/host/xhci-rcar.c
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci.h

index 93b6976480188c6b32fa8b8e7f6617caedb65ca7..653b47c45591dcffb49e4957e0d90e34c5db8c3f 100644 (file)
@@ -270,17 +270,12 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
                                "QUIRK: Fresco Logic revision %u "
                                "has broken MSI implementation",
                                pdev->revision);
-               xhci->quirks |= XHCI_TRUST_TX_LENGTH;
        }
 
        if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC &&
                        pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1009)
                xhci->quirks |= XHCI_BROKEN_STREAMS;
 
-       if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC &&
-                       pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1100)
-               xhci->quirks |= XHCI_TRUST_TX_LENGTH;
-
        if (pdev->vendor == PCI_VENDOR_ID_NEC)
                xhci->quirks |= XHCI_NEC_HOST;
 
@@ -307,11 +302,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
                xhci->quirks |= XHCI_RESET_ON_RESUME;
        }
 
-       if (pdev->vendor == PCI_VENDOR_ID_AMD) {
-               xhci->quirks |= XHCI_TRUST_TX_LENGTH;
-               if (pdev->device == 0x43f7)
-                       xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW;
-       }
+       if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x43f7)
+               xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW;
 
        if ((pdev->vendor == PCI_VENDOR_ID_AMD) &&
                ((pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4) ||
@@ -399,12 +391,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
        if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
                        pdev->device == PCI_DEVICE_ID_EJ168) {
                xhci->quirks |= XHCI_RESET_ON_RESUME;
-               xhci->quirks |= XHCI_TRUST_TX_LENGTH;
                xhci->quirks |= XHCI_BROKEN_STREAMS;
        }
        if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
            pdev->device == 0x0014) {
-               xhci->quirks |= XHCI_TRUST_TX_LENGTH;
                xhci->quirks |= XHCI_ZERO_64B_REGS;
        }
        if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
@@ -434,7 +424,6 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
        }
        if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
                pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI) {
-               xhci->quirks |= XHCI_TRUST_TX_LENGTH;
                xhci->quirks |= XHCI_NO_64BIT_SUPPORT;
        }
        if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
index ab9c5969e4624eed70e759c938e697a636bf9fa6..8b357647728c2b6ca135d0388cfb0281b2d3b01a 100644 (file)
@@ -214,8 +214,7 @@ static int xhci_rcar_resume_quirk(struct usb_hcd *hcd)
  */
 #define SET_XHCI_PLAT_PRIV_FOR_RCAR(firmware)                          \
        .firmware_name = firmware,                                      \
-       .quirks = XHCI_NO_64BIT_SUPPORT | XHCI_TRUST_TX_LENGTH |        \
-                 XHCI_SLOW_SUSPEND,                                    \
+       .quirks = XHCI_NO_64BIT_SUPPORT |  XHCI_SLOW_SUSPEND,           \
        .init_quirk = xhci_rcar_init_quirk,                             \
        .plat_start = xhci_rcar_start,                                  \
        .resume_quirk = xhci_rcar_resume_quirk,
@@ -229,8 +228,7 @@ static const struct xhci_plat_priv xhci_plat_renesas_rcar_gen3 = {
 };
 
 static const struct xhci_plat_priv xhci_plat_renesas_rzv2m = {
-       .quirks = XHCI_NO_64BIT_SUPPORT | XHCI_TRUST_TX_LENGTH |
-                 XHCI_SLOW_SUSPEND,
+       .quirks = XHCI_NO_64BIT_SUPPORT | XHCI_SLOW_SUSPEND,
        .init_quirk = xhci_rzv2m_init_quirk,
        .plat_start = xhci_rzv2m_start,
 };
index 0a7c70ae5edc3dded6394ce511699313cc377827..07c529e072c9e140f6e03ffb34fb7722513badb2 100644 (file)
@@ -2397,8 +2397,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep,
                        break;
                if (remaining) {
                        frame->status = short_framestatus;
-                       if (xhci->quirks & XHCI_TRUST_TX_LENGTH)
-                               sum_trbs_for_length = true;
+                       sum_trbs_for_length = true;
                        break;
                }
                frame->status = 0;
@@ -2648,15 +2647,11 @@ static int handle_tx_event(struct xhci_hcd *xhci,
         * transfer type
         */
        case COMP_SUCCESS:
-               if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) == 0)
-                       break;
-               if (xhci->quirks & XHCI_TRUST_TX_LENGTH ||
-                   ep_ring->last_td_was_short)
+               if (EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) {
                        trb_comp_code = COMP_SHORT_PACKET;
-               else
-                       xhci_warn_ratelimited(xhci,
-                                             "WARN Successful completion on short TX for slot %u ep %u: needs XHCI_TRUST_TX_LENGTH quirk?\n",
-                                             slot_id, ep_index);
+                       xhci_dbg(xhci, "Successful completion on short TX for slot %u ep %u with last td short %d\n",
+                                slot_id, ep_index, ep_ring->last_td_was_short);
+               }
                break;
        case COMP_SHORT_PACKET:
                break;
index 8c96dd6ef3d4fd211231d500eb4df35d0f1c013f..933f8a296014ffb84622647a3fec8602583c40dd 100644 (file)
@@ -1588,7 +1588,7 @@ struct xhci_hcd {
 #define XHCI_RESET_ON_RESUME   BIT_ULL(7)
 #define        XHCI_SW_BW_CHECKING     BIT_ULL(8)
 #define XHCI_AMD_0x96_HOST     BIT_ULL(9)
-#define XHCI_TRUST_TX_LENGTH   BIT_ULL(10)
+#define XHCI_TRUST_TX_LENGTH   BIT_ULL(10) /* Deprecated */
 #define XHCI_LPM_SUPPORT       BIT_ULL(11)
 #define XHCI_INTEL_HOST                BIT_ULL(12)
 #define XHCI_SPURIOUS_REBOOT   BIT_ULL(13)
@@ -1725,8 +1725,6 @@ static inline bool xhci_has_one_roothub(struct xhci_hcd *xhci)
        dev_err(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
 #define xhci_warn(xhci, fmt, args...) \
        dev_warn(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
-#define xhci_warn_ratelimited(xhci, fmt, args...) \
-       dev_warn_ratelimited(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
 #define xhci_info(xhci, fmt, args...) \
        dev_info(xhci_to_hcd(xhci)->self.controller , fmt , ## args)