IOMMU: Make iommu_ops per-bus_type
Subsystems (8)
v2 cover IOMMU: Make iommu_ops per-bus_type
Hi again,
here is the new version of the patch-set to make the iommu_ops used in the iommu-api a bus_type property. This will allow us to move code out of the iommu drivers into generic code and it simplifies the implementation of the Alex' device-group property.
It converts all iommu drivers to use the new registration interface and completly removes the register_iommu interface.
Greg, can you please look at patch 2 again and let me know if you have any objections on this version? It think I addressed all your previous objections.
In case you have no objections and give your Ack we can move on converting IOMMU drivers to make use of that change and Alex' can move on with his iommu-groups patch-set :)
Regards,
Joerg
Changes v1->v2:
* Added kernel-doc comments to bus_set_iommu function
* Removed iommu.h include from device.h and added a forward declaration for struct iommu_ops
Diffstat:
arch/ia64/kvm/kvm-ia64.c | 3 +- arch/x86/kvm/x86.c | 3 +- drivers/base/bus.c | 29 ++++++++++++++++++ drivers/iommu/amd_iommu.c | 2 +- drivers/iommu/intel-iommu.c | 2 +- drivers/iommu/iommu.c | 58 ++++++++++++++++++++++++------------ drivers/iommu/msm_iommu.c | 2 +- drivers/iommu/omap-iommu.c | 2 +- drivers/media/video/omap3isp/isp.c | 2 +- include/linux/device.h | 10 ++++++ include/linux/iommu.h | 21 +++++++------ virt/kvm/iommu.c | 4 +- 12 files changed, 100 insertions(+), 38 deletions(-)
PATCH v2 1/10 iommu/core: Define iommu_ops and register_iommu only with CONFIG_IOMMU_API
This makes it impossible to compile an iommu driver into the kernel without selecting CONFIG_IOMMU_API.
--- include/linux/iommu.h | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
include/linux/iommu.h +3 -5
@@ -34,6 +34,8 @@ struct iommu_domain {#define IOMMU_CAP_CACHE_COHERENCY 0x1#define IOMMU_CAP_INTR_REMAP 0x2/* isolates device intrs */ +#ifdef CONFIG_IOMMU_API + struct iommu_ops { int (*domain_init)(struct iommu_domain *domain); void (*domain_destroy)(struct iommu_domain *domain);
@@ -49,8 +51,6 @@ struct iommu_ops { unsigned long cap); }; -#ifdef CONFIG_IOMMU_API -extern void register_iommu (struct iommu_ops *ops);extern bool iommu_found (void );extern struct iommu_domain *iommu_domain_alloc (void );
@@ -70,9 +70,7 @@ extern int iommu_domain_has_cap(struct iommu_domain *domain,#else /* CONFIG_IOMMU_API */ -static inline void register_iommu (struct iommu_ops *ops) -{ -} +struct iommu_ops {};static inline bool iommu_found (void ) {
Signature · 1 line
1.7.4.1
PATCH v2 2/10 Driver core: Add iommu_ops to bus_type
In reply to Joerg RoedelThis is the starting point to make the iommu_ops used for the iommu-api a per-bus-type structure. It is required to easily implement bus-specific setup in the iommu-layer. The first user will be the iommu-group attribute in sysfs.
--- drivers/base/bus.c | 29 +++++++++++++++++++++++++++++ drivers/iommu/iommu.c | 4 ++++ include/linux/device.h | 10 ++++++++++ include/linux/iommu.h | 2 ++ 4 files changed, 45 insertions(+), 0 deletions(-)
drivers/base/bus.c +29 -0
@@ -1028,6 +1028,35 @@ void bus_sort_breadthfirst(struct bus_type *bus, }EXPORT_SYMBOL_GPL (bus_sort_breadthfirst); +#ifdef CONFIG_IOMMU_API +/** +* bus_set_iommu - set iommu-callbacks for the bus +* @bus: bus. +* @ops: the callbacks provided by the iommu-driver +* +* This function is called by an iommu driver to set the iommu methods +* used for a particular bus. Drivers for devices on that bus can use +* the iommu-api after these ops are registered. +* This special function is needed because IOMMUs are usually devices on +* the bus itself, so the iommu drivers are not initialized when the bus +* is set up. With this function the iommu-driver can set the iommu-ops +* afterwards. +*/ +int bus_set_iommu (struct bus_type *bus,struct iommu_ops *ops) +{ +if (bus->iommu_ops !=NULL ) +return -EBUSY ; + + bus->iommu_ops = ops; + +/* Do IOMMU specific setup for this bus-type */ +iommu_bus_init (bus, ops); + +return 0 ; +} +EXPORT_SYMBOL_GPL (bus_set_iommu); +#endif +int __init buses_init (void ) { bus_kset =kset_create_and_add ("bus" , &bus_uevent_ops,NULL );
drivers/iommu/iommu.c +4 -0
@@ -34,6 +34,10 @@ void register_iommu(struct iommu_ops *ops) iommu_ops = ops; } +void iommu_bus_init (struct bus_type *bus,struct iommu_ops *ops) +{ +} +bool iommu_found (void ) {return iommu_ops !=NULL ;
include/linux/device.h +10 -0
@@ -33,6 +33,7 @@ struct class;struct subsys_private ;struct bus_type ;struct device_node ; +struct iommu_ops ;struct bus_attribute {struct attribute attr;
@@ -46,6 +47,7 @@ struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store)extern int __must_check bus_create_file (struct bus_type *,struct bus_attribute *);extern void bus_remove_file (struct bus_type *,struct bus_attribute *); +extern void iommu_bus_init (struct bus_type *bus,struct iommu_ops *ops);/** * struct bus_type - The bus type of the device
@@ -67,6 +69,9 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *);* @resume: Called to bring a device on this bus out of sleep mode. * @pm: Power management operations of this bus, callback the specific * device driver's pm-ops. +* @iommu_ops IOMMU specific operations for this bus, used to attach IOMMU +* driver implementations to a bus and allow the driver to do +* bus-specific setup * @p: The private data of the driver core, only the driver core can * touch this. *
@@ -96,6 +101,8 @@ struct bus_type {const struct dev_pm_ops *pm; +struct iommu_ops *iommu_ops; +struct subsys_private *p; };
@@ -148,6 +155,9 @@ extern int bus_unregister_notifier(struct bus_type *bus,#define BUS_NOTIFY_UNBOUND_DRIVER 0x00000006/* driver is unbound from the device */ +/* IOMMU related bus functions */ +int bus_set_iommu (struct bus_type *bus,struct iommu_ops *ops); +extern struct kset *bus_get_kset (struct bus_type *bus);extern struct klist *bus_get_device_klist (struct bus_type *bus);
include/linux/iommu.h +2 -0
@@ -25,6 +25,7 @@#define IOMMU_WRITE (2)#define IOMMU_CACHE (4)/* DMA cache coherency */ +struct bus_type ;struct device ;struct iommu_domain {
@@ -52,6 +53,7 @@ struct iommu_ops { };extern void register_iommu (struct iommu_ops *ops); +extern void iommu_bus_init (struct bus_type *bus,struct iommu_ops *ops);extern bool iommu_found (void );extern struct iommu_domain *iommu_domain_alloc (void );extern void iommu_domain_free (struct iommu_domain *domain);
Signature · 1 line
1.7.4.1
Re: [PATCH 02/10] Driver core: Add iommu_ops to bus_type
Quoted 18 lines · Joerg Roedel
This is the starting point to make the
iommu_opsused for the iommu-api a per-bus-type structure. It is required to easily implement bus-specific setup in the iommu-layer. The first user will be the iommu-group attribute in sysfs.Signed-off-by Joerg Roedel <[email protected]>--- drivers/base/bus.c | 29 +++++++++++++++++++++++++++++ drivers/iommu/iommu.c | 4 ++++ include/linux/device.h | 10 ++++++++++ include/linux/iommu.h | 2 ++ 4 files changed, 45 insertions(+), 0 deletions(-)drivers/base/bus.c +0
-0
drivers/base/bus.c void bus_sort_breadthfirst(struct bus_type *bus, · line 1032
Quoted 5 lines
drivers/base/bus.c +2
-0@@ -1028,6 +1028,35 @@ void bus_sort_breadthfirst(struct bus_type *bus, }EXPORT_SYMBOL_GPL (bus_sort_breadthfirst); +#ifdef CONFIG_IOMMU_API +/**
This ifdef really isn't needed, is it? I think you can remove it.
Other than that, looks much better, thanks.
greg k-h
Re: [PATCH 02/10] Driver core: Add iommu_ops to bus_type
Quoted 22 lines · Greg KH
Quoted 21 lines · Joerg Roedel
This is the starting point to make the
iommu_opsused for the iommu-api a per-bus-type structure. It is required to easily implement bus-specific setup in the iommu-layer. The first user will be the iommu-group attribute in sysfs.Signed-off-by Joerg Roedel <[email protected]>--- drivers/base/bus.c | 29 +++++++++++++++++++++++++++++ drivers/iommu/iommu.c | 4 ++++ include/linux/device.h | 10 ++++++++++ include/linux/iommu.h | 2 ++ 4 files changed, 45 insertions(+), 0 deletions(-)drivers/base/bus.c +0
-0@@ -1028,6 +1028,35 @@ void bus_sort_breadthfirst(struct bus_type *bus, }EXPORT_SYMBOL_GPL (bus_sort_breadthfirst);
Quoted 4 lines
drivers/base/bus.c void bus_sort_breadthfirst(struct bus_type *bus, · line 1032
Quoted 2 lines
drivers/base/bus.c +2
-0+#ifdef CONFIG_IOMMU_API +/** This ifdef really isn't needed, is it? I think you can remove it.
Actually, iommu_bus_init is only defined with CONFIG_IOMMU_API=y. But you are right, the ifdef is not very nice here. I solved this situation by moving the function into drivers/iommu/iommu.c which is only compiled with CONFIG_IOMMU_API=y anyway, so no ifdef is required anymore.
Quoted 1 line
Other than that, looks much better, thanks.
Great, I sent a new round if these patches. Moving this function to another file caused some changes in the following patches too during the rebase.
Thanks,
Joerg
Signature · 5 lines
AMD Operating System Research Center Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach General Managers: Alberto Bozzo, Andrew Bowd Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
PATCH v2 3/10 iommu/core: Add bus_type parameter to iommu_domain_alloc
In reply to Joerg RoedelThis is necessary to store a pointer to the bus-specific iommu_ops in the iommu-domain structure. It will be used later to call into bus-specific iommu-ops.
--- drivers/iommu/iommu.c | 14 +++++++++++++- drivers/media/video/omap3isp/isp.c | 2 +- include/linux/iommu.h | 6 ++++-- virt/kvm/iommu.c | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-)
drivers/iommu/iommu.c +13 -1
@@ -16,6 +16,7 @@* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <linux/device.h> #include <linux/kernel.h> #include <linux/bug.h> #include <linux/types.h>
@@ -44,15 +45,26 @@ bool iommu_found(void) }EXPORT_SYMBOL_GPL (iommu_found); -struct iommu_domain *iommu_domain_alloc (void ) +struct iommu_domain *iommu_domain_alloc (struct bus_type *bus) {struct iommu_domain *domain; +struct iommu_ops *ops;int ret; +if (bus->iommu_ops) + ops = bus->iommu_ops; +else + ops = iommu_ops; + +if (ops ==NULL ) +return NULL ; + domain =kmalloc (sizeof (*domain),GFP_KERNEL );if (!domain)return NULL ; + domain->ops = ops; + ret = iommu_ops->domain_init (domain);if (ret) goto out_free;
drivers/media/video/omap3isp/isp.c +1 -1
@@ -2141,7 +2141,7 @@ static int isp_probe(struct platform_device *pdev)/* to be removed once iommu migration is complete */ isp->iommu =to_iommu (isp->iommu_dev); - isp->domain =iommu_domain_alloc (); + isp->domain =iommu_domain_alloc (pdev->dev.bus);if (!isp->domain) {dev_err (isp->dev,"can't alloc iommu domain\n" ); ret = -ENOMEM ;
include/linux/iommu.h +4 -2
@@ -25,10 +25,12 @@#define IOMMU_WRITE (2)#define IOMMU_CACHE (4)/* DMA cache coherency */ +struct iommu_ops ;struct bus_type ;struct device ;struct iommu_domain { +struct iommu_ops *ops;void *priv; };
@@ -55,7 +57,7 @@ struct iommu_ops {extern void register_iommu (struct iommu_ops *ops);extern void iommu_bus_init (struct bus_type *bus,struct iommu_ops *ops);extern bool iommu_found (void ); -extern struct iommu_domain *iommu_domain_alloc (void ); +extern struct iommu_domain *iommu_domain_alloc (struct bus_type *bus);extern void iommu_domain_free (struct iommu_domain *domain);extern int iommu_attach_device (struct iommu_domain *domain,struct device *dev);
@@ -79,7 +81,7 @@ static inline bool iommu_found(void)return false; } -static inline struct iommu_domain *iommu_domain_alloc (void ) +static inline struct iommu_domain *iommu_domain_alloc (struct bus_type *bus) {return NULL ; }
virt/kvm/iommu.c +1 -1
@@ -233,7 +233,7 @@ int kvm_iommu_map_guest(struct kvm *kvm)return -ENODEV ; } - kvm->arch.iommu_domain =iommu_domain_alloc (); + kvm->arch.iommu_domain =iommu_domain_alloc (&pci_bus_type);if (!kvm->arch.iommu_domain)return -ENOMEM ;
Signature · 1 line
1.7.4.1
PATCH v2 4/10 iommu/core: Convert iommu_found to iommu_present
In reply to Joerg RoedelWith per-bus iommu_ops the iommu_found function needs to work on a bus_type too. This patch adds a bus_type parameter to that function and converts all call-places.
The function is also renamed to iommu_present because the function now checks if an iommu is present for a given bus and does not check for a global iommu anymore.
--- arch/ia64/kvm/kvm-ia64.c | 3 ++- arch/x86/kvm/x86.c | 3 ++- drivers/iommu/iommu.c | 9 ++++++--- include/linux/iommu.h | 4 ++-- virt/kvm/iommu.c | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-)
arch/ia64/kvm/kvm-ia64.c +2 -1
@@ -33,6 +33,7 @@#include <linux/uaccess.h> #include <linux/iommu.h> #include <linux/intel-iommu.h> +#include <linux/pci.h> #include <asm/pgtable.h> #include <asm/gcc_intrin.h>
@@ -204,7 +205,7 @@ int kvm_dev_ioctl_check_extension(long ext) r =KVM_COALESCED_MMIO_PAGE_OFFSET ;break ;case KVM_CAP_IOMMU : - r =iommu_found (); + r =iommu_present (&pci_bus_type);break ;default : r =0 ;
arch/x86/kvm/x86.c +2 -1
@@ -44,6 +44,7 @@#include <linux/perf_event.h> #include <linux/uaccess.h> #include <linux/hash.h> +#include <linux/pci.h> #include <trace/events/kvm.h> #define CREATE_TRACE_POINTS
@@ -2095,7 +2096,7 @@ int kvm_dev_ioctl_check_extension(long ext) r =0 ;break ;case KVM_CAP_IOMMU : - r =iommu_found (); + r =iommu_present (&pci_bus_type);break ;case KVM_CAP_MCE : r =KVM_MAX_MCE_BANKS ;
drivers/iommu/iommu.c +6 -3
@@ -39,11 +39,14 @@ void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops) { } -bool iommu_found (void ) +bool iommu_present (struct bus_type *bus) { -return iommu_ops !=NULL ; +if (bus->iommu_ops !=NULL ) +return true; +else +return iommu_ops !=NULL ; } -EXPORT_SYMBOL_GPL (iommu_found); +EXPORT_SYMBOL_GPL (iommu_present);struct iommu_domain *iommu_domain_alloc (struct bus_type *bus) {
include/linux/iommu.h +2 -2
@@ -56,7 +56,7 @@ struct iommu_ops {extern void register_iommu (struct iommu_ops *ops);extern void iommu_bus_init (struct bus_type *bus,struct iommu_ops *ops); -extern bool iommu_found (void ); +extern bool iommu_present (struct bus_type *bus);extern struct iommu_domain *iommu_domain_alloc (struct bus_type *bus);extern void iommu_domain_free (struct iommu_domain *domain); extern int iommu_attach_device(struct iommu_domain *domain,
@@ -76,7 +76,7 @@ extern int iommu_domain_has_cap(struct iommu_domain *domain,struct iommu_ops {}; -static inline bool iommu_found (void ) +static inline bool iommu_present (struct bus_type *bus) {return false; }
virt/kvm/iommu.c +1 -1
@@ -228,7 +228,7 @@ int kvm_iommu_map_guest(struct kvm *kvm) {int r; -if (!iommu_found ()) { +if (!iommu_present (&pci_bus_type)) {printk (KERN_ERR "%s: iommu not found\n" , __func__);return -ENODEV ; }
Signature · 1 line
1.7.4.1
PATCH v2 5/10 iommu/core: Use bus->iommu_ops in the iommu-api
In reply to Joerg RoedelUse the per-bus iommu-ops in the functions of the iommu-api instead of the global iommu_ops.
--- drivers/iommu/iommu.c | 34 +++++++++++++++++++++++++++------- 1 files changed, 27 insertions(+), 7 deletions(-)
drivers/iommu/iommu.c +27 -7
@@ -83,34 +83,48 @@ EXPORT_SYMBOL_GPL(iommu_domain_alloc);void iommu_domain_free (struct iommu_domain *domain) { - iommu_ops->domain_destroy (domain); +if (likely (domain->ops->domain_destroy !=NULL )) + domain->ops->domain_destroy (domain); +kfree (domain); }EXPORT_SYMBOL_GPL (iommu_domain_free);int iommu_attach_device (struct iommu_domain *domain,struct device *dev) { -return iommu_ops->attach_dev (domain, dev); +if (unlikely (domain->ops->attach_dev ==NULL )) +return -ENODEV ; + +return domain->ops->attach_dev (domain, dev); }EXPORT_SYMBOL_GPL (iommu_attach_device);void iommu_detach_device (struct iommu_domain *domain,struct device *dev) { - iommu_ops->detach_dev (domain, dev); +if (unlikely (domain->ops->detach_dev ==NULL )) +return ; + + domain->ops->detach_dev (domain, dev); }EXPORT_SYMBOL_GPL (iommu_detach_device);phys_addr_t iommu_iova_to_phys (struct iommu_domain *domain,unsigned long iova) { -return iommu_ops->iova_to_phys (domain, iova); +if (unlikely (domain->ops->iova_to_phys ==NULL )) +return 0 ; + +return domain->ops->iova_to_phys (domain, iova); }EXPORT_SYMBOL_GPL (iommu_iova_to_phys);int iommu_domain_has_cap (struct iommu_domain *domain,unsigned long cap) { -return iommu_ops->domain_has_cap (domain, cap); +if (unlikely (domain->ops->domain_has_cap ==NULL )) +return 0 ; + +return domain->ops->domain_has_cap (domain, cap); }EXPORT_SYMBOL_GPL (iommu_domain_has_cap);
@@ -119,11 +133,14 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova, {size_t size; +if (unlikely (domain->ops->map ==NULL )) +return -ENODEV ; + size =PAGE_SIZE << gfp_order;BUG_ON (!IS_ALIGNED (iova | paddr, size)); -return iommu_ops->map (domain, iova, paddr, gfp_order, prot); +return domain->ops->map (domain, iova, paddr, gfp_order, prot); }EXPORT_SYMBOL_GPL (iommu_map);
@@ -131,10 +148,13 @@ int iommu_unmap(struct iommu_domain *domain, unsigned long iova, int gfp_order) {size_t size; +if (unlikely (domain->ops->unmap ==NULL )) +return -ENODEV ; + size =PAGE_SIZE << gfp_order;BUG_ON (!IS_ALIGNED (iova, size)); -return iommu_ops->unmap (domain, iova, gfp_order); +return domain->ops->unmap (domain, iova, gfp_order); }EXPORT_SYMBOL_GPL (iommu_unmap);
Signature · 1 line
1.7.4.1
PATCH v2 6/10 iommu/amd: Use bus_set_iommu instead of register_iommu
In reply to Joerg RoedelConvert the AMD IOMMU driver to use the new interface for publishing the iommu_ops.
--- drivers/iommu/amd_iommu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/iommu/amd_iommu.c +1 -1
@@ -2493,7 +2493,7 @@ static unsigned device_dma_ops_init(void)void __init amd_iommu_init_api (void ) { -register_iommu (&amd_iommu_ops); +bus_set_iommu (&pci_bus_type, &amd_iommu_ops); }int __init amd_iommu_init_dma_ops (void )
Signature · 1 line
1.7.4.1
PATCH v2 7/10 iommu/vt-d: Use bus_set_iommu instead of register_iommu
In reply to Joerg RoedelConvert the Intel IOMMU driver to use the new interface for publishing the iommu_ops.
--- drivers/iommu/intel-iommu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/iommu/intel-iommu.c +1 -1
@@ -3486,7 +3486,7 @@ int __init intel_iommu_init(void)init_iommu_pm_ops (); -register_iommu (&intel_iommu_ops); +bus_set_iommu (&pci_bus_type, &intel_iommu_ops);bus_register_notifier (&pci_bus_type, &device_nb);
Signature · 1 line
1.7.4.1
PATCH v2 8/10 iommu/omap: Use bus_set_iommu instead of register_iommu
In reply to Joerg RoedelConvert the OMAP IOMMU driver on ARM to use the new interface for publishing the iommu_ops.
--- drivers/iommu/omap-iommu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/iommu/omap-iommu.c +1 -1
@@ -1250,7 +1250,7 @@ static int __init omap_iommu_init(void)return -ENOMEM ; iopte_cachep = p; -register_iommu (&omap_iommu_ops); +bus_set_iommu (&platform_bus_type, &omap_iommu_ops);return platform_driver_register (&omap_iommu_driver); }
Signature · 1 line
1.7.4.1
PATCH v2 9/10 iommu/msm: Use bus_set_iommu instead of register_iommu
In reply to Joerg RoedelConvert the MSM IOMMU driver for ARM to use the new interface for publishing the iommu_ops.
--- drivers/iommu/msm_iommu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/iommu/msm_iommu.c +1 -1
@@ -728,7 +728,7 @@ static void __init setup_iommu_tex_classes(void)static int __init msm_iommu_init (void ) {setup_iommu_tex_classes (); -register_iommu (&msm_iommu_ops); +bus_set_iommu (&platform_bus_type, &msm_iommu_ops);return 0 ; }
Signature · 1 line
1.7.4.1
PATCH v2 10/10 iommu/core: Remove global iommu_ops and register_iommu
In reply to Joerg RoedelWith all IOMMU drivers being converted to bus_set_iommu the global iommu_ops are no longer required. The same is true for the deprecated register_iommu function.
--- drivers/iommu/iommu.c | 27 ++++----------------------- include/linux/iommu.h | 1 - 2 files changed, 4 insertions(+), 24 deletions(-)
drivers/iommu/iommu.c +4 -23
@@ -25,50 +25,31 @@#include <linux/errno.h> #include <linux/iommu.h> -static struct iommu_ops *iommu_ops; - -void register_iommu (struct iommu_ops *ops) -{ -if (iommu_ops) -BUG (); - - iommu_ops = ops; -} -void iommu_bus_init (struct bus_type *bus,struct iommu_ops *ops) { }bool iommu_present (struct bus_type *bus) { -if (bus->iommu_ops !=NULL ) -return true; -else -return iommu_ops !=NULL ; +return bus->iommu_ops !=NULL ; }EXPORT_SYMBOL_GPL (iommu_present);struct iommu_domain *iommu_domain_alloc (struct bus_type *bus) {struct iommu_domain *domain; -struct iommu_ops *ops;int ret; -if (bus->iommu_ops) - ops = bus->iommu_ops; -else - ops = iommu_ops; - -if (ops ==NULL ) +if (bus ==NULL || bus->iommu_ops ==NULL )return NULL ; domain =kmalloc (sizeof (*domain),GFP_KERNEL );if (!domain)return NULL ; - domain->ops = ops; + domain->ops = bus->iommu_ops; - ret = iommu_ops->domain_init (domain); + ret = domain->ops->domain_init (domain);if (ret) goto out_free;
include/linux/iommu.h +0 -1
@@ -54,7 +54,6 @@ struct iommu_ops { unsigned long cap); }; -extern void register_iommu (struct iommu_ops *ops);extern void iommu_bus_init (struct bus_type *bus,struct iommu_ops *ops);extern bool iommu_present (struct bus_type *bus);extern struct iommu_domain *iommu_domain_alloc (struct bus_type *bus);
Signature · 1 line
1.7.4.1