From: Sjur Brændeland <[email protected]>

Call enable_iommu from rproc_boot and disable_iommu from rproc_shutdown.
This make it simpler to keep enable/disable in balance.

Signed-off-by: Sjur Brændeland <[email protected]>
---
 drivers/remoteproc/remoteproc_core.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c 
b/drivers/remoteproc/remoteproc_core.c
index dd3bfaf..ceca76c 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -141,6 +141,7 @@ static void rproc_disable_iommu(struct rproc *rproc)
 
        iommu_detach_device(domain, dev);
        iommu_domain_free(domain);
+       rproc->domain = NULL;
 
        return;
 }
@@ -816,16 +817,6 @@ static int rproc_fw_boot(struct rproc *rproc, const struct 
firmware *fw)
 
        dev_info(dev, "Booting fw image %s, size %zd\n", name, fw->size);
 
-       /*
-        * if enabling an IOMMU isn't relevant for this rproc, this is
-        * just a nop
-        */
-       ret = rproc_enable_iommu(rproc);
-       if (ret) {
-               dev_err(dev, "can't enable iommu: %d\n", ret);
-               return ret;
-       }
-
        rproc->bootaddr = rproc_get_boot_addr(rproc, fw);
 
        /* look for the resource table */
@@ -1045,12 +1036,23 @@ int rproc_boot(struct rproc *rproc)
                goto downref_rproc;
        }
 
+       /*
+        * if enabling an IOMMU isn't relevant for this rproc, this is
+        * just a nop
+        */
+       ret = rproc_enable_iommu(rproc);
+       if (ret) {
+               dev_err(dev, "can't enable iommu: %d\n", ret);
+               goto downref_rproc;
+       }
+
        ret = rproc_fw_boot(rproc, firmware_p);
 
        release_firmware(firmware_p);
 
 downref_rproc:
        if (ret) {
+               rproc_disable_iommu(rproc);
                module_put(dev->parent->driver->owner);
                atomic_dec(&rproc->power);
        }
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to