From: Arnaud Pouliquen <arnaud.pouliquen@st.com> To: Bjorn Andersson <bjorn.andersson@linaro.org>, Ohad Ben-Cohen <ohad@wizery.com>, Mathieu Poirier <mathieu.poirier@linaro.org> Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, arnaud.pouliquen@st.com Subject: [RFC 16/18] remoteproc: Parse virtio node for memory region Date: Thu, 16 Apr 2020 18:13:29 +0200 [thread overview] Message-ID: <20200416161331.7606-17-arnaud.pouliquen@st.com> (raw) In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> Add the possibility to declare memories associated to the virtio paltform in the device tree. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com> --- drivers/remoteproc/remoteproc_virtio.c | 77 +++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 0fd938afd146..3302ee7d6c14 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -610,12 +610,71 @@ static const struct component_ops rproc_virtio_ops = { .unbind = rproc_virtio_unbind, }; +static int rproc_virtio_of_parse(struct device *dev, struct rproc_vdev *rvdev) +{ + struct device_node *np = dev->of_node; + struct rproc *rproc = rvdev->rproc; + struct of_phandle_iterator it; + struct rproc_mem_entry *mem; + struct reserved_mem *rmem; + char name[32]; + u64 da; + int index = 0; + + /* the reg is used to specify the vdev index */ + if (of_property_read_u32(np, "reg", &rvdev->index)) + return -EINVAL; + /* Register associated reserved memory regions */ + of_phandle_iterator_init(&it, np, "memory-region", NULL, 0); + + while (of_phandle_iterator_next(&it) == 0) { + rmem = of_reserved_mem_lookup(it.node); + if (!rmem) { + dev_err(dev, "unable to acquire memory-region\n"); + return -EINVAL; + } + + if (rproc_pa_to_da(rproc, rmem->base, &da) < 0) { + dev_err(dev, "memory region not valid %pa\n", + &rmem->base); + return -EINVAL; + } + + snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); + if (strcmp(it.node->name, name)) { + /* Register memory region */ + mem = rproc_mem_entry_init(dev, NULL, + (dma_addr_t)rmem->base, + rmem->size, da, + rproc_default_mem_alloc, + rproc_default_mem_release, + it.node->name); + + if (mem) + rproc_coredump_add_segment(rproc, da, + rmem->size); + } else { + /* Register reserved memory for vdev buffer alloc */ + mem = rproc_of_resm_mem_entry_init(dev, index, + rmem->size, + rmem->base, + it.node->name); + } + + if (!mem) + return -ENOMEM; + + rproc_add_carveout(rproc, mem); + index++; + } + + return 0; +} + static int rproc_virtio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node; struct rproc_vdev *rvdev; - struct rproc *rproc; int ret; rvdev = devm_kzalloc(&pdev->dev, sizeof(*rvdev), GFP_KERNEL); @@ -627,18 +686,16 @@ static int rproc_virtio_probe(struct platform_device *pdev) * The platform device is declared in the device tree * retrieve rproc struct through the remoteproc platform */ - rproc = rproc_get_by_node(dev->parent->of_node); + rvdev->rproc = rproc_get_by_node(dev->parent->of_node); - /* the reg is used to specify the vdev index */ - if (of_property_read_u32(np, "reg", &rvdev->index)) - return -EINVAL; + ret = rproc_virtio_of_parse(dev, rvdev); } else { struct rproc_vdev_data *vdev_data = pdev->dev.platform_data; if (!vdev_data) return -EINVAL; - rproc = container_of(dev->parent, struct rproc, dev); + rvdev->rproc = container_of(dev->parent, struct rproc, dev); rvdev->rsc_offset = vdev_data->rsc_offset; rvdev->rsc = vdev_data->rsc; @@ -649,8 +706,10 @@ static int rproc_virtio_probe(struct platform_device *pdev) if (ret) return ret; } + if (ret) + return ret; + rvdev->pdev = pdev; - rvdev->rproc = rproc; platform_set_drvdata(pdev, rvdev); @@ -658,7 +717,7 @@ static int rproc_virtio_probe(struct platform_device *pdev) if (ret) return ret; - rproc_register_rvdev(rproc, rvdev); + rproc_register_rvdev(rvdev->rproc, rvdev); return 0; } -- 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Arnaud Pouliquen <arnaud.pouliquen@st.com> To: Bjorn Andersson <bjorn.andersson@linaro.org>, Ohad Ben-Cohen <ohad@wizery.com>, Mathieu Poirier <mathieu.poirier@linaro.org> Cc: <linux-remoteproc@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-stm32@st-md-mailman.stormreply.com>, <arnaud.pouliquen@st.com> Subject: [RFC 16/18] remoteproc: Parse virtio node for memory region Date: Thu, 16 Apr 2020 18:13:29 +0200 [thread overview] Message-ID: <20200416161331.7606-17-arnaud.pouliquen@st.com> (raw) Message-ID: <20200416161329.IacgJJPr4pOicCfPsk9Aa8fknj4sIQHWODrGqZ5TskA@z> (raw) In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> Add the possibility to declare memories associated to the virtio paltform in the device tree. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com> --- drivers/remoteproc/remoteproc_virtio.c | 77 +++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 0fd938afd146..3302ee7d6c14 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -610,12 +610,71 @@ static const struct component_ops rproc_virtio_ops = { .unbind = rproc_virtio_unbind, }; +static int rproc_virtio_of_parse(struct device *dev, struct rproc_vdev *rvdev) +{ + struct device_node *np = dev->of_node; + struct rproc *rproc = rvdev->rproc; + struct of_phandle_iterator it; + struct rproc_mem_entry *mem; + struct reserved_mem *rmem; + char name[32]; + u64 da; + int index = 0; + + /* the reg is used to specify the vdev index */ + if (of_property_read_u32(np, "reg", &rvdev->index)) + return -EINVAL; + /* Register associated reserved memory regions */ + of_phandle_iterator_init(&it, np, "memory-region", NULL, 0); + + while (of_phandle_iterator_next(&it) == 0) { + rmem = of_reserved_mem_lookup(it.node); + if (!rmem) { + dev_err(dev, "unable to acquire memory-region\n"); + return -EINVAL; + } + + if (rproc_pa_to_da(rproc, rmem->base, &da) < 0) { + dev_err(dev, "memory region not valid %pa\n", + &rmem->base); + return -EINVAL; + } + + snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); + if (strcmp(it.node->name, name)) { + /* Register memory region */ + mem = rproc_mem_entry_init(dev, NULL, + (dma_addr_t)rmem->base, + rmem->size, da, + rproc_default_mem_alloc, + rproc_default_mem_release, + it.node->name); + + if (mem) + rproc_coredump_add_segment(rproc, da, + rmem->size); + } else { + /* Register reserved memory for vdev buffer alloc */ + mem = rproc_of_resm_mem_entry_init(dev, index, + rmem->size, + rmem->base, + it.node->name); + } + + if (!mem) + return -ENOMEM; + + rproc_add_carveout(rproc, mem); + index++; + } + + return 0; +} + static int rproc_virtio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node; struct rproc_vdev *rvdev; - struct rproc *rproc; int ret; rvdev = devm_kzalloc(&pdev->dev, sizeof(*rvdev), GFP_KERNEL); @@ -627,18 +686,16 @@ static int rproc_virtio_probe(struct platform_device *pdev) * The platform device is declared in the device tree * retrieve rproc struct through the remoteproc platform */ - rproc = rproc_get_by_node(dev->parent->of_node); + rvdev->rproc = rproc_get_by_node(dev->parent->of_node); - /* the reg is used to specify the vdev index */ - if (of_property_read_u32(np, "reg", &rvdev->index)) - return -EINVAL; + ret = rproc_virtio_of_parse(dev, rvdev); } else { struct rproc_vdev_data *vdev_data = pdev->dev.platform_data; if (!vdev_data) return -EINVAL; - rproc = container_of(dev->parent, struct rproc, dev); + rvdev->rproc = container_of(dev->parent, struct rproc, dev); rvdev->rsc_offset = vdev_data->rsc_offset; rvdev->rsc = vdev_data->rsc; @@ -649,8 +706,10 @@ static int rproc_virtio_probe(struct platform_device *pdev) if (ret) return ret; } + if (ret) + return ret; + rvdev->pdev = pdev; - rvdev->rproc = rproc; platform_set_drvdata(pdev, rvdev); @@ -658,7 +717,7 @@ static int rproc_virtio_probe(struct platform_device *pdev) if (ret) return ret; - rproc_register_rvdev(rproc, rvdev); + rproc_register_rvdev(rvdev->rproc, rvdev); return 0; } -- 2.17.1
next prev parent reply other threads:[~2020-04-16 16:13 UTC|newest] Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-16 16:13 [RFC 00/18] remoteproc: Decorelate virtio from core Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 01/18] remoteproc: Store resource table address in rvdev Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 02/18] remoteproc: Introduce virtio device add/remove functions in core Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-21 20:41 ` Mathieu Poirier 2020-04-22 12:30 ` Arnaud POULIQUEN 2020-04-22 12:30 ` Arnaud POULIQUEN 2020-04-22 16:57 ` Mathieu Poirier 2020-04-16 16:13 ` [RFC 03/18] remoteproc: Move rvdev management in rproc_virtio Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-21 22:18 ` Mathieu Poirier 2020-04-22 17:26 ` Mathieu Poirier 2020-04-16 16:13 ` [RFC 04/18] remoteproc: Add rproc_get_by_node helper Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 05/18] remoteproc: Create platform device for vdev Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 06/18] remoteproc: Add component in core for child devices synchronization Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 07/18] remoteproc: Add component bind/unbind for virtio platform Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 08/18] remoteproc: Externalize carveout functions Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 09/18] remoteproc: Move vring management from core to virtio Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 10/18] remoteproc: Add capability to populate rproc subnode devices Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 11/18] remoteproc: Add child node component in rproc match list Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 12/18] remoteproc: Support of pre-registered virtio device Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 13/18] remoteproc: Add memory default allocator helper Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 14/18] remoteproc: Add pa to da translation API Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 15/18] remoteproc: associate memory entry to a device Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen [this message] 2020-04-16 16:13 ` [RFC 16/18] remoteproc: Parse virtio node for memory region Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 17/18] remoteproc: stm32: Add the pa to da ops Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-16 16:13 ` [RFC 18/18] ARM: dts: stm32: Declare a virtio device Arnaud Pouliquen 2020-04-16 16:13 ` Arnaud Pouliquen 2020-04-23 17:26 ` [RFC 00/18] remoteproc: Decorelate virtio from core Mathieu Poirier
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=20200416161331.7606-17-arnaud.pouliquen@st.com \ --to=arnaud.pouliquen@st.com \ --cc=bjorn.andersson@linaro.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-remoteproc@vger.kernel.org \ --cc=linux-stm32@st-md-mailman.stormreply.com \ --cc=mathieu.poirier@linaro.org \ --cc=ohad@wizery.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.