[PATCH] usb: host: xhci: don't issue Reset Device from invalid states

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

 



According to Figure 10 Slot State Diagram on xHCI Specification revision
1.1 page 83, it's stated that Reset Device Command is only valid from
Slot Context States Configured and Addressed. We shouldn't issue Reset
Device Command from any other states.

This patch makes sure we're compliant with the spec in that regard.

Cc: <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx>
---
 drivers/usb/host/xhci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1cd56417cbec..ce5030fed590 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3434,6 +3434,7 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
 	struct xhci_command *reset_device_cmd;
 	int last_freed_endpoint;
 	struct xhci_slot_ctx *slot_ctx;
+	int state;
 	int old_active_eps = 0;
 
 	ret = xhci_check_args(hcd, udev, NULL, 0, false, __func__);
@@ -3472,8 +3473,9 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
 
 	/* If device is not setup, there is no point in resetting it */
 	slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx);
-	if (GET_SLOT_STATE(le32_to_cpu(slot_ctx->dev_state)) ==
-						SLOT_STATE_DISABLED)
+	state = GET_SLOT_STATE(le32_to_cpu(slot_ctx->dev_state));
+	if (state != SLOT_STATE_ADDRESSED &&
+			state != SLOT_STATE_CONFIGURED)
 		return 0;
 
 	xhci_dbg(xhci, "Resetting device with slot ID %u\n", slot_id);
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux