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] [thread-next>] [day] [month] [year] [list]
Message-ID: <1463456936-10634-6-git-send-email-jiada_wang@mentor.com>
Date:	Tue, 17 May 2016 12:48:51 +0900
From:	Jiada Wang <jiada_wang@...tor.com>
To:	<vinod.koul@...el.com>, <dan.j.williams@...el.com>
CC:	<dmaengine@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<shawnguo@...nel.org>, <kernel@...gutronix.de>,
	<george_davis@...tor.com>, <jiada_wang@...tor.com>
Subject: [PATCH 05/10] dma: imx-sdma: add flag to indicate SDMA channel state

There is race between STOP of SDMA channel and finish of
SDMA transfer, so some times, even after sdma_disable_channel()
is called, the bit of 'terminated channel' in INTR may still get
asserted, thus cause an extra sdma tasklet be called.
Add flag 'enabled' to each sdma channel to indicate its state.
only when SDMA channel is in its enabled state, irq handler
can schedule a sdma tasklet for it.

Signed-off-by: Jiada Wang <jiada_wang@...tor.com>
---
 drivers/dma/imx-sdma.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 36f5e39..ef5d37c 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -327,6 +327,7 @@ struct sdma_channel {
 	unsigned int			chn_real_count;
 	struct tasklet_struct		tasklet;
 	struct imx_dma_data		data;
+	bool				enabled;
 };
 
 #define IMX_DMA_SG_LOOP		BIT(0)
@@ -562,7 +563,13 @@ static int sdma_config_ownership(struct sdma_channel *sdmac,
 
 static void sdma_enable_channel(struct sdma_engine *sdma, int channel)
 {
+	struct sdma_channel *sdmac = &sdma->channel[channel];
+	unsigned long flags;
+
+	spin_lock_irqsave(&sdmac->lock, flags);
+	sdmac->enabled = true;
 	writel(BIT(channel), sdma->regs + SDMA_H_START);
+	spin_unlock_irqrestore(&sdmac->lock, flags);
 }
 
 /*
@@ -740,9 +747,12 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id)
 		int channel = fls(stat) - 1;
 		struct sdma_channel *sdmac = &sdma->channel[channel];
 
-		tasklet_schedule(&sdmac->tasklet);
+		spin_lock(&sdmac->lock);
+		if (sdmac->enabled)
+			tasklet_schedule(&sdmac->tasklet);
 
 		__clear_bit(channel, &stat);
+		spin_unlock(&sdmac->lock);
 	}
 
 	return IRQ_HANDLED;
@@ -906,9 +916,13 @@ static int sdma_disable_channel(struct dma_chan *chan)
 	struct sdma_channel *sdmac = to_sdma_chan(chan);
 	struct sdma_engine *sdma = sdmac->sdma;
 	int channel = sdmac->channel;
+	unsigned long flags;
 
+	spin_lock_irqsave(&sdmac->lock, flags);
+	sdmac->enabled = false;
 	writel_relaxed(BIT(channel), sdma->regs + SDMA_H_STATSTOP);
 	sdmac->status = DMA_ERROR;
+	spin_unlock_irqrestore(&sdmac->lock, flags);
 
 	return 0;
 }
-- 
2.4.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ