Re: [BK PATCH] USB update for 2.6.3

Linus Torvalds
2004-02-20T18:35:28Z

On Fri, 20 Feb 2004, Hollis Blanchard wrote:
>
> And USB, when it creates its bus_type, does this:
> int usb_dma_supported(struct device *dev, u64 mask) {
> usb_dev *usbdev = to_usb_device(dev);
> return usbdev->root_hub->controller->bus->dma_supported(controller, u64 mask)
> }

So? The above has absolutely nothing to do with "dma_alloc_coherent()".
Also, it is wrong. It is not necessarily guaranteed that the device that
is the host controller ha sanythign to do with the "bus->dma_supported"
thing.

The point is, that DMA is always _always_ done on the host controller.
Trying to make things look any different is silly and wrong.

THE ABOVE CODE IS CRAP!

The correct thing to do is

int usb_dma_supported(struct usb_dev *dev, u64 mask)
{
struct device *host = dev->root_hub->controller;
return dma_supported(host);
}

and anything else is FUNDAMENTALLY WRONG!

Imagine, for example, that the bus is a PCI bus, but the USB host
controller has a bug in that it only supports 24-bit DMA. Asking for what
the bus of the host controller supports is non-sensical, and has
absolutely zero to do with that the actual host device supports.

See?

(That actual bug is totally irrelevant, though. The _fundamnetal_ bug is
in your way of thinking. For one thing, if you have a function called
"usb_dma_xxx()", then it takes a _USB_ device, not a generic device.
Because the function clearly doesn't even WORK with a generic device, it
only works with a "struct usb_dev". So don't "lie" about things like that
in your interfaces and confuse the issue).

Linus