From 077eb0a09d73775c4b971b9c245446fed51393d6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 20 Jun 2024 16:20:08 +0000 Subject: [PATCH] Revert "usb: xhci: Add timeout argument in address_device USB HCD callback" This reverts commit 5f9b63193bcac6938298ec8f079e533da6db5e86 which is commit a769154c7cac037914ba375ae88aae55b2c853e0 upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: I77f823bdc857c0eb1a1f500b469f4678597d1484 Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 2 +- drivers/usb/host/xhci-mem.c | 2 -- drivers/usb/host/xhci-ring.c | 11 +++++------ drivers/usb/host/xhci.c | 23 +++++++---------------- drivers/usb/host/xhci.h | 10 ++-------- include/linux/usb/hcd.h | 5 ++--- 6 files changed, 17 insertions(+), 36 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 8895f2301876..8e03ccb23ba1 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -4739,7 +4739,7 @@ static int hub_set_address(struct usb_device *udev, int devnum) if (udev->state != USB_STATE_DEFAULT) return -EINVAL; if (hcd->driver->address_device) - retval = hcd->driver->address_device(hcd, udev, timeout_ms); + retval = hcd->driver->address_device(hcd, udev); else retval = usb_control_msg(udev, usb_sndaddr0pipe(), USB_REQ_SET_ADDRESS, 0, devnum, 0, diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 9be58e6dd290..060b83a2ce11 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1832,8 +1832,6 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, } command->status = 0; - /* set default timeout to 5000 ms */ - command->timeout_ms = XHCI_CMD_DEFAULT_TIMEOUT; INIT_LIST_HEAD(&command->cmd_list); return command; } diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index c11c1b1185ef..bfee7c695d86 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -334,10 +334,9 @@ void xhci_ring_cmd_db(struct xhci_hcd *xhci) } EXPORT_SYMBOL_GPL(xhci_ring_cmd_db); -static bool xhci_mod_cmd_timer(struct xhci_hcd *xhci) +static bool xhci_mod_cmd_timer(struct xhci_hcd *xhci, unsigned long delay) { - return mod_delayed_work(system_wq, &xhci->cmd_timer, - msecs_to_jiffies(xhci->current_cmd->timeout_ms)); + return mod_delayed_work(system_wq, &xhci->cmd_timer, delay); } static struct xhci_command *xhci_next_queued_cmd(struct xhci_hcd *xhci) @@ -381,7 +380,7 @@ static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci, if ((xhci->cmd_ring->dequeue != xhci->cmd_ring->enqueue) && !(xhci->xhc_state & XHCI_STATE_DYING)) { xhci->current_cmd = cur_cmd; - xhci_mod_cmd_timer(xhci); + xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT); xhci_ring_cmd_db(xhci); } } @@ -1765,7 +1764,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci, if (!list_is_singular(&xhci->cmd_list)) { xhci->current_cmd = list_first_entry(&cmd->cmd_list, struct xhci_command, cmd_list); - xhci_mod_cmd_timer(xhci); + xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT); } else if (xhci->current_cmd == cmd) { xhci->current_cmd = NULL; } @@ -4342,7 +4341,7 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd, /* if there are no other commands queued we start the timeout timer */ if (list_empty(&xhci->cmd_list)) { xhci->current_cmd = cmd; - xhci_mod_cmd_timer(xhci); + xhci_mod_cmd_timer(xhci, XHCI_CMD_DEFAULT_TIMEOUT); } list_add_tail(&cmd->cmd_list, &xhci->cmd_list); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index b835af8dcbc2..3b9c8b71ff1a 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4224,18 +4224,12 @@ disable_slot: return 0; } -/** - * xhci_setup_device - issues an Address Device command to assign a unique - * USB bus address. - * @hcd: USB host controller data structure. - * @udev: USB dev structure representing the connected device. - * @setup: Enum specifying setup mode: address only or with context. - * @timeout_ms: Max wait time (ms) for the command operation to complete. - * - * Return: 0 if successful; otherwise, negative error code. +/* + * Issue an Address Device command and optionally send a corresponding + * SetAddress request to the device. */ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev, - enum xhci_setup_dev setup, unsigned int timeout_ms) + enum xhci_setup_dev setup) { const char *act = setup == SETUP_CONTEXT_ONLY ? "context" : "address"; unsigned long flags; @@ -4292,7 +4286,6 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev, } command->in_ctx = virt_dev->in_ctx; - command->timeout_ms = timeout_ms; slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx); @@ -4426,17 +4419,15 @@ out: return ret; } -int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev, - unsigned int timeout_ms) +int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) { - return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ADDRESS, timeout_ms); + return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ADDRESS); } EXPORT_SYMBOL_GPL(xhci_address_device); static int xhci_enable_device(struct usb_hcd *hcd, struct usb_device *udev) { - return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ONLY, - XHCI_CMD_DEFAULT_TIMEOUT); + return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ONLY); } /* diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 67d9b22e8d84..91754f5e786e 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -817,9 +817,6 @@ struct xhci_command { union xhci_trb *command_trb; struct list_head cmd_list; - /* xHCI command response timeout in milliseconds */ - unsigned int timeout_ms; - ANDROID_KABI_RESERVE(1); ANDROID_KABI_RESERVE(2); }; @@ -1583,11 +1580,8 @@ struct xhci_td { unsigned int num_trbs; }; -/* - * xHCI command default timeout value in milliseconds. - * USB 3.2 spec, section 9.2.6.1 - */ -#define XHCI_CMD_DEFAULT_TIMEOUT 5000 +/* xHCI command default timeout value */ +#define XHCI_CMD_DEFAULT_TIMEOUT (5 * HZ) /* command descriptor */ struct xhci_cd { diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index bc919c56262a..3269c0e733ac 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -377,9 +377,8 @@ struct hc_driver { * or bandwidth constraints. */ void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *); - /* Set the hardware-chosen device address */ - int (*address_device)(struct usb_hcd *, struct usb_device *udev, - unsigned int timeout_ms); + /* Returns the hardware-chosen device address */ + int (*address_device)(struct usb_hcd *, struct usb_device *udev); /* prepares the hardware to send commands to the device */ int (*enable_device)(struct usb_hcd *, struct usb_device *udev); /* Notifies the HCD after a hub descriptor is fetched.