]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
Merge branches 'iommu/fixes', 'arm/rockchip', 'x86/amd' and 'core' into next
authorJoerg Roedel <jroedel@suse.de>
Fri, 14 Jul 2023 14:24:32 +0000 (16:24 +0200)
committerJoerg Roedel <jroedel@suse.de>
Fri, 14 Jul 2023 14:24:32 +0000 (16:24 +0200)
1  2  3  4 
drivers/iommu/iommu.c

index caaf563d38ae090246c602a0b982fbe4d5a9ccf1,da340f11c5f5b6e9bc03824594c4a78f18067f1f,da340f11c5f5b6e9bc03824594c4a78f18067f1f,e67f6562da73b2b007d93f9600f2739c7c77413a..4352a149a935e882be64123e4c327775420bdf2c
@@@@@ -500,44 -500,44 -500,44 -561,39 +561,39 @@@@@ static void __iommu_group_remove_device
    {
        struct iommu_group *group = dev->iommu_group;
        struct group_device *device;
---     const struct iommu_ops *ops;
--- 
---     if (!dev->iommu || !group)
---             return;
--- 
---     iommu_device_unlink(dev->iommu->iommu_dev, dev);
    
        mutex_lock(&group->mutex);
---     device = __iommu_group_remove_device(group, dev);
+++     for_each_group_device(group, device) {
+++             if (device->dev != dev)
+++                     continue;
    
---     /*
---      * If the group has become empty then ownership must have been released,
---      * and the current domain must be set back to NULL or the default
---      * domain.
---      */
---     if (list_empty(&group->devices))
---             WARN_ON(group->owner_cnt ||
---                     group->domain != group->default_domain);
+++             list_del(&device->list);
+++             __iommu_group_free_device(group, device);
+++             if (dev->iommu && dev->iommu->iommu_dev)
+++                     iommu_deinit_device(dev);
+++             else
+++                     dev->iommu_group = NULL;
+++             break;
+++     }
+++     mutex_unlock(&group->mutex);
    
        /*
---      * release_device() must stop using any attached domain on the device.
---      * If there are still other devices in the group they are not effected
---      * by this callback.
---      *
---      * The IOMMU driver must set the device to either an identity or
---      * blocking translation and stop using any domain pointer, as it is
---      * going to be freed.
+++      * Pairs with the get in iommu_init_device() or
+++      * iommu_group_add_device()
         */
---     ops = dev_iommu_ops(dev);
---     if (ops->release_device)
---             ops->release_device(dev);
---     mutex_unlock(&group->mutex);
+++     iommu_group_put(group);
+++ }
+   
 --     if (device)
 --             __iommu_group_release_device(group, device);
+++ static void iommu_release_device(struct device *dev)
+++ {
+++     struct iommu_group *group = dev->iommu_group;
    
-       if (device)
-               __iommu_group_release_device(group, device);
 --     module_put(ops->owner);
 --     dev_iommu_free(dev);
+++     if (group)
+++             __iommu_group_remove_device(dev);
 ++ 
-       module_put(ops->owner);
-       dev_iommu_free(dev);
+++     /* Free any fwspec if no iommu_driver was ever attached */
+++     if (dev->iommu)
+++             dev_iommu_free(dev);
    }
    
    static int __init iommu_set_def_domain_type(char *str)