[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1487775954-16258-1-git-send-email-anuragku@xilinx.com>
Date: Wed, 22 Feb 2017 20:35:54 +0530
From: Anurag Kumar Vulisha <anurag.kumar.vulisha@...inx.com>
To: <mathias.nyman@...el.com>, <gregkh@...uxfoundation.org>
CC: <linux-usb@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<anirudh@...inx.com>, <punnaia@...inx.com>,
Anurag Kumar Vulisha <anuragku@...inx.com>
Subject: [RFC PATCH] xhci: Use Cached ring during endpoint ring allocation
Currently during endpoint initialization, a new endpoint ring is alloacte
using xhci_ring_alloc(), if this function fails to allocate ring a cached
ring(if available) is assigned to endpoint ring.
This patch modifies the code that during endpoint initialization, if cached
ring is available it is assigned to the endpoint ring. If cached rings are
not available then xhci_ring_alloc() is called to allocate a new ring.
Doing so will avoid unncessary memory allocations if cached ring is already
available for use. This also fixes endpoint "Ring expansion failed" error
which occurs due to insufficient memory during ring expansion.
Signed-off-by: Anurag Kumar Vulisha <anuragku@...inx.com>
---
drivers/usb/host/xhci-mem.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 8414ed2..587b6c6 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1514,19 +1514,22 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
mult = 0;
/* Set up the endpoint ring */
- virt_dev->eps[ep_index].new_ring =
- xhci_ring_alloc(xhci, 2, 1, ring_type, max_packet, mem_flags);
- if (!virt_dev->eps[ep_index].new_ring) {
+ if (virt_dev->num_rings_cached > 0) {
/* Attempt to use the ring cache */
- if (virt_dev->num_rings_cached == 0)
- return -ENOMEM;
virt_dev->num_rings_cached--;
virt_dev->eps[ep_index].new_ring =
virt_dev->ring_cache[virt_dev->num_rings_cached];
virt_dev->ring_cache[virt_dev->num_rings_cached] = NULL;
xhci_reinit_cached_ring(xhci, virt_dev->eps[ep_index].new_ring,
1, ring_type);
+ } else {
+ virt_dev->eps[ep_index].new_ring =
+ xhci_ring_alloc(xhci, 2, 1, ring_type, max_packet,
+ mem_flags);
+ if (!virt_dev->eps[ep_index].new_ring)
+ return -ENOMEM;
}
+
virt_dev->eps[ep_index].skip = false;
ep_ring = virt_dev->eps[ep_index].new_ring;
--
2.1.1
Powered by blists - more mailing lists