[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <A2975661238FB949B60364EF0F2C257439BE753A@SHSMSX104.ccr.corp.intel.com>
Date: Tue, 1 May 2018 09:22:31 +0000
From: "Liu, Yi L" <yi.l.liu@...el.com>
To: Lu Baolu <baolu.lu@...ux.intel.com>,
David Woodhouse <dwmw2@...radead.org>,
Joerg Roedel <joro@...tes.org>
CC: "Raj, Ashok" <ashok.raj@...el.com>,
"Kumar, Sanjay K" <sanjay.k.kumar@...el.com>,
"Pan, Jacob jun" <jacob.jun.pan@...el.com>,
"Tian, Kevin" <kevin.tian@...el.com>,
"Sun, Yi Y" <yi.y.sun@...el.com>,
"iommu@...ts.linux-foundation.org" <iommu@...ts.linux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Jacob Pan <jacob.jun.pan@...ux.intel.com>
Subject: RE: [PATCH 7/9] iommu/vt-d: Calculate PTS value
> From: Lu Baolu [mailto:baolu.lu@...ux.intel.com]
> Sent: Tuesday, April 17, 2018 11:03 AM
>
> Calculate PTS (PASID Table Size) value for the extended
> context entry from the real size of the PASID table for
> a domain.
>
> Cc: Ashok Raj <ashok.raj@...el.com>
> Cc: Jacob Pan <jacob.jun.pan@...ux.intel.com>
> Cc: Kevin Tian <kevin.tian@...el.com>
> Cc: Liu Yi L <yi.l.liu@...el.com>
> Signed-off-by: Lu Baolu <baolu.lu@...ux.intel.com>
Looks good to me.
Reviewed-by: Liu, Yi L <yi.l.liu@...el.com>
Regards,
Yi Liu
> ---
> drivers/iommu/intel-iommu.c | 22 ++++++++--------------
> 1 file changed, 8 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 99c643b..d4f9cea 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -5146,22 +5146,16 @@ static void intel_iommu_put_resv_regions(struct device
> *dev,
>
> #ifdef CONFIG_INTEL_IOMMU_SVM
> #define MAX_NR_PASID_BITS (20)
> -static inline unsigned long intel_iommu_get_pts(struct intel_iommu *iommu)
> +static inline unsigned long intel_iommu_get_pts(struct dmar_domain *domain)
> {
> - /*
> - * Convert ecap_pss to extend context entry pts encoding, also
> - * respect the soft pasid_max value set by the iommu.
> - * - number of PASID bits = ecap_pss + 1
> - * - number of PASID table entries = 2^(pts + 5)
> - * Therefore, pts = ecap_pss - 4
> - * e.g. KBL ecap_pss = 0x13, PASID has 20 bits, pts = 15
> - */
> - if (ecap_pss(iommu->ecap) < 5)
> + int pts;
> +
> + pts = find_first_bit((unsigned long *)&domain->max_pasid,
> + MAX_NR_PASID_BITS);
> + if (pts < 5)
> return 0;
>
> - /* pasid_max is encoded as actual number of entries not the bits */
> - return find_first_bit((unsigned long *)&iommu->pasid_max,
> - MAX_NR_PASID_BITS) - 5;
> + return pts - 5;
> }
>
> int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev
> *sdev)
> @@ -5198,7 +5192,7 @@ int intel_iommu_enable_pasid(struct intel_iommu
> *iommu, struct intel_svm_dev *sd
> if (iommu->pasid_state_table)
> context[1].hi = (u64)virt_to_phys(iommu-
> >pasid_state_table);
> context[1].lo = (u64)virt_to_phys(iommu->pasid_table) |
> - intel_iommu_get_pts(iommu);
> + intel_iommu_get_pts(domain);
>
> wmb();
> /* CONTEXT_TT_MULTI_LEVEL and CONTEXT_TT_DEV_IOTLB are
> both
> --
> 2.7.4
Powered by blists - more mailing lists