aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci.h
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2010-04-02 18:34:43 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-20 16:21:38 -0400
commite9df17eb1408cfafa3d1844bfc7f22c7237b31b8 (patch)
tree175badf12e5098bd15bc5d6a37642badd7c6f4b9 /drivers/usb/host/xhci.h
parent8df75f42f8e67e2851cdcf6da91640fb881defd1 (diff)
USB: xhci: Correct assumptions about number of rings per endpoint.
Much of the xHCI driver code assumes that endpoints only have one ring. Now an endpoint can have one ring per enabled stream ID, so correct that assumption. Use functions that translate the stream_id field in the URB or the DMA address of a TRB into the correct stream ring. Correct the polling loop to print out all enabled stream rings. Make the URB cancellation routine find the correct stream ring if the URB has stream_id set. Make sure the URB enqueueing routine does the same. Also correct the code that handles stalled/halted endpoints. Check that commands and registers that can take stream IDs handle them properly. That includes ringing an endpoint doorbell, resetting a stalled/halted endpoint, and setting a transfer ring dequeue pointer (since that command can set the dequeue pointer in a stream context or an endpoint context). Correct the transfer event handler to translate a TRB DMA address into the stream ring it was enqueued to. Make the code to allocate and prepare TD structures adds the TD to the right td_list for the stream ring. Make sure the code to give the first TRB in a TD to the hardware manipulates the correct stream ring. When an endpoint stalls, store the stream ID of the stream ring that stalled in the xhci_virt_ep structure. Use that instead of the stream ID in the URB, since an URB may be re-used after it is given back after a non-control endpoint stall. 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.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 7a9447cb6ea9..dada2fb59261 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -444,6 +444,7 @@ struct xhci_doorbell_array {
444 444
445/* Endpoint Target - bits 0:7 */ 445/* Endpoint Target - bits 0:7 */
446#define EPI_TO_DB(p) (((p) + 1) & 0xff) 446#define EPI_TO_DB(p) (((p) + 1) & 0xff)
447#define STREAM_ID_TO_DB(p) (((p) & 0xffff) << 16)
447 448
448 449
449/** 450/**
@@ -714,6 +715,7 @@ struct xhci_virt_ep {
714 /* The TRB that was last reported in a stopped endpoint ring */ 715 /* The TRB that was last reported in a stopped endpoint ring */
715 union xhci_trb *stopped_trb; 716 union xhci_trb *stopped_trb;
716 struct xhci_td *stopped_td; 717 struct xhci_td *stopped_td;
718 unsigned int stopped_stream;
717 /* Watchdog timer for stop endpoint command to cancel URBs */ 719 /* Watchdog timer for stop endpoint command to cancel URBs */
718 struct timer_list stop_cmd_timer; 720 struct timer_list stop_cmd_timer;
719 int stop_cmds_pending; 721 int stop_cmds_pending;
@@ -871,6 +873,10 @@ struct xhci_event_cmd {
871#define TRB_TO_EP_INDEX(p) ((((p) & (0x1f << 16)) >> 16) - 1) 873#define TRB_TO_EP_INDEX(p) ((((p) & (0x1f << 16)) >> 16) - 1)
872#define EP_ID_FOR_TRB(p) ((((p) + 1) & 0x1f) << 16) 874#define EP_ID_FOR_TRB(p) ((((p) + 1) & 0x1f) << 16)
873 875
876/* Set TR Dequeue Pointer command TRB fields */
877#define TRB_TO_STREAM_ID(p) ((((p) & (0xffff << 16)) >> 16))
878#define STREAM_ID_FOR_TRB(p) ((((p)) & 0xffff) << 16)
879
874 880
875/* Port Status Change Event TRB fields */ 881/* Port Status Change Event TRB fields */
876/* Port ID - bits 31:24 */ 882/* Port ID - bits 31:24 */
@@ -1040,6 +1046,7 @@ struct xhci_ring {
1040 * if we own the TRB (if we are the consumer). See section 4.9.1. 1046 * if we own the TRB (if we are the consumer). See section 4.9.1.
1041 */ 1047 */
1042 u32 cycle_state; 1048 u32 cycle_state;
1049 unsigned int stream_id;
1043}; 1050};
1044 1051
1045struct xhci_erst_entry { 1052struct xhci_erst_entry {
@@ -1265,6 +1272,9 @@ void xhci_dbg_ring_ptrs(struct xhci_hcd *xhci, struct xhci_ring *ring);
1265void xhci_dbg_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int last_ep); 1272void xhci_dbg_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int last_ep);
1266char *xhci_get_slot_state(struct xhci_hcd *xhci, 1273char *xhci_get_slot_state(struct xhci_hcd *xhci,
1267 struct xhci_container_ctx *ctx); 1274 struct xhci_container_ctx *ctx);
1275void xhci_dbg_ep_rings(struct xhci_hcd *xhci,
1276 unsigned int slot_id, unsigned int ep_index,
1277 struct xhci_virt_ep *ep);
1268 1278
1269/* xHCI memory management */ 1279/* xHCI memory management */
1270void xhci_mem_cleanup(struct xhci_hcd *xhci); 1280void xhci_mem_cleanup(struct xhci_hcd *xhci);
@@ -1302,6 +1312,18 @@ void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci,
1302void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci, 1312void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci,
1303 struct xhci_ep_ctx *ep_ctx, 1313 struct xhci_ep_ctx *ep_ctx,
1304 struct xhci_virt_ep *ep); 1314 struct xhci_virt_ep *ep);
1315struct xhci_ring *xhci_dma_to_transfer_ring(
1316 struct xhci_virt_ep *ep,
1317 u64 address);
1318struct xhci_ring *xhci_urb_to_transfer_ring(struct xhci_hcd *xhci,
1319 struct urb *urb);
1320struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci,
1321 unsigned int slot_id, unsigned int ep_index,
1322 unsigned int stream_id);
1323struct xhci_ring *xhci_stream_id_to_ring(
1324 struct xhci_virt_device *dev,
1325 unsigned int ep_index,
1326 unsigned int stream_id);
1305struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, 1327struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
1306 bool allocate_in_ctx, bool allocate_completion, 1328 bool allocate_in_ctx, bool allocate_completion,
1307 gfp_t mem_flags); 1329 gfp_t mem_flags);
@@ -1374,9 +1396,11 @@ int xhci_queue_reset_ep(struct xhci_hcd *xhci, int slot_id,
1374int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id); 1396int xhci_queue_reset_device(struct xhci_hcd *xhci, u32 slot_id);
1375void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, 1397void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
1376 unsigned int slot_id, unsigned int ep_index, 1398 unsigned int slot_id, unsigned int ep_index,
1377 struct xhci_td *cur_td, struct xhci_dequeue_state *state); 1399 unsigned int stream_id, struct xhci_td *cur_td,
1400 struct xhci_dequeue_state *state);
1378void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci, 1401void xhci_queue_new_dequeue_state(struct xhci_hcd *xhci,
1379 unsigned int slot_id, unsigned int ep_index, 1402 unsigned int slot_id, unsigned int ep_index,
1403 unsigned int stream_id,
1380 struct xhci_dequeue_state *deq_state); 1404 struct xhci_dequeue_state *deq_state);
1381void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci, 1405void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci,
1382 struct usb_device *udev, unsigned int ep_index); 1406 struct usb_device *udev, unsigned int ep_index);