]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/amd: Add support for enabling/disabling IOMMU features
authorWei Huang <wei.huang2@amd.com>
Thu, 18 Apr 2024 10:33:48 +0000 (10:33 +0000)
committerJoerg Roedel <jroedel@suse.de>
Fri, 26 Apr 2024 10:15:57 +0000 (12:15 +0200)
Add support for struct iommu_ops.dev_{enable/disable}_feat. Please note
that the empty feature switches will be populated by subsequent patches.

Signed-off-by: Wei Huang <wei.huang2@amd.com>
Co-developed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20240418103400.6229-4-vasant.hegde@amd.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/iommu.c

index 394623abbaa487368f61b7709a955f7bde2c01c3..a22ecd8479dbe62cb1ac5b70133e95855b4fa635 100644 (file)
@@ -2791,6 +2791,32 @@ static const struct iommu_dirty_ops amd_dirty_ops = {
        .read_and_clear_dirty = amd_iommu_read_and_clear_dirty,
 };
 
+static int amd_iommu_dev_enable_feature(struct device *dev,
+                                       enum iommu_dev_features feat)
+{
+       int ret;
+
+       switch (feat) {
+       default:
+               ret = -EINVAL;
+               break;
+       }
+       return ret;
+}
+
+static int amd_iommu_dev_disable_feature(struct device *dev,
+                                        enum iommu_dev_features feat)
+{
+       int ret;
+
+       switch (feat) {
+       default:
+               ret = -EINVAL;
+               break;
+       }
+       return ret;
+}
+
 const struct iommu_ops amd_iommu_ops = {
        .capable = amd_iommu_capable,
        .domain_alloc = amd_iommu_domain_alloc,
@@ -2803,6 +2829,8 @@ const struct iommu_ops amd_iommu_ops = {
        .is_attach_deferred = amd_iommu_is_attach_deferred,
        .pgsize_bitmap  = AMD_IOMMU_PGSIZES,
        .def_domain_type = amd_iommu_def_domain_type,
+       .dev_enable_feat = amd_iommu_dev_enable_feature,
+       .dev_disable_feat = amd_iommu_dev_disable_feature,
        .default_domain_ops = &(const struct iommu_domain_ops) {
                .attach_dev     = amd_iommu_attach_device,
                .map_pages      = amd_iommu_map_pages,