Re: Bug 55481 - [xHCI Stream bug] xHCI linux driver xhci_alloc_stream_ctx() function

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

 



Hi Gene,

I know that the xHCI driver has several issues with the streams
implementation.  Right now, these are lower priority bugs because the
only driver that uses streams (UAS) is pretty broken, and basically does
not work.  I will get to your bug reports, but please stop pinging me
every other day about them.  Wait at least a week between pings.

Thanks,
Sarah Sharp

On Wed, Mar 20, 2013 at 04:30:45PM +0800, Gene.Chang wrote:
> P: Taichien Chang
> M: Sarah Sharp <sarah.a.sharp@xxxxxxxxxxxxxxx>
> L: linux-usb@xxxxxxxxxxxxxxx
> W:
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/host/xhci-mem.c?id=refs/tags/v3.9-rc2#n451
> S: Obsolete
> F: drivers/usb/host/xhci-mem.c
> K: xhci_alloc_stream_ctx
> ===========================================================================================
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=55481
> 
> I found some bugs in xHCI driver.
> 
> In xhci_alloc_stream_ctx() function,  (xhci-mem.c)
> 
> In my opinion, dma_pool_alloc can allocate a size of
> SMALL_STREAM_ARRAY_SIZE bytes memory for 16 stream contexts.
> or also can allocate a size of MEDIUM_STREAM_ARRAY_SIZE bytes memory for 64
> stream contexts. That size is defined in xhci.h.
> -----------------------------------------------------------------------------
> #define SMALL_STREAM_ARRAY_SIZE 256
> #define MEDIUM_STREAM_ARRAY_SIZE 1024
> ------------------------------------------------------------------------------
> If dma_pool_create set the size of MEDIUM_STREAM_ARRAY_SIZE or
> MEDIUM_STREAM_ARRAY_SIZE for dma_pool_alloc,"num_stream_ctxs" should not be
> a size condition for allocation by dma_pool_alloc.
> 
> Otherwise, "sizeof(struct xhci_stream_ctx)*num_stream_ctxs" can be a
> condition for several size allocation for dma_pool_alloc.
> 
> 
> so I think that this function can be modified as follows:
> ---------------------------------------------------------------------------------------------------------------
> static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci,
> unsigned int num_stream_ctxs, dma_addr_t *dma,
>  gfp_t mem_flags)
> {
> struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
> 
> -if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE)
> +if (sizeof(struct xhci_stream_ctx)*num_stream_ctxs >
> MEDIUM_STREAM_ARRAY_SIZE)
>  return dma_alloc_coherent(&pdev->dev,
> sizeof(struct xhci_stream_ctx)*num_stream_ctxs,
> dma, mem_flags);
> 
> -else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE)
> +else if (sizeof(struct xhci_stream_ctx)*num_stream_ctxs <=
> SMALL_STREAM_ARRAY_SIZE)
>  return dma_pool_alloc(xhci->small_streams_pool,
> mem_flags, dma);
> else
>  return dma_pool_alloc(xhci->medium_streams_pool,
> mem_flags, dma);
> }
> -------------------------------------------------------------------------------------------------------------------
--
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