public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Krzysztof Kozłowski" <k.kozlowski@samsung.com>
To: Robert Baldyga <r.baldyga@samsung.com>, vinod.koul@intel.com
Cc: dan.j.williams@intel.com, ars@metafoo.de,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	m.szyprowski@samsung.com, l.czerwinski@samsung.com
Subject: Re: [PATCH 2/2] dma: pl330: add DMA_PAUSE feature
Date: Tue, 25 Nov 2014 14:41:40 +0100	[thread overview]
Message-ID: <54748714.1040005@samsung.com> (raw)
In-Reply-To: <1416918346-2442-3-git-send-email-r.baldyga@samsung.com>

On 25.11.2014 13:25, 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.
> 
> Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
> ---
>  drivers/dma/pl330.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
> index c32806d..9c64421 100644
> --- a/drivers/dma/pl330.c
> +++ b/drivers/dma/pl330.c
> @@ -2115,6 +2115,26 @@ static int pl330_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, unsigned
>  		list_splice_tail_init(&pch->completed_list, &pl330->desc_pool);
>  		spin_unlock_irqrestore(&pch->lock, flags);
>  		break;
> +	case DMA_PAUSE:

pm_runtime_get_sync() here? If transfer is ongoing this shouldn't be
needed but if this is called after all transfers complete then device
will be suspended.

> +		/*
> +		 * 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.
> +		 */
> +		spin_lock_irqsave(&pch->lock, flags);
> +
> +		spin_lock(&pl330->lock);
> +		_stop(pch->thread);
> +		spin_unlock(&pl330->lock);
> +
> +		pch->thread->req[0].desc = NULL;
> +		pch->thread->req[1].desc = NULL;
> +		pch->thread->req_running = -1;
> +
> +		spin_unlock_irqrestore(&pch->lock, flags);

symmetric pm_runtime_put + autosuspend.

Best regards,
Krzysztof



      reply	other threads:[~2014-11-25 13:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-25 12:25 [PATCH 0/2] dma: pl330: improve status checking Robert Baldyga
2014-11-25 12:25 ` [PATCH 1/2] dma: pl330: improve pl330_tx_status() function Robert Baldyga
2014-11-25 12:43   ` Lars-Peter Clausen
2014-11-25 13:56   ` Krzysztof Kozłowski
     [not found]     ` <CAM4voamo307W_v8gy-eegTmV+yBSQG8eRKLgFxredR2SJt6PPA@mail.gmail.com>
2014-11-26 10:00       ` Padma Venkat
2014-11-25 12:25 ` [PATCH 2/2] dma: pl330: add DMA_PAUSE feature Robert Baldyga
2014-11-25 13:41   ` Krzysztof Kozłowski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54748714.1040005@samsung.com \
    --to=k.kozlowski@samsung.com \
    --cc=ars@metafoo.de \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=l.czerwinski@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=r.baldyga@samsung.com \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox