提交 58844d4a 编写于 作者: J Jonathan Bell 提交者: Zheng Zengkai

usb: add plumbing for updating interrupt endpoint interval state

raspberrypi inclusion
category: feature
bugzilla: 50432

--------------------------------

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: NJonathan Bell <jonathan@raspberrypi.org>
Signed-off-by: NFang Yafen <yafen@iscas.ac.cn>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 7316e106
...@@ -1938,6 +1938,16 @@ int usb_hcd_alloc_bandwidth(struct usb_device *udev, ...@@ -1938,6 +1938,16 @@ int usb_hcd_alloc_bandwidth(struct usb_device *udev,
return ret; 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 /* Disables the endpoint: synchronizes with the hcd to make sure all
* endpoint state is gone from hardware. usb_hcd_flush_endpoint() must * endpoint state is gone from hardware. usb_hcd_flush_endpoint() must
* have been called previously. Use for set_configuration, set_interface, * have been called previously. Use for set_configuration, set_interface,
......
...@@ -1259,6 +1259,21 @@ static void remove_intf_ep_devs(struct usb_interface *intf) ...@@ -1259,6 +1259,21 @@ static void remove_intf_ep_devs(struct usb_interface *intf)
intf->ep_devs_created = 0; 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 * usb_disable_endpoint -- Disable an endpoint by address
* @dev: the device whose endpoint is being disabled * @dev: the device whose endpoint is being disabled
......
...@@ -1836,6 +1836,8 @@ extern int usb_clear_halt(struct usb_device *dev, int pipe); ...@@ -1836,6 +1836,8 @@ extern int usb_clear_halt(struct usb_device *dev, int pipe);
extern int usb_reset_configuration(struct usb_device *dev); extern int usb_reset_configuration(struct usb_device *dev);
extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate); 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_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 */ /* this request isn't really synchronous, but it belongs with the others */
extern int usb_driver_set_configuration(struct usb_device *udev, int config); extern int usb_driver_set_configuration(struct usb_device *udev, int config);
......
...@@ -382,6 +382,11 @@ struct hc_driver { ...@@ -382,6 +382,11 @@ struct hc_driver {
* or bandwidth constraints. * or bandwidth constraints.
*/ */
void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *); 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 */ /* Returns the hardware-chosen device address */
int (*address_device)(struct usb_hcd *, struct usb_device *udev); int (*address_device)(struct usb_hcd *, struct usb_device *udev);
/* prepares the hardware to send commands to the device */ /* prepares the hardware to send commands to the device */
...@@ -443,6 +448,8 @@ extern void usb_hcd_unmap_urb_setup_for_dma(struct usb_hcd *, struct urb *); ...@@ -443,6 +448,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_unmap_urb_for_dma(struct usb_hcd *, struct urb *);
extern void usb_hcd_flush_endpoint(struct usb_device *udev, extern void usb_hcd_flush_endpoint(struct usb_device *udev,
struct usb_host_endpoint *ep); 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, extern void usb_hcd_disable_endpoint(struct usb_device *udev,
struct usb_host_endpoint *ep); struct usb_host_endpoint *ep);
extern void usb_hcd_reset_endpoint(struct usb_device *udev, extern void usb_hcd_reset_endpoint(struct usb_device *udev,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册