diff options
Diffstat (limited to 'drivers/usb/host/xhci.h')
-rw-r--r-- | drivers/usb/host/xhci.h | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 4b254b6fa245..ea389e9a4931 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -609,6 +609,10 @@ struct xhci_ep_ctx { | |||
609 | #define MAX_PACKET_MASK (0xffff << 16) | 609 | #define MAX_PACKET_MASK (0xffff << 16) |
610 | #define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff) | 610 | #define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff) |
611 | 611 | ||
612 | /* tx_info bitmasks */ | ||
613 | #define AVG_TRB_LENGTH_FOR_EP(p) ((p) & 0xffff) | ||
614 | #define MAX_ESIT_PAYLOAD_FOR_EP(p) (((p) & 0xffff) << 16) | ||
615 | |||
612 | 616 | ||
613 | /** | 617 | /** |
614 | * struct xhci_input_control_context | 618 | * struct xhci_input_control_context |
@@ -652,13 +656,17 @@ struct xhci_virt_ep { | |||
652 | struct xhci_ring *new_ring; | 656 | struct xhci_ring *new_ring; |
653 | unsigned int ep_state; | 657 | unsigned int ep_state; |
654 | #define SET_DEQ_PENDING (1 << 0) | 658 | #define SET_DEQ_PENDING (1 << 0) |
655 | #define EP_HALTED (1 << 1) | 659 | #define EP_HALTED (1 << 1) /* For stall handling */ |
660 | #define EP_HALT_PENDING (1 << 2) /* For URB cancellation */ | ||
656 | /* ---- Related to URB cancellation ---- */ | 661 | /* ---- Related to URB cancellation ---- */ |
657 | struct list_head cancelled_td_list; | 662 | struct list_head cancelled_td_list; |
658 | unsigned int cancels_pending; | ||
659 | /* The TRB that was last reported in a stopped endpoint ring */ | 663 | /* The TRB that was last reported in a stopped endpoint ring */ |
660 | union xhci_trb *stopped_trb; | 664 | union xhci_trb *stopped_trb; |
661 | struct xhci_td *stopped_td; | 665 | struct xhci_td *stopped_td; |
666 | /* Watchdog timer for stop endpoint command to cancel URBs */ | ||
667 | struct timer_list stop_cmd_timer; | ||
668 | int stop_cmds_pending; | ||
669 | struct xhci_hcd *xhci; | ||
662 | }; | 670 | }; |
663 | 671 | ||
664 | struct xhci_virt_device { | 672 | struct xhci_virt_device { |
@@ -673,6 +681,10 @@ struct xhci_virt_device { | |||
673 | struct xhci_container_ctx *out_ctx; | 681 | struct xhci_container_ctx *out_ctx; |
674 | /* Used for addressing devices and configuration changes */ | 682 | /* Used for addressing devices and configuration changes */ |
675 | struct xhci_container_ctx *in_ctx; | 683 | struct xhci_container_ctx *in_ctx; |
684 | /* Rings saved to ensure old alt settings can be re-instated */ | ||
685 | struct xhci_ring **ring_cache; | ||
686 | int num_rings_cached; | ||
687 | #define XHCI_MAX_RINGS_CACHED 31 | ||
676 | struct xhci_virt_ep eps[31]; | 688 | struct xhci_virt_ep eps[31]; |
677 | struct completion cmd_completion; | 689 | struct completion cmd_completion; |
678 | /* Status of the last command issued for this device */ | 690 | /* Status of the last command issued for this device */ |
@@ -824,9 +836,6 @@ struct xhci_event_cmd { | |||
824 | /* Normal TRB fields */ | 836 | /* Normal TRB fields */ |
825 | /* transfer_len bitmasks - bits 0:16 */ | 837 | /* transfer_len bitmasks - bits 0:16 */ |
826 | #define TRB_LEN(p) ((p) & 0x1ffff) | 838 | #define TRB_LEN(p) ((p) & 0x1ffff) |
827 | /* TD size - number of bytes remaining in the TD (including this TRB): | ||
828 | * bits 17 - 21. Shift the number of bytes by 10. */ | ||
829 | #define TD_REMAINDER(p) ((((p) >> 10) & 0x1f) << 17) | ||
830 | /* Interrupter Target - which MSI-X vector to target the completion event at */ | 839 | /* Interrupter Target - which MSI-X vector to target the completion event at */ |
831 | #define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22) | 840 | #define TRB_INTR_TARGET(p) (((p) & 0x3ff) << 22) |
832 | #define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff) | 841 | #define GET_INTR_TARGET(p) (((p) >> 22) & 0x3ff) |
@@ -1022,6 +1031,8 @@ struct xhci_scratchpad { | |||
1022 | #define ERST_ENTRIES 1 | 1031 | #define ERST_ENTRIES 1 |
1023 | /* Poll every 60 seconds */ | 1032 | /* Poll every 60 seconds */ |
1024 | #define POLL_TIMEOUT 60 | 1033 | #define POLL_TIMEOUT 60 |
1034 | /* Stop endpoint command timeout (secs) for URB cancellation watchdog timer */ | ||
1035 | #define XHCI_STOP_EP_CMD_TIMEOUT 5 | ||
1025 | /* XXX: Make these module parameters */ | 1036 | /* XXX: Make these module parameters */ |
1026 | 1037 | ||
1027 | 1038 | ||
@@ -1083,6 +1094,21 @@ struct xhci_hcd { | |||
1083 | struct timer_list event_ring_timer; | 1094 | struct timer_list event_ring_timer; |
1084 | int zombie; | 1095 | int zombie; |
1085 | #endif | 1096 | #endif |
1097 | /* Host controller watchdog timer structures */ | ||
1098 | unsigned int xhc_state; | ||
1099 | /* Host controller is dying - not responding to commands. "I'm not dead yet!" | ||
1100 | * | ||
1101 | * xHC interrupts have been disabled and a watchdog timer will (or has already) | ||
1102 | * halt the xHCI host, and complete all URBs with an -ESHUTDOWN code. Any code | ||
1103 | * that sees this status (other than the timer that set it) should stop touching | ||
1104 | * hardware immediately. Interrupt handlers should return immediately when | ||
1105 | * they see this status (any time they drop and re-acquire xhci->lock). | ||
1106 | * xhci_urb_dequeue() should call usb_hcd_check_unlink_urb() and return without | ||
1107 | * putting the TD on the canceled list, etc. | ||
1108 | * | ||
1109 | * There are no reports of xHCI host controllers that display this issue. | ||
1110 | */ | ||
1111 | #define XHCI_STATE_DYING (1 << 0) | ||
1086 | /* Statistics */ | 1112 | /* Statistics */ |
1087 | int noops_submitted; | 1113 | int noops_submitted; |
1088 | int noops_handled; | 1114 | int noops_handled; |
@@ -1188,6 +1214,8 @@ void xhci_dbg_erst(struct xhci_hcd *xhci, struct xhci_erst *erst); | |||
1188 | void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci); | 1214 | void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci); |
1189 | void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring); | 1215 | void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring); |
1190 | void xhci_dbg_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int last_ep); | 1216 | void xhci_dbg_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int last_ep); |
1217 | char *xhci_get_slot_state(struct xhci_hcd *xhci, | ||
1218 | struct xhci_container_ctx *ctx); | ||
1191 | 1219 | ||
1192 | /* xHCI memory management */ | 1220 | /* xHCI memory management */ |
1193 | void xhci_mem_cleanup(struct xhci_hcd *xhci); | 1221 | void xhci_mem_cleanup(struct xhci_hcd *xhci); |
@@ -1211,8 +1239,12 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, | |||
1211 | struct usb_device *udev, struct usb_host_endpoint *ep, | 1239 | struct usb_device *udev, struct usb_host_endpoint *ep, |
1212 | gfp_t mem_flags); | 1240 | gfp_t mem_flags); |
1213 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring); | 1241 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring); |
1242 | void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, | ||
1243 | struct xhci_virt_device *virt_dev, | ||
1244 | unsigned int ep_index); | ||
1214 | struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, | 1245 | struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, |
1215 | bool allocate_completion, gfp_t mem_flags); | 1246 | bool allocate_in_ctx, bool allocate_completion, |
1247 | gfp_t mem_flags); | ||
1216 | void xhci_free_command(struct xhci_hcd *xhci, | 1248 | void xhci_free_command(struct xhci_hcd *xhci, |
1217 | struct xhci_command *command); | 1249 | struct xhci_command *command); |
1218 | 1250 | ||
@@ -1223,6 +1255,7 @@ void xhci_unregister_pci(void); | |||
1223 | #endif | 1255 | #endif |
1224 | 1256 | ||
1225 | /* xHCI host controller glue */ | 1257 | /* xHCI host controller glue */ |
1258 | void xhci_quiesce(struct xhci_hcd *xhci); | ||
1226 | int xhci_halt(struct xhci_hcd *xhci); | 1259 | int xhci_halt(struct xhci_hcd *xhci); |
1227 | int xhci_reset(struct xhci_hcd *xhci); | 1260 | int xhci_reset(struct xhci_hcd *xhci); |
1228 | int xhci_init(struct usb_hcd *hcd); | 1261 | int xhci_init(struct usb_hcd *hcd); |
@@ -1241,11 +1274,16 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status); | |||
1241 | int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep); | 1274 | int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep); |
1242 | int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep); | 1275 | int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep); |
1243 | void xhci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep); | 1276 | void xhci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep); |
1277 | int xhci_reset_device(struct usb_hcd *hcd, struct usb_device *udev); | ||
1244 | int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); | 1278 | int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); |
1245 | void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); | 1279 | void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev); |
1246 | 1280 | ||
1247 | /* xHCI ring, segment, TRB, and TD functions */ | 1281 | /* xHCI ring, segment, TRB, and TD functions */ |
1248 | dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg, union xhci_trb *trb); | 1282 | dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg, union xhci_trb *trb); |
1283 | struct xhci_segment *trb_in_td(struct xhci_segment *start_seg, | ||
1284 | union xhci_trb *start_trb, union xhci_trb *end_trb, | ||
1285 | dma_addr_t suspect_dma); | ||
1286 | int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code); | ||
1249 | void xhci_ring_cmd_db(struct xhci_hcd *xhci); | 1287 | void xhci_ring_cmd_db(struct xhci_hcd *xhci); |
1250 | void *xhci_setup_one_noop(struct xhci_hcd *xhci); | 1288 | void *xhci_setup_one_noop(struct xhci_hcd *xhci); |
1251 | void xhci_handle_event(struct xhci_hcd *xhci); | 1289 | void xhci_handle_event(struct xhci_hcd *xhci); |
@@ -1267,6 +1305,7 @@ int xhci_queue_evaluate_context(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, | |||
1267 | u32 slot_id); | 1305 | u32 slot_id); |
1268 | int xhci_queue_reset_ep(struct xhci_hcd *xhci, int slot_id, | 1306 | int xhci_queue_reset_ep(struct xhci_hcd *xhci, int slot_id, |
1269 | unsigned int ep_index); | 1307 | unsigned int ep_index); |
1308 | int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id); | ||
1270 | void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, | 1309 | void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, |
1271 | unsigned int slot_id, unsigned int ep_index, | 1310 | unsigned int slot_id, unsigned int ep_index, |
1272 | struct xhci_td *cur_td, struct xhci_dequeue_state *state); | 1311 | struct xhci_td *cur_td, struct xhci_dequeue_state *state); |
@@ -1278,6 +1317,7 @@ void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, | |||
1278 | void xhci_queue_config_ep_quirk(struct xhci_hcd *xhci, | 1317 | void xhci_queue_config_ep_quirk(struct xhci_hcd *xhci, |
1279 | unsigned int slot_id, unsigned int ep_index, | 1318 | unsigned int slot_id, unsigned int ep_index, |
1280 | struct xhci_dequeue_state *deq_state); | 1319 | struct xhci_dequeue_state *deq_state); |
1320 | void xhci_stop_endpoint_command_watchdog(unsigned long arg); | ||
1281 | 1321 | ||
1282 | /* xHCI roothub code */ | 1322 | /* xHCI roothub code */ |
1283 | int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, | 1323 | int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, |