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

iommu: Remove domain_init and domain_free iommu_ops

All drivers have been converted to the new domain_alloc and
domain_free iommu-ops. So remove the old ones and get rid of
iommu_domain->priv too, as this is no longer needed when the
struct iommu_domain is embedded in the private structures of
the iommu drivers.

Tested-by: Thierry Reding <treding@nvidia.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>

+2 -31
+2 -28
drivers/iommu/iommu.c
··· 900 900 901 901 struct iommu_domain *iommu_domain_alloc(struct bus_type *bus) 902 902 { 903 - const struct iommu_ops *ops; 904 903 struct iommu_domain *domain; 905 904 906 905 if (bus == NULL || bus->iommu_ops == NULL) 907 906 return NULL; 908 907 909 - ops = bus->iommu_ops; 910 - 911 - if (ops->domain_alloc) 912 - domain = ops->domain_alloc(IOMMU_DOMAIN_UNMANAGED); 913 - else 914 - domain = kzalloc(sizeof(*domain), GFP_KERNEL); 915 - 908 + domain = bus->iommu_ops->domain_alloc(IOMMU_DOMAIN_UNMANAGED); 916 909 if (!domain) 917 910 return NULL; 918 911 919 912 domain->ops = bus->iommu_ops; 920 913 domain->type = IOMMU_DOMAIN_UNMANAGED; 921 914 922 - if (ops->domain_init && domain->ops->domain_init(domain)) 923 - goto out_free; 924 - 925 915 return domain; 926 - 927 - out_free: 928 - if (ops->domain_free) 929 - ops->domain_free(domain); 930 - else 931 - kfree(domain); 932 - 933 - return NULL; 934 916 } 935 917 EXPORT_SYMBOL_GPL(iommu_domain_alloc); 936 918 937 919 void iommu_domain_free(struct iommu_domain *domain) 938 920 { 939 - const struct iommu_ops *ops = domain->ops; 940 - 941 - if (likely(ops->domain_destroy != NULL)) 942 - ops->domain_destroy(domain); 943 - 944 - if (ops->domain_free) 945 - ops->domain_free(domain); 946 - else 947 - kfree(domain); 921 + domain->ops->domain_free(domain); 948 922 } 949 923 EXPORT_SYMBOL_GPL(iommu_domain_free); 950 924
-3
include/linux/iommu.h
··· 78 78 struct iommu_domain { 79 79 unsigned type; 80 80 const struct iommu_ops *ops; 81 - void *priv; 82 81 iommu_fault_handler_t handler; 83 82 void *handler_token; 84 83 struct iommu_domain_geometry geometry; ··· 137 138 */ 138 139 struct iommu_ops { 139 140 bool (*capable)(enum iommu_cap); 140 - int (*domain_init)(struct iommu_domain *domain); 141 - void (*domain_destroy)(struct iommu_domain *domain); 142 141 143 142 /* Domain allocation and freeing by the iommu driver */ 144 143 struct iommu_domain *(*domain_alloc)(unsigned iommu_domain_type);