Commit 2d7a3dc3 authored by Laurentiu Tudor's avatar Laurentiu Tudor Committed by Christoph Hellwig
Browse files

USB: drop HCD_LOCAL_MEM flag



With the addition of the local memory allocator, the HCD_LOCAL_MEM
flag can be dropped and the checks against it replaced with a check
for the localmem_pool ptr being initialized.

Signed-off-by: default avatarLaurentiu Tudor <laurentiu.tudor@nxp.com>
Tested-by: default avatarFredrik Noring <noring@nocrew.org>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 7d995329
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ int hcd_buffer_create(struct usb_hcd *hcd)

	if (!IS_ENABLED(CONFIG_HAS_DMA) ||
	    (!is_device_dma_capable(hcd->self.sysdev) &&
	     !(hcd->driver->flags & HCD_LOCAL_MEM)))
	     !hcd->localmem_pool))
		return 0;

	for (i = 0; i < HCD_BUFFER_POOLS; i++) {
@@ -130,8 +130,7 @@ void *hcd_buffer_alloc(

	/* some USB hosts just use PIO */
	if (!IS_ENABLED(CONFIG_HAS_DMA) ||
	    (!is_device_dma_capable(bus->sysdev) &&
	     !(hcd->driver->flags & HCD_LOCAL_MEM))) {
	    !is_device_dma_capable(bus->sysdev)) {
		*dma = ~(dma_addr_t) 0;
		return kmalloc(size, mem_flags);
	}
@@ -162,8 +161,7 @@ void hcd_buffer_free(
	}

	if (!IS_ENABLED(CONFIG_HAS_DMA) ||
	    (!is_device_dma_capable(bus->sysdev) &&
	     !(hcd->driver->flags & HCD_LOCAL_MEM))) {
	    !is_device_dma_capable(bus->sysdev)) {
		kfree(addr);
		return;
	}
+6 −9
Original line number Diff line number Diff line
@@ -1347,14 +1347,14 @@ EXPORT_SYMBOL_GPL(usb_hcd_unlink_urb_from_ep);
 * using regular system memory - like pci devices doing bus mastering.
 *
 * To support host controllers with limited dma capabilities we provide dma
 * bounce buffers. This feature can be enabled using the HCD_LOCAL_MEM flag.
 * bounce buffers. This feature can be enabled by initializing
 * hcd->localmem_pool using usb_hcd_setup_local_mem().
 * For this to work properly the host controller code must first use the
 * function dma_declare_coherent_memory() to point out which memory area
 * that should be used for dma allocations.
 *
 * The HCD_LOCAL_MEM flag then tells the usb code to allocate all data for
 * dma using dma_alloc_coherent() which in turn allocates from the memory
 * area pointed out with dma_declare_coherent_memory().
 * The initialized hcd->localmem_pool then tells the usb code to allocate all
 * data for dma using the genalloc API.
 *
 * So, to summarize...
 *
@@ -1364,9 +1364,6 @@ EXPORT_SYMBOL_GPL(usb_hcd_unlink_urb_from_ep);
 *   (a) "normal" kernel memory is no good, and
 *   (b) there's not enough to share
 *
 * - The only *portable* hook for such stuff in the
 *   DMA framework is dma_declare_coherent_memory()
 *
 * - So we use that, even though the primary requirement
 *   is that the memory be "local" (hence addressable
 *   by that device), not "coherent".
@@ -1533,7 +1530,7 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
						urb->setup_dma))
				return -EAGAIN;
			urb->transfer_flags |= URB_SETUP_MAP_SINGLE;
		} else if (hcd->driver->flags & HCD_LOCAL_MEM) {
		} else if (hcd->localmem_pool) {
			ret = hcd_alloc_coherent(
					urb->dev->bus, mem_flags,
					&urb->setup_dma,
@@ -1603,7 +1600,7 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
				else
					urb->transfer_flags |= URB_DMA_MAP_SINGLE;
			}
		} else if (hcd->driver->flags & HCD_LOCAL_MEM) {
		} else if (hcd->localmem_pool) {
			ret = hcd_alloc_coherent(
					urb->dev->bus, mem_flags,
					&urb->transfer_dma,
+1 −1
Original line number Diff line number Diff line
@@ -559,7 +559,7 @@ static int ehci_init(struct usb_hcd *hcd)
	ehci->command = temp;

	/* Accept arbitrarily long scatter-gather lists */
	if (!(hcd->driver->flags & HCD_LOCAL_MEM))
	if (!hcd->localmem_pool)
		hcd->self.sg_tablesize = ~0;

	/* Prepare for unlinking active QHs */
+1 −1
Original line number Diff line number Diff line
@@ -4995,7 +4995,7 @@ static int hcd_fotg210_init(struct usb_hcd *hcd)
	fotg210->command = temp;

	/* Accept arbitrarily long scatter-gather lists */
	if (!(hcd->driver->flags & HCD_LOCAL_MEM))
	if (!hcd->localmem_pool)
		hcd->self.sg_tablesize = ~0;
	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -448,7 +448,7 @@ static int ohci_init (struct ohci_hcd *ohci)
	struct usb_hcd *hcd = ohci_to_hcd(ohci);

	/* Accept arbitrarily long scatter-gather lists */
	if (!(hcd->driver->flags & HCD_LOCAL_MEM))
	if (!hcd->localmem_pool)
		hcd->self.sg_tablesize = ~0;

	if (distrust_firmware)
Loading