On 07.03.2025 12:23, Luca Fancellu wrote:
>>>>> +
>>>>> +static inline int iommu_domain_init(struct domain *d, unsigned int opts)
>>>>> +{
>>>>> +    /*
>>>>> +     * Return as the real iommu_domain_init() would: Success when
>>>>> +     * !is_iommu_enabled(), following from !iommu_enabled when 
>>>>> !HAS_PASSTHROUGH
>>>>> +     */
>>>>> +    return 0;
>>>>> +}
>>>>> +
>>>>> +static inline void iommu_hwdom_init(struct domain *d) {}
>>>>> +
>>>>> +static inline void iommu_domain_destroy(struct domain *d) {}
>>>>> +
>>>>> +#endif /* HAS_PASSTHROUGH */
>>>>> +
>>>>> /*
>>>>>  * The following flags are passed to map (applicable ones also to unmap)
>>>>>  * operations, while some are passed back by lookup operations.
>>>>> @@ -209,6 +233,8 @@ struct msi_msg;
>>>>> #ifdef CONFIG_HAS_DEVICE_TREE
>>>>> #include <xen/device_tree.h>
>>>>> +#ifdef CONFIG_HAS_PASSTHROUGH
>>>>> +
>>>>> int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev);
>>>>> int iommu_deassign_dt_device(struct domain *d, struct dt_device_node 
>>>>> *dev);
>>>>> int iommu_dt_domain_init(struct domain *d);
>>>>> @@ -238,6 +264,26 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, 
>>>>> struct domain *d,
>>>>>  */
>>>>> int iommu_remove_dt_device(struct dt_device_node *np);
>>>>> +#else
>>>>> +
>>>>> +static inline int iommu_assign_dt_device(struct domain *d,
>>>>> +                                         struct dt_device_node *dev)
>>>>> +{
>>>>> +    return -EINVAL;
>>>>> +}
>>>>> +
>>>>> +static inline int iommu_add_dt_device(struct dt_device_node *np)
>>>>> +{
>>>>> +    return 1;
>>>>
>>>> I would suggest to add a comment explain what 1 means. IIRC, this means 
>>>> "no iommu" present.
>>>
>>> Would it be ok something like in iommu_domain_init:
>>>
>>> /*
>>> * Returns as the real iommu_add_dt_device() would: Error “no iommu" because
>>> * !iommu_enabled due to the fact that !HAS_PASSTHROUGH
>>> */
>>
>> We had been there before, hadn't we? Personally I find the suggested text
>> hard to follow.
> 
> well, I’ve taken your suggestion for iommu_domain_init and adapted here, 
> maybe the adaptation didn’t meet your criteria then :)

I wasn't overly happy with that other comment either.

> But ...
> 
>> How about
>>
>>    /*
>>     * !HAS_PASSTHROUGH => !iommu_enabled (see the non-stub
>>     * iommu_add_dt_device())
>>     */
>>
>> If that's too terse, adding a few words should be fine.
> 
> as long as you are happy with that, I’m happy as well, please let me know
> if you want a v5 with this or if you would do the modificaiton on commit.

I first need to get to looking at v4 as a whole.

Jan

Reply via email to