• Lucas Stach's avatar
    spi: imx: read back the RX/TX watermark levels earlier · 2ed82e9e
    Lucas Stach authored
    [ Upstream commit f511ab09 ]
    
    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: f62caccd (spi: spi-imx: add DMA support)
    Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
    2ed82e9e
spi-imx.c 32.9 KB