From: Wendy Liang <wendy.liang@xilinx.com>
To: <bjorn.andersson@linaro.org>
Cc: <linux-remoteproc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
"Wendy Liang" <wendy.liang@xilinx.com>,
Wendy Liang <jliang@xilinx.com>,
Michal Simek <michal.simek@xilinx.com>
Subject: [RFC LINUX PATCH 2/3] remoteproc: add rproc_mem resource entry handler
Date: Fri, 24 Mar 2017 12:22:15 -0700 [thread overview]
Message-ID: <1490383336-23117-3-git-send-email-jliang@xilinx.com> (raw)
In-Reply-To: <1490383336-23117-1-git-send-email-jliang@xilinx.com>
From: Wendy Liang <wendy.liang@xilinx.com>
Add resource table handler to handle fw_rsc_rproc_mem entry.
Signed-off-by: Wendy Liang <jliang@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
drivers/remoteproc/remoteproc_core.c | 37 ++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 3dabb20..0ffd9dc 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -720,6 +720,42 @@ static int rproc_handle_carveout(struct rproc *rproc,
return ret;
}
+/**
+ * rproc_handle_rproc_mem() - handle remote processor memory
+ * @rproc: rproc handle
+ * @rsc: the resource entry
+ * @avail: size of available data (for image validation)
+ *
+ * This function will handle declare the remote procesor's memory
+ * as DMA memory of the remoteproc, and then, the host can use it
+ * as shared memory, e.g. vrings ahre shared buffers.
+ */
+static int rproc_handle_rproc_mem(struct rproc *rproc,
+ struct fw_rsc_rproc_mem *rsc,
+ int offset, int avail)
+{
+ struct device *dev = &rproc->dev;
+ int ret;
+
+ if (sizeof(*rsc) > avail) {
+ dev_err(dev, "rproc_mem rsc is truncated\n");
+ return -EINVAL;
+ }
+
+ if (rsc->pa == FW_RSC_ADDR_ANY) {
+ dev_err(dev, "not able to declare rproc mem, pa is 0x%x\n",
+ rsc->pa);
+ return -EINVAL;
+ }
+ ret = dma_declare_coherent_memory(dev->parent, rsc->pa,
+ rsc->pa, rsc->len, DMA_MEMORY_MAP);
+ if (!ret) {
+ dev_err(dev, "failed to declare rproc mem as DMA mem.\n");
+ return -ENOMEM;
+ }
+ return 0;
+}
+
/*
* A lookup table for resource handlers. The indices are defined in
* enum fw_resource_type.
@@ -729,6 +765,7 @@ static int rproc_handle_carveout(struct rproc *rproc,
[RSC_DEVMEM] = (rproc_handle_resource_t)rproc_handle_devmem,
[RSC_TRACE] = (rproc_handle_resource_t)rproc_handle_trace,
[RSC_VDEV] = (rproc_handle_resource_t)rproc_handle_vdev,
+ [RSC_RPROC_MEM] = (rproc_handle_resource_t)rproc_handle_rproc_mem,
};
/* handle firmware resource entries before booting the remote processor */
--
1.9.1
next prev parent reply other threads:[~2017-03-24 19:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-24 19:22 [RFC LINUX PATCH 0/3] Allow remote to specify shared memory Wendy Liang
2017-03-24 19:22 ` [RFC LINUX PATCH 1/3] remoteproc: add rproc mem resource entry Wendy Liang
2017-03-24 19:22 ` Wendy Liang [this message]
2017-03-24 19:22 ` [RFC LINUX PATCH 3/3] remoteproc: Release DMA declare mem when cleanup rsc Wendy Liang
2017-03-27 15:54 ` [RFC LINUX PATCH 0/3] Allow remote to specify shared memory Suman Anna
2017-03-28 18:52 ` Wendy Liang
2017-03-28 23:24 ` Suman Anna
2017-03-29 16:41 ` Jiaying Liang
2017-03-29 18:56 ` Loic PALLARDY
2017-03-30 17:39 ` Jiaying Liang
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=1490383336-23117-3-git-send-email-jliang@xilinx.com \
--to=wendy.liang@xilinx.com \
--cc=bjorn.andersson@linaro.org \
--cc=jliang@xilinx.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=michal.simek@xilinx.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®