From: Baolu Lu <baolu.lu@linux.intel.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: baolu.lu@linux.intel.com, "Liu, Jingqi" <jingqi.liu@intel.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Kevin Tian <kevin.tian@intel.com>,
Jean-Philippe Brucker <jean-philippe@linaro.org>,
Nicolin Chen <nicolinc@nvidia.com>, Yi Liu <yi.l.liu@intel.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>,
iommu@lists.linux.dev, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 09/12] iommu: Make iommu_queue_iopf() more generic
Date: Fri, 22 Sep 2023 20:47:35 +0800 [thread overview]
Message-ID: <d6f6dbad-c341-fe6b-a430-7bbf4bcfba31@linux.intel.com> (raw)
In-Reply-To: <20230922124303.GE13795@ziepe.ca>
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
next prev parent reply other threads:[~2023-09-22 12:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-14 8:56 [PATCH v5 00/12] iommu: Prepare to deliver page faults to user space Lu Baolu
2023-09-14 8:56 ` [PATCH v5 01/12] iommu: Move iommu fault data to linux/iommu.h Lu Baolu
2023-09-14 8:56 ` [PATCH v5 02/12] iommu/arm-smmu-v3: Remove unrecoverable faults reporting Lu Baolu
2023-09-14 8:56 ` [PATCH v5 03/12] iommu: Remove unrecoverable fault data Lu Baolu
2023-09-14 8:56 ` [PATCH v5 04/12] iommu: Cleanup iopf data structure definitions Lu Baolu
2023-09-14 8:56 ` [PATCH v5 05/12] iommu: Merge iopf_device_param into iommu_fault_param Lu Baolu
2023-09-14 8:56 ` [PATCH v5 06/12] iommu: Remove iommu_[un]register_device_fault_handler() Lu Baolu
2023-09-14 8:56 ` [PATCH v5 07/12] iommu: Merge iommu_fault_event and iopf_fault Lu Baolu
2023-09-25 6:47 ` Tian, Kevin
2023-09-14 8:56 ` [PATCH v5 08/12] iommu: Prepare for separating SVA and IOPF Lu Baolu
2023-09-14 8:56 ` [PATCH v5 09/12] iommu: Make iommu_queue_iopf() more generic Lu Baolu
2023-09-21 15:25 ` Liu, Jingqi
2023-09-21 23:34 ` Jason Gunthorpe
2023-09-22 2:44 ` Baolu Lu
2023-09-22 12:43 ` Jason Gunthorpe
2023-09-22 12:47 ` Baolu Lu [this message]
2023-09-25 6:49 ` Tian, Kevin
2023-09-14 8:56 ` [PATCH v5 10/12] iommu: Separate SVA and IOPF Lu Baolu
2023-09-25 6:49 ` Tian, Kevin
2023-09-14 8:56 ` [PATCH v5 11/12] iommu: Consolidate per-device fault data management Lu Baolu
2023-09-25 6:54 ` Tian, Kevin
2023-09-14 8:56 ` [PATCH v5 12/12] iommu: Improve iopf_queue_flush_dev() Lu Baolu
2023-09-25 7:00 ` Tian, Kevin
2023-09-26 1:49 ` Baolu Lu
2023-09-26 2:00 ` Tian, Kevin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d6f6dbad-c341-fe6b-a430-7bbf4bcfba31@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe@linaro.org \
--cc=jgg@ziepe.ca \
--cc=jingqi.liu@intel.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
--cc=yi.l.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox