Commit 7b81cb6b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Greg Kroah-Hartman
Browse files

usb: add a HCD_DMA flag instead of guestimating DMA capabilities



The usb core is the only major place in the kernel that checks for
a non-NULL device dma_mask to see if a device is DMA capable.  This
is generally a bad idea, as all major busses always set up a DMA mask,
even if the device is not DMA capable - in fact bus layers like PCI
can't even know if a device is DMA capable at enumeration time.  This
leads to lots of workaround in HCD drivers, and also prevented us from
setting up a DMA mask for platform devices by default last time we
tried.

Replace this guess with an explicit HCD_DMA that is set by drivers that
appear to have DMA support.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20190816062435.881-4-hch@lst.de


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0709831a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3512,7 +3512,7 @@ static const struct hc_driver octeon_hc_driver = {
	.product_desc		= "Octeon Host Controller",
	.hcd_priv_size		= sizeof(struct octeon_hcd),
	.irq			= octeon_usb_irq,
	.flags			= HCD_MEMORY | HCD_USB2,
	.flags			= HCD_MEMORY | HCD_DMA | HCD_USB2,
	.start			= octeon_usb_start,
	.stop			= octeon_usb_stop,
	.urb_enqueue		= octeon_usb_urb_enqueue,
+0 −1
Original line number Diff line number Diff line
@@ -2454,7 +2454,6 @@ struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver,
	hcd->self.controller = dev;
	hcd->self.sysdev = sysdev;
	hcd->self.bus_name = bus_name;
	hcd->self.uses_dma = (sysdev->dma_mask != NULL);

	timer_setup(&hcd->rh_timer, rh_timer_func, 0);
#ifdef CONFIG_PM
+3 −3
Original line number Diff line number Diff line
@@ -5062,13 +5062,13 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
		dwc2_hc_driver.reset_device = dwc2_reset_device;
	}

	if (hsotg->params.host_dma)
		dwc2_hc_driver.flags |= HCD_DMA;

	hcd = usb_create_hcd(&dwc2_hc_driver, hsotg->dev, dev_name(hsotg->dev));
	if (!hcd)
		goto error1;

	if (!hsotg->params.host_dma)
		hcd->self.uses_dma = 0;

	hcd->has_tt = 1;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ static const struct hc_driver ehci_grlib_hc_driver = {
	 * generic hardware linkage
	 */
	.irq			= ehci_irq,
	.flags			= HCD_MEMORY | HCD_USB2 | HCD_BH,
	.flags			= HCD_MEMORY | HCD_DMA | HCD_USB2 | HCD_BH,

	/*
	 * basic lifecycle operations
+1 −1
Original line number Diff line number Diff line
@@ -1193,7 +1193,7 @@ static const struct hc_driver ehci_hc_driver = {
	 * generic hardware linkage
	 */
	.irq =			ehci_irq,
	.flags =		HCD_MEMORY | HCD_USB2 | HCD_BH,
	.flags =		HCD_MEMORY | HCD_DMA | HCD_USB2 | HCD_BH,

	/*
	 * basic lifecycle operations
Loading