]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.19.7/spi-imx-read-back-the-rx-tx-watermark-levels-earlier.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.19.7 / spi-imx-read-back-the-rx-tx-watermark-levels-earlier.patch
1 From f511ab09dfb0fe7b2335eccac51ff9f001a32e4a Mon Sep 17 00:00:00 2001
2 From: Lucas Stach <l.stach@pengutronix.de>
3 Date: Wed, 1 Apr 2015 10:46:15 +0200
4 Subject: spi: imx: read back the RX/TX watermark levels earlier
5
6 From: Lucas Stach <l.stach@pengutronix.de>
7
8 commit f511ab09dfb0fe7b2335eccac51ff9f001a32e4a upstream.
9
10 They are used to decide if the controller can do DMA on a buffer
11 of a specific length and thus are needed before any transfer is attempted.
12
13 This fixes a memory leak where the SPI core uses the drivers can_dma()
14 callback to determine if a buffer needs to be mapped. As the watermark
15 levels aren't correct at that point the driver falsely claims to be able to
16 DMA the buffer when it fact it isn't.
17 After the transfer has been done the core uses the same callback to
18 determine if it needs to unmap the buffers. As the driver now correctly
19 claims to not being able to DMA the buffer the core doesn't attempt to
20 unmap the buffer which leaves the SGT leaking.
21
22 Fixes: f62caccd12c17e4 (spi: spi-imx: add DMA support)
23 Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
24 Signed-off-by: Mark Brown <broonie@kernel.org>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26
27 ---
28 drivers/spi/spi-imx.c | 4 ++--
29 1 file changed, 2 insertions(+), 2 deletions(-)
30
31 --- a/drivers/spi/spi-imx.c
32 +++ b/drivers/spi/spi-imx.c
33 @@ -371,8 +371,6 @@ static int __maybe_unused mx51_ecspi_con
34 if (spi_imx->dma_is_inited) {
35 dma = readl(spi_imx->base + MX51_ECSPI_DMA);
36
37 - spi_imx->tx_wml = spi_imx_get_fifosize(spi_imx) / 2;
38 - spi_imx->rx_wml = spi_imx_get_fifosize(spi_imx) / 2;
39 spi_imx->rxt_wml = spi_imx_get_fifosize(spi_imx) / 2;
40 rx_wml_cfg = spi_imx->rx_wml << MX51_ECSPI_DMA_RX_WML_OFFSET;
41 tx_wml_cfg = spi_imx->tx_wml << MX51_ECSPI_DMA_TX_WML_OFFSET;
42 @@ -869,6 +867,8 @@ static int spi_imx_sdma_init(struct devi
43 master->max_dma_len = MAX_SDMA_BD_BYTES;
44 spi_imx->bitbang.master->flags = SPI_MASTER_MUST_RX |
45 SPI_MASTER_MUST_TX;
46 + spi_imx->tx_wml = spi_imx_get_fifosize(spi_imx) / 2;
47 + spi_imx->rx_wml = spi_imx_get_fifosize(spi_imx) / 2;
48 spi_imx->dma_is_inited = 1;
49
50 return 0;