]> Git Repo - J-linux.git/commitdiff
iommu/amd: Add ops->release_domain
authorVasant Hegde <[email protected]>
Wed, 30 Oct 2024 06:35:55 +0000 (06:35 +0000)
committerJoerg Roedel <[email protected]>
Wed, 30 Oct 2024 10:06:47 +0000 (11:06 +0100)
In release path, remove device from existing domain and attach it to
blocked domain. So that all DMAs from device is blocked.

Note that soon blocked_domain will support other ops like
set_dev_pasid() but release_domain supports only attach_dev ops.
Hence added separate 'release_domain' variable.

Signed-off-by: Vasant Hegde <[email protected]>
Reviewed-by: Jason Gunthorpe <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Joerg Roedel <[email protected]>
drivers/iommu/amd/iommu.c

index a481c4565bc34a1c169aa229d5e8a6f0a455c397..fd39b54578830ead0cd1f8678a8b182127aa3198 100644 (file)
@@ -2515,6 +2515,14 @@ void amd_iommu_init_identity_domain(void)
        protection_domain_init(&identity_domain, NUMA_NO_NODE);
 }
 
+/* Same as blocked domain except it supports only ops->attach_dev() */
+static struct iommu_domain release_domain = {
+       .type = IOMMU_DOMAIN_BLOCKED,
+       .ops = &(const struct iommu_domain_ops) {
+               .attach_dev     = blocked_domain_attach_device,
+       }
+};
+
 static int amd_iommu_attach_device(struct iommu_domain *dom,
                                   struct device *dev)
 {
@@ -2894,6 +2902,7 @@ static int amd_iommu_dev_disable_feature(struct device *dev,
 const struct iommu_ops amd_iommu_ops = {
        .capable = amd_iommu_capable,
        .blocked_domain = &blocked_domain,
+       .release_domain = &release_domain,
        .identity_domain = &identity_domain.domain,
        .domain_alloc = amd_iommu_domain_alloc,
        .domain_alloc_user = amd_iommu_domain_alloc_user,
This page took 0.052377 seconds and 4 git commands to generate.