Revert "usb: xhci: Add timeout argument in address_device USB HCD callback"

This reverts commit 5f9b63193b 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 <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2024-06-20 16:20:08 +00:00
parent 992f4a2013
commit 077eb0a09d
6 changed files with 17 additions and 36 deletions

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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);
}
/*

View File

@@ -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 {

View File

@@ -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.