remoteproc: configure IOMMU only if device address requested
authorLoic Pallardy <loic.pallardy@st.com>
Fri, 27 Jul 2018 13:14:36 +0000 (15:14 +0200)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Wed, 10 Oct 2018 05:38:37 +0000 (22:38 -0700)
If there is no IOMMU associate to remote processor device,
remoteproc_core won't be able to satisfy device address requested
in firmware resource table.
Return an error as configuration won't be coherent.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/remoteproc/remoteproc_core.c

index aa62067..8ca752c 100644 (file)
@@ -657,7 +657,15 @@ static int rproc_handle_carveout(struct rproc *rproc,
         * to use the iommu-based DMA API: we expect 'dma' to contain the
         * physical address in this case.
         */
-       if (rproc->domain) {
+
+       if (rsc->da != FW_RSC_ADDR_ANY && !rproc->domain) {
+               dev_err(dev->parent,
+                       "Bad carveout rsc configuration\n");
+               ret = -ENOMEM;
+               goto dma_free;
+       }
+
+       if (rsc->da != FW_RSC_ADDR_ANY && rproc->domain) {
                mapping = kzalloc(sizeof(*mapping), GFP_KERNEL);
                if (!mapping) {
                        ret = -ENOMEM;