diff mbox

[v3,2/2] dma: pl330: add DMA_PAUSE feature

Message ID 1418208918-28127-3-git-send-email-r.baldyga@samsung.com (mailing list archive)
State Rejected
Headers show

Commit Message

Robert Baldyga Dec. 10, 2014, 10:55 a.m. UTC
DMA_PAUSE command is used for halting DMA transfer on chosen channel.
It can be useful when we want to safely read residue before terminating
all requests on channel. Otherwise there can be situation when some data
is transferred before channel termination but after reading residue,
which obviously results with data loss. To avoid this situation we can
pause channel, read residue and then terminate all requests.
This scenario is common, for example, in serial port drivers.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
---
 drivers/dma/pl330.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Vinod Koul Feb. 11, 2015, 12:24 a.m. UTC | #1
On Wed, Dec 10, 2014 at 11:55:18AM +0100, Robert Baldyga wrote:
> DMA_PAUSE command is used for halting DMA transfer on chosen channel.
> It can be useful when we want to safely read residue before terminating
> all requests on channel. Otherwise there can be situation when some data
> is transferred before channel termination but after reading residue,
> which obviously results with data loss. To avoid this situation we can
> pause channel, read residue and then terminate all requests.
> This scenario is common, for example, in serial port drivers.
And where is the resume here? Also this needs rebase
Robert Baldyga Feb. 11, 2015, 11:02 a.m. UTC | #2
On 02/11/2015 01:24 AM, Vinod Koul wrote:
> On Wed, Dec 10, 2014 at 11:55:18AM +0100, Robert Baldyga wrote:
>> DMA_PAUSE command is used for halting DMA transfer on chosen channel.
>> It can be useful when we want to safely read residue before terminating
>> all requests on channel. Otherwise there can be situation when some data
>> is transferred before channel termination but after reading residue,
>> which obviously results with data loss. To avoid this situation we can
>> pause channel, read residue and then terminate all requests.
>> This scenario is common, for example, in serial port drivers.
> And where is the resume here? Also this needs rebase
> 

We can't have resume on this hardware. It's in comment. DMA_PAUSE
feature is added only to freeze channel state before its termination to
allow safe residue read.

BTW I was almost sure that you have applied these patches to your tree
about two months ago. In mainline kernel there is already samsung serial
driver using DMA, which wouldn't work without these changes. Hence it
would be great to have my patches applied ASAP. I will send v4 today.

Thanks,
Robert Baldyga
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 2f4d561..ead4369 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -2137,6 +2137,25 @@  static int pl330_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, unsigned
 		pm_runtime_mark_last_busy(pl330->ddma.dev);
 		pm_runtime_put_autosuspend(pl330->ddma.dev);
 		break;
+	case DMA_PAUSE:
+		/*
+		 * We don't support DMA_RESUME command because of hardware
+		 * limitations, so after pausing the channel we cannot restore
+		 * it to active state. We have to terminate channel and setup
+		 * DMA transfer again. This pause feature was implemented to
+		 * allow safely read residue before channel termination.
+		 */
+		pm_runtime_get_sync(pl330->ddma.dev);
+		spin_lock_irqsave(&pch->lock, flags);
+
+		spin_lock(&pl330->lock);
+		_stop(pch->thread);
+		spin_unlock(&pl330->lock);
+
+		spin_unlock_irqrestore(&pch->lock, flags);
+		pm_runtime_mark_last_busy(pl330->ddma.dev);
+		pm_runtime_put_autosuspend(pl330->ddma.dev);
+		break;
 	case DMA_SLAVE_CONFIG:
 		slave_config = (struct dma_slave_config *)arg;