Re: [PATCHv5 2/9] driver/core: populate devices in order for IOMMUs

From: Hiroshi Doyu
Date: Tue Nov 19 2013 - 22:17:23 EST


Stephen Warren <swarren@xxxxxxxxxxxxx> wrote @ Tue, 19 Nov 2013 22:22:47 +0100:

> On 11/19/2013 05:03 AM, Hiroshi Doyu wrote:
> > Hi Thierry,
> >
> > Thierry Reding <thierry.reding@xxxxxxxxx> wrote @ Tue, 19 Nov 2013 11:25:07 +0100:
> >
> >> From earlier discussions I thought the goal was to actually defer this
> >> until all nodes referred to by the iommus property were actually
> >> registered. The above only checks that the phandles can be resolved to
> >> valid struct device_node:s. That doesn't mean that an actual IOMMU has
> >> been registered for it, only that the devices have been created.
> >
> > Currently "bus->iommu_ops" is set at the end of tegra_smmu_probe(). So
> > if "bus->iommu_ops" is set, it means that an iommu instance is
> > populated at that time.
>
> Yes, but that's the register bus, upon which the device is a client, not
> the bus upon which the device is a bus master. They aren't necessarily
> the same.
>
> There's no getting around the fact that, as Thierry said, you need to
> search for a registered IOMMU device for each phandle, and defer probe
> if any aren't registered yet.
>
> If we do that, then you shouldn't need to look at the value of
> dev->bus->iommu_ops at all; if all IOMMUs in the list were registered,
> then iommu_ops must have been set when (one of them) was registered, and
> if not, then it possibly wasn't, so defer probe.
>
> That way, this code won't have to change if the core IOMMU code gets
> extended to support multiple IOMMUs, devices mastering transactions onto
> buses other than their register bus, etc.

Does the above mean the following?

int of_iommu_attach(struct device *dev)
{
int i;
struct of_phandle_args args;

of_property_for_each_phandle_with_args(dev->of_node, "iommus",
"#iommu-cells", i, &args)
if (!args->np->dev->driver)
return -EPROBE_DEFER;
return 0;
}


"args->np->dev->driver" needs the following patch:

http://lists.linuxfoundation.org/pipermail/iommu/2013-July/006023.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/