dmaengine: pl330: fix irq race with terminate_all
authorJohn Keeping <john@metanate.com>
Tue, 17 Jul 2018 10:48:16 +0000 (11:48 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Sep 2018 06:38:00 +0000 (08:38 +0200)
commite1cfd4533ffb2d882ef7a49e6b8d9ef033a95cd1
treec03ef4cbcad58275198cad68a7dbf2acd0829c5e
parent58119f9bd94df9f52304d95296245daf3373e382
dmaengine: pl330: fix irq race with terminate_all

[ Upstream commit e49756544a21f5625b379b3871d27d8500764670 ]

In pl330_update() when checking if a channel has been aborted, the
channel's lock is not taken, only the overall pl330_dmac lock.  But in
pl330_terminate_all() the aborted flag (req_running==-1) is set under
the channel lock and not the pl330_dmac lock.

With threaded interrupts, this leads to a potential race:

    pl330_terminate_all         pl330_update
    -------------------         ------------
    lock channel
                                entry
    lock pl330
    _stop channel
    unlock pl330
                                lock pl330
                                check req_running != -1
    req_running = -1
                                _start channel

Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/dma/pl330.c