From b008df60c6369ba0290fa7daa177375407a12e07 Mon Sep 17 00:00:00 2001 From: Andiry Xu Date: Mon, 5 Mar 2012 17:49:34 +0800 Subject: xHCI: count free TRBs on transfer ring In the past, the room_on_ring() check was implemented by walking all over the ring, which is wasteful and complicated. Count the number of free TRBs instead. The free TRBs number should be updated when enqueue/dequeue pointer is updated, or upon the completion of a set dequeue pointer command. Signed-off-by: Andiry Xu Signed-off-by: Sarah Sharp Tested-by: Paul Zimmerman --- drivers/usb/host/xhci-mem.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/usb/host/xhci-mem.c') diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index bdea4de867b..212012c97df 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -135,6 +135,12 @@ static void xhci_initialize_ring_info(struct xhci_ring *ring) /* Not necessary for new rings, but needed for re-initialized rings */ ring->enq_updates = 0; ring->deq_updates = 0; + + /* + * Each segment has a link TRB, and leave an extra TRB for SW + * accounting purpose + */ + ring->num_trbs_free = ring->num_segs * (TRBS_PER_SEGMENT - 1) - 1; } /** -- cgit v1.2.3