From: Baolu Lu <baolu.lu@linux.intel.com>
To: Tina Zhang <tina.zhang@intel.com>, iommu@lists.linux.dev
Cc: baolu.lu@linux.intel.com, Kevin Tian <kevin.tian@intel.com>
Subject: Re: [PATCH 09/11] iommu/vt-d: Reuse intel_iommu_set_dev_pasid function
Date: Wed, 17 Jan 2024 15:40:12 +0800 [thread overview]
Message-ID: <5f57c685-04ab-4c70-b305-aa42b97b703a@linux.intel.com> (raw)
In-Reply-To: <20240116011146.18645-10-tina.zhang@intel.com>
On 2024/1/16 9:11, Tina Zhang wrote:
> Refactor intel_iommu_set_dev_pasid() and make it be reused by sva domain
> as the set_dev_pasid operation.
>
> Signed-off-by: Tina Zhang <tina.zhang@intel.com>
> ---
> drivers/iommu/intel/iommu.c | 43 ++++++++++++++++++++++++++-----------
> drivers/iommu/intel/iommu.h | 2 ++
> drivers/iommu/intel/svm.c | 42 +-----------------------------------
> 3 files changed, 33 insertions(+), 54 deletions(-)
>
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index af466ba301b7..8d1b9de78a43 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -4574,7 +4574,7 @@ static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid)
> intel_drain_pasid_prq(dev, pasid);
> }
>
> -static int intel_iommu_set_dev_pasid(struct iommu_domain *domain,
> +int intel_iommu_set_dev_pasid(struct iommu_domain *domain,
> struct device *dev, ioasid_t pasid)
> {
> struct device_domain_info *info = dev_iommu_priv_get(dev);
> @@ -4593,31 +4593,48 @@ static int intel_iommu_set_dev_pasid(struct iommu_domain *domain,
> if (context_copied(iommu, info->bus, info->devfn))
> return -EBUSY;
>
> - ret = prepare_domain_attach_device(domain, dev);
> - if (ret)
> - return ret;
> -
> dev_pasid = kzalloc(sizeof(*dev_pasid), GFP_KERNEL);
> if (!dev_pasid)
> return -ENOMEM;
>
> - ret = domain_attach_iommu(dmar_domain, iommu);
> - if (ret)
> - goto out_free;
> + dev_pasid->dev = dev;
> + dev_pasid->pasid = pasid;
> + if (domain_type_is_sva(dmar_domain)) {
> + dev_pasid->did = FLPT_DEFAULT_DID;
> + dev_pasid->sid = PCI_DEVID(info->bus, info->devfn);
> + if (info->ats_enabled) {
> + dev_pasid->qdep = info->ats_qdep;
> + if (dev_pasid->qdep >= QI_DEV_EIOTLB_MAX_INVS)
> + dev_pasid->qdep = 0;
> + }
This is generic device information. There's no need to do it only for
the SVA domain; otherwise, you'll have to check the domain type every
time you use these fields.
> + } else {
> + ret = prepare_domain_attach_device(domain, dev);
The prepare_domain_attach_device() function is called to check whether
the device is compatible with the domain to be attached. You could make
it work for the SVA domain as well, rather than ignoring it.
> + if (ret)
> + goto out_free;
> +
> + ret = domain_attach_iommu(dmar_domain, iommu);
The same here.
The domain_attach_iommu() is called to setup the relationship between a
domain and an iommu. You should make it compatible with sva domain as
well.
Best regards,
baolu
next prev parent reply other threads:[~2024-01-17 7:40 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-16 1:11 [PATCH 00/11] iommu/vt-d: Remove superfluous IOMMU IOTLB invalidations Tina Zhang
2024-01-16 1:11 ` [PATCH 01/11] iommu/vt-d: Retire the treatment for revoking PASIDs with pending pgfaults Tina Zhang
2024-01-16 1:11 ` [PATCH 02/11] iommu/vt-d: Remove initialization for dynamically heap-allocated rcu_head Tina Zhang
2024-01-16 1:11 ` [PATCH 03/11] iommu/vt-d: Refactor intel_svm_set_dev_pasid function Tina Zhang
2024-01-16 1:11 ` [PATCH 04/11] iommu/vt-d: Retire struct intel_svm_dev Tina Zhang
2024-01-17 7:20 ` Baolu Lu
2024-01-30 3:04 ` Zhang, Tina
2024-02-16 3:28 ` Zhang, Tina
2024-01-16 1:11 ` [PATCH 05/11] iommu: Add ops->domain_alloc_sva() Tina Zhang
2024-01-16 1:11 ` [PATCH 06/11] iommu/vt-d: Retire struct intel_svm Tina Zhang
2024-01-16 1:11 ` [PATCH 07/11] iommu/vt-d: Use RCU for dev_pasids list updates in set/remove_dev_pasid() Tina Zhang
2024-01-17 7:30 ` Baolu Lu
2024-01-16 1:11 ` [PATCH 08/11] iommu/vt-d: Add domain_type_is_sva helper function Tina Zhang
2024-01-17 7:32 ` Baolu Lu
2024-02-19 0:13 ` Zhang, Tina
2024-02-19 1:05 ` Baolu Lu
2024-01-16 1:11 ` [PATCH 09/11] iommu/vt-d: Reuse intel_iommu_set_dev_pasid function Tina Zhang
2024-01-17 7:40 ` Baolu Lu [this message]
2024-02-19 1:01 ` Zhang, Tina
2024-02-19 1:17 ` Baolu Lu
2024-01-16 1:11 ` [PATCH 10/11] iommu/vt-d: Retire intel_svm_remove_dev_pasid function Tina Zhang
2024-01-16 1:11 ` [PATCH 11/11] iommu/vt-d: Remove superfluous IOMMU IOTLB invalidations Tina Zhang
2024-01-17 7:59 ` Baolu Lu
2024-02-16 5:38 ` Zhang, Tina
2024-02-18 9:19 ` Baolu Lu
2024-02-18 13:09 ` Zhang, Tina
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=5f57c685-04ab-4c70-b305-aa42b97b703a@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=kevin.tian@intel.com \
--cc=tina.zhang@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