aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci.h
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2009-09-04 13:53:13 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-23 09:46:39 -0400
commit913a8a344ffcaf0b4a586d6662a2c66a7106557d (patch)
tree07a2a10118ab15bd4c597c1b1460c8028a3b1adc /drivers/usb/host/xhci.h
parent5270b951b9cd5e50aea55cb52684a171fb10381c (diff)
USB: xhci: Change how xHCI commands are handled.
Some commands to the xHCI hardware cannot be allowed to fail due to out of memory issues or the command ring being full. Add a way to reserve a TRB on the command ring, and make all command queueing functions indicate whether they are using a reserved TRB. Add a way to pre-allocate all the memory a command might need. A command needs an input context, a variable to store the status, and (optionally) a completion for the caller to wait on. Change all code that assumes the input device context, status, and completion for a command is stored in the xhci virtual USB device structure (xhci_virt_device). Store pending completions in a FIFO in xhci_virt_device. Make the event handler for a configure endpoint command check to see whether a pending command in the list has completed. We need to use separate input device contexts for some configure endpoint commands, since multiple drivers can submit requests at the same time that require a configure endpoint command. 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.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 627092286d1b..36f7d4f91d9f 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -620,6 +620,22 @@ struct xhci_input_control_ctx {
620 u32 rsvd2[6]; 620 u32 rsvd2[6];
621}; 621};
622 622
623/* Represents everything that is needed to issue a command on the command ring.
624 * It's useful to pre-allocate these for commands that cannot fail due to
625 * out-of-memory errors, like freeing streams.
626 */
627struct xhci_command {
628 /* Input context for changing device state */
629 struct xhci_container_ctx *in_ctx;
630 u32 status;
631 /* If completion is null, no one is waiting on this command
632 * and the structure can be freed after the command completes.
633 */
634 struct completion *completion;
635 union xhci_trb *command_trb;
636 struct list_head cmd_list;
637};
638
623/* drop context bitmasks */ 639/* drop context bitmasks */
624#define DROP_EP(x) (0x1 << x) 640#define DROP_EP(x) (0x1 << x)
625/* add context bitmasks */ 641/* add context bitmasks */
@@ -658,6 +674,7 @@ struct xhci_virt_device {
658 struct completion cmd_completion; 674 struct completion cmd_completion;
659 /* Status of the last command issued for this device */ 675 /* Status of the last command issued for this device */
660 u32 cmd_status; 676 u32 cmd_status;
677 struct list_head cmd_list;
661}; 678};
662 679
663 680
@@ -920,6 +937,8 @@ union xhci_trb {
920 * It must also be greater than 16. 937 * It must also be greater than 16.
921 */ 938 */
922#define TRBS_PER_SEGMENT 64 939#define TRBS_PER_SEGMENT 64
940/* Allow two commands + a link TRB, along with any reserved command TRBs */
941#define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3)
923#define SEGMENT_SIZE (TRBS_PER_SEGMENT*16) 942#define SEGMENT_SIZE (TRBS_PER_SEGMENT*16)
924/* TRB buffer pointers can't cross 64KB boundaries */ 943/* TRB buffer pointers can't cross 64KB boundaries */
925#define TRB_MAX_BUFF_SHIFT 16 944#define TRB_MAX_BUFF_SHIFT 16
@@ -1040,6 +1059,7 @@ struct xhci_hcd {
1040 /* data structures */ 1059 /* data structures */
1041 struct xhci_device_context_array *dcbaa; 1060 struct xhci_device_context_array *dcbaa;
1042 struct xhci_ring *cmd_ring; 1061 struct xhci_ring *cmd_ring;
1062 unsigned int cmd_ring_reserved_trbs;
1043 struct xhci_ring *event_ring; 1063 struct xhci_ring *event_ring;
1044 struct xhci_erst erst; 1064 struct xhci_erst erst;
1045 /* Scratchpad */ 1065 /* Scratchpad */
@@ -1178,12 +1198,20 @@ unsigned int xhci_get_endpoint_flag_from_index(unsigned int ep_index);
1178unsigned int xhci_last_valid_endpoint(u32 added_ctxs); 1198unsigned int xhci_last_valid_endpoint(u32 added_ctxs);
1179void xhci_endpoint_zero(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, struct usb_host_endpoint *ep); 1199void xhci_endpoint_zero(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, struct usb_host_endpoint *ep);
1180void xhci_endpoint_copy(struct xhci_hcd *xhci, 1200void xhci_endpoint_copy(struct xhci_hcd *xhci,
1181 struct xhci_virt_device *vdev, unsigned int ep_index); 1201 struct xhci_container_ctx *in_ctx,
1182void xhci_slot_copy(struct xhci_hcd *xhci, struct xhci_virt_device *vdev); 1202 struct xhci_container_ctx *out_ctx,
1203 unsigned int ep_index);
1204void xhci_slot_copy(struct xhci_hcd *xhci,
1205 struct xhci_container_ctx *in_ctx,
1206 struct xhci_container_ctx *out_ctx);
1183int xhci_endpoint_init(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, 1207int xhci_endpoint_init(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev,
1184 struct usb_device *udev, struct usb_host_endpoint *ep, 1208 struct usb_device *udev, struct usb_host_endpoint *ep,
1185 gfp_t mem_flags); 1209 gfp_t mem_flags);
1186void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring); 1210void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring);
1211struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
1212 bool allocate_completion, gfp_t mem_flags);
1213void xhci_free_command(struct xhci_hcd *xhci,
1214 struct xhci_command *command);
1187 1215
1188#ifdef CONFIG_PCI 1216#ifdef CONFIG_PCI
1189/* xHCI PCI glue */ 1217/* xHCI PCI glue */
@@ -1229,7 +1257,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb,
1229int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb, 1257int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb,
1230 int slot_id, unsigned int ep_index); 1258 int slot_id, unsigned int ep_index);
1231int xhci_queue_configure_endpoint(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, 1259int xhci_queue_configure_endpoint(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
1232 u32 slot_id); 1260 u32 slot_id, bool command_must_succeed);
1233int xhci_queue_evaluate_context(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, 1261int xhci_queue_evaluate_context(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
1234 u32 slot_id); 1262 u32 slot_id);
1235int xhci_queue_reset_ep(struct xhci_hcd *xhci, int slot_id, 1263int xhci_queue_reset_ep(struct xhci_hcd *xhci, int slot_id,