lkml.org 
[lkml]   [2023]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v5 09/12] iommu: Make iommu_queue_iopf() more generic
From
On 2023/9/22 20:43, Jason Gunthorpe wrote:
> On Fri, Sep 22, 2023 at 10:44:45AM +0800, Baolu Lu wrote:
>
>>>>> @@ -112,6 +110,7 @@ int iommu_queue_iopf(struct iommu_fault *fault, struct device *dev)
>>>>> {
>>>>> int ret;
>>>>> struct iopf_group *group;
>>>>> + struct iommu_domain *domain;
>>>>> struct iopf_fault *iopf, *next;
>>>>> struct iommu_fault_param *iopf_param;
>>>>> struct dev_iommu *param = dev->iommu;
>>>>> @@ -143,6 +142,19 @@ int iommu_queue_iopf(struct iommu_fault *fault, struct device *dev)
>>>>> return 0;
>>>>> }
>>>>> + if (fault->prm.flags & IOMMU_FAULT_PAGE_REQUEST_PASID_VALID)
>>>>> + domain = iommu_get_domain_for_dev_pasid(dev, fault->prm.pasid, 0);
>>>>> + else
>>>>> + domain = iommu_get_domain_for_dev(dev);
>>>>> +
>>>>> + if (!domain || !domain->iopf_handler) {
>>>> Does it need to check if 'domain' is error ?  Like below:
>>>>
>>>>          if (!domain || IS_ERR(domain) || !domain->iopf_handler)
>>> Urk, yes, but not like that
>>>
>>> The IF needs to be moved into the else block as each individual
>>> function has its own return convention.
>> iommu_get_domain_for_dev_pasid() returns an ERR_PTR only if the matching
>> domain type is specified (non-zero).
>>
>> Adding IS_ERR(domain) in the else block will make the code more
>> readable. Alternatively we can put a comment around above code to
>> explain that ERR_PTR is not a case here.
> You should check it because you'll probably get a static tool
> complaint otherwise

Okay, got you.

Best regards,
baolu

\
 
 \ /
  Last update: 2023-09-22 16:30    [W:0.040 / U:0.460 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site