Skip to content

Commit a82efb8

Browse files
Shameer Kolothumjoergroedel
authored andcommitted
iommu: Add device ATS supported capability
PCIe ATS may be disabled by platform firmware, root complex limitations, or kernel policy even when a device advertises the ATS capability in its PCI configuration space. Add a new IOMMU_CAP_PCI_ATS_SUPPORTED capability to allow IOMMU drivers to report the effective ATS decision for a device. When this capability is true for a device, ATS may be enabled for that device, but it does not imply that ATS is currently enabled. A subsequent patch will extend iommufd to expose the effective ATS status to userspace. Suggested-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent d6c65b0 commit a82efb8

4 files changed

Lines changed: 13 additions & 0 deletions

File tree

drivers/iommu/amd/iommu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,6 +2985,12 @@ static bool amd_iommu_capable(struct device *dev, enum iommu_cap cap)
29852985

29862986
return amd_iommu_hd_support(iommu);
29872987
}
2988+
case IOMMU_CAP_PCI_ATS_SUPPORTED: {
2989+
struct iommu_dev_data *dev_data = dev_iommu_priv_get(dev);
2990+
2991+
return amd_iommu_iotlb_sup &&
2992+
(dev_data->flags & AMD_IOMMU_DEVICE_FLAG_ATS_SUP);
2993+
}
29882994
default:
29892995
break;
29902996
}

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ static const char * const event_class_str[] = {
107107
};
108108

109109
static int arm_smmu_alloc_cd_tables(struct arm_smmu_master *master);
110+
static bool arm_smmu_ats_supported(struct arm_smmu_master *master);
110111

111112
static void parse_driver_options(struct arm_smmu_device *smmu)
112113
{
@@ -2494,6 +2495,8 @@ static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap)
24942495
return true;
24952496
case IOMMU_CAP_DIRTY_TRACKING:
24962497
return arm_smmu_dbm_capable(master->smmu);
2498+
case IOMMU_CAP_PCI_ATS_SUPPORTED:
2499+
return arm_smmu_ats_supported(master);
24972500
default:
24982501
return false;
24992502
}

drivers/iommu/intel/iommu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,6 +3220,8 @@ static bool intel_iommu_capable(struct device *dev, enum iommu_cap cap)
32203220
return ecap_sc_support(info->iommu->ecap);
32213221
case IOMMU_CAP_DIRTY_TRACKING:
32223222
return ssads_supported(info->iommu);
3223+
case IOMMU_CAP_PCI_ATS_SUPPORTED:
3224+
return info->ats_supported;
32233225
default:
32243226
return false;
32253227
}

include/linux/iommu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ enum iommu_cap {
272272
*/
273273
IOMMU_CAP_DEFERRED_FLUSH,
274274
IOMMU_CAP_DIRTY_TRACKING, /* IOMMU supports dirty tracking */
275+
/* ATS is supported and may be enabled for this device */
276+
IOMMU_CAP_PCI_ATS_SUPPORTED,
275277
};
276278

277279
/* These are the possible reserved region types */

0 commit comments

Comments
 (0)