spi: imx: read back the RX/TX watermark levels earlier
authorLucas Stach <l.stach@pengutronix.de>
Wed, 1 Apr 2015 08:46:15 +0000 (10:46 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 May 2015 20:01:46 +0000 (22:01 +0200)
commitbc90eb37fb52fd013103a82b2117ead4dabdbf80
tree97cd905d8eef4b139c2a055666d641d5b8c5f10d
parentd6e6b42583ff9439f73e7a0a936856969c0d9373
spi: imx: read back the RX/TX watermark levels earlier

commit f511ab09dfb0fe7b2335eccac51ff9f001a32e4a upstream.

They are used to decide if the controller can do DMA on a buffer
of a specific length and thus are needed before any transfer is attempted.

This fixes a memory leak where the SPI core uses the drivers can_dma()
callback to determine if a buffer needs to be mapped. As the watermark
levels aren't correct at that point the driver falsely claims to be able to
DMA the buffer when it fact it isn't.
After the transfer has been done the core uses the same callback to
determine if it needs to unmap the buffers. As the driver now correctly
claims to not being able to DMA the buffer the core doesn't attempt to
unmap the buffer which leaves the SGT leaking.

Fixes: f62caccd12c17e4 (spi: spi-imx: add DMA support)
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/spi/spi-imx.c