Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommu: Remove detach_dev callback

The detach_dev callback of domain ops is not called in the IOMMU core.
Remove this callback to avoid dead code. The trace event for detaching
domain from device is removed accordingly.

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20230110025408.667767-6-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>

authored by

Lu Baolu and committed by
Joerg Roedel
8f9930fa dd8a25c5

+4 -42
-1
drivers/iommu/iommu-traces.c
··· 18 18 19 19 /* iommu_device_event */ 20 20 EXPORT_TRACEPOINT_SYMBOL_GPL(attach_device_to_domain); 21 - EXPORT_TRACEPOINT_SYMBOL_GPL(detach_device_from_domain); 22 21 23 22 /* iommu_map_unmap */ 24 23 EXPORT_TRACEPOINT_SYMBOL_GPL(map);
+4 -32
drivers/iommu/iommu.c
··· 2045 2045 return 0; 2046 2046 } 2047 2047 2048 - static void __iommu_detach_device(struct iommu_domain *domain, 2049 - struct device *dev) 2050 - { 2051 - domain->ops->detach_dev(domain, dev); 2052 - trace_detach_device_from_domain(dev); 2053 - } 2054 - 2055 2048 void iommu_detach_device(struct iommu_domain *domain, struct device *dev) 2056 2049 { 2057 2050 struct iommu_group *group; ··· 2149 2156 } 2150 2157 EXPORT_SYMBOL_GPL(iommu_attach_group); 2151 2158 2152 - static int iommu_group_do_detach_device(struct device *dev, void *data) 2153 - { 2154 - struct iommu_domain *domain = data; 2155 - 2156 - __iommu_detach_device(domain, dev); 2157 - 2158 - return 0; 2159 - } 2160 - 2161 2159 static int iommu_group_do_set_platform_dma(struct device *dev, void *data) 2162 2160 { 2163 2161 const struct iommu_ops *ops = dev_iommu_ops(dev); ··· 2168 2184 return 0; 2169 2185 2170 2186 /* 2171 - * New drivers should support default domains and so the detach_dev() op 2172 - * will never be called. Otherwise the NULL domain represents some 2187 + * New drivers should support default domains, so set_platform_dma() 2188 + * op will never be called. Otherwise the NULL domain represents some 2173 2189 * platform specific behavior. 2174 2190 */ 2175 2191 if (!new_domain) { 2176 - struct group_device *grp_dev; 2177 - 2178 - grp_dev = list_first_entry(&group->devices, 2179 - struct group_device, list); 2180 - 2181 - if (dev_iommu_ops(grp_dev->dev)->set_platform_dma_ops) 2182 - __iommu_group_for_each_dev(group, NULL, 2183 - iommu_group_do_set_platform_dma); 2184 - else if (group->domain->ops->detach_dev) 2185 - __iommu_group_for_each_dev(group, group->domain, 2186 - iommu_group_do_detach_device); 2187 - else 2188 - WARN_ON_ONCE(1); 2189 - 2192 + __iommu_group_for_each_dev(group, NULL, 2193 + iommu_group_do_set_platform_dma); 2190 2194 group->domain = NULL; 2191 2195 return 0; 2192 2196 }
-2
include/linux/iommu.h
··· 299 299 * * EBUSY - device is attached to a domain and cannot be changed 300 300 * * ENODEV - device specific errors, not able to be attached 301 301 * * <others> - treated as ENODEV by the caller. Use is discouraged 302 - * @detach_dev: detach an iommu domain from a device 303 302 * @set_dev_pasid: set an iommu domain to a pasid of device 304 303 * @map: map a physically contiguous memory region to an iommu domain 305 304 * @map_pages: map a physically contiguous set of pages of the same size to ··· 319 320 */ 320 321 struct iommu_domain_ops { 321 322 int (*attach_dev)(struct iommu_domain *domain, struct device *dev); 322 - void (*detach_dev)(struct iommu_domain *domain, struct device *dev); 323 323 int (*set_dev_pasid)(struct iommu_domain *domain, struct device *dev, 324 324 ioasid_t pasid); 325 325
-7
include/trace/events/iommu.h
··· 76 76 TP_ARGS(dev) 77 77 ); 78 78 79 - DEFINE_EVENT(iommu_device_event, detach_device_from_domain, 80 - 81 - TP_PROTO(struct device *dev), 82 - 83 - TP_ARGS(dev) 84 - ); 85 - 86 79 TRACE_EVENT(map, 87 80 88 81 TP_PROTO(unsigned long iova, phys_addr_t paddr, size_t size),