linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND 0/2] dmaengine: edma: cyclic slot limitation wa and TPTC pm fix
@ 2016-04-06 10:01 Peter Ujfalusi
  2016-04-06 10:01 ` [RESEND 1/2] dmaengine: edma: Remove dynamic TPTC power management feature Peter Ujfalusi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2016-04-06 10:01 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams
  Cc: dmaengine, linux-kernel, linux-omap, linux-arm-kernel, nsekhar,
	tony, t-kristo, john.ogness

Hi Vinod,

I just noticed that the following two patch got lost somehow. If it is still
possible, it would be great to send them for 4.6 as they are correcting
important issues in the driver.

Thanks,
Peter
---
John Ogness (1):
  dmaengine: edma: special case slot limit workaround

Peter Ujfalusi (1):
  dmaengine: edma: Remove dynamic TPTC power management feature

 drivers/dma/edma.c | 63 ++++++++++++++++++++++--------------------------------
 1 file changed, 25 insertions(+), 38 deletions(-)

-- 
2.8.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RESEND 1/2] dmaengine: edma: Remove dynamic TPTC power management feature
  2016-04-06 10:01 [RESEND 0/2] dmaengine: edma: cyclic slot limitation wa and TPTC pm fix Peter Ujfalusi
@ 2016-04-06 10:01 ` Peter Ujfalusi
  2016-04-06 10:01 ` [RESEND 2/2] dmaengine: edma: special case slot limit workaround Peter Ujfalusi
  2016-04-06 14:30 ` [RESEND 0/2] dmaengine: edma: cyclic slot limitation wa and TPTC pm fix Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2016-04-06 10:01 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams
  Cc: dmaengine, linux-kernel, linux-omap, linux-arm-kernel, nsekhar,
	tony, t-kristo, john.ogness

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(-)

diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index ee3463e774f8..13b6a23dc06b 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -1570,32 +1570,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)
 {
@@ -1632,8 +1606,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:
@@ -1670,7 +1642,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;
 
@@ -2417,10 +2388,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;
@@ -2450,8 +2419,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);
 		}
 	}
 
@@ -2475,7 +2442,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 = {
-- 
2.8.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [RESEND 2/2] dmaengine: edma: special case slot limit workaround
  2016-04-06 10:01 [RESEND 0/2] dmaengine: edma: cyclic slot limitation wa and TPTC pm fix Peter Ujfalusi
  2016-04-06 10:01 ` [RESEND 1/2] dmaengine: edma: Remove dynamic TPTC power management feature Peter Ujfalusi
@ 2016-04-06 10:01 ` Peter Ujfalusi
  2016-04-06 14:30 ` [RESEND 0/2] dmaengine: edma: cyclic slot limitation wa and TPTC pm fix Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2016-04-06 10:01 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams
  Cc: dmaengine, linux-kernel, linux-omap, linux-arm-kernel, nsekhar,
	tony, t-kristo, john.ogness

From: John Ogness <john.ogness@linutronix.de>

Currently drivers are limited to 19 slots for cyclic transfers.
However, if the DMA burst size is the same as the period size,
the period size can be changed to the full buffer size and
intermediate interrupts activated. Since intermediate interrupts
will trigger for each burst and the burst size is the same as
the period size, the driver will get interrupts each period as
expected. This has the benefit of allowing the functionality of
many more slots, but only uses 2 slots.

This workaround is only active if more than 19 slots are needed
and the burst size matches the period size.

Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
---
 drivers/dma/edma.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index 13b6a23dc06b..04070baab78a 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -1238,6 +1238,7 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
 	struct edma_desc *edesc;
 	dma_addr_t src_addr, dst_addr;
 	enum dma_slave_buswidth dev_width;
+	bool use_intermediate = false;
 	u32 burst;
 	int i, ret, nslots;
 
@@ -1279,8 +1280,21 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
 	 * but the synchronization is difficult to achieve with Cyclic and
 	 * cannot be guaranteed, so we error out early.
 	 */
-	if (nslots > MAX_NR_SG)
-		return NULL;
+	if (nslots > MAX_NR_SG) {
+		/*
+		 * If the burst and period sizes are the same, we can put
+		 * the full buffer into a single period and activate
+		 * intermediate interrupts. This will produce interrupts
+		 * after each burst, which is also after each desired period.
+		 */
+		if (burst == period_len) {
+			period_len = buf_len;
+			nslots = 2;
+			use_intermediate = true;
+		} else {
+			return NULL;
+		}
+	}
 
 	edesc = kzalloc(sizeof(*edesc) + nslots * sizeof(edesc->pset[0]),
 			GFP_ATOMIC);
@@ -1358,8 +1372,13 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
 		/*
 		 * Enable period interrupt only if it is requested
 		 */
-		if (tx_flags & DMA_PREP_INTERRUPT)
+		if (tx_flags & DMA_PREP_INTERRUPT) {
 			edesc->pset[i].param.opt |= TCINTEN;
+
+			/* Also enable intermediate interrupts if necessary */
+			if (use_intermediate)
+				edesc->pset[i].param.opt |= ITCINTEN;
+		}
 	}
 
 	/* Place the cyclic channel to highest priority queue */
-- 
2.8.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RESEND 0/2] dmaengine: edma: cyclic slot limitation wa and TPTC pm fix
  2016-04-06 10:01 [RESEND 0/2] dmaengine: edma: cyclic slot limitation wa and TPTC pm fix Peter Ujfalusi
  2016-04-06 10:01 ` [RESEND 1/2] dmaengine: edma: Remove dynamic TPTC power management feature Peter Ujfalusi
  2016-04-06 10:01 ` [RESEND 2/2] dmaengine: edma: special case slot limit workaround Peter Ujfalusi
@ 2016-04-06 14:30 ` Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2016-04-06 14:30 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: dan.j.williams, dmaengine, linux-kernel, linux-omap,
	linux-arm-kernel, nsekhar, tony, t-kristo, john.ogness

On Wed, Apr 06, 2016 at 01:01:45PM +0300, Peter Ujfalusi wrote:
> Hi Vinod,
> 
> I just noticed that the following two patch got lost somehow. If it is still
> possible, it would be great to send them for 4.6 as they are correcting
> important issues in the driver.

Done now. I will check how they got dropped
They should be in topic branch though..

-- 
~Vinod

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-06 14:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-06 10:01 [RESEND 0/2] dmaengine: edma: cyclic slot limitation wa and TPTC pm fix Peter Ujfalusi
2016-04-06 10:01 ` [RESEND 1/2] dmaengine: edma: Remove dynamic TPTC power management feature Peter Ujfalusi
2016-04-06 10:01 ` [RESEND 2/2] dmaengine: edma: special case slot limit workaround Peter Ujfalusi
2016-04-06 14:30 ` [RESEND 0/2] dmaengine: edma: cyclic slot limitation wa and TPTC pm fix Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).