aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/iommu/intel-iommu.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index d8376c2d18b3..96566d504d2a 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -5197,6 +5197,25 @@ static void intel_iommu_remove_device(struct device *dev)
5197} 5197}
5198 5198
5199#ifdef CONFIG_INTEL_IOMMU_SVM 5199#ifdef CONFIG_INTEL_IOMMU_SVM
5200#define MAX_NR_PASID_BITS (20)
5201static inline unsigned long intel_iommu_get_pts(struct intel_iommu *iommu)
5202{
5203 /*
5204 * Convert ecap_pss to extend context entry pts encoding, also
5205 * respect the soft pasid_max value set by the iommu.
5206 * - number of PASID bits = ecap_pss + 1
5207 * - number of PASID table entries = 2^(pts + 5)
5208 * Therefore, pts = ecap_pss - 4
5209 * e.g. KBL ecap_pss = 0x13, PASID has 20 bits, pts = 15
5210 */
5211 if (ecap_pss(iommu->ecap) < 5)
5212 return 0;
5213
5214 /* pasid_max is encoded as actual number of entries not the bits */
5215 return find_first_bit((unsigned long *)&iommu->pasid_max,
5216 MAX_NR_PASID_BITS) - 5;
5217}
5218
5200int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sdev) 5219int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sdev)
5201{ 5220{
5202 struct device_domain_info *info; 5221 struct device_domain_info *info;
@@ -5229,7 +5248,9 @@ int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sd
5229 5248
5230 if (!(ctx_lo & CONTEXT_PASIDE)) { 5249 if (!(ctx_lo & CONTEXT_PASIDE)) {
5231 context[1].hi = (u64)virt_to_phys(iommu->pasid_state_table); 5250 context[1].hi = (u64)virt_to_phys(iommu->pasid_state_table);
5232 context[1].lo = (u64)virt_to_phys(iommu->pasid_table) | ecap_pss(iommu->ecap); 5251 context[1].lo = (u64)virt_to_phys(iommu->pasid_table) |
5252 intel_iommu_get_pts(iommu);
5253
5233 wmb(); 5254 wmb();
5234 /* CONTEXT_TT_MULTI_LEVEL and CONTEXT_TT_DEV_IOTLB are both 5255 /* CONTEXT_TT_MULTI_LEVEL and CONTEXT_TT_DEV_IOTLB are both
5235 * extended to permit requests-with-PASID if the PASIDE bit 5256 * extended to permit requests-with-PASID if the PASIDE bit