summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMichael Walle <michael@walle.cc>2020-03-10 08:33:13 +0100
committerMark Brown <broonie@kernel.org>2020-03-10 18:34:57 +0000
commit22ee9de1ecfb4459a9b3a959994f6ccb4a3827a4 (patch)
tree97e7f93558ef65670c42ed1dd0a7556342ac7179 /drivers
parent36098a1db74a33ee51833d09ee3ea14fd7f90f51 (diff)
spi: spi-fsl-dspi: fix DMA mapping
Use the correct device to request the DMA mapping. Otherwise the IOMMU doesn't get the mapping and it will generate a page fault. The error messages look like: [ 3.008452] arm-smmu 5000000.iommu: Unhandled context fault: fsr=0x402, iova=0xf9800000, fsynr=0x3f0022, cbfrsynra=0x828, cb=8 [ 3.020123] arm-smmu 5000000.iommu: Unhandled context fault: fsr=0x402, iova=0xf9800000, fsynr=0x3f0022, cbfrsynra=0x828, cb=8 This was tested on a custom board with a LS1028A SoC. Signed-off-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20200310073313.21277-1-michael@walle.cc Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/spi/spi-fsl-dspi.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 0683a3fbd48c..50e3382f0c50 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -497,14 +497,16 @@ static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr)
goto err_tx_channel;
}
- dma->tx_dma_buf = dma_alloc_coherent(dev, dspi->devtype_data->dma_bufsize,
+ dma->tx_dma_buf = dma_alloc_coherent(dma->chan_tx->device->dev,
+ dspi->devtype_data->dma_bufsize,
&dma->tx_dma_phys, GFP_KERNEL);
if (!dma->tx_dma_buf) {
ret = -ENOMEM;
goto err_tx_dma_buf;
}
- dma->rx_dma_buf = dma_alloc_coherent(dev, dspi->devtype_data->dma_bufsize,
+ dma->rx_dma_buf = dma_alloc_coherent(dma->chan_rx->device->dev,
+ dspi->devtype_data->dma_bufsize,
&dma->rx_dma_phys, GFP_KERNEL);
if (!dma->rx_dma_buf) {
ret = -ENOMEM;
@@ -541,10 +543,12 @@ static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr)
return 0;
err_slave_config:
- dma_free_coherent(dev, dspi->devtype_data->dma_bufsize,
+ dma_free_coherent(dma->chan_rx->device->dev,
+ dspi->devtype_data->dma_bufsize,
dma->rx_dma_buf, dma->rx_dma_phys);
err_rx_dma_buf:
- dma_free_coherent(dev, dspi->devtype_data->dma_bufsize,
+ dma_free_coherent(dma->chan_tx->device->dev,
+ dspi->devtype_data->dma_bufsize,
dma->tx_dma_buf, dma->tx_dma_phys);
err_tx_dma_buf:
dma_release_channel(dma->chan_tx);
@@ -560,20 +564,19 @@ err_tx_channel:
static void dspi_release_dma(struct fsl_dspi *dspi)
{
struct fsl_dspi_dma *dma = dspi->dma;
- struct device *dev = &dspi->pdev->dev;
if (!dma)
return;
if (dma->chan_tx) {
- dma_unmap_single(dev, dma->tx_dma_phys,
+ dma_unmap_single(dma->chan_tx->device->dev, dma->tx_dma_phys,
dspi->devtype_data->dma_bufsize,
DMA_TO_DEVICE);
dma_release_channel(dma->chan_tx);
}
if (dma->chan_rx) {
- dma_unmap_single(dev, dma->rx_dma_phys,
+ dma_unmap_single(dma->chan_rx->device->dev, dma->rx_dma_phys,
dspi->devtype_data->dma_bufsize,
DMA_FROM_DEVICE);
dma_release_channel(dma->chan_rx);