Skip to content

Commit a0e086b

Browse files
hegdevasantjoergroedel
authored andcommitted
iommu/amd: Add ops->release_domain
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 <vasant.hegde@amd.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/20241030063556.6104-12-vasant.hegde@amd.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 0b13649 commit a0e086b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,6 +2515,14 @@ void amd_iommu_init_identity_domain(void)
25152515
protection_domain_init(&identity_domain, NUMA_NO_NODE);
25162516
}
25172517

2518+
/* Same as blocked domain except it supports only ops->attach_dev() */
2519+
static struct iommu_domain release_domain = {
2520+
.type = IOMMU_DOMAIN_BLOCKED,
2521+
.ops = &(const struct iommu_domain_ops) {
2522+
.attach_dev = blocked_domain_attach_device,
2523+
}
2524+
};
2525+
25182526
static int amd_iommu_attach_device(struct iommu_domain *dom,
25192527
struct device *dev)
25202528
{
@@ -2894,6 +2902,7 @@ static int amd_iommu_dev_disable_feature(struct device *dev,
28942902
const struct iommu_ops amd_iommu_ops = {
28952903
.capable = amd_iommu_capable,
28962904
.blocked_domain = &blocked_domain,
2905+
.release_domain = &release_domain,
28972906
.identity_domain = &identity_domain.domain,
28982907
.domain_alloc = amd_iommu_domain_alloc,
28992908
.domain_alloc_user = amd_iommu_domain_alloc_user,

0 commit comments

Comments
 (0)