Re: [PATCH 0/6] of: iommu-map parsing for multi-cell IOMMU

From: Charan Teja Kalla

Date: Wed Nov 26 2025 - 12:30:11 EST


Thanks a lot Robin!!

On 11/24/2025 10:21 PM, Robin Murphy wrote:
>> ----------------------8888---------------------------------------------
>>
>> diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c
>> index a511ecf21fcd..ac005e70de7d 100644
>> --- a/drivers/iommu/of_iommu.c
>> +++ b/drivers/iommu/of_iommu.c
>> @@ -16,6 +16,7 @@
>>   #include <linux/pci.h>
>>   #include <linux/slab.h>
>>   #include <linux/fsl/mc.h>
>> +#include <linux/platform_device.h>
>>     #include "iommu-priv.h"
>>   @@ -41,6 +42,18 @@ static int of_iommu_xlate(struct device *dev,
>>       return ret;
>>   }
>>   +static int of_iommu_configure_cb(void *arg, u32 *id_out)
>> +{
>> +    struct of_phandle_args *iommu_spec =
>> +        (struct of_phandle_args *)((void *)id_out - offsetof(struct
>> of_phandle_args, args));
>
> Not sure whether to be impressed or disgusted... If we are to take a
> callback approach then it should probably standardise on passing a full
> of_phandle_args to encode the map output. Particularly given what I've
> just noticed below...
>
Sure... will make patches based on this...

>> +    struct device *dev = arg;
>> +    int err;
>> +
>> +    err = of_iommu_xlate(dev, iommu_spec);
>> +    of_node_put(iommu_spec->np);
>> +    return err;
>> +}
>> +
>>   static int of_iommu_configure_dev_id(struct device_node *master_np,
>>                        struct device *dev,
>>                        const u32 *id)
>> @@ -48,12 +61,10 @@ static int of_iommu_configure_dev_id(struct
>> device_node *master_np,
>>       struct of_phandle_args iommu_spec = { .args_count = 1 };
>
> Oh dear, I totally overlooked this, and off the top of my head I'm not
> sure it's simple to fix 🙁
>
> So it's still not actually working as intended. Oh well, I did say it
> was untested...
I assume you are talking about the .args_count here, since of_map_id()
filling id_out, should we also pass the &args_count and let of_map_id()
fill that(with cell_count) or as you mentioned, pass the complete
of_phandle_args ?

Thanks,
Charan