• Fredrik Noring's avatar
    USB: Fix incorrect DMA allocations for local memory pool drivers · f8c63edf
    Fredrik Noring authored
    Fix commit 7b81cb6b ("usb: add a HCD_DMA flag instead of
    guestimating DMA capabilities") where local memory USB drivers
    erroneously allocate DMA memory instead of pool memory, causing
    
    	OHCI Unrecoverable Error, disabled
    	HC died; cleaning up
    
    The order between hcd_uses_dma() and hcd->localmem_pool is now
    arranged as in hcd_buffer_alloc() and hcd_buffer_free(), with the
    test for hcd->localmem_pool placed first.
    
    As an alternative, one might consider adjusting hcd_uses_dma() with
    
     static inline bool hcd_uses_dma(struct usb_hcd *hcd)
     {
    -	return IS_ENABLED(CONFIG_HAS_DMA) && (hcd->driver->flags & HCD_DMA);
    +	return IS_ENABLED(CONFIG_HAS_DMA) &&
    +		(hcd->driver->flags & HCD_DMA) &&
    +		(hcd->localmem_pool == NULL);
     }
    
    One can also consider unsetting HCD_DMA for local memory pool drivers.
    
    Fixes: 7b81cb6b ("usb: add a HCD_DMA flag instead of guestimating DMA capabilities")
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: default avatarFredrik Noring <noring@nocrew.org>
    Link: https://lore.kernel.org/r/20191210172905.GA52526@sx9Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    f8c63edf
scsiglue.c 19.9 KB