Prepare for the global command ring by using command structures
internally in functions calling xhci_queue_stop_endpoint()

Signed-off-by: Mathias Nyman <mathias.ny...@linux.intel.com>
---
 drivers/usb/host/xhci-hub.c | 14 ++++++++++++--
 drivers/usb/host/xhci.c     |  3 +++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 805f234..f93c842 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -20,7 +20,8 @@
  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <linux/gfp.h>
+
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 
 #include "xhci.h"
@@ -284,8 +285,17 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int 
slot_id, int suspend)
 
        spin_lock_irqsave(&xhci->lock, flags);
        for (i = LAST_EP_INDEX; i > 0; i--) {
-               if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue)
+               if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue) {
+                       struct xhci_command *command;
+                       command = xhci_alloc_command(xhci, false, false,
+                                                    GFP_NOIO);
+                       if (!command) {
+                               xhci_free_command(xhci, cmd);
+                               return -ENOMEM;
+                       }
                        xhci_queue_stop_endpoint(xhci, slot_id, i, suspend);
+                       kfree(command);
+               }
        }
        cmd->command_trb = xhci_find_next_enqueue(xhci->cmd_ring);
        list_add_tail(&cmd->cmd_list, &virt_dev->cmd_list);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index a60e432..054132b 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1467,6 +1467,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb 
*urb, int status)
        unsigned int ep_index;
        struct xhci_ring *ep_ring;
        struct xhci_virt_ep *ep;
+       struct xhci_command *command;
 
        xhci = hcd_to_xhci(hcd);
        spin_lock_irqsave(&xhci->lock, flags);
@@ -1536,6 +1537,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb 
*urb, int status)
         * the first cancellation to be handled.
         */
        if (!(ep->ep_state & EP_HALT_PENDING)) {
+               command = xhci_alloc_command(xhci, false, false, GFP_ATOMIC);
                ep->ep_state |= EP_HALT_PENDING;
                ep->stop_cmds_pending++;
                ep->stop_cmd_timer.expires = jiffies +
@@ -1543,6 +1545,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb 
*urb, int status)
                add_timer(&ep->stop_cmd_timer);
                xhci_queue_stop_endpoint(xhci, urb->dev->slot_id, ep_index, 0);
                xhci_ring_cmd_db(xhci);
+               kfree(command);
        }
 done:
        spin_unlock_irqrestore(&xhci->lock, flags);
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to