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 08/10] xhci: Add a global command queue
Date: Thu, 30 Jan 2014 16:10:25 +0200 [thread overview]
Message-ID: <1391091027-31783-9-git-send-email-mathias.nyman@linux.intel.com> (raw)
In-Reply-To: <1391091027-31783-1-git-send-email-mathias.nyman@linux.intel.com>
Create a list to store command structures, add a strucure to it every time
a command is submitted, and remove it from the list once we get a
command completion event matching the command.
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
drivers/usb/host/xhci-mem.c | 8 ++++++++
drivers/usb/host/xhci-ring.c | 13 ++++++++++++-
drivers/usb/host/xhci.h | 1 +
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 49b8bd0..7f8e4c3 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1694,6 +1694,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
{
struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
struct xhci_cd *cur_cd, *next_cd;
+ struct xhci_command *cur_cmd, *next_cmd;
int size;
int i, j, num_ports;
@@ -1722,6 +1723,12 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
kfree(cur_cd);
}
+ list_for_each_entry_safe(cur_cmd, next_cmd,
+ &xhci->cmd_list, cmd_list) {
+ list_del(&cur_cmd->cmd_list);
+ kfree(cur_cmd);
+ }
+
for (i = 1; i < MAX_HC_SLOTS; ++i)
xhci_free_virt_device(xhci, i);
@@ -2223,6 +2230,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
int i;
INIT_LIST_HEAD(&xhci->cancel_cmd_list);
+ INIT_LIST_HEAD(&xhci->cmd_list);
page_size = xhci_readl(xhci, &xhci->op_regs->page_size);
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 6f6018c..5ccf642 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1502,6 +1502,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
dma_addr_t cmd_dequeue_dma;
u32 cmd_comp_code;
union xhci_trb *cmd_trb;
+ struct xhci_command *cmd;
u32 cmd_type;
cmd_dma = le64_to_cpu(event->cmd_trb);
@@ -1519,6 +1520,13 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
return;
}
+ cmd = list_entry(xhci->cmd_list.next, struct xhci_command, cmd_list);
+
+ if (cmd->command_trb != xhci->cmd_ring->dequeue) {
+ xhci_err(xhci,
+ "Command completion event does not match command\n");
+ return;
+ }
trace_xhci_cmd_completion(cmd_trb, (struct xhci_generic_trb *) event);
cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status));
@@ -1588,6 +1596,9 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
xhci->error_bitmask |= 1 << 6;
break;
}
+
+ list_del(&cmd->cmd_list);
+
inc_deq(xhci, xhci->cmd_ring);
}
@@ -3989,7 +4000,7 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
return ret;
}
cmd->command_trb = xhci->cmd_ring->enqueue;
-
+ list_add_tail(&cmd->cmd_list, &xhci->cmd_list);
queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3,
field4 | xhci->cmd_ring->cycle_state);
return 0;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index d02b73d..71aed35 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1475,6 +1475,7 @@ struct xhci_hcd {
#define CMD_RING_STATE_ABORTED (1 << 1)
#define CMD_RING_STATE_STOPPED (1 << 2)
struct list_head cancel_cmd_list;
+ struct list_head cmd_list;
unsigned int cmd_ring_reserved_trbs;
struct xhci_ring *event_ring;
struct xhci_erst erst;
--
1.8.1.2
next prev parent reply other threads:[~2014-01-30 14:03 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 ` [RFCv2 04/10] xhci: use command structures for xhci_queue_stop_endpoint() Mathias Nyman
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 ` Mathias Nyman [this message]
2014-02-05 6:57 ` [RFCv2 08/10] xhci: Add a global command queue 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-9-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