[PATCH 02/13] iommu: Move bus setup to IOMMU device registration

Robin Murphy robin.murphy at arm.com
Fri Apr 22 12:02:12 PDT 2022


On 2022-04-22 19:37, Krishna Reddy wrote:
> Good effort to isolate bus config from smmu drivers.
> Reviewed-By: Krishna Reddy <vdumpa at nvidia.com>

Thanks!

> I have an orthogonal question here.
> Can the following code handle the case, where different buses have different type of SMMU instances(like one bus has SMMUv2 and another bus has SMMUv3)?
> If it need to handle the above case, can the smmu device bus be matched with specific bus here and ops set only for that bus?

Not yet, but that is one of the end goals that this is all working 
towards. I think the stuff that I've added to the dev branch[1] today 
should have reached the point where that becomes viable, but I'll need 
to rig up a system to test it next week.

Intermediate solutions aren't worth it because in practice you 
inevitably end up needing both IOMMU drivers to share the platform "bus" 
anyway.

Cheers,
Robin.

[1] https://gitlab.arm.com/linux-arm/linux-rm/-/commits/iommu/bus

> 
> 
>> +       for (int i = 0; i < ARRAY_SIZE(iommu_buses); i++) {
>> +               struct bus_type *bus = iommu_buses[i];
>> +               const struct iommu_ops *bus_ops = bus->iommu_ops;
>> +               int err;
>> +
>> +               WARN_ON(bus_ops && bus_ops != ops);
>> +               bus->iommu_ops = ops;
>> +               err = bus_iommu_probe(bus);
>> +               if (err) {
>> +                       bus_for_each_dev(bus, NULL, iommu,
>> remove_iommu_group);
>> +                       bus->iommu_ops = bus_ops;
>> +                       return err;
>> +               }
>> +       }
> 
> 
> -KR



More information about the linux-arm-kernel mailing list