lkml.org 
[lkml]   [2021]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 022/323] spi: spi-ti-qspi: Free DMA resources
    Date
    From: Tudor Ambarus <tudor.ambarus@microchip.com>

    commit 1d309cd688a76fb733f0089d36dc630327b32d59 upstream.

    Release the RX channel and free the dma coherent memory when
    devm_spi_register_master() fails.

    Fixes: 5720ec0a6d26 ("spi: spi-ti-qspi: Add DMA support for QSPI mmap read")
    Cc: stable@vger.kernel.org
    Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
    Link: https://lore.kernel.org/r/20210218130950.90155-1-tudor.ambarus@microchip.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/spi/spi-ti-qspi.c | 20 ++++++++++++++------
    1 file changed, 14 insertions(+), 6 deletions(-)

    --- a/drivers/spi/spi-ti-qspi.c
    +++ b/drivers/spi/spi-ti-qspi.c
    @@ -643,6 +643,17 @@ static int ti_qspi_runtime_resume(struct
    return 0;
    }

    +static void ti_qspi_dma_cleanup(struct ti_qspi *qspi)
    +{
    + if (qspi->rx_bb_addr)
    + dma_free_coherent(qspi->dev, QSPI_DMA_BUFFER_SIZE,
    + qspi->rx_bb_addr,
    + qspi->rx_bb_dma_addr);
    +
    + if (qspi->rx_chan)
    + dma_release_channel(qspi->rx_chan);
    +}
    +
    static const struct of_device_id ti_qspi_match[] = {
    {.compatible = "ti,dra7xxx-qspi" },
    {.compatible = "ti,am4372-qspi" },
    @@ -794,6 +805,8 @@ no_dma:
    if (!ret)
    return 0;

    + ti_qspi_dma_cleanup(qspi);
    +
    pm_runtime_disable(&pdev->dev);
    free_master:
    spi_master_put(master);
    @@ -812,12 +825,7 @@ static int ti_qspi_remove(struct platfor
    pm_runtime_put_sync(&pdev->dev);
    pm_runtime_disable(&pdev->dev);

    - if (qspi->rx_bb_addr)
    - dma_free_coherent(qspi->dev, QSPI_DMA_BUFFER_SIZE,
    - qspi->rx_bb_addr,
    - qspi->rx_bb_dma_addr);
    - if (qspi->rx_chan)
    - dma_release_channel(qspi->rx_chan);
    + ti_qspi_dma_cleanup(qspi);

    return 0;
    }

    \
     
     \ /
      Last update: 2021-05-20 12:31    [W:4.070 / U:0.056 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site