summaryrefslogtreecommitdiff
path: root/drivers/rpmsg
diff options
context:
space:
mode:
authorRichard Zhu <hongxing.zhu@nxp.com>2018-12-11 09:44:31 +0800
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:35:51 +0800
commit04e944b4539a6c73e57cf1f847eff73649f728c9 (patch)
tree82fceb27e82fddde1d37f37ee530f0fc8d561c31 /drivers/rpmsg
parent503fe07760fba948276189066a15595349453523 (diff)
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 <hongxing.zhu@nxp.com> Acked-by: Fugang Duan <fugang.duan@nxp.com>
Diffstat (limited to 'drivers/rpmsg')
-rw-r--r--drivers/rpmsg/imx_rpmsg.c34
1 files changed, 28 insertions, 6 deletions
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 <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_irq.h>
+#include <linux/of_reserved_mem.h>
#include <linux/platform_device.h>
#include <linux/rpmsg.h>
#include <linux/slab.h>
@@ -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