Patch "xhci: Don't issue Reset Device command to Etron xHCI host" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    xhci: Don't issue Reset Device command to Etron xHCI host

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     xhci-don-t-issue-reset-device-command-to-etron-xhci-.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit fabff60c0a2041a9ddaa9dadc1974668923838a7
Author: Kuangyi Chiang <ki.chiang65@xxxxxxxxx>
Date:   Wed Nov 6 12:14:44 2024 +0200

    xhci: Don't issue Reset Device command to Etron xHCI host
    
    [ Upstream commit 76d98856b1c6d06ce18f32c20527a4f9d283e660 ]
    
    Sometimes the hub driver does not recognize the USB device connected
    to the external USB2.0 hub when the system resumes from S4.
    
    After the SetPortFeature(PORT_RESET) request is completed, the hub
    driver calls the HCD reset_device callback, which will issue a Reset
    Device command and free all structures associated with endpoints
    that were disabled.
    
    This happens when the xHCI driver issue a Reset Device command to
    inform the Etron xHCI host that the USB device associated with a
    device slot has been reset. Seems that the Etron xHCI host can not
    perform this command correctly, affecting the USB device.
    
    To work around this, the xHCI driver should obtain a new device slot
    with reference to commit 651aaf36a7d7 ("usb: xhci: Handle USB transaction
    error on address command"), which is another way to inform the Etron
    xHCI host that the USB device has been reset.
    
    Add a new XHCI_ETRON_HOST quirk flag to invoke the workaround in
    xhci_discover_or_reset_device().
    
    Fixes: 2a8f82c4ceaf ("USB: xhci: Notify the xHC when a device is reset.")
    Cc: stable@xxxxxxxxxxxxxxx
    Signed-off-by: Kuangyi Chiang <ki.chiang65@xxxxxxxxx>
    Signed-off-by: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20241106101459.775897-19-mathias.nyman@xxxxxxxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index d36158df83afc..340d9597d1ab0 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -458,6 +458,7 @@ 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 ||
 	     pdev->device == PCI_DEVICE_ID_EJ188)) {
+		xhci->quirks |= XHCI_ETRON_HOST;
 		xhci->quirks |= XHCI_RESET_ON_RESUME;
 		xhci->quirks |= XHCI_BROKEN_STREAMS;
 	}
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index f005ce1f91ca2..3bd70e6ad64ba 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3642,6 +3642,8 @@ void xhci_free_device_endpoint_resources(struct xhci_hcd *xhci,
 				xhci->num_active_eps);
 }
 
+static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev);
+
 /*
  * This submits a Reset Device Command, which will set the device state to 0,
  * set the device address to 0, and disable all the endpoints except the default
@@ -3712,6 +3714,23 @@ static int xhci_discover_or_reset_device(struct usb_hcd *hcd,
 						SLOT_STATE_DISABLED)
 		return 0;
 
+	if (xhci->quirks & XHCI_ETRON_HOST) {
+		/*
+		 * Obtaining a new device slot to inform the xHCI host that
+		 * the USB device has been reset.
+		 */
+		ret = xhci_disable_slot(xhci, udev->slot_id);
+		xhci_free_virt_device(xhci, udev->slot_id);
+		if (!ret) {
+			ret = xhci_alloc_dev(hcd, udev);
+			if (ret == 1)
+				ret = 0;
+			else
+				ret = -EINVAL;
+		}
+		return ret;
+	}
+
 	trace_xhci_discover_or_reset_device(slot_ctx);
 
 	xhci_dbg(xhci, "Resetting device with slot ID %u\n", slot_id);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index a0005a1124938..4bbd12db7239a 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1660,6 +1660,7 @@ struct xhci_hcd {
 #define XHCI_ZHAOXIN_HOST	BIT_ULL(46)
 #define XHCI_WRITE_64_HI_LO	BIT_ULL(47)
 #define XHCI_CDNS_SCTX_QUIRK	BIT_ULL(48)
+#define XHCI_ETRON_HOST	BIT_ULL(49)
 
 	unsigned int		num_active_eps;
 	unsigned int		limit_active_eps;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux