From: Vinod Koul <vkoul@kernel.org>
To: Radhey Shyam Pandey <radheys@xilinx.com>
Cc: Sebastian von Ohr <vonohr@smaract.com>,
Appana Durga Kedareswara Rao <appanad@xilinx.com>,
Michal Simek <michals@xilinx.com>,
"dmaengine@vger.kernel.org" <dmaengine@vger.kernel.org>
Subject: Re: [PATCH] dmaengine: xilinx_dma: Add missing check for empty list
Date: Wed, 11 Mar 2020 14:46:22 +0530 [thread overview]
Message-ID: <20200311091622.GL4885@vkoul-mobl> (raw)
In-Reply-To: <CH2PR02MB7000C592992EEFBFB01D5735C7E30@CH2PR02MB7000.namprd02.prod.outlook.com>
On 06-03-20, 13:57, Radhey Shyam Pandey wrote:
> > -----Original Message-----
> > From: Vinod Koul <vkoul@kernel.org>
> > Sent: Friday, March 6, 2020 7:04 PM
> > To: Sebastian von Ohr <vonohr@smaract.com>; Appana Durga Kedareswara
> > Rao <appanad@xilinx.com>; Radhey Shyam Pandey <radheys@xilinx.com>;
> > Michal Simek <michals@xilinx.com>
> > Cc: dmaengine@vger.kernel.org
> > Subject: Re: [PATCH] dmaengine: xilinx_dma: Add missing check for empty list
>
> Minor nit - Better to also add <...> "in device_tx_status callback "
> >
> > On 03-03-20, 14:05, Sebastian von Ohr wrote:
> > > The DMA transfer might finish just after checking the state with
> > > dma_cookie_status, but before the lock is acquired. Not checking for
> > > an empty list in xilinx_dma_tx_status may result in reading random
> > > data or data corruption when desc is written to. This can be reliably
> > > triggered by using dma_sync_wait to wait for DMA completion.
> >
> > Appana, Radhey can you please test this..?
>
> Sure, we will test it. Changes look fine. Though had a question in mind,
> for a generic fix to this problem, should we make locking mandatory for
> all cookie helper functions? Or is there any limitation?
>
> The framework say for dma_cookie_status says locking is not required. This
> scenario is a race condition when the driver calls dma_cookie_status and
> it sees it's not completed, but then since there is no locking and dma
> completion comes and it changes cookie state and removes the element
> from active list to done list. When driver access it in tx_status it results
> in data corruption/crash.
The expectation is that you would lock while looking at list and then
return.. So you should not have issues..
--
~Vinod
next prev parent reply other threads:[~2020-03-11 9:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-03 13:05 [PATCH] dmaengine: xilinx_dma: Add missing check for empty list Sebastian von Ohr
2020-03-06 13:34 ` Vinod Koul
2020-03-06 13:57 ` Radhey Shyam Pandey
2020-03-11 9:16 ` Vinod Koul [this message]
2020-04-07 7:52 ` Sebastian von Ohr
2020-04-07 16:03 ` Radhey Shyam Pandey
2020-04-08 7:12 ` Sebastian von Ohr
2020-04-08 14:06 ` Radhey Shyam Pandey
2020-04-08 15:19 ` Sebastian von Ohr
2020-04-09 7:40 ` Radhey Shyam Pandey
2020-04-15 16:12 ` 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=20200311091622.GL4885@vkoul-mobl \
--to=vkoul@kernel.org \
--cc=appanad@xilinx.com \
--cc=dmaengine@vger.kernel.org \
--cc=michals@xilinx.com \
--cc=radheys@xilinx.com \
--cc=vonohr@smaract.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;
as well as URLs for NNTP newsgroup(s).