Hi Eric,

>-----Original Message-----
>From: Eric Auger <eric.au...@redhat.com>
>Subject: Re: [PATCH v2 09/19] intel_iommu: Introduce two helpers
>vtd_as_from/to_iommu_pasid_locked
>
>Hi Zhenzhong,
>
>On 7/7/25 5:12 AM, Duan, Zhenzhong wrote:
>> Hi Eric,
>>
>>> -----Original Message-----
>>> From: Duan, Zhenzhong
>>> Subject: RE: [PATCH v2 09/19] intel_iommu: Introduce two helpers
>>> vtd_as_from/to_iommu_pasid_locked
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: Eric Auger <eric.au...@redhat.com>
>>>> Subject: Re: [PATCH v2 09/19] intel_iommu: Introduce two helpers
>>>> vtd_as_from/to_iommu_pasid_locked
>>>>
>>>> Hi Zhenzhong,
>>>>
>>>> On 6/20/25 9:18 AM, Zhenzhong Duan wrote:
>>>>> PCI device supports two request types, Requests-without-PASID and
>>>>> Requests-with-PASID. Requests-without-PASID doesn't include a PASID
>TLP
>>>>> prefix, IOMMU fetches rid_pasid from context entry and use it as
>>> IOMMU's
>>>>> pasid to index pasid table.
>>>>>
>>>>> So we need to translate between PCI's pasid and IOMMU's pasid
>specially
>>>>> for Requests-without-PASID, e.g., PCI_NO_PASID(-1) <-> rid_pasid.
>>>>> For Requests-with-PASID, PCI's pasid and IOMMU's pasid are same
>value.
>>>>>
>>>>> vtd_as_from_iommu_pasid_locked() translates from BDF+iommu_pasid
>to
>>>> vtd_as
>>>>> which contains PCI's pasid vtd_as->pasid.
>>>>>
>>>>> vtd_as_to_iommu_pasid_locked() translates from BDF+vtd_as->pasid to
>>>> iommu_pasid.
>>>>> Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com>
>>>>> ---
>>>>>  hw/i386/intel_iommu.c | 58
>>>> +++++++++++++++++++++++++++++++++++++++++++
>>>>>  1 file changed, 58 insertions(+)
>>>>>
>>>>> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
>>>>> index 9d4adc9458..8948b8370f 100644
>>>>> --- a/hw/i386/intel_iommu.c
>>>>> +++ b/hw/i386/intel_iommu.c
>>>>> @@ -1602,6 +1602,64 @@ static int
>>>> vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num,
>>>>>      return 0;
>>>>>  }
>>>>>
>>>>> +static inline int vtd_as_to_iommu_pasid_locked(VTDAddressSpace
>>> *vtd_as,
>>>>> +                                               uint32_t
>>> *pasid)
>>>> Is it meaningful to use inline here and below? Below I guess you do so
>>>> to avoid "defined but not used" compilation error but I don't think it
>>>> should stay as is.
>>> Yes, that's the only reason I define the both inline.
>>> Do you have other suggestions to avoid compilation error if not use inline?
>> I find I am not clear on above comments yet, do you just want to remove
>inline flag?
>> Maybe merging the two helpers to other patches using them to avoid inline?
>In the past what I did in such situation consisted in introducing a
>declaration of the static function before its definition and when the
>actual user is introduced, in a subsequent patch, remove the spurious
>declaration.
>Now, reading
>https://www.reddit.com/r/cpp_questions/comments/15kfije/how_to_decide
>_if_a_function_should_be_inline_or/,
>maybe adding the inline here is not a problem given the compiler may or
>may not inline the function.

Thanks for the link, this refreshes my understanding to inline.

BRs,
Zhenzhong

Reply via email to