Commit ee4aa54b authored by Hans de Goede's avatar Hans de Goede Committed by Sarah Sharp

xhci: Check size rather then number of streams when allocating stream ctxs

Before this a device needing ie 32 stream ctxs would end up with an entry from
the small_streams_pool which has 256 bytes entries, where as 32 stream ctxs
need 512 bytes. Things actually keep running for a surprisingly long time
before crashing because of this.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
parent df613834
...@@ -520,12 +520,12 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci, ...@@ -520,12 +520,12 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci,
struct xhci_stream_ctx *stream_ctx, dma_addr_t dma) struct xhci_stream_ctx *stream_ctx, dma_addr_t dma)
{ {
struct device *dev = xhci_to_hcd(xhci)->self.controller; struct device *dev = xhci_to_hcd(xhci)->self.controller;
size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE) if (size > MEDIUM_STREAM_ARRAY_SIZE)
dma_free_coherent(dev, dma_free_coherent(dev, size,
sizeof(struct xhci_stream_ctx)*num_stream_ctxs,
stream_ctx, dma); stream_ctx, dma);
else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE) else if (size <= SMALL_STREAM_ARRAY_SIZE)
return dma_pool_free(xhci->small_streams_pool, return dma_pool_free(xhci->small_streams_pool,
stream_ctx, dma); stream_ctx, dma);
else else
...@@ -548,12 +548,12 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci, ...@@ -548,12 +548,12 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci,
gfp_t mem_flags) gfp_t mem_flags)
{ {
struct device *dev = xhci_to_hcd(xhci)->self.controller; struct device *dev = xhci_to_hcd(xhci)->self.controller;
size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs;
if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE) if (size > MEDIUM_STREAM_ARRAY_SIZE)
return dma_alloc_coherent(dev, return dma_alloc_coherent(dev, size,
sizeof(struct xhci_stream_ctx)*num_stream_ctxs,
dma, mem_flags); dma, mem_flags);
else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE) else if (size <= SMALL_STREAM_ARRAY_SIZE)
return dma_pool_alloc(xhci->small_streams_pool, return dma_pool_alloc(xhci->small_streams_pool,
mem_flags, dma); mem_flags, dma);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment