Skip to contentSkip to conversation

iommu/vt-d: Fix intel_pasid_max_id

PATCH In review Eric Auger 2 participants 3 messages Apr 30, 2019 IOMMU

lore
Share & tools
lore

Eric Auger

author
#0 lore raw

PATCH 1/1 iommu/vt-d: Fix intel_pasid_max_id

Extended Capability Register PSS field (PASID Size Supported) corresponds to the PASID bit size -1.

"A value of N in this field indicates hardware supports PASID field of N+1 bits (For example, value of 7 in this field, indicates 8-bit PASIDs are supported)".

Fix the computation of intel_pasid_max_id accordingly.

Fixes 562831747f62 ("iommu/vt-d: Global PASID name space")
---
 drivers/iommu/intel-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +1 -1
index 28cb713d728c..c3f1bfc81d2e 100644
@@ -3331,7 +3331,7 @@ static int __init init_dmars(void)
 		 * than the smallest supported.
 		 */
 		if (pasid_supported(iommu)) {
-			u32 temp = 2 << ecap_pss(iommu->ecap);
+			u32 temp = 2 << (ecap_pss(iommu->ecap) + 1);
 
 			intel_pasid_max_id = min_t(u32, temp,
 						   intel_pasid_max_id);
Signature · 1 line
2.20.1
#1 lore raw
Quoted 21 lines · On Tue, 30 Apr 2019 09:29:40 +0200 Eric Auger <[email protected]> wrote:

Extended Capability Register PSS field (PASID Size Supported) corresponds to the PASID bit size -1.

"A value of N in this field indicates hardware supports PASID field of N+1 bits (For example, value of 7 in this field, indicates 8-bit PASIDs are supported)".

Fix the computation of intel_pasid_max_id accordingly.

Fixes 562831747f62 ("iommu/vt-d: Global PASID name space")
---
 drivers/iommu/intel-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +0 -0
index 28cb713d728c..c3f1bfc81d2e 100644

drivers/iommu/intel-iommu.c static int __init init_dmars(void) · line 3334

Quoted 5 lines
drivers/iommu/intel-iommu.c +1 -1
@@ -3331,7 +3331,7 @@ static int __init init_dmars(void)
 		 * than the smallest supported.
 		 */
 		if (pasid_supported(iommu)) {
-			u32 temp = 2 << ecap_pss(iommu->ecap);
+			u32 temp = 2 << (ecap_pss(iommu->ecap) + 1);

here it is "2 << bits" not "1 << bits", so the original code is correct.

But I agree it would be more clear to the spec. if we do:
1 << (ecap_pss(iommu->ecap) + 1);

Quoted 3 lines
drivers/iommu/intel-iommu.c +0 -0
 			intel_pasid_max_id = min_t(u32, temp,
 						   intel_pasid_max_id);
author
#2 lore raw

Hi Jacob,

Quoted 31 lines · Jacob Pan
Quoted 21 lines · On Tue, 30 Apr 2019 09:29:40 +0200 Eric Auger <[email protected]> wrote:

Extended Capability Register PSS field (PASID Size Supported) corresponds to the PASID bit size -1.

"A value of N in this field indicates hardware supports PASID field of N+1 bits (For example, value of 7 in this field, indicates 8-bit PASIDs are supported)".

Fix the computation of intel_pasid_max_id accordingly.

Fixes 562831747f62 ("iommu/vt-d: Global PASID name space")
---
 drivers/iommu/intel-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +0 -0
index 28cb713d728c..c3f1bfc81d2e 100644

drivers/iommu/intel-iommu.c static int __init init_dmars(void) · line 3334

Quoted 5 lines
drivers/iommu/intel-iommu.c +1 -1
@@ -3331,7 +3331,7 @@ static int __init init_dmars(void)
 		 * than the smallest supported.
 		 */
 		if (pasid_supported(iommu)) {
-			u32 temp = 2 << ecap_pss(iommu->ecap);
+			u32 temp = 2 << (ecap_pss(iommu->ecap) + 1);

here it is "2 << bits" not "1 << bits", so the original code is correct.

Quoted 2 lines

But I agree it would be more clear to the spec. if we do:
1 << (ecap_pss(iommu->ecap) + 1);

Oups OK, my eyes. Forget it :-(

Thanks

Eric

Quoted 4 lines
Quoted 3 lines
drivers/iommu/intel-iommu.c +0 -0
 			intel_pasid_max_id = min_t(u32, temp,
 						   intel_pasid_max_id);