From 04e944b4539a6c73e57cf1f847eff73649f728c9 Mon Sep 17 00:00:00 2001 From: Richard Zhu Date: Tue, 11 Dec 2018 09:44:31 +0800 Subject: MLK-20637-2 rpmsg: imx: alloc share mem from per dev dma pool - reserve one per dev dma pool, and alloc the share memory from it. Signed-off-by: Richard Zhu Acked-by: Fugang Duan --- drivers/rpmsg/imx_rpmsg.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'drivers/rpmsg/imx_rpmsg.c') diff --git a/drivers/rpmsg/imx_rpmsg.c b/drivers/rpmsg/imx_rpmsg.c index 30cc8b8194ce..5cb97a0bb65d 100644 --- a/drivers/rpmsg/imx_rpmsg.c +++ b/drivers/rpmsg/imx_rpmsg.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -527,7 +528,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev) ret = imx_rpmsg_mu_init(rpdev); if (ret) { pr_err("unable to initialize mu module.\n"); - return ret; + goto vdev_err_out; } INIT_DELAYED_WORK(&(rpdev->rpmsg_work), rpmsg_work_handler); BLOCKING_INIT_NOTIFIER_HEAD(&(rpdev->notifier)); @@ -539,7 +540,8 @@ static int imx_rpmsg_probe(struct platform_device *pdev) rpdev->vdev_nums = 1; if (rpdev->vdev_nums > MAX_VDEV_NUMS) { pr_err("vdev-nums exceed the max %d\n", MAX_VDEV_NUMS); - return -EINVAL; + ret = -EINVAL; + goto vdev_err_out; } rpdev->first_notify = rpdev->vdev_nums; @@ -548,13 +550,24 @@ static int imx_rpmsg_probe(struct platform_device *pdev) rpdev->vdev_nums); if (ret) { pr_err("No vring buffer.\n"); - return -ENOMEM; + ret = -ENOMEM; + goto vdev_err_out; } } else { pr_err("No remote m4 processor.\n"); - return -ENODEV; + ret = -ENODEV; + goto vdev_err_out; } + + if (rpdev->variant == IMX8QM || rpdev->variant == IMX8QXP) { + if (of_reserved_mem_device_init(&pdev->dev)) { + dev_err(&pdev->dev, + "dev doesn't have specific DMA pool.\n"); + ret = -ENOMEM; + goto vdev_err_out; + } + } for (j = 0; j < rpdev->vdev_nums; j++) { pr_debug("%s rpdev%d vdev%d: vring0 0x%x, vring1 0x%x\n", __func__, rpdev->core_id, rpdev->vdev_nums, @@ -570,13 +583,22 @@ static int imx_rpmsg_probe(struct platform_device *pdev) if (ret) { pr_err("%s failed to register rpdev: %d\n", __func__, ret); - return ret; + goto err_out; } - } + platform_set_drvdata(pdev, rpdev); return ret; + +err_out: + if (rpdev->variant == IMX8QM || rpdev->variant == IMX8QXP) + of_reserved_mem_device_release(&pdev->dev); +vdev_err_out: + if (rpdev->variant == IMX7D || rpdev->variant == IMX8QXP + || rpdev->variant == IMX8QM) + clk_disable_unprepare(rpdev->mu_clk); + return ret; } #ifdef CONFIG_PM_SLEEP -- cgit v1.2.3