From: Yi Liu <yi.l.liu@intel.com>
To: Ethan Zhao <haifeng.zhao@linux.intel.com>,
<baolu.lu@linux.intel.com>, <bhelgaas@google.com>,
<robin.murphy@arm.com>, <jgg@ziepe.ca>
Cc: <kevin.tian@intel.com>, <dwmw2@infradead.org>, <will@kernel.org>,
<lukas@wunner.de>, <iommu@lists.linux.dev>,
<linux-kernel@vger.kernel.org>, <linux-pci@vger.kernel.org>
Subject: Re: [PATCH v12 3/5] iommu/vt-d: simplify parameters of qi_submit_sync() ATS invalidation callers
Date: Mon, 29 Jan 2024 17:37:50 +0800 [thread overview]
Message-ID: <b7a8ee11-7fa7-4240-9d52-651f17bfe213@intel.com> (raw)
In-Reply-To: <20240129034924.817005-4-haifeng.zhao@linux.intel.com>
On 2024/1/29 11:49, Ethan Zhao wrote:
> fold parameters back to struct device_domain_info *info instead of extract
> and pass them, thus decrease the number of the parameter passed for
> following functions
>
> qi_flush_dev_iotlb()
> qi_flush_dev_iotlb_pasid()
> quirk_extra_dev_tlb_flush()
>
> no function change.
>
> Signed-off-by: Ethan Zhao <haifeng.zhao@linux.intel.com>
> ---
> drivers/iommu/intel/dmar.c | 26 ++++++++++++++++++++++----
> drivers/iommu/intel/iommu.c | 29 +++++++----------------------
> drivers/iommu/intel/iommu.h | 17 ++++++++---------
> drivers/iommu/intel/nested.c | 9 ++-------
> drivers/iommu/intel/pasid.c | 9 ++-------
> drivers/iommu/intel/svm.c | 17 ++++++++---------
> 6 files changed, 49 insertions(+), 58 deletions(-)
>
> diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
> index 23cb80d62a9a..ab5e1760bd59 100644
> --- a/drivers/iommu/intel/dmar.c
> +++ b/drivers/iommu/intel/dmar.c
> @@ -1517,11 +1517,20 @@ void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
> qi_submit_sync(iommu, &desc, 1, 0);
> }
>
> -void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,
> - u16 qdep, u64 addr, unsigned mask)
> +void qi_flush_dev_iotlb(struct intel_iommu *iommu,
> + struct device_domain_info *info, u64 addr,
If you want to fold the parameters, why iommu is left? info also includes
iommu pointer.
> + unsigned int mask)
> {
> + u16 sid, qdep, pfsid;
> struct qi_desc desc;
>
> + if (!info || !info->ats_enabled)
> + return;
> +
> + sid = info->bus << 8 | info->devfn;
> + qdep = info->ats_qdep;
> + pfsid = info->pfsid;
> +
> /*
> * VT-d spec, section 4.3:
> *
> @@ -1590,11 +1599,20 @@ void qi_flush_piotlb(struct intel_iommu *iommu, u16 did, u32 pasid, u64 addr,
> }
>
> /* PASID-based device IOTLB Invalidate */
> -void qi_flush_dev_iotlb_pasid(struct intel_iommu *iommu, u16 sid, u16 pfsid,
> - u32 pasid, u16 qdep, u64 addr, unsigned int size_order)
> +void qi_flush_dev_iotlb_pasid(struct intel_iommu *iommu,
> + struct device_domain_info *info, u64 addr, u32 pasid,
> + unsigned int size_order)
> {
> unsigned long mask = 1UL << (VTD_PAGE_SHIFT + size_order - 1);
> struct qi_desc desc = {.qw1 = 0, .qw2 = 0, .qw3 = 0};
> + u16 sid, qdep, pfsid;
> +
> + if (!info || !dev_is_pci(info->dev))
> + return;
> +
> + sid = info->bus << 8 | info->devfn;
> + qdep = info->ats_qdep;
> + pfsid = info->pfsid;
>
> /*
> * VT-d spec, section 4.3:
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 6fb5f6fceea1..e5902944b3db 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -1310,16 +1310,11 @@ static void iommu_disable_pci_caps(struct device_domain_info *info)
> static void __iommu_flush_dev_iotlb(struct device_domain_info *info,
> u64 addr, unsigned int mask)
> {
> - u16 sid, qdep;
> -
> if (!info || !info->ats_enabled)
> return;
>
> - sid = info->bus << 8 | info->devfn;
> - qdep = info->ats_qdep;
> - qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> - qdep, addr, mask);
> - quirk_extra_dev_tlb_flush(info, addr, mask, IOMMU_NO_PASID, qdep);
> + qi_flush_dev_iotlb(info->iommu, info, addr, mask);
> + quirk_extra_dev_tlb_flush(info, addr, IOMMU_NO_PASID, mask);
> }
>
> static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
> @@ -1342,11 +1337,7 @@ static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
> if (!info->ats_enabled)
> continue;
>
> - qi_flush_dev_iotlb_pasid(info->iommu,
> - PCI_DEVID(info->bus, info->devfn),
> - info->pfsid, dev_pasid->pasid,
> - info->ats_qdep, addr,
> - mask);
> + qi_flush_dev_iotlb_pasid(info->iommu, info, addr, dev_pasid->pasid, mask);
> }
> spin_unlock_irqrestore(&domain->lock, flags);
> }
> @@ -4990,22 +4981,16 @@ static void __init check_tylersburg_isoch(void)
> *
> * As a reminder, #6 will *NEED* this quirk as we enable nested translation.
> */
> -void quirk_extra_dev_tlb_flush(struct device_domain_info *info,
> - unsigned long address, unsigned long mask,
> - u32 pasid, u16 qdep)
> +void quirk_extra_dev_tlb_flush(struct device_domain_info *info, u32 pasid,
> + unsigned long address, unsigned long mask)
> {
> - u16 sid;
> -
> if (likely(!info->dtlb_extra_inval))
> return;
>
> - sid = PCI_DEVID(info->bus, info->devfn);
> if (pasid == IOMMU_NO_PASID) {
> - qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> - qdep, address, mask);
> + qi_flush_dev_iotlb(info->iommu, info, address, mask);
> } else {
> - qi_flush_dev_iotlb_pasid(info->iommu, sid, info->pfsid,
> - pasid, qdep, address, mask);
> + qi_flush_dev_iotlb_pasid(info->iommu, info, address, pasid, mask);
> }
> }
>
> diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h
> index d02f916d8e59..f68f17476d85 100644
> --- a/drivers/iommu/intel/iommu.h
> +++ b/drivers/iommu/intel/iommu.h
> @@ -1037,18 +1037,17 @@ void qi_flush_context(struct intel_iommu *iommu, u16 did,
> u16 sid, u8 fm, u64 type);
> void qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
> unsigned int size_order, u64 type);
> -void qi_flush_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 pfsid,
> - u16 qdep, u64 addr, unsigned mask);
> -
> +void qi_flush_dev_iotlb(struct intel_iommu *iommu,
> + struct device_domain_info *info, u64 addr,
> + unsigned int mask);
> void qi_flush_piotlb(struct intel_iommu *iommu, u16 did, u32 pasid, u64 addr,
> unsigned long npages, bool ih);
>
> -void qi_flush_dev_iotlb_pasid(struct intel_iommu *iommu, u16 sid, u16 pfsid,
> - u32 pasid, u16 qdep, u64 addr,
> - unsigned int size_order);
> -void quirk_extra_dev_tlb_flush(struct device_domain_info *info,
> - unsigned long address, unsigned long pages,
> - u32 pasid, u16 qdep);
> +void qi_flush_dev_iotlb_pasid(struct intel_iommu *iommu,
> + struct device_domain_info *info, u64 addr,
> + u32 pasid, unsigned int size_order);
> +void quirk_extra_dev_tlb_flush(struct device_domain_info *info, u32 pasid,
> + unsigned long address, unsigned long mask);
> void qi_flush_pasid_cache(struct intel_iommu *iommu, u16 did, u64 granu,
> u32 pasid);
>
> diff --git a/drivers/iommu/intel/nested.c b/drivers/iommu/intel/nested.c
> index f26c7f1c46cc..d15f72b55940 100644
> --- a/drivers/iommu/intel/nested.c
> +++ b/drivers/iommu/intel/nested.c
> @@ -78,18 +78,13 @@ static void nested_flush_dev_iotlb(struct dmar_domain *domain, u64 addr,
> {
> struct device_domain_info *info;
> unsigned long flags;
> - u16 sid, qdep;
>
> spin_lock_irqsave(&domain->lock, flags);
> list_for_each_entry(info, &domain->devices, link) {
> if (!info->ats_enabled)
> continue;
> - sid = info->bus << 8 | info->devfn;
> - qdep = info->ats_qdep;
> - qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> - qdep, addr, mask);
> - quirk_extra_dev_tlb_flush(info, addr, mask,
> - IOMMU_NO_PASID, qdep);
> + qi_flush_dev_iotlb(info->iommu, info, addr, mask);
> + quirk_extra_dev_tlb_flush(info, IOMMU_NO_PASID, addr, mask);
> }
> spin_unlock_irqrestore(&domain->lock, flags);
> }
> diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
> index 953592125e4a..5dacdea3cab7 100644
> --- a/drivers/iommu/intel/pasid.c
> +++ b/drivers/iommu/intel/pasid.c
> @@ -208,7 +208,6 @@ devtlb_invalidation_with_pasid(struct intel_iommu *iommu,
> struct device *dev, u32 pasid)
> {
> struct device_domain_info *info;
> - u16 sid, qdep, pfsid;
>
> info = dev_iommu_priv_get(dev);
> if (!info || !info->ats_enabled)
> @@ -217,10 +216,6 @@ devtlb_invalidation_with_pasid(struct intel_iommu *iommu,
> if (pci_dev_is_disconnected(to_pci_dev(dev)))
> return;
>
> - sid = info->bus << 8 | info->devfn;
> - qdep = info->ats_qdep;
> - pfsid = info->pfsid;
> -
> /*
> * When PASID 0 is used, it indicates RID2PASID(DMA request w/o PASID),
> * devTLB flush w/o PASID should be used. For non-zero PASID under
> @@ -228,9 +223,9 @@ devtlb_invalidation_with_pasid(struct intel_iommu *iommu,
> * efficient to flush devTLB specific to the PASID.
> */
> if (pasid == IOMMU_NO_PASID)
> - qi_flush_dev_iotlb(iommu, sid, pfsid, qdep, 0, 64 - VTD_PAGE_SHIFT);
> + qi_flush_dev_iotlb(iommu, info, 0, 64 - VTD_PAGE_SHIFT);
> else
> - qi_flush_dev_iotlb_pasid(iommu, sid, pfsid, pasid, qdep, 0, 64 - VTD_PAGE_SHIFT);
> + qi_flush_dev_iotlb_pasid(iommu, info, 0, pasid, 64 - VTD_PAGE_SHIFT);
> }
>
> void intel_pasid_tear_down_entry(struct intel_iommu *iommu, struct device *dev,
> diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
> index 40edd282903f..89168b31bf31 100644
> --- a/drivers/iommu/intel/svm.c
> +++ b/drivers/iommu/intel/svm.c
> @@ -181,11 +181,10 @@ static void __flush_svm_range_dev(struct intel_svm *svm,
>
> qi_flush_piotlb(sdev->iommu, sdev->did, svm->pasid, address, pages, ih);
> if (info->ats_enabled) {
> - qi_flush_dev_iotlb_pasid(sdev->iommu, sdev->sid, info->pfsid,
> - svm->pasid, sdev->qdep, address,
> + qi_flush_dev_iotlb_pasid(sdev->iommu, info, address, svm->pasid,
> order_base_2(pages));
> - quirk_extra_dev_tlb_flush(info, address, order_base_2(pages),
> - svm->pasid, sdev->qdep);
> + quirk_extra_dev_tlb_flush(info, svm->pasid, address,
> + order_base_2(pages));
> }
> }
>
> @@ -227,11 +226,11 @@ static void intel_flush_svm_all(struct intel_svm *svm)
>
> qi_flush_piotlb(sdev->iommu, sdev->did, svm->pasid, 0, -1UL, 0);
> if (info->ats_enabled) {
> - qi_flush_dev_iotlb_pasid(sdev->iommu, sdev->sid, info->pfsid,
> - svm->pasid, sdev->qdep,
> - 0, 64 - VTD_PAGE_SHIFT);
> - quirk_extra_dev_tlb_flush(info, 0, 64 - VTD_PAGE_SHIFT,
> - svm->pasid, sdev->qdep);
> + qi_flush_dev_iotlb_pasid(sdev->iommu, info, 0,
> + svm->pasid,
> + 64 - VTD_PAGE_SHIFT);
> + quirk_extra_dev_tlb_flush(info, svm->pasid, 0,
> + 64 - VTD_PAGE_SHIFT);
> }
> }
> rcu_read_unlock();
--
Regards,
Yi Liu
next prev parent reply other threads:[~2024-01-29 9:34 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-29 3:49 [PATCH v12 0/5] fix vt-d hard lockup when hotplug ATS capable device Ethan Zhao
2024-01-29 3:49 ` [PATCH v12 1/5] PCI: make pci_dev_is_disconnected() helper public for other drivers Ethan Zhao
2024-01-29 8:50 ` Tian, Kevin
2024-01-30 5:23 ` Ethan Zhao
2024-01-30 5:25 ` Ethan Zhao
2024-01-30 6:23 ` Tian, Kevin
2024-01-29 3:49 ` [PATCH v12 2/5] iommu/vt-d: don't issue ATS Invalidation request when device is disconnected Ethan Zhao
2024-01-29 8:53 ` Tian, Kevin
2024-01-29 9:32 ` Yi Liu
2024-01-30 5:37 ` Ethan Zhao
2024-01-31 4:25 ` Yi Liu
2024-01-31 5:25 ` Ethan Zhao
2024-01-29 3:49 ` [PATCH v12 3/5] iommu/vt-d: simplify parameters of qi_submit_sync() ATS invalidation callers Ethan Zhao
2024-01-29 9:37 ` Yi Liu [this message]
2024-01-30 5:43 ` Ethan Zhao
2024-01-29 3:49 ` [PATCH v12 4/5] iommu/vt-d: pass pdev parameter for qi_check_fault() and refactor callers Ethan Zhao
2024-01-29 8:58 ` Tian, Kevin
2024-01-30 7:30 ` Ethan Zhao
2024-02-08 7:15 ` Dan Carpenter
2024-02-09 2:08 ` Ethan Zhao
2024-01-29 3:49 ` [PATCH v12 5/5] iommu/vt-d: improve ITE fault handling if target device isn't present Ethan Zhao
2024-01-29 9:06 ` Tian, Kevin
2024-01-29 9:21 ` Yi Liu
2024-01-30 5:12 ` Ethan Zhao
2024-01-30 6:22 ` Tian, Kevin
2024-01-30 8:15 ` Ethan Zhao
2024-01-30 8:43 ` Tian, Kevin
2024-01-30 9:13 ` Ethan Zhao
2024-01-30 9:24 ` Tian, Kevin
2024-01-31 5:42 ` Ethan Zhao
2024-01-30 16:29 ` Jason Gunthorpe
2024-01-31 6:21 ` Baolu Lu
2024-02-01 19:34 ` Jason Gunthorpe
2024-02-15 7:37 ` Baolu Lu
2024-01-29 14:48 ` Baolu Lu
2024-01-30 3:28 ` Tian, Kevin
2024-01-30 8:43 ` Ethan Zhao
2024-01-29 9:33 ` Yi Liu
2024-01-29 5:16 ` [PATCH v12 0/5] fix vt-d hard lockup when hotplug ATS capable device Ethan Zhao
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=b7a8ee11-7fa7-4240-9d52-651f17bfe213@intel.com \
--to=yi.l.liu@intel.com \
--cc=baolu.lu@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=dwmw2@infradead.org \
--cc=haifeng.zhao@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/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