Merge branch 'iommu/fixes' into core
authorJoerg Roedel <jroedel@suse.de>
Mon, 27 Nov 2023 10:23:54 +0000 (11:23 +0100)
committerJoerg Roedel <jroedel@suse.de>
Mon, 27 Nov 2023 10:23:54 +0000 (11:23 +0100)
1  2 
drivers/iommu/iommu.c
drivers/iommu/of_iommu.c
include/linux/iommu.h

@@@ -484,12 -485,12 +484,13 @@@ static void iommu_deinit_device(struct 
        dev_iommu_free(dev);
  }
  
+ DEFINE_MUTEX(iommu_probe_device_lock);
  static int __iommu_probe_device(struct device *dev, struct list_head *group_list)
  {
 -      const struct iommu_ops *ops = dev->bus->iommu_ops;
 +      const struct iommu_ops *ops;
 +      struct iommu_fwspec *fwspec;
        struct iommu_group *group;
-       static DEFINE_MUTEX(iommu_probe_device_lock);
        struct group_device *gdev;
        int ret;
  
@@@ -2116,13 -2094,19 +2116,20 @@@ static struct iommu_domain *__iommu_dom
        else if (ops->domain_alloc)
                domain = ops->domain_alloc(alloc_type);
        else
-               return NULL;
+               return ERR_PTR(-EOPNOTSUPP);
  
+       /*
+        * Many domain_alloc ops now return ERR_PTR, make things easier for the
+        * driver by accepting ERR_PTR from all domain_alloc ops instead of
+        * having two rules.
+        */
+       if (IS_ERR(domain))
+               return domain;
        if (!domain)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
  
        domain->type = type;
 +      domain->owner = ops;
        /*
         * If not already set, assume all sizes by default; the driver
         * may override this later
@@@ -2166,13 -2141,15 +2178,17 @@@ static int __iommu_domain_alloc_dev(str
  
  struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus)
  {
 +      const struct iommu_ops *ops = NULL;
 +      int err = bus_for_each_dev(bus, NULL, &ops, __iommu_domain_alloc_dev);
+       struct iommu_domain *domain;
  
 -      if (bus == NULL || bus->iommu_ops == NULL)
 +      if (err || !ops)
                return NULL;
 -      domain = __iommu_domain_alloc(bus->iommu_ops, NULL,
 -                                  IOMMU_DOMAIN_UNMANAGED);
 +
-       return __iommu_domain_alloc(ops, NULL, IOMMU_DOMAIN_UNMANAGED);
++      domain = __iommu_domain_alloc(ops, NULL, IOMMU_DOMAIN_UNMANAGED);
+       if (IS_ERR(domain))
+               return NULL;
+       return domain;
  }
  EXPORT_SYMBOL_GPL(iommu_domain_alloc);
  
Simple merge
Simple merge