]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/vt-d: Make the blocked domain support PASID
authorYi Liu <yi.l.liu@intel.com>
Wed, 4 Dec 2024 12:29:26 +0000 (04:29 -0800)
committerJoerg Roedel <jroedel@suse.de>
Wed, 18 Dec 2024 08:39:36 +0000 (09:39 +0100)
The blocked domain can be extended to park PASID of a device to be the
DMA blocking state. By this the remove_dev_pasid() op is dropped.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Link: https://lore.kernel.org/r/20241204122928.11987-6-yi.l.liu@intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel/iommu.c

index 79e0da9eb626cc73e98d35254f54463d46709ef6..aecfbcf1206c09cb6cd3fbd93efc7bc79a4bf9ef 100644 (file)
@@ -3250,10 +3250,15 @@ static int blocking_domain_attach_dev(struct iommu_domain *domain,
        return 0;
 }
 
+static int blocking_domain_set_dev_pasid(struct iommu_domain *domain,
+                                        struct device *dev, ioasid_t pasid,
+                                        struct iommu_domain *old);
+
 static struct iommu_domain blocking_domain = {
        .type = IOMMU_DOMAIN_BLOCKED,
        .ops = &(const struct iommu_domain_ops) {
                .attach_dev     = blocking_domain_attach_dev,
+               .set_dev_pasid  = blocking_domain_set_dev_pasid,
        }
 };
 
@@ -4099,13 +4104,16 @@ void domain_remove_dev_pasid(struct iommu_domain *domain,
        kfree(dev_pasid);
 }
 
-static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
-                                        struct iommu_domain *domain)
+static int blocking_domain_set_dev_pasid(struct iommu_domain *domain,
+                                        struct device *dev, ioasid_t pasid,
+                                        struct iommu_domain *old)
 {
        struct device_domain_info *info = dev_iommu_priv_get(dev);
 
        intel_pasid_tear_down_entry(info->iommu, dev, pasid, false);
-       domain_remove_dev_pasid(domain, dev, pasid);
+       domain_remove_dev_pasid(old, dev, pasid);
+
+       return 0;
 }
 
 struct dev_pasid_info *
@@ -4478,7 +4486,6 @@ const struct iommu_ops intel_iommu_ops = {
        .dev_disable_feat       = intel_iommu_dev_disable_feat,
        .is_attach_deferred     = intel_iommu_is_attach_deferred,
        .def_domain_type        = device_def_domain_type,
-       .remove_dev_pasid       = intel_iommu_remove_dev_pasid,
        .pgsize_bitmap          = SZ_4K,
        .page_response          = intel_iommu_page_response,
        .default_domain_ops = &(const struct iommu_domain_ops) {