diff mbox

dmaengine: edma: Remove dynamic TPTC power management feature

Message ID 1453885906-17652-1-git-send-email-peter.ujfalusi@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Ujfalusi Jan. 27, 2016, 9:11 a.m. UTC
The dynamic or on demand pm_runtime does not work correctly on am335x and
am437x due to interference with hwmod.
Fall back using the pm_runtime usage as it was in the old driver stack,
meaning that at probe time call pm_runtime_enable() and
pm_runtime_get_sync() for the TPTCs as well.

Fixes: 1be5336bc7ba ("dmaengine: edma: New device tree binding")

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reported-by: Tero Kristo <t-kristo@ti.com>
---
 drivers/dma/edma.c | 38 +++-----------------------------------
 1 file changed, 3 insertions(+), 35 deletions(-)

Comments

Tony Lindgren Jan. 27, 2016, 3:54 p.m. UTC | #1
* Peter Ujfalusi <peter.ujfalusi@ti.com> [160127 01:12]:
> The dynamic or on demand pm_runtime does not work correctly on am335x and
> am437x due to interference with hwmod.

Hmm care expand a bit what is the problem with this "interference"?

Regards,

Tony
Peter Ujfalusi Jan. 28, 2016, 9 a.m. UTC | #2
On 01/27/2016 05:54 PM, Tony Lindgren wrote:
> * Peter Ujfalusi <peter.ujfalusi@ti.com> [160127 01:12]:
>> The dynamic or on demand pm_runtime does not work correctly on am335x and
>> am437x due to interference with hwmod.
> 
> Hmm care expand a bit what is the problem with this "interference"?

The idea was to enable/power on only the TPTCs which is actually in use and
leave the unused ones off. Which is is nice and all, but...
The original implementation did the pm_runtime calls for the tptcs from the
edma tpcc driver instance and the main issue was that I did the pm_runtime
calls in the edma-tpcc pm callbacks as well.
Since omap hwmod/device also handles pm_runtime on behalf of the drivers we
got nasty issues, kernel crash, warnings on suspend/resume.

Then I did implemented the on demand power management in a totally different
way, still keeping only tptcs enabled which is in use.
In this way all the omap hwmod/device incoherency was gone and things looked
fine, but it turned out that on second suspend we are not able to wake up the
board.
I and Tero debugged this a bit and it turns out that we need to kepp all tptcs
enabled and powered, otherwise the HW will not going to be able to complete
the transition, breaking suspend/resume.

With pm_runtime_enable() + get_sync() on all tptcs we can suspend and resume
w/o problems and they will be disabled/enabled by omap hwmod/device code,
following nicely the power state of the system.

As a note: I did tried the suspend/resume with the old code with dra7, but it
turned out that on dra7 SW has no control over the tptc power state, it
follows the system in HW.

In short: The implementation was flawed and even if the implementation is
correct the HW will lock up if we do on demand tptc power management.
Tony Lindgren Jan. 28, 2016, 5:11 p.m. UTC | #3
* Peter Ujfalusi <peter.ujfalusi@ti.com> [160128 01:01]:
> On 01/27/2016 05:54 PM, Tony Lindgren wrote:
> > * Peter Ujfalusi <peter.ujfalusi@ti.com> [160127 01:12]:
> >> The dynamic or on demand pm_runtime does not work correctly on am335x and
> >> am437x due to interference with hwmod.
> > 
> > Hmm care expand a bit what is the problem with this "interference"?
> 
> The idea was to enable/power on only the TPTCs which is actually in use and
> leave the unused ones off. Which is is nice and all, but...
> The original implementation did the pm_runtime calls for the tptcs from the
> edma tpcc driver instance and the main issue was that I did the pm_runtime
> calls in the edma-tpcc pm callbacks as well.
> Since omap hwmod/device also handles pm_runtime on behalf of the drivers we
> got nasty issues, kernel crash, warnings on suspend/resume.
> 
> Then I did implemented the on demand power management in a totally different
> way, still keeping only tptcs enabled which is in use.
> In this way all the omap hwmod/device incoherency was gone and things looked
> fine, but it turned out that on second suspend we are not able to wake up the
> board.
> I and Tero debugged this a bit and it turns out that we need to kepp all tptcs
> enabled and powered, otherwise the HW will not going to be able to complete
> the transition, breaking suspend/resume.

Probably you only need to keep the tptcs being used enabled though? They
should be completely independent otherwise?

> With pm_runtime_enable() + get_sync() on all tptcs we can suspend and resume
> w/o problems and they will be disabled/enabled by omap hwmod/device code,
> following nicely the power state of the system.
> 
> As a note: I did tried the suspend/resume with the old code with dra7, but it
> turned out that on dra7 SW has no control over the tptc power state, it
> follows the system in HW.
> 
> In short: The implementation was flawed and even if the implementation is
> correct the HW will lock up if we do on demand tptc power management.

OK interesting.

Regards,

Tony
diff mbox

Patch

diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index d92d65549406..c1b052f7b68c 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -1560,32 +1560,6 @@  static irqreturn_t dma_ccerr_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static void edma_tc_set_pm_state(struct edma_tc *tc, bool enable)
-{
-	struct platform_device *tc_pdev;
-	int ret;
-
-	if (!IS_ENABLED(CONFIG_OF) || !tc)
-		return;
-
-	tc_pdev = of_find_device_by_node(tc->node);
-	if (!tc_pdev) {
-		pr_err("%s: TPTC device is not found\n", __func__);
-		return;
-	}
-	if (!pm_runtime_enabled(&tc_pdev->dev))
-		pm_runtime_enable(&tc_pdev->dev);
-
-	if (enable)
-		ret = pm_runtime_get_sync(&tc_pdev->dev);
-	else
-		ret = pm_runtime_put_sync(&tc_pdev->dev);
-
-	if (ret < 0)
-		pr_err("%s: pm_runtime_%s_sync() failed for %s\n", __func__,
-		       enable ? "get" : "put", dev_name(&tc_pdev->dev));
-}
-
 /* Alloc channel resources */
 static int edma_alloc_chan_resources(struct dma_chan *chan)
 {
@@ -1622,8 +1596,6 @@  static int edma_alloc_chan_resources(struct dma_chan *chan)
 		EDMA_CHAN_SLOT(echan->ch_num), chan->chan_id,
 		echan->hw_triggered ? "HW" : "SW");
 
-	edma_tc_set_pm_state(echan->tc, true);
-
 	return 0;
 
 err_slot:
@@ -1660,7 +1632,6 @@  static void edma_free_chan_resources(struct dma_chan *chan)
 		echan->alloced = false;
 	}
 
-	edma_tc_set_pm_state(echan->tc, false);
 	echan->tc = NULL;
 	echan->hw_triggered = false;
 
@@ -2369,10 +2340,8 @@  static int edma_pm_suspend(struct device *dev)
 	int i;
 
 	for (i = 0; i < ecc->num_channels; i++) {
-		if (echan[i].alloced) {
+		if (echan[i].alloced)
 			edma_setup_interrupt(&echan[i], false);
-			edma_tc_set_pm_state(echan[i].tc, false);
-		}
 	}
 
 	return 0;
@@ -2402,8 +2371,6 @@  static int edma_pm_resume(struct device *dev)
 
 			/* Set up channel -> slot mapping for the entry slot */
 			edma_set_chmap(&echan[i], echan[i].slot[0]);
-
-			edma_tc_set_pm_state(echan[i].tc, true);
 		}
 	}
 
@@ -2427,7 +2394,8 @@  static struct platform_driver edma_driver = {
 
 static int edma_tptc_probe(struct platform_device *pdev)
 {
-	return 0;
+	pm_runtime_enable(&pdev->dev);
+	return pm_runtime_get_sync(&pdev->dev);
 }
 
 static struct platform_driver edma_tptc_driver = {