Return-Path: Received: from mail-sn1nam01on0126.outbound.protection.outlook.com ([104.47.32.126]:12224 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932887AbeCCW3H (ORCPT ); Sat, 3 Mar 2018 17:29:07 -0500 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 40/84] dmaengine: bcm2835-dma: Use vchan_terminate_vdesc() instead of desc_free Date: Sat, 3 Mar 2018 22:26:22 +0000 Message-ID: <20180303222518.26271-40-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: stable-owner@vger.kernel.org List-ID: From: Peter Ujfalusi [ Upstream commit de92436ac40ffe9933230aa503e24dbb5ede9201 ] 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 Acked-by: Eric Anholt Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/bcm2835-dma.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 6204cc32d09c..847f84a41a69 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -812,7 +812,7 @@ static int bcm2835_dma_terminate_all(struct dma_chan *c= han) * c->desc is NULL and exit.) */ if (c->desc) { - bcm2835_dma_desc_free(&c->desc->vd); + vchan_terminate_vdesc(&c->desc->vd); c->desc =3D NULL; bcm2835_dma_abort(c->chan_base); =20 @@ -836,6 +836,13 @@ static int bcm2835_dma_terminate_all(struct dma_chan *= chan) return 0; } =20 +static void bcm2835_dma_synchronize(struct dma_chan *chan) +{ + struct bcm2835_chan *c =3D to_bcm2835_dma_chan(chan); + + vchan_synchronize(&c->vc); +} + static int bcm2835_dma_chan_init(struct bcm2835_dmadev *d, int chan_id, int irq, unsigned int irq_flags) { @@ -942,6 +949,7 @@ static int bcm2835_dma_probe(struct platform_device *pd= ev) od->ddev.device_prep_dma_memcpy =3D bcm2835_dma_prep_dma_memcpy; od->ddev.device_config =3D bcm2835_dma_slave_config; od->ddev.device_terminate_all =3D bcm2835_dma_terminate_all; + od->ddev.device_synchronize =3D bcm2835_dma_synchronize; od->ddev.src_addr_widths =3D BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); od->ddev.dst_addr_widths =3D BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); od->ddev.directions =3D BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV) | --=20 2.14.1