]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/amd: Add helper function to check GIOSUP/GTSUP
authorVasant Hegde <vasant.hegde@amd.com>
Mon, 28 Oct 2024 09:38:03 +0000 (09:38 +0000)
committerJoerg Roedel <jroedel@suse.de>
Tue, 29 Oct 2024 09:08:20 +0000 (10:08 +0100)
amd_iommu_gt_ppr_supported() only checks for GTSUP. To support PASID
with V2 page table we need GIOSUP as well. Hence add new helper function
to check GIOSUP/GTSUP.

Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20241028093810.5901-6-vasant.hegde@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/amd_iommu.h
drivers/iommu/amd/init.c

index 6386fa4556d9b8060544264d98b6af30c8d4de46..3b6c6332b09fb8801a8dd4ebc267d11e25c48721 100644 (file)
@@ -118,9 +118,14 @@ static inline bool check_feature2(u64 mask)
        return (amd_iommu_efr2 & mask);
 }
 
+static inline bool amd_iommu_v2_pgtbl_supported(void)
+{
+       return (check_feature(FEATURE_GIOSUP) && check_feature(FEATURE_GT));
+}
+
 static inline bool amd_iommu_gt_ppr_supported(void)
 {
-       return (check_feature(FEATURE_GT) &&
+       return (amd_iommu_v2_pgtbl_supported() &&
                check_feature(FEATURE_PPR) &&
                check_feature(FEATURE_EPHSUP));
 }
index 43131c3a21726f3360de6ba843ed30048343cbbf..7ae478d95e2bdbaf975546a06df47914532fa563 100644 (file)
@@ -2071,8 +2071,7 @@ static int __init iommu_init_pci(struct amd_iommu *iommu)
        init_iommu_perf_ctr(iommu);
 
        if (amd_iommu_pgtable == AMD_IOMMU_V2) {
-               if (!check_feature(FEATURE_GIOSUP) ||
-                   !check_feature(FEATURE_GT)) {
+               if (!amd_iommu_v2_pgtbl_supported()) {
                        pr_warn("Cannot enable v2 page table for DMA-API. Fallback to v1.\n");
                        amd_iommu_pgtable = AMD_IOMMU_V1;
                }