Return-Path: From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Peter Ujfalusi , Vinod Koul , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 41/84] dmaengine: amba-pl08x: Use vchan_terminate_vdesc() instead of desc_free Date: Sat, 3 Mar 2018 22:26:23 +0000 Message-ID: <20180303222518.26271-41-alexander.levin@microsoft.com> References: <20180303222518.26271-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222518.26271-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: linux-kernel-owner@vger.kernel.org List-ID: From: Peter Ujfalusi [ Upstream commit 47d71bc75d072ce25c1063aa629e55e1cfb961b2 ] To avoid race with vchan_complete, use the race free way to terminate running transfer. Implement the device_synchronize callback to make sure that the terminated descriptor is freed. Signed-off-by: Peter Ujfalusi Reviewed-by: Linus Walleij Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/amba-pl08x.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index b52b0d55247e..97483df1f82e 100644 --- a/drivers/dma/amba-pl08x.c +++ b/drivers/dma/amba-pl08x.c @@ -2182,7 +2182,7 @@ static int pl08x_terminate_all(struct dma_chan *chan) } /* Dequeue jobs and free LLIs */ if (plchan->at) { - pl08x_desc_free(&plchan->at->vd); + vchan_terminate_vdesc(&plchan->at->vd); plchan->at =3D NULL; } /* Dequeue jobs not yet fired as well */ @@ -2193,6 +2193,13 @@ static int pl08x_terminate_all(struct dma_chan *chan= ) return 0; } =20 +static void pl08x_synchronize(struct dma_chan *chan) +{ + struct pl08x_dma_chan *plchan =3D to_pl08x_chan(chan); + + vchan_synchronize(&plchan->vc); +} + static int pl08x_pause(struct dma_chan *chan) { struct pl08x_dma_chan *plchan =3D to_pl08x_chan(chan); @@ -2773,6 +2780,7 @@ static int pl08x_probe(struct amba_device *adev, cons= t struct amba_id *id) pl08x->memcpy.device_pause =3D pl08x_pause; pl08x->memcpy.device_resume =3D pl08x_resume; pl08x->memcpy.device_terminate_all =3D pl08x_terminate_all; + pl08x->memcpy.device_synchronize =3D pl08x_synchronize; pl08x->memcpy.src_addr_widths =3D PL80X_DMA_BUSWIDTHS; pl08x->memcpy.dst_addr_widths =3D PL80X_DMA_BUSWIDTHS; pl08x->memcpy.directions =3D BIT(DMA_MEM_TO_MEM); @@ -2802,6 +2810,7 @@ static int pl08x_probe(struct amba_device *adev, cons= t struct amba_id *id) pl08x->slave.device_pause =3D pl08x_pause; pl08x->slave.device_resume =3D pl08x_resume; pl08x->slave.device_terminate_all =3D pl08x_terminate_all; + pl08x->slave.device_synchronize =3D pl08x_synchronize; pl08x->slave.src_addr_widths =3D PL80X_DMA_BUSWIDTHS; pl08x->slave.dst_addr_widths =3D PL80X_DMA_BUSWIDTHS; pl08x->slave.directions =3D --=20 2.14.1