diff mbox series

[v4,17/17] rpmsg: virtio: allocate buffer from parent

Message ID 1532697292-14272-18-git-send-email-loic.pallardy@st.com
State Superseded
Headers show
Series remoteproc: add fixed memory region support | expand

Commit Message

Loic Pallardy July 27, 2018, 1:14 p.m. UTC
Remoteproc is now capable to create one specific sub-device per
virtio link to associate a dedicated memory pool.
This implies to change device used by virtio_rpmsg for
buffer allocation from grand-parent to parent.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>

---
 drivers/rpmsg/virtio_rpmsg_bus.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
1.9.1

Comments

Anup Patel Sept. 28, 2018, 7:56 a.m. UTC | #1
On Fri, Jul 27, 2018 at 6:45 PM Loic Pallardy <loic.pallardy@st.com> wrote:
>

> Remoteproc is now capable to create one specific sub-device per

> virtio link to associate a dedicated memory pool.

> This implies to change device used by virtio_rpmsg for

> buffer allocation from grand-parent to parent.

>

> Signed-off-by: Loic Pallardy <loic.pallardy@st.com>

> ---

>  drivers/rpmsg/virtio_rpmsg_bus.c | 6 +++---

>  1 file changed, 3 insertions(+), 3 deletions(-)

>

> diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c

> index 664f957..5c89201 100644

> --- a/drivers/rpmsg/virtio_rpmsg_bus.c

> +++ b/drivers/rpmsg/virtio_rpmsg_bus.c

> @@ -912,7 +912,7 @@ static int rpmsg_probe(struct virtio_device *vdev)

>         total_buf_space = vrp->num_bufs * vrp->buf_size;

>

>         /* allocate coherent memory for the buffers */

> -       bufs_va = dma_alloc_coherent(vdev->dev.parent->parent,

> +       bufs_va = dma_alloc_coherent(vdev->dev.parent,

>                                      total_buf_space, &vrp->bufs_dma,

>                                      GFP_KERNEL);

>         if (!bufs_va) {

> @@ -980,7 +980,7 @@ static int rpmsg_probe(struct virtio_device *vdev)

>         return 0;

>

>  free_coherent:

> -       dma_free_coherent(vdev->dev.parent->parent, total_buf_space,

> +       dma_free_coherent(vdev->dev.parent, total_buf_space,

>                           bufs_va, vrp->bufs_dma);

>  vqs_del:

>         vdev->config->del_vqs(vrp->vdev);

> @@ -1015,7 +1015,7 @@ static void rpmsg_remove(struct virtio_device *vdev)

>

>         vdev->config->del_vqs(vrp->vdev);

>

> -       dma_free_coherent(vdev->dev.parent->parent, total_buf_space,

> +       dma_free_coherent(vdev->dev.parent, total_buf_space,

>                           vrp->rbufs, vrp->bufs_dma);

>

>         kfree(vrp);

> --

> 1.9.1

>


Reviewed-by: Anup Patel <anup@brainfault.org>


Also, tried this patch on Linux running inside Guest/VM on
Xvisor ARM/ARM64.
Tested-by: Anup Patel <anup@brainfault.org>


Regards,
Anup
diff mbox series

Patch

diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index 664f957..5c89201 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -912,7 +912,7 @@  static int rpmsg_probe(struct virtio_device *vdev)
 	total_buf_space = vrp->num_bufs * vrp->buf_size;
 
 	/* allocate coherent memory for the buffers */
-	bufs_va = dma_alloc_coherent(vdev->dev.parent->parent,
+	bufs_va = dma_alloc_coherent(vdev->dev.parent,
 				     total_buf_space, &vrp->bufs_dma,
 				     GFP_KERNEL);
 	if (!bufs_va) {
@@ -980,7 +980,7 @@  static int rpmsg_probe(struct virtio_device *vdev)
 	return 0;
 
 free_coherent:
-	dma_free_coherent(vdev->dev.parent->parent, total_buf_space,
+	dma_free_coherent(vdev->dev.parent, total_buf_space,
 			  bufs_va, vrp->bufs_dma);
 vqs_del:
 	vdev->config->del_vqs(vrp->vdev);
@@ -1015,7 +1015,7 @@  static void rpmsg_remove(struct virtio_device *vdev)
 
 	vdev->config->del_vqs(vrp->vdev);
 
-	dma_free_coherent(vdev->dev.parent->parent, total_buf_space,
+	dma_free_coherent(vdev->dev.parent, total_buf_space,
 			  vrp->rbufs, vrp->bufs_dma);
 
 	kfree(vrp);