drivers/iommu: Allow IOMMU bus ops to be unregistered
authorWill Deacon <will@kernel.org>
Thu, 19 Dec 2019 12:03:43 +0000 (12:03 +0000)
committerJoerg Roedel <jroedel@suse.de>
Mon, 23 Dec 2019 13:06:05 +0000 (14:06 +0100)
'bus_set_iommu()' allows IOMMU drivers to register their ops for a given
bus type. Unfortunately, it then doesn't allow them to be removed, which
is necessary for modular drivers to shutdown cleanly so that they can be
reloaded later on.

Allow 'bus_set_iommu()' to take a NULL 'ops' argument, which clear the
ops pointer for the selected bus_type.

Signed-off-by: Will Deacon <will@kernel.org>
Tested-by: John Garry <john.garry@huawei.com> # smmu v3
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iommu.c

index 32ceda1d50314ccd87cd790c100f92904fa3a10e..ffe6f685ceae4ae9104df389d2a9fb9c4536d586 100644 (file)
@@ -1558,6 +1558,11 @@ int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops)
 {
        int err;
 
+       if (ops == NULL) {
+               bus->iommu_ops = NULL;
+               return 0;
+       }
+
        if (bus->iommu_ops != NULL)
                return -EBUSY;