From: Joerg Roedel Date: Mon, 27 Nov 2023 10:23:54 +0000 (+0100) Subject: Merge branch 'iommu/fixes' into core X-Git-Tag: v6.8-rc1~49^2^8~17 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=61f054f3c8a6d6081e078e93aba144760aed17c9;p=linux-block.git Merge branch 'iommu/fixes' into core --- 61f054f3c8a6d6081e078e93aba144760aed17c9 diff --cc drivers/iommu/iommu.c index 254f42b4220b,33e2a9b5d339..0d25468d53a6 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@@ -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);