usb: host: xhci: check DYING state earlier
PATCH 2/20 usb: host: xhci: check DYING state earlier
Quoted 3 lines · Felipe Balbi
Instead of allocating urb priv and, maybe, bail out due to xhci being in DYING state, we can move the check earlier and avoid the memory allocation altogether.
This also moves checking for DYING outside the lock.
Most cases set DYING with lock held, so if we first get the lock before checking DYING we have a better chance of not being in the process of dying.
Small thing, but so is this cleanup, so not sure its worth the change
-Mathias
Quoted 40 lines
While at that, also remove an unnecessary empty line.
Signed-off-by Felipe Balbi <[email protected]>--- drivers/usb/host/xhci.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)drivers/usb/host/xhci.c +6
-6@@ -1299,6 +1299,12 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag true, true, __func__) <= 0)return -EINVAL ; +if (xhci->xhc_state &XHCI_STATE_DYING ) { +xhci_dbg (xhci,"Ep 0x%x: URB %p submitted for non-responsive xHCI host.\n" , + urb->ep->desc.bEndpointAddress, urb); +return -ESHUTDOWN ; + } + slot_id = urb->dev->slot_id; ep_index =xhci_get_endpoint_index (&urb->ep->desc); ep_state = &xhci->devs[slot_id]->eps[ep_index].ep_state;@@ -1347,12 +1353,6 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flagspin_lock_irqsave (&xhci->lock, flags); -if (xhci->xhc_state &XHCI_STATE_DYING ) { -xhci_dbg (xhci,"Ep 0x%x: URB %p submitted for non-responsive xHCI host.\n" , - urb->ep->desc.bEndpointAddress, urb); - ret = -ESHUTDOWN ; - goto free_priv; - }if (*ep_state &EP_SOFT_CLEAR_TOGGLE ) {xhci_warn (xhci,"Can't enqueue URB while manually clearing toggle\n" ); ret = -EINVAL ;
drivers/usb/host/xhci.c static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag · line 1365
Quoted 7 lines
drivers/usb/host/xhci.c +0
-1@@ -1360,7 +1360,6 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag }switch (usb_endpoint_type (&urb->ep->desc)) { -case USB_ENDPOINT_XFER_CONTROL : ret =xhci_queue_ctrl_tx (xhci,GFP_ATOMIC , urb, slot_id, ep_index);
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html