mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, "Liu, Jingqi" <jingqi.liu@intel.com>
Cc: baolu.lu@linux.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 10:44:45 +0800	[thread overview]
Message-ID: <e7c773f6-969c-0097-1bca-24d276e8a8f6@linux.intel.com> (raw)
In-Reply-To: <20230921233402.GC13795@ziepe.ca>



On 9/22/23 7:34 AM, Jason Gunthorpe wrote:
> On Thu, Sep 21, 2023 at 11:25:56PM +0800, Liu, Jingqi wrote:
>>
>> On 9/14/2023 4:56 PM, Lu Baolu wrote:
>>> Make iommu_queue_iopf() more generic by making the iopf_group a minimal
>>> set of iopf's that an iopf handler of domain should handle and respond
>>> to. Add domain parameter to struct iopf_group so that the handler can
>>> retrieve and use it directly.
>>>
>>> Change iommu_queue_iopf() to forward groups of iopf's to the domain's
>>> iopf handler. This is also a necessary step to decouple the sva iopf
>>> handling code from this interface.
>>>
>>> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
>>> ---
>>>    include/linux/iommu.h      |  4 ++--
>>>    drivers/iommu/iommu-sva.h  |  6 ++---
>>>    drivers/iommu/io-pgfault.c | 49 ++++++++++++++++++++++++++++----------
>>>    drivers/iommu/iommu-sva.c  |  3 +--
>>>    4 files changed, 42 insertions(+), 20 deletions(-)
>>>
>> ......
>>
>>> @@ -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.

Best regards,
baolu

  reply	other threads:[~2023-09-22  2: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 [this message]
2023-09-22 12:43         ` Jason Gunthorpe
2023-09-22 12:47           ` Baolu Lu
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=e7c773f6-969c-0097-1bca-24d276e8a8f6@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

Powered by JetHome