lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ab012ccc-21e4-e487-4ef1-056c36a65cd0@st.com>
Date:   Thu, 21 Sep 2017 14:47:59 +0200
From:   Pierre Yves MORDRET <pierre-yves.mordret@...com>
To:     Peter Ujfalusi <peter.ujfalusi@...com>,
        Vinod Koul <vinod.koul@...el.com>,
        Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Alexandre Torgue <alexandre.torgue@...com>,
        Russell King <linux@...linux.org.uk>,
        Dan Williams <dan.j.williams@...el.com>,
        "M'boumba Cedric Madianga" <cedric.madianga@...il.com>,
        Fabrice GASNIER <fabrice.gasnier@...com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        Fabien DESSENNE <fabien.dessenne@...com>,
        Amelie Delaunay <amelie.delaunay@...com>,
        <dmaengine@...r.kernel.org>, <devicetree@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 2/4] dmaengine: Add STM32 DMAMUX driver



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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ