Re: [BK PATCH] USB update for 2.6.3

Benjamin Herrenschmidt
2004-02-20T06:48:10Z

> Well, we do. The pcibios_xxx routines get called for all PCI devices
> during discovery, and that's when you'd fill them in.

But what about USB or FireWire devices ? In theory, I'd like to see
the driver for those not have to bother about beeing hosted by a PCI
device or whatever else (there are typically non-PCI OHCI USBs on
embedded platform, faking a pci_dev is becoming painful).

So it would actually make sense to be able to pass whatever struct
device we are on, and have a real inheritance of the DMA functions
going down the bus, don't you think ?

> Anyway, I found the bug - the "asm-generic/dma-mapping.h" compatibility
> macros _do_ work, but the EHCI controller driver doesn't actually include
> that header file. Oops.

Heh.

> > We should have a way, when creating a device, to fill it properly, like
> >
> > platform_device_setup(struct device *new_dev, struct device *parent)
>
> No no. That wouldn't work AT ALL, since the whole point is that you need
> to know what the device is - ie you need to fill in the information when
> you get the "struct pci_dev *" (because different buses would most likely
> have different behaviour, and could have different requirements for DMA
> mapping etc).

And ? Where is the problem ? By default, you inherit from the parent
and that's just fine. The platform sets the ops for the root PCIs and
everybody below that inherit from them, same goes for VIO. If at one
level in the hierarchy, there is a "brake" (a bridge to a different
kind of bus that has additional restrictions), then the above routine
can "know" this via the new_dev bus type and setup appropriate mapping
functions.

> So the platform code that actually knows what the device is (pcibios_xxx
> for PCI devices) would fill in the platform pointer.

Hrm... and we keep it empty for USB, FireWire, etc... or we add
platform_usb_xxxx, platform_ieee1394_* etc... for all those cases ?

> Anyway, I got it all working with the trivial patch..
>
> ===== drivers/usb/host/ehci-hcd.c 1.67 vs edited =====
> --- 1.67/drivers/usb/host/ehci-hcd.c Wed Feb 11 03:42:39 2004
> +++ edited/drivers/usb/host/ehci-hcd.c Thu Feb 19 22:42:53 2004
> @@ -41,6 +41,7 @@
> #include <linux/reboot.h>
> #include <linux/usb.h>
> #include <linux/moduleparam.h>
> +#include <linux/dma-mapping.h>
>
> #include "../core/hcd.h"
>
>
> so this works for now, even though it's really really ugly (and it _will_
> BUG() out if anybody ever passes a non-PCI-related "struct device" to the
> thing).
>
> Let's see if it boots too. So far it's only compiled successfully ;)
>
> Linus
--
Benjamin Herrenschmidt <benh@kernel.crashing.org>