public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: <linux-usb@vger.kernel.org>
Cc: <sarah.a.sharp@linux.intel.com>, <dan.j.williams@intel.com>,
	<linux-kernel@vger.kernel.org>,
	Mathias Nyman <mathias.nyman@linux.intel.com>
Subject: [RFCv2 04/10] xhci: use command structures for xhci_queue_stop_endpoint()
Date: Thu, 30 Jan 2014 16:10:21 +0200	[thread overview]
Message-ID: <1391091027-31783-5-git-send-email-mathias.nyman@linux.intel.com> (raw)
In-Reply-To: <1391091027-31783-1-git-send-email-mathias.nyman@linux.intel.com>

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

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

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 805f234..68bc1c6 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,18 @@ 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) {
+				spin_unlock_irqrestore(&xhci->lock, flags);
+				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 4ce8c85..d4684d0 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1466,6 +1466,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);
@@ -1535,6 +1536,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 +
@@ -1542,6 +1544,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


  parent reply	other threads:[~2014-01-30 14:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-30 14:10 [RFCv2 00/10] xhci: re-work command queue management Mathias Nyman
2014-01-30 14:10 ` [RFCv2 01/10] xhci: Use command structures when calling xhci_configure_endpoint Mathias Nyman
2014-02-05  2:21   ` Dan Williams
2014-02-05 15:00     ` Mathias Nyman
2014-01-30 14:10 ` [RFCv2 02/10] xhci: use a command structure internally in xhci_address_device() Mathias Nyman
2014-01-30 14:10 ` [RFCv2 03/10] xhci: use command structures for xhci_queue_slot_control() Mathias Nyman
2014-01-30 14:10 ` Mathias Nyman [this message]
2014-01-30 14:10 ` [RFCv2 05/10] xhci: use command structure for xhci_queue_new_dequeue_state() Mathias Nyman
2014-01-30 14:10 ` [RFCv2 06/10] xhci: use command structures for xhci_queue_reset_ep() Mathias Nyman
2014-01-30 14:10 ` [RFCv2 07/10] xhci: Use command structured when queuing commands Mathias Nyman
2014-01-30 14:10 ` [RFCv2 08/10] xhci: Add a global command queue Mathias Nyman
2014-02-05  6:57   ` Dan Williams
2014-02-05 22:23     ` Sarah Sharp
2014-01-30 14:10 ` [RFCv2 09/10] xhci: Use completion and status in " Mathias Nyman
2014-01-30 14:10 ` [RFCv2 10/10] xhci: rework command timeout and cancellation, Mathias Nyman
2014-01-30 14:25 ` [RFCv2 00/10] xhci: re-work command queue management David Laight
2014-01-30 22:39   ` Sarah Sharp
2014-02-05  2:35   ` Dan Williams
2014-02-05  9:22     ` David Laight
2014-02-05 16:48       ` Dan Williams
2014-02-05 17:05         ` David Laight
2014-02-05 17:27           ` Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391091027-31783-5-git-send-email-mathias.nyman@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sarah.a.sharp@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox