Skip to content

Commit 8e0f93c

Browse files
committed
Merge tag 'spi-fix-v4.5-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fixes from Mark Brown: "A few driver specific fixes for the Rockchip and i.MX SPI controllers, especially for the i.MX they're annoying bugs if you run into them" * tag 'spi-fix-v4.5-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: imx: fix spi resource leak with dma transfer spi: imx: allow only WML aligned transfers to use DMA spi: rockchip: add missing spi_master_put spi: rockchip: disable runtime pm when in err case
2 parents 718e47a + 3ee20ab commit 8e0f93c

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

drivers/spi/spi-imx.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi,
204204
{
205205
struct spi_imx_data *spi_imx = spi_master_get_devdata(master);
206206

207-
if (spi_imx->dma_is_inited &&
208-
transfer->len > spi_imx->wml * sizeof(u32))
207+
if (spi_imx->dma_is_inited && transfer->len >= spi_imx->wml &&
208+
(transfer->len % spi_imx->wml) == 0)
209209
return true;
210210
return false;
211211
}
@@ -919,8 +919,6 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
919919
struct dma_async_tx_descriptor *desc_tx = NULL, *desc_rx = NULL;
920920
int ret;
921921
unsigned long timeout;
922-
u32 dma;
923-
int left;
924922
struct spi_master *master = spi_imx->bitbang.master;
925923
struct sg_table *tx = &transfer->tx_sg, *rx = &transfer->rx_sg;
926924

@@ -954,13 +952,6 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
954952
/* Trigger the cspi module. */
955953
spi_imx->dma_finished = 0;
956954

957-
dma = readl(spi_imx->base + MX51_ECSPI_DMA);
958-
dma = dma & (~MX51_ECSPI_DMA_RXT_WML_MASK);
959-
/* Change RX_DMA_LENGTH trigger dma fetch tail data */
960-
left = transfer->len % spi_imx->wml;
961-
if (left)
962-
writel(dma | (left << MX51_ECSPI_DMA_RXT_WML_OFFSET),
963-
spi_imx->base + MX51_ECSPI_DMA);
964955
/*
965956
* Set these order to avoid potential RX overflow. The overflow may
966957
* happen if we enable SPI HW before starting RX DMA due to rescheduling
@@ -992,10 +983,6 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
992983
spi_imx->devtype_data->reset(spi_imx);
993984
dmaengine_terminate_all(master->dma_rx);
994985
}
995-
dma &= ~MX51_ECSPI_DMA_RXT_WML_MASK;
996-
writel(dma |
997-
spi_imx->wml << MX51_ECSPI_DMA_RXT_WML_OFFSET,
998-
spi_imx->base + MX51_ECSPI_DMA);
999986
}
1000987

1001988
spi_imx->dma_finished = 1;

drivers/spi/spi-rockchip.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ static int rockchip_spi_probe(struct platform_device *pdev)
749749
return 0;
750750

751751
err_register_master:
752+
pm_runtime_disable(&pdev->dev);
752753
if (rs->dma_tx.ch)
753754
dma_release_channel(rs->dma_tx.ch);
754755
if (rs->dma_rx.ch)
@@ -778,6 +779,8 @@ static int rockchip_spi_remove(struct platform_device *pdev)
778779
if (rs->dma_rx.ch)
779780
dma_release_channel(rs->dma_rx.ch);
780781

782+
spi_master_put(master);
783+
781784
return 0;
782785
}
783786

0 commit comments

Comments
 (0)