[PATCH 3/4] Change xhci_handle_event to take an xhci_erst

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When we have multiple event queues, we'll only want to
handle events on a single queue.

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@xxxxxxxxx>
---
 drivers/usb/host/xhci-mem.c  |    4 ++--
 drivers/usb/host/xhci-ring.c |   32 ++++++++++++++++----------------
 drivers/usb/host/xhci.h      |    1 +
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 2ad7443..d153cef 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2016,14 +2016,14 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
 	xhci->dba = (void __iomem *) xhci->cap_regs + val;
 	xhci_dbg_regs(xhci);
 	xhci_print_run_regs(xhci);
-	/* Set ir_set to interrupt register set 0 */
-	xhci->erst.ir_set = &xhci->run_regs->ir_set[0];
 
 	/*
 	 * Event ring setup: Allocate a normal ring, but also setup
 	 * the event ring segment table (ERST).  Section 4.9.3.
 	 */
 	xhci_dbg(xhci, "// Allocating event ring\n");
+	xhci->erst.hcd = xhci;
+	xhci->erst.ir_set = &xhci->run_regs->ir_set[0];
 	xhci->erst.ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, false, flags);
 	if (!xhci->erst.ring)
 		goto fail;
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 92e9b5c..c3c2aec 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2179,22 +2179,22 @@ cleanup:
  * Returns >0 for "possibly more events to process" (caller should call again),
  * otherwise 0 if done.  In future, <0 returns should indicate error code.
  */
-static int xhci_handle_event(struct xhci_hcd *xhci)
+static int xhci_handle_event(struct xhci_erst *erst)
 {
 	union xhci_trb *event;
 	int update_ptrs = 1;
 	int ret;
 
-	if (!xhci->erst.ring || !xhci->erst.ring->dequeue) {
-		xhci->error_bitmask |= 1 << 1;
+	if (!erst->ring || !erst->ring->dequeue) {
+		erst->hcd->error_bitmask |= 1 << 1;
 		return 0;
 	}
 
-	event = xhci->erst.ring->dequeue;
+	event = erst->ring->dequeue;
 	/* Does the HC or OS own the TRB? */
 	if ((le32_to_cpu(event->event_cmd.flags) & TRB_CYCLE) !=
-	    xhci->erst.ring->cycle_state) {
-		xhci->error_bitmask |= 1 << 2;
+	    erst->ring->cycle_state) {
+		erst->hcd->error_bitmask |= 1 << 2;
 		return 0;
 	}
 
@@ -2206,38 +2206,38 @@ static int xhci_handle_event(struct xhci_hcd *xhci)
 	/* FIXME: Handle more event types. */
 	switch ((le32_to_cpu(event->event_cmd.flags) & TRB_TYPE_BITMASK)) {
 	case TRB_TYPE(TRB_COMPLETION):
-		handle_cmd_completion(xhci, &event->event_cmd);
+		handle_cmd_completion(erst->hcd, &event->event_cmd);
 		break;
 	case TRB_TYPE(TRB_PORT_STATUS):
-		handle_port_status(xhci, event);
+		handle_port_status(erst->hcd, event);
 		update_ptrs = 0;
 		break;
 	case TRB_TYPE(TRB_TRANSFER):
-		ret = handle_tx_event(xhci, &event->trans_event);
+		ret = handle_tx_event(erst->hcd, &event->trans_event);
 		if (ret < 0)
-			xhci->error_bitmask |= 1 << 9;
+			erst->hcd->error_bitmask |= 1 << 9;
 		else
 			update_ptrs = 0;
 		break;
 	default:
 		if ((le32_to_cpu(event->event_cmd.flags) & TRB_TYPE_BITMASK) >=
 		    TRB_TYPE(48))
-			handle_vendor_event(xhci, event);
+			handle_vendor_event(erst->hcd, event);
 		else
-			xhci->error_bitmask |= 1 << 3;
+			erst->hcd->error_bitmask |= 1 << 3;
 	}
 	/* Any of the above functions may drop and re-acquire the lock, so check
 	 * to make sure a watchdog timer didn't mark the host as non-responsive.
 	 */
-	if (xhci->xhc_state & XHCI_STATE_DYING) {
-		xhci_dbg(xhci, "xHCI host dying, returning from "
+	if (erst->hcd->xhc_state & XHCI_STATE_DYING) {
+		xhci_dbg(erst->hcd, "xHCI host dying, returning from "
 				"event handler.\n");
 		return 0;
 	}
 
 	if (update_ptrs)
 		/* Update SW event ring dequeue pointer */
-		inc_deq(xhci, xhci->erst.ring, true);
+		inc_deq(erst->hcd, erst->ring, true);
 
 	/* Are there more items on the event ring?  Caller will call us again to
 	 * check.
@@ -2312,7 +2312,7 @@ hw_died:
 	/* FIXME this should be a delayed service routine
 	 * that clears the EHB.
 	 */
-	while (xhci_handle_event(xhci) > 0) {}
+	while (xhci_handle_event(&xhci->erst) > 0) {}
 
 	temp_64 = xhci_read_64(xhci, &xhci->erst.ir_set->erst_dequeue);
 	/* If necessary, update the HW's version of the event ring deq ptr. */
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index db2491b..45fa667 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1135,6 +1135,7 @@ struct xhci_erst_entry {
 };
 
 struct xhci_erst {
+	struct xhci_hcd		*hcd;
 	struct xhci_ring	*ring;
 	struct xhci_intr_reg __iomem *ir_set;
 	struct xhci_erst_entry	*entries;
-- 
1.7.4.4

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux