All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vinod.koul@intel.com>
To: Siva Yerramreddy <siva.krishna.kumar.reddy.yerramreddy@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>,
	dmaengine@vger.kernel.org, Sudeep Dutt <sudeep.dutt@intel.com>,
	Nikhil Rao <nikhil.rao@intel.com>,
	Ashutosh Dixit <ashutosh.dixit@intel.com>,
	linux-kernel@vger.kernel.org,
	Russell King <rmk+kernel@arm.linux.org.uk>
Subject: Re: [PATCH dmaengine-fixes 1/1] dmaengine: read completed cookie before used cookie
Date: Mon, 17 Feb 2014 14:05:33 +0530	[thread overview]
Message-ID: <20140217083533.GW10628@intel.com> (raw)
In-Reply-To: <d0106d723f7455208f83e50522007fee7887e67e.1392419479.git.siva.krishna.kumar.reddy.yerramreddy@intel.com>

On Fri, Feb 14, 2014 at 03:32:57PM -0800, Siva Yerramreddy wrote:
> When running dmatest with my yet-to-be submitted driver for the Intel MIC DMA
> engine, dmatest detected "dma0chan3-copy5: result #8096161:completion busy
> status with src_off=0x0 dst_off=0x0 len=0x40 (0)". This is caused by reading
> the used cookie before the completed cookie in dma_cookie_status(),  if a DMA
> request is submitted in between the two reads, and completes,  the completed
> cookie will be newer than the used cookie value read previously.  Reversing
> the order of reads ensures that the completed cookie is for a DMA request
> older than the used cookie.
> 
> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> Reviewed-by: Sudeep Dutt <sudeep.dutt@intel.com>
> Reviewed-by: Nikhil Rao <nikhil.rao@intel.com>
> Signed-off-by: Siva Yerramreddy <siva.krishna.kumar.reddy.yerramreddy@intel.com>
> ---
>  drivers/dma/dmaengine.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h
> index 17f983a..4c96892 100644
> --- a/drivers/dma/dmaengine.h
> +++ b/drivers/dma/dmaengine.h
> @@ -7,6 +7,7 @@
>  
>  #include <linux/bug.h>
>  #include <linux/dmaengine.h>
> +#include <asm/barrier.h>
>  
>  /**
>   * dma_cookie_init - initialize the cookies for a DMA channel
> @@ -69,8 +70,13 @@ static inline enum dma_status dma_cookie_status(struct dma_chan *chan,
>  {
>  	dma_cookie_t used, complete;
>  
> -	used = chan->cookie;
>  	complete = chan->completed_cookie;
> +	/*
> +	 * If this order is not maintained, used can end up being older than
> +	 * complete
> +	 */
> +	smp_rmb();
> +	used = chan->cookie;
>  	barrier();
>  	if (state) {
>  		state->last = complete;
The idea is right to grab the channle cookie after completed. But I dont see why
you need another barrier in between these two?

Dan,

This really is intresting case where the request completed raced with status.
I am sure for us slow slave users we may not see such issues :D but for these
and other memcpy cases do we really need to bother checking the status properly
and getting right data or delayed reporting is fine?

-- 
~Vinod

  reply	other threads:[~2014-02-17  8:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-14 23:32 [PATCH dmaengine-fixes 1/1] dmaengine: read completed cookie before used cookie Siva Yerramreddy
2014-02-17  8:35 ` Vinod Koul [this message]
2014-04-10  3:31 ` Dan Williams

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=20140217083533.GW10628@intel.com \
    --to=vinod.koul@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nikhil.rao@intel.com \
    --cc=rmk+kernel@arm.linux.org.uk \
    --cc=siva.krishna.kumar.reddy.yerramreddy@intel.com \
    --cc=sudeep.dutt@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 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.