From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam01on0092.outbound.protection.outlook.com ([104.47.32.92]:36128 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728640AbeIGFOT (ORCPT ); Fri, 7 Sep 2018 01:14:19 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: John Keeping , Vinod Koul , Sasha Levin Subject: [PATCH AUTOSEL 4.18 25/88] dmaengine: pl330: fix irq race with terminate_all Date: Fri, 7 Sep 2018 00:36:09 +0000 Message-ID: <20180907003547.57567-25-alexander.levin@microsoft.com> References: <20180907003547.57567-1-alexander.levin@microsoft.com> In-Reply-To: <20180907003547.57567-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: John Keeping [ 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=3D=3D-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 !=3D -1 req_running =3D -1 _start channel Signed-off-by: John Keeping Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/pl330.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index de0957fe9668..bb6dfa2e1e8a 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2257,13 +2257,14 @@ static int pl330_terminate_all(struct dma_chan *cha= n) =20 pm_runtime_get_sync(pl330->ddma.dev); spin_lock_irqsave(&pch->lock, flags); + spin_lock(&pl330->lock); _stop(pch->thread); - spin_unlock(&pl330->lock); - pch->thread->req[0].desc =3D NULL; pch->thread->req[1].desc =3D NULL; pch->thread->req_running =3D -1; + spin_unlock(&pl330->lock); + power_down =3D pch->active; pch->active =3D false; =20 --=20 2.17.1