From: Loic Pallardy <loic.pallardy@st.com> To: bjorn.andersson@linaro.org, ohad@wizery.com Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, arnaud.pouliquen@st.com, benjamin.gaignard@linaro.org, s-anna@ti.com, Loic Pallardy <loic.pallardy@st.com> Subject: [PATCH 5/7] remoteproc: fix rproc_alloc_carveout() for rproc with iommu domain Date: Thu, 29 Nov 2018 22:29:26 +0100 [thread overview] Message-ID: <1543526968-56091-6-git-send-email-loic.pallardy@st.com> (raw) In-Reply-To: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> Correct remoteproc core behavior when memory carveout device address is fixed in resource table and rproc device doesn't have associated IOMMU. Current returned error is breaking legacy on TI platforms. This patch restores previous behavior. It adds a warn message when allocation doesn't fit carveout request, but doesn't stop rproc_start() sequence anymore. Fixes: 3bc8140b157c ("remoteproc: configure IOMMU only if device address requested") Signed-off-by: Loic Pallardy <loic.pallardy@st.com> --- drivers/remoteproc/remoteproc_core.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 61c954bd695e..f19bc6961e40 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -719,6 +719,18 @@ static int rproc_alloc_carveout(struct rproc *rproc, dev_dbg(dev, "carveout va %pK, dma %pad, len 0x%x\n", va, &dma, mem->len); + if (mem->da != FW_RSC_ADDR_ANY && !rproc->domain) { + /* + * Check requested da is equal to dma address + * and print a warn message in case of missalignment. + * Don't stop rproc_start sequence as coprocessor may + * build pa to da translation on its side. + */ + if (mem->da != (u32)dma) + dev_warn(dev->parent, + "Allocated carveout doesn't fit device address request\n"); + } + /* * Ok, this is non-standard. * @@ -736,15 +748,7 @@ static int rproc_alloc_carveout(struct rproc *rproc, * to use the iommu-based DMA API: we expect 'dma' to contain the * physical address in this case. */ - - if (mem->da != FW_RSC_ADDR_ANY) { - if (!rproc->domain) { - dev_err(dev->parent, - "Bad carveout rsc configuration\n"); - ret = -ENOMEM; - goto dma_free; - } - + if (mem->da != FW_RSC_ADDR_ANY && rproc->domain) { mapping = kzalloc(sizeof(*mapping), GFP_KERNEL); if (!mapping) { ret = -ENOMEM; @@ -771,7 +775,9 @@ static int rproc_alloc_carveout(struct rproc *rproc, dev_dbg(dev, "carveout mapped 0x%x to %pad\n", mem->da, &dma); - } else { + } + + if (mem->da == FW_RSC_ADDR_ANY) { /* Update device address as undefined by requester */ if (sizeof(dma_addr_t) > sizeof(u32)) dev_warn(dev, "DMA address cast in 32bit to fit resource table format\n"); -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: Loic Pallardy <loic.pallardy@st.com> To: <bjorn.andersson@linaro.org>, <ohad@wizery.com> Cc: <linux-remoteproc@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <arnaud.pouliquen@st.com>, <benjamin.gaignard@linaro.org>, <s-anna@ti.com>, Loic Pallardy <loic.pallardy@st.com> Subject: [PATCH 5/7] remoteproc: fix rproc_alloc_carveout() for rproc with iommu domain Date: Thu, 29 Nov 2018 22:29:26 +0100 [thread overview] Message-ID: <1543526968-56091-6-git-send-email-loic.pallardy@st.com> (raw) In-Reply-To: <1543526968-56091-1-git-send-email-loic.pallardy@st.com> Correct remoteproc core behavior when memory carveout device address is fixed in resource table and rproc device doesn't have associated IOMMU. Current returned error is breaking legacy on TI platforms. This patch restores previous behavior. It adds a warn message when allocation doesn't fit carveout request, but doesn't stop rproc_start() sequence anymore. Fixes: 3bc8140b157c ("remoteproc: configure IOMMU only if device address requested") Signed-off-by: Loic Pallardy <loic.pallardy@st.com> --- drivers/remoteproc/remoteproc_core.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 61c954bd695e..f19bc6961e40 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -719,6 +719,18 @@ static int rproc_alloc_carveout(struct rproc *rproc, dev_dbg(dev, "carveout va %pK, dma %pad, len 0x%x\n", va, &dma, mem->len); + if (mem->da != FW_RSC_ADDR_ANY && !rproc->domain) { + /* + * Check requested da is equal to dma address + * and print a warn message in case of missalignment. + * Don't stop rproc_start sequence as coprocessor may + * build pa to da translation on its side. + */ + if (mem->da != (u32)dma) + dev_warn(dev->parent, + "Allocated carveout doesn't fit device address request\n"); + } + /* * Ok, this is non-standard. * @@ -736,15 +748,7 @@ static int rproc_alloc_carveout(struct rproc *rproc, * to use the iommu-based DMA API: we expect 'dma' to contain the * physical address in this case. */ - - if (mem->da != FW_RSC_ADDR_ANY) { - if (!rproc->domain) { - dev_err(dev->parent, - "Bad carveout rsc configuration\n"); - ret = -ENOMEM; - goto dma_free; - } - + if (mem->da != FW_RSC_ADDR_ANY && rproc->domain) { mapping = kzalloc(sizeof(*mapping), GFP_KERNEL); if (!mapping) { ret = -ENOMEM; @@ -771,7 +775,9 @@ static int rproc_alloc_carveout(struct rproc *rproc, dev_dbg(dev, "carveout mapped 0x%x to %pad\n", mem->da, &dma); - } else { + } + + if (mem->da == FW_RSC_ADDR_ANY) { /* Update device address as undefined by requester */ if (sizeof(dma_addr_t) > sizeof(u32)) dev_warn(dev, "DMA address cast in 32bit to fit resource table format\n"); -- 2.7.4
next prev parent reply other threads:[~2018-11-29 21:29 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-11-29 21:29 [PATCH 0/7] remoteproc: Fixes for memoy carveout management Loic Pallardy 2018-11-29 21:29 ` Loic Pallardy 2018-11-29 21:29 ` [PATCH 1/7] remoteproc: correct rproc_mem_entry_init() comments Loic Pallardy 2018-11-29 21:29 ` Loic Pallardy 2018-11-29 21:29 ` [PATCH 2/7] remoteproc: fix rproc_da_to_va in case of unallocated carveout Loic Pallardy 2018-11-29 21:29 ` Loic Pallardy 2018-11-29 21:29 ` [PATCH 3/7] remoteproc: fix rproc_alloc_carveout() bad variable cast Loic Pallardy 2018-11-29 21:29 ` Loic Pallardy 2018-11-29 21:29 ` [PATCH 4/7] remoteproc: add warning on resource table cast Loic Pallardy 2018-11-29 21:29 ` Loic Pallardy 2018-11-30 14:33 ` Arnd Bergmann 2018-11-30 20:48 ` Loic PALLARDY 2018-11-29 21:29 ` Loic Pallardy [this message] 2018-11-29 21:29 ` [PATCH 5/7] remoteproc: fix rproc_alloc_carveout() for rproc with iommu domain Loic Pallardy 2018-11-29 21:29 ` [PATCH 6/7] remoteproc: fix trace buffer va initialization Loic Pallardy 2018-11-29 21:29 ` Loic Pallardy 2018-12-06 20:37 ` Loic PALLARDY 2018-12-06 20:37 ` Loic PALLARDY 2018-11-29 21:29 ` [PATCH 7/7] remoteproc: fix rproc_check_carveout_da() returned error and comments Loic Pallardy 2018-11-29 21:29 ` Loic Pallardy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1543526968-56091-6-git-send-email-loic.pallardy@st.com \ --to=loic.pallardy@st.com \ --cc=arnaud.pouliquen@st.com \ --cc=benjamin.gaignard@linaro.org \ --cc=bjorn.andersson@linaro.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-remoteproc@vger.kernel.org \ --cc=ohad@wizery.com \ --cc=s-anna@ti.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.