Commit 41df6dcc authored by Joerg Roedel's avatar Joerg Roedel

iommu: Keep a list of allocated groups in __iommu_probe_device()

This is needed to defer default_domain allocation for new IOMMU groups
until all devices have been added to the group.
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
Tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Acked-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/20200429133712.31431-10-joro@8bytes.orgSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 6e1aa204
...@@ -44,6 +44,7 @@ struct iommu_group { ...@@ -44,6 +44,7 @@ struct iommu_group {
int id; int id;
struct iommu_domain *default_domain; struct iommu_domain *default_domain;
struct iommu_domain *domain; struct iommu_domain *domain;
struct list_head entry;
}; };
struct group_device { struct group_device {
...@@ -184,7 +185,7 @@ static void dev_iommu_free(struct device *dev) ...@@ -184,7 +185,7 @@ static void dev_iommu_free(struct device *dev)
dev->iommu = NULL; dev->iommu = NULL;
} }
static int __iommu_probe_device(struct device *dev) 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 = dev->bus->iommu_ops;
struct iommu_device *iommu_dev; struct iommu_device *iommu_dev;
...@@ -204,6 +205,9 @@ static int __iommu_probe_device(struct device *dev) ...@@ -204,6 +205,9 @@ static int __iommu_probe_device(struct device *dev)
} }
iommu_group_put(group); iommu_group_put(group);
if (group_list && !group->default_domain && list_empty(&group->entry))
list_add_tail(&group->entry, group_list);
iommu_device_link(iommu_dev, dev); iommu_device_link(iommu_dev, dev);
return 0; return 0;
...@@ -234,7 +238,7 @@ int iommu_probe_device(struct device *dev) ...@@ -234,7 +238,7 @@ int iommu_probe_device(struct device *dev)
if (ops->probe_device) { if (ops->probe_device) {
struct iommu_group *group; struct iommu_group *group;
ret = __iommu_probe_device(dev); ret = __iommu_probe_device(dev, NULL);
/* /*
* Try to allocate a default domain - needs support from the * Try to allocate a default domain - needs support from the
...@@ -567,6 +571,7 @@ struct iommu_group *iommu_group_alloc(void) ...@@ -567,6 +571,7 @@ struct iommu_group *iommu_group_alloc(void)
group->kobj.kset = iommu_group_kset; group->kobj.kset = iommu_group_kset;
mutex_init(&group->mutex); mutex_init(&group->mutex);
INIT_LIST_HEAD(&group->devices); INIT_LIST_HEAD(&group->devices);
INIT_LIST_HEAD(&group->entry);
BLOCKING_INIT_NOTIFIER_HEAD(&group->notifier); BLOCKING_INIT_NOTIFIER_HEAD(&group->notifier);
ret = ida_simple_get(&iommu_group_ida, 0, 0, GFP_KERNEL); ret = ida_simple_get(&iommu_group_ida, 0, 0, GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment