From: Pierre Yves MORDRET <pierre-yves.mordret@st.com>
To: Peter Ujfalusi <peter.ujfalusi@ti.com>,
Vinod Koul <vinod.koul@intel.com>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@st.com>,
Russell King <linux@armlinux.org.uk>,
Dan Williams <dan.j.williams@intel.com>,
"M'boumba Cedric Madianga" <cedric.madianga@gmail.com>,
Fabrice GASNIER <fabrice.gasnier@st.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Fabien DESSENNE <fabien.dessenne@st.com>,
Amelie Delaunay <amelie.delaunay@st.com>,
<dmaengine@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 2/4] dmaengine: Add STM32 DMAMUX driver
Date: Thu, 21 Sep 2017 14:47:59 +0200 [thread overview]
Message-ID: <ab012ccc-21e4-e487-4ef1-056c36a65cd0@st.com> (raw)
In-Reply-To: <a88a83ba-9477-36ae-87ba-a35f477a5ca1@ti.com>
On 09/21/2017 01:25 PM, Peter Ujfalusi wrote:
>
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>
>
> Great that you got it working w/o a custom API!
> I have one comment, which actually valid for the ti-dma-crossbar driver
> as well...
Yes. That cleans up a little bit the sw architecture. But still this custom API
allowed both DMAMUX and DMA at the same time since using the same channel ID
allocator.
Ok this is another story to be addressed out of this thread ;)
>
>> +static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
>> + struct of_dma *ofdma)
>> +
>> + spin_lock_irqsave(&dmamux->lock, flags);
>> + mux->chan_id = find_first_zero_bit(dmamux->dma_inuse,
>> + dmamux->dma_requests);
>
> you pick the first available chan_id here under the lock.
>
>> + spin_unlock_irqrestore(&dmamux->lock, flags);
>> + if (mux->chan_id == dmamux->dma_requests) {
>> ...
>> + /* Set dma request */
>> + spin_lock_irqsave(&dmamux->lock, flags);
>> + if (!IS_ERR(dmamux->clk)) {
>> ...
>> + spin_unlock_irqrestore(&dmamux->lock, flags);
>> +
>> + set_bit(mux->chan_id, dmamux->dma_inuse);
>
> But nothing stops other parallel threads to pick the same chan_id since
> you have released the lock (released, got the lock to protect the set
> dma request and released it again). imho the find_first_zero_bit() and
> the set_bit() should be done within the same lock to avoid race conditions.
>
> - Péter
>
Yep good catch : That's correct. Even if probability to happen is rather low, it
may happen.
Will solve that.
Py
next prev parent reply other threads:[~2017-09-21 12:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-07 11:52 [PATCH v4 0/4] Add STM32 DMAMUX support Pierre-Yves MORDRET
2017-09-07 11:52 ` [PATCH v4 1/4] dt-bindings: Document the STM32 DMAMUX bindings Pierre-Yves MORDRET
2017-09-11 20:24 ` Rob Herring
2017-09-07 11:52 ` [PATCH v4 2/4] dmaengine: Add STM32 DMAMUX driver Pierre-Yves MORDRET
2017-09-21 11:25 ` Peter Ujfalusi
2017-09-21 12:47 ` Pierre Yves MORDRET [this message]
2017-09-07 11:52 ` [PATCH v4 3/4] dt-bindings: stm32-dma: add a property to handle STM32 DMAMUX Pierre-Yves MORDRET
2017-09-13 17:45 ` Rob Herring
2017-09-07 11:52 ` [PATCH v4 4/4] ARM: configs: stm32: Add MDMA support in STM32 defconfig Pierre-Yves MORDRET
2017-09-21 7:59 ` [PATCH v4 0/4] Add STM32 DMAMUX support Pierre Yves MORDRET
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=ab012ccc-21e4-e487-4ef1-056c36a65cd0@st.com \
--to=pierre-yves.mordret@st.com \
--cc=alexandre.torgue@st.com \
--cc=amelie.delaunay@st.com \
--cc=cedric.madianga@gmail.com \
--cc=dan.j.williams@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=fabien.dessenne@st.com \
--cc=fabrice.gasnier@st.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mark.rutland@arm.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=peter.ujfalusi@ti.com \
--cc=robh+dt@kernel.org \
--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
all inboxes | Powered by JetHome®