Message ID | 20220826121141.50743-10-baolu.lu@linux.intel.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | iommu: SVA and IOPF refactoring | expand |
On Fri, Aug 26, 2022 at 08:11:33PM +0800, Lu Baolu wrote: > The Intel IOMMU hardwares support blocking DMA transactions by clearing > the translation table entries. This implements a real blocking domain to > avoid using an empty UNMANAGED domain. The detach_dev callback of the > domain ops is not used in any path. Remove it to avoid dead code as well. > > Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> > Tested-by: Tony Zhu <tony.zhu@intel.com> > --- > drivers/iommu/intel/iommu.c | 25 ++++++++++++++++++------- > 1 file changed, 18 insertions(+), 7 deletions(-) At this point I'd suggest to make a little series that does all the blocking domain stuff in one shot The removal of detach_dev callbacks is pretty nice for clarity. Jason
On 2022/8/26 22:54, Jason Gunthorpe wrote: > On Fri, Aug 26, 2022 at 08:11:33PM +0800, Lu Baolu wrote: >> The Intel IOMMU hardwares support blocking DMA transactions by clearing >> the translation table entries. This implements a real blocking domain to >> avoid using an empty UNMANAGED domain. The detach_dev callback of the >> domain ops is not used in any path. Remove it to avoid dead code as well. >> >> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> >> Tested-by: Tony Zhu <tony.zhu@intel.com> >> --- >> drivers/iommu/intel/iommu.c | 25 ++++++++++++++++++------- >> 1 file changed, 18 insertions(+), 7 deletions(-) > > At this point I'd suggest to make a little series that does all the > blocking domain stuff in one shot > > The removal of detach_dev callbacks is pretty nice for clarity. Yes. As you saw, I have a separated series for above purpose. Best regards, baolu
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 64d30895a4c8..ffd1ff69bf25 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4127,12 +4127,30 @@ static int md_domain_init(struct dmar_domain *domain, int guest_width) return 0; } +/* + * Intel IOMMU blocking domain support: + */ +static int blocking_domain_attach_dev(struct iommu_domain *domain, + struct device *dev) +{ + dmar_remove_one_dev_info(dev); + return 0; +} + +static struct iommu_domain blocking_domain = { + .ops = &(const struct iommu_domain_ops) { + .attach_dev = blocking_domain_attach_dev + } +}; + static struct iommu_domain *intel_iommu_domain_alloc(unsigned type) { struct dmar_domain *dmar_domain; struct iommu_domain *domain; switch (type) { + case IOMMU_DOMAIN_BLOCKED: + return &blocking_domain; case IOMMU_DOMAIN_DMA: case IOMMU_DOMAIN_DMA_FQ: case IOMMU_DOMAIN_UNMANAGED: @@ -4239,12 +4257,6 @@ static int intel_iommu_attach_device(struct iommu_domain *domain, return domain_add_dev_info(to_dmar_domain(domain), dev); } -static void intel_iommu_detach_device(struct iommu_domain *domain, - struct device *dev) -{ - dmar_remove_one_dev_info(dev); -} - static int intel_iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t hpa, size_t size, int iommu_prot, gfp_t gfp) @@ -4767,7 +4779,6 @@ const struct iommu_ops intel_iommu_ops = { #endif .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = intel_iommu_attach_device, - .detach_dev = intel_iommu_detach_device, .map_pages = intel_iommu_map_pages, .unmap_pages = intel_iommu_unmap_pages, .iotlb_sync_map = intel_iommu_iotlb_sync_map,