[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220816083854.1491886-3-raychi@google.com>
Date: Tue, 16 Aug 2022 16:38:54 +0800
From: Ray Chi <raychi@...gle.com>
To: gregkh@...uxfoundation.org, mathias.nyman@...el.com,
stern@...land.harvard.edu
Cc: badhri@...gle.com, albertccwang@...gle.com,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
Ray Chi <raychi@...gle.com>
Subject: [PATCH 2/2] usb: xhci: add check_init_status hook support
In general, xHCI didn't do anything for port initialization. However,
there are some requirement or limitation on various platforms, so
vendors need to do some error handlings if the device connected to a
broken USB accessory.
This patch also add the hook to xhci_driver_overrides so that vendors
can add their specific protection easily if needed.
Signed-off-by: Ray Chi <raychi@...gle.com>
---
drivers/usb/host/xhci.c | 17 +++++++++++++++++
drivers/usb/host/xhci.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 65858f607437..f237af9d6e2e 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4358,6 +4358,20 @@ static int xhci_enable_device(struct usb_hcd *hcd, struct usb_device *udev)
return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ONLY);
}
+/*
+ * The function could get the status of port initialization.
+ */
+static int xhci_check_init_status(struct usb_hcd *hcd, struct usb_device *udev, int r)
+{
+ /*
+ * In general, this function is not necessory. Some platforms may
+ * need doing error handling when the port initialization takes a
+ * long time to do. The device can use the override callback to
+ * do specific handlings.
+ */
+ return 0;
+}
+
/*
* Transfer the port index into real index in the HW port status
* registers. Caculate offset between the port's PORTSC register
@@ -5455,6 +5469,7 @@ static const struct hc_driver xhci_hc_driver = {
.enable_device = xhci_enable_device,
.update_hub_device = xhci_update_hub_device,
.reset_device = xhci_discover_or_reset_device,
+ .check_init_status = xhci_check_init_status,
/*
* scheduling support
@@ -5503,6 +5518,8 @@ void xhci_init_driver(struct hc_driver *drv,
drv->check_bandwidth = over->check_bandwidth;
if (over->reset_bandwidth)
drv->reset_bandwidth = over->reset_bandwidth;
+ if (over->check_init_status)
+ drv->check_init_status = over->check_init_status;
}
}
EXPORT_SYMBOL_GPL(xhci_init_driver);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 1960b47acfb2..33ce873236e9 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1944,6 +1944,7 @@ struct xhci_driver_overrides {
struct usb_host_endpoint *ep);
int (*check_bandwidth)(struct usb_hcd *, struct usb_device *);
void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *);
+ int (*check_init_status)(struct usb_hcd *hcd, struct usb_device *udev, int r);
};
#define XHCI_CFC_DELAY 10
--
2.37.1.595.g718a3a8f04-goog
Powered by blists - more mailing lists