MLK-20446 rpmsg: imx: only use the timeout by the first notify
authorRichard Zhu <hongxing.zhu@nxp.com>
Thu, 22 Nov 2018 06:11:05 +0000 (14:11 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
To make sure that the message wound't be discarded when
M4 is running normally or in the suspend mode. Only use
the timeout mechanism by the first notify when the vdev
is registered.

Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
(cherry picked from commit aaf42a6c2c224aa9bd88b13abcf8f848f2eab073)
Signed-off-by: Arulpandiyan Vadivel <arulpandiyan_vadivel@mentor.com>
drivers/rpmsg/imx_rpmsg.c

index fcd0c76..da87ca5 100644 (file)
@@ -55,6 +55,7 @@ struct imx_rpmsg_vproc {
        struct clk *mu_clk;
        enum imx_rpmsg_variants variant;
        int vdev_nums;
+       int first_notify;
 #define MAX_VDEV_NUMS  8
        struct imx_virdev ivdev[MAX_VDEV_NUMS];
        void __iomem *mu_base;
@@ -126,8 +127,17 @@ static bool imx_rpmsg_notify(struct virtqueue *vq)
         * Use the timeout MU send message here.
         * Since that M4 core may not be loaded, and the first MSG may
         * not be handled by M4 when multi-vdev is enabled.
+        * To make sure that the message wound't be discarded when M4
+        * is running normally or in the suspend mode. Only use
+        * the timeout mechanism by the first notify when the vdev is
+        * registered.
         */
-       MU_SendMessageTimeout(rpvq->rpdev->mu_base, 1, mu_rpmsg, 200);
+       if (unlikely(rpvq->rpdev->first_notify > 0)) {
+               rpvq->rpdev->first_notify--;
+               MU_SendMessageTimeout(rpvq->rpdev->mu_base, 1, mu_rpmsg, 200);
+       } else {
+               MU_SendMessage(rpvq->rpdev->mu_base, 1, mu_rpmsg);
+       }
        mutex_unlock(&rpvq->rpdev->lock);
 
        return true;
@@ -531,6 +541,7 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
                pr_err("vdev-nums exceed the max %d\n", MAX_VDEV_NUMS);
                return -EINVAL;
        }
+       rpdev->first_notify = rpdev->vdev_nums;
 
        if (!strcmp(rpdev->rproc_name, "m4")) {
                ret = set_vring_phy_buf(pdev, rpdev,