1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter.git synced 2025-02-15 04:42:02 +00:00
openmptcprouter/root/target/linux/brcm2708/patches-4.19/0664-usb-add-plumbing-for-updating-interrupt-endpoint-int.patch
Ycarus (Yannick Chabanois) 5f08b288eb Add RPI4 beta support
2019-06-24 19:52:48 +02:00

115 lines
4.5 KiB
Diff

From ed37a9faa3e7e0525c15cd6ce2d75c0570e4ff38 Mon Sep 17 00:00:00 2001
From: Jonathan Bell <jonathan@raspberrypi.org>
Date: Tue, 11 Jun 2019 10:55:00 +0100
Subject: [PATCH 664/678] usb: add plumbing for updating interrupt endpoint
interval state
xHCI caches device and endpoint data after the interface is configured,
so an explicit command needs to be issued for any device driver wanting
to alter the polling interval of an endpoint.
Add usb_fixup_endpoint() to allow drivers to do this. The fixup must be
called after calculating endpoint bandwidth requirements but before any
URBs are submitted.
If polling intervals are shortened, any bandwidth reservations are no
longer valid but in practice polling intervals are only ever relaxed.
Limit the scope to interrupt transfers for now.
Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
---
drivers/usb/core/hcd.c | 10 ++++++++++
drivers/usb/core/message.c | 15 +++++++++++++++
include/linux/usb.h | 2 ++
include/linux/usb/hcd.h | 7 +++++++
4 files changed, 34 insertions(+)
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index b82a7d787add..69268aa21d38 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2071,6 +2071,16 @@ int usb_hcd_alloc_bandwidth(struct usb_device *udev,
return ret;
}
+void usb_hcd_fixup_endpoint(struct usb_device *udev,
+ struct usb_host_endpoint *ep, int interval)
+{
+ struct usb_hcd *hcd;
+
+ hcd = bus_to_hcd(udev->bus);
+ if (hcd->driver->fixup_endpoint)
+ hcd->driver->fixup_endpoint(hcd, udev, ep, interval);
+}
+
/* Disables the endpoint: synchronizes with the hcd to make sure all
* endpoint state is gone from hardware. usb_hcd_flush_endpoint() must
* have been called previously. Use for set_configuration, set_interface,
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 9b5411635f96..28a5c5ed0f2c 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1113,6 +1113,21 @@ static void remove_intf_ep_devs(struct usb_interface *intf)
intf->ep_devs_created = 0;
}
+void usb_fixup_endpoint(struct usb_device *dev, int epaddr, int interval)
+{
+ unsigned int epnum = epaddr & USB_ENDPOINT_NUMBER_MASK;
+ struct usb_host_endpoint *ep;
+
+ if (usb_endpoint_out(epaddr))
+ ep = dev->ep_out[epnum];
+ else
+ ep = dev->ep_in[epnum];
+
+ if (ep && usb_endpoint_xfer_int(&ep->desc))
+ usb_hcd_fixup_endpoint(dev, ep, interval);
+}
+EXPORT_SYMBOL_GPL(usb_fixup_endpoint);
+
/**
* usb_disable_endpoint -- Disable an endpoint by address
* @dev: the device whose endpoint is being disabled
diff --git a/include/linux/usb.h b/include/linux/usb.h
index ff010d1fd1c7..379a0acf0e03 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1809,6 +1809,8 @@ extern int usb_clear_halt(struct usb_device *dev, int pipe);
extern int usb_reset_configuration(struct usb_device *dev);
extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
extern void usb_reset_endpoint(struct usb_device *dev, unsigned int epaddr);
+extern void usb_fixup_endpoint(struct usb_device *dev, int epaddr,
+ int interval);
/* this request isn't really synchronous, but it belongs with the others */
extern int usb_driver_set_configuration(struct usb_device *udev, int config);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 97e2ddec18b1..b5d0875b5595 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -379,6 +379,11 @@ struct hc_driver {
* or bandwidth constraints.
*/
void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *);
+ /* Override the endpoint-derived interval
+ * (if there is any cached hardware state).
+ */
+ void (*fixup_endpoint)(struct usb_hcd *hcd, struct usb_device *udev,
+ struct usb_host_endpoint *ep, int interval);
/* 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 */
@@ -435,6 +440,8 @@ extern void usb_hcd_unmap_urb_setup_for_dma(struct usb_hcd *, struct urb *);
extern void usb_hcd_unmap_urb_for_dma(struct usb_hcd *, struct urb *);
extern void usb_hcd_flush_endpoint(struct usb_device *udev,
struct usb_host_endpoint *ep);
+extern void usb_hcd_fixup_endpoint(struct usb_device *udev,
+ struct usb_host_endpoint *ep, int interval);
extern void usb_hcd_disable_endpoint(struct usb_device *udev,
struct usb_host_endpoint *ep);
extern void usb_hcd_reset_endpoint(struct usb_device *udev,
--
2.19.1