Re: [RFC 2/4] driver core: Allow early registration of devices

From: Thierry Reding
Date: Mon Aug 19 2013 - 17:42:05 EST


On Mon, Aug 19, 2013 at 02:53:37PM -0600, Stephen Warren wrote:
> On 08/19/2013 02:10 PM, Thierry Reding wrote:
> > On Mon, Aug 19, 2013 at 01:43:59PM -0600, Stephen Warren wrote:
> >> On 08/17/2013 05:17 AM, Thierry Reding wrote: ...
> >>> Well, the most obvious cases where early initialization is
> >>> needed are interrupt controllers and clocks.
> >>
> >> ... and IOMMUs, which apparently need to initialize before any
> >> devices whose transactions are routed through the IOMMU, in order
> >> to set themselves up as the IOMMU for the relevant devices.
> >>
> >> It's possible that the CPU-visible bus structure isn't a strict
> >> inverse/reverse of the device-visible bus-structure. A device may
> >> have CPU-visible registers on one bus segment, but inject master
> >> transactions onto an unrelated bus segment. So it may not be as
> >> simple as making a bus driver for the bus segment affected by the
> >> IOMMU, and having that driver trigger instantiation of all its
> >> children.
> >
> > Well, perhaps that can be handled via deferred probing? The only
> > thing preventing that right now is that drivers aren't actively
> > aware of the IOMMUs existence. If we can make it a requirement that
> > each driver needing the services of an IOMMU actively requests that
> > service, then deferred probing should be able to deal with it.
>
> I believe the hope was to specifically avoid drivers knowing about the
> presence of an IOMMU. Drivers would simply use standard dma
> alloc/map/unmap APIs, and those APIs would internally set up any IOMMU
> HW is present and necessary.
>
> Having e.g. a DT property that says "this is your IOMMU" which drivers
> had to explicitly handle parsing, and/or requiring drivers to make
> some call during probe to say "bind to an IOMMU" (unless that API can
> simply be called in all cases including when there actually is no
> IOMMU) would be a bit annoying.

Yes, I don't think drivers should have to do that manually either. In my
opinion it falls in the same category as setting up the default pinmux
state, which is now handled by the core as well.

> > That doesn't necessarily mean that drivers need to be doing it
> > manually. It strikes me as the kind of thing that could easily be
> > done by the core. In fact I've been thinking of doing something
> > similar to resolve devicetree IRQ references at probe time, rather
> > than at device creation time to remove the need for interrupt chips
> > to register early.
>
> If we can make this automatic and hidden yet still use deferred
> probing, then that'd likely be just fine.

I plan to investigate how this could be done for the IRQ reference
resolution and if that can be done it should be possible to do it for
IOMMUs as well.

Thierry

Attachment: pgp00000.pgp
Description: PGP signature