From c6ef11f827d12e61f26c737b1199655065cf77f9 Mon Sep 17 00:00:00 2001
From: Han Xu <han.xu@nxp.com>
Date: Wed, 8 Nov 2017 15:55:27 -0600
Subject: [PATCH] MLK-16786: dma: mxs-dma: fix the unbalanced runtime pm
 counter

mxs-dma init function will call runtime pm init, the redundant
pm_runtime_force_resume will mess up the counter. Also remove some
unnecessary code.

Signed-off-by: Han Xu <han.xu@nxp.com>
Reviewed-by: Frank Li <frank.li@nxp.com>

During 4.14 rebase squashed the following:

MLK-16800: dma: mxs-dma: correctly handle mxs-dma clock

enable mxs-dma clock before HW reset and disable clock after it.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
Signed-off-by: Srikanth Krishnakar <Srikanth_Krishnakar@mentor.com>
---
 drivers/dma/mxs-dma.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index 81780532b4e6c4..5a16998a99e2e2 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -1,5 +1,6 @@
 /*
  * Copyright 2011-2015 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2017 NXP
  *
  * Refer to drivers/dma/imx-sdma.c
  *
@@ -720,8 +721,8 @@ static int mxs_dma_init_rpm(struct mxs_dma_engine *mxs_dma)
 
 static int mxs_dma_init(struct mxs_dma_engine *mxs_dma)
 {
-	int ret;
 	struct device *dev = &mxs_dma->pdev->dev;
+	int ret;
 
 	ret = mxs_dma_init_rpm(mxs_dma);
 	if (ret)
@@ -749,10 +750,10 @@ static int mxs_dma_init(struct mxs_dma_engine *mxs_dma)
 	writel(MXS_DMA_CHANNELS_MASK << MXS_DMA_CHANNELS,
 		mxs_dma->base + HW_APBHX_CTRL1 + STMP_OFFSET_REG_SET);
 
-err_clk:
 	pm_runtime_mark_last_busy(dev);
 	pm_runtime_put_autosuspend(dev);
 
+err_clk:
 	return ret;
 }
 
@@ -923,13 +924,10 @@ static int mxs_dma_pm_resume(struct device *dev)
 	struct mxs_dma_engine *mxs_dma = dev_get_drvdata(dev);
 	int ret;
 
-	ret = pm_runtime_force_resume(dev);
-	if (ret)
-		return ret;
-
 	ret = mxs_dma_init(mxs_dma);
 	if (ret)
 		return ret;
+
 	return 0;
 }
 
-- 
GitLab