All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Sanjay R Mehta <Sanju.Mehta@amd.com>
Cc: gregkh@linuxfoundation.org, dan.j.williams@intel.com,
	Thomas.Lendacky@amd.com, robh@kernel.org,
	mchehab+samsung@kernel.org, davem@davemloft.net,
	linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH] dmaengine: ptdma: fix concurrency issue with multiple dma transfer
Date: Mon, 3 Jan 2022 17:04:05 +0530	[thread overview]
Message-ID: <YdLfLc8lfOektWmi@matsya> (raw)
In-Reply-To: <1639735118-9798-1-git-send-email-Sanju.Mehta@amd.com>

On 17-12-21, 03:58, Sanjay R Mehta wrote:
> From: Sanjay R Mehta <sanju.mehta@amd.com>
> 
> The command should be submitted only if the engine is idle,
> for this, the next available descriptor is checked and set the flag
> to false in case the descriptor is non-empty.
> 
> Also need to segregate the cases when DMA is complete or not.
> In case if DMA is already complete there is no need to handle it
> again and gracefully exit from the function.
> 
> Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
> ---
>  drivers/dma/ptdma/ptdma-dmaengine.c | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/dma/ptdma/ptdma-dmaengine.c b/drivers/dma/ptdma/ptdma-dmaengine.c
> index c9e52f6..91b93e8 100644
> --- a/drivers/dma/ptdma/ptdma-dmaengine.c
> +++ b/drivers/dma/ptdma/ptdma-dmaengine.c
> @@ -100,12 +100,17 @@ static struct pt_dma_desc *pt_handle_active_desc(struct pt_dma_chan *chan,
>  		spin_lock_irqsave(&chan->vc.lock, flags);
>  
>  		if (desc) {
> -			if (desc->status != DMA_ERROR)
> -				desc->status = DMA_COMPLETE;
> -
> -			dma_cookie_complete(tx_desc);
> -			dma_descriptor_unmap(tx_desc);
> -			list_del(&desc->vd.node);
> +			if (desc->status != DMA_COMPLETE) {
> +				if (desc->status != DMA_ERROR)
> +					desc->status = DMA_COMPLETE;
> +
> +				dma_cookie_complete(tx_desc);
> +				dma_descriptor_unmap(tx_desc);
> +				list_del(&desc->vd.node);
> +			} else {
> +				/* Don't handle it twice */
> +				tx_desc = NULL;
> +			}
>  		}
>  
>  		desc = pt_next_dma_desc(chan);
> @@ -233,9 +238,14 @@ static void pt_issue_pending(struct dma_chan *dma_chan)
>  	struct pt_dma_chan *chan = to_pt_chan(dma_chan);
>  	struct pt_dma_desc *desc;
>  	unsigned long flags;
> +	bool engine_is_idle = true;
>  
>  	spin_lock_irqsave(&chan->vc.lock, flags);
>  
> +	desc = pt_next_dma_desc(chan);
> +	if (desc)
> +		engine_is_idle = false;
> +
>  	vchan_issue_pending(&chan->vc);
>  
>  	desc = pt_next_dma_desc(chan);
> @@ -243,7 +253,7 @@ static void pt_issue_pending(struct dma_chan *dma_chan)
>  	spin_unlock_irqrestore(&chan->vc.lock, flags);
>  
>  	/* If there was nothing active, start processing */
> -	if (desc)
> +	if (engine_is_idle)

Can you explain why do you need this flag and why desc is not
sufficient..

It also sounds like 2 patches to me...

>  		pt_cmd_callback(desc, 0);
>  }
>  
> -- 
> 2.7.4

-- 
~Vinod

  reply	other threads:[~2022-01-03 11:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17  9:58 [PATCH] dmaengine: ptdma: fix concurrency issue with multiple dma transfer Sanjay R Mehta
2022-01-03 11:34 ` Vinod Koul [this message]
2022-01-10  7:57   ` Sanjay R Mehta
2022-01-18 12:05     ` Sanjay R Mehta
2022-01-19  4:23     ` Vinod Koul

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=YdLfLc8lfOektWmi@matsya \
    --to=vkoul@kernel.org \
    --cc=Sanju.Mehta@amd.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=dan.j.williams@intel.com \
    --cc=davem@davemloft.net \
    --cc=dmaengine@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+samsung@kernel.org \
    --cc=robh@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.