From 12ce2f1b43c4033b4be346f5f69d11dd7e5c78b3 Mon Sep 17 00:00:00 2001
From: Fugang Duan <fugang.duan@nxp.com>
Date: Wed, 20 Mar 2019 15:06:58 +0800
Subject: [PATCH] MLK-21194 rpmsg: imx_rpmsg: clear pending partition reboot
 irq status

Clear pending interrupt status of partition reboot during rpmsg
driver probe to avoid to unregister/register virtio device again.

Tested-by: Clark Wang <xiaoning.wang@nxp.com>
Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
---
 drivers/rpmsg/imx_rpmsg.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/rpmsg/imx_rpmsg.c b/drivers/rpmsg/imx_rpmsg.c
index fab8b6ba257d6a..e8878967b6cc48 100644
--- a/drivers/rpmsg/imx_rpmsg.c
+++ b/drivers/rpmsg/imx_rpmsg.c
@@ -694,6 +694,8 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
 		uint32_t mu_id;
 		sc_err_t sciErr;
 		static sc_ipc_t mu_ipchandle;
+		uint32_t irq_status;
+
 		/* Get muB partition id and enable irq in SCFW then */
 		if (of_property_read_u32(np, "mub-partition",
 					&rpdev->mub_partition))
@@ -712,6 +714,15 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
 			return sciErr;
 		};
 
+		/* Clear any pending partition reset interrupt during
+		 * rpmsg probe.
+		 */
+		sciErr = sc_irq_status(mu_ipchandle, SC_R_MU_1A,
+				       SC_IRQ_GROUP_REBOOTED,
+				       &irq_status);
+		if (sciErr != SC_ERR_NONE)
+			pr_info("Cannot get partition reboot interrupt status\n");
+
 		/* Request for the partition reset interrupt. */
 		sciErr = sc_irq_enable(mu_ipchandle, SC_R_MU_1A,
 				       SC_IRQ_GROUP_REBOOTED,
-- 
GitLab