diff options
author | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2009-04-27 22:58:38 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-06-16 00:44:49 -0400 |
commit | f94e0186312b0fc39f41eed4e21836ed74b7efe1 (patch) | |
tree | d445d846f62c23cfbefc4958168d9cf4bacea3a4 /drivers/usb/host/xhci.h | |
parent | 79abb1ab13cee5ba488210798b6e7bbae0b391ac (diff) |
USB: xhci: Bandwidth allocation support
Since the xHCI host controller hardware (xHC) has an internal schedule, it
needs a better representation of what devices are consuming bandwidth on
the bus. Each device is represented by a device context, with data about
the device, endpoints, and pointers to each endpoint ring.
We need to update the endpoint information for a device context before a
new configuration or alternate interface setting is selected. We setup an
input device context with modified endpoint information and newly
allocated endpoint rings, and then submit a Configure Endpoint Command to
the hardware.
The host controller can reject the new configuration if it exceeds the bus
bandwidth, or the host controller doesn't have enough internal resources
for the configuration. If the command fails, we still have the older
device context with the previous configuration. If the command succeeds,
we free the old endpoint rings.
The root hub isn't a real device, so always say yes to any bandwidth
changes for it.
The USB core will enable, disable, and then enable endpoint 0 several
times during the initialization sequence. The device will always have an
endpoint ring for endpoint 0 and bandwidth allocated for that, unless the
device is disconnected or gets a SetAddress 0 request. So we don't pay
attention for when xhci_check_bandwidth() is called for a re-add of
endpoint 0.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/xhci.h')
-rw-r--r-- | drivers/usb/host/xhci.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index fc8dcd2aa770..1a6fd997c343 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -486,8 +486,6 @@ struct xhci_slot_ctx { | |||
486 | #define LAST_CTX_MASK (0x1f << 27) | 486 | #define LAST_CTX_MASK (0x1f << 27) |
487 | #define LAST_CTX(p) ((p) << 27) | 487 | #define LAST_CTX(p) ((p) << 27) |
488 | #define LAST_CTX_TO_EP_NUM(p) (((p) >> 27) - 1) | 488 | #define LAST_CTX_TO_EP_NUM(p) (((p) >> 27) - 1) |
489 | /* Plus one for the slot context flag */ | ||
490 | #define EPI_TO_FLAG(p) (1 << ((p) + 1)) | ||
491 | #define SLOT_FLAG (1 << 0) | 489 | #define SLOT_FLAG (1 << 0) |
492 | #define EP0_FLAG (1 << 1) | 490 | #define EP0_FLAG (1 << 1) |
493 | 491 | ||
@@ -566,7 +564,7 @@ struct xhci_ep_ctx { | |||
566 | /* bits 10:14 are Max Primary Streams */ | 564 | /* bits 10:14 are Max Primary Streams */ |
567 | /* bit 15 is Linear Stream Array */ | 565 | /* bit 15 is Linear Stream Array */ |
568 | /* Interval - period between requests to an endpoint - 125u increments. */ | 566 | /* Interval - period between requests to an endpoint - 125u increments. */ |
569 | #define EP_INTERVAL (0xff << 16) | 567 | #define EP_INTERVAL(p) ((p & 0xff) << 16) |
570 | 568 | ||
571 | /* ep_info2 bitmasks */ | 569 | /* ep_info2 bitmasks */ |
572 | /* | 570 | /* |
@@ -626,6 +624,11 @@ struct xhci_virt_device { | |||
626 | dma_addr_t in_ctx_dma; | 624 | dma_addr_t in_ctx_dma; |
627 | /* FIXME when stream support is added */ | 625 | /* FIXME when stream support is added */ |
628 | struct xhci_ring *ep_rings[31]; | 626 | struct xhci_ring *ep_rings[31]; |
627 | /* Temporary storage in case the configure endpoint command fails and we | ||
628 | * have to restore the device state to the previous state | ||
629 | */ | ||
630 | struct xhci_ring *new_ep_rings[31]; | ||
631 | struct completion cmd_completion; | ||
629 | /* Status of the last command issued for this device */ | 632 | /* Status of the last command issued for this device */ |
630 | u32 cmd_status; | 633 | u32 cmd_status; |
631 | }; | 634 | }; |
@@ -1075,6 +1078,10 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id); | |||
1075 | int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, struct usb_device *udev, gfp_t flags); | 1078 | int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, struct usb_device *udev, gfp_t flags); |
1076 | int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev); | 1079 | int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *udev); |
1077 | unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc); | 1080 | unsigned int xhci_get_endpoint_index(struct usb_endpoint_descriptor *desc); |
1081 | unsigned int xhci_get_endpoint_flag(struct usb_endpoint_descriptor *desc); | ||
1082 | void xhci_endpoint_zero(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, struct usb_host_endpoint *ep); | ||
1083 | int xhci_endpoint_init(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, struct usb_device *udev, struct usb_host_endpoint *ep); | ||
1084 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring); | ||
1078 | 1085 | ||
1079 | #ifdef CONFIG_PCI | 1086 | #ifdef CONFIG_PCI |
1080 | /* xHCI PCI glue */ | 1087 | /* xHCI PCI glue */ |
@@ -1096,6 +1103,10 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev); | |||
1096 | int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev); | 1103 | int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev); |
1097 | int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags); | 1104 | int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags); |
1098 | int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status); | 1105 | int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status); |
1106 | int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep); | ||
1107 | int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep); | ||
1108 | int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); | ||
1109 | void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); | ||
1099 | 1110 | ||
1100 | /* xHCI ring, segment, TRB, and TD functions */ | 1111 | /* xHCI ring, segment, TRB, and TD functions */ |
1101 | dma_addr_t trb_virt_to_dma(struct xhci_segment *seg, union xhci_trb *trb); | 1112 | dma_addr_t trb_virt_to_dma(struct xhci_segment *seg, union xhci_trb *trb); |
@@ -1106,6 +1117,7 @@ void set_hc_event_deq(struct xhci_hcd *xhci); | |||
1106 | int queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id); | 1117 | int queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id); |
1107 | int queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, u32 slot_id); | 1118 | int queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, u32 slot_id); |
1108 | int queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, int slot_id, unsigned int ep_index); | 1119 | int queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, int slot_id, unsigned int ep_index); |
1120 | int queue_configure_endpoint(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, u32 slot_id); | ||
1109 | 1121 | ||
1110 | /* xHCI roothub code */ | 1122 | /* xHCI roothub code */ |
1111 | int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, | 1123 | int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, |