未验证 提交 83048015 编写于 作者: V Vignesh Raghavendra 提交者: Mark Brown

spi: spi-cadence-quadspi: Fix mapping of buffers for DMA reads

Buffers need to mapped to DMA channel's device pointer instead of SPI
controller's device pointer as its system DMA that actually does data
transfer.
Data inconsistencies have been reported when reading from flash
without this fix.

Fixes: ffa639e0 ("mtd: spi-nor: cadence-quadspi: Add DMA support for direct mode reads")
Signed-off-by: NVignesh Raghavendra <vigneshr@ti.com>
Tested-by: NJan Kiszka <jan.kiszka@siemens.com>
Link: https://lore.kernel.org/r/20200831130720.4524-1-vigneshr@ti.comSigned-off-by: NMark Brown <broonie@kernel.org>
上级 ea8be08c
...@@ -907,14 +907,16 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata, ...@@ -907,14 +907,16 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
struct dma_async_tx_descriptor *tx; struct dma_async_tx_descriptor *tx;
dma_cookie_t cookie; dma_cookie_t cookie;
dma_addr_t dma_dst; dma_addr_t dma_dst;
struct device *ddev;
if (!cqspi->rx_chan || !virt_addr_valid(buf)) { if (!cqspi->rx_chan || !virt_addr_valid(buf)) {
memcpy_fromio(buf, cqspi->ahb_base + from, len); memcpy_fromio(buf, cqspi->ahb_base + from, len);
return 0; return 0;
} }
dma_dst = dma_map_single(dev, buf, len, DMA_FROM_DEVICE); ddev = cqspi->rx_chan->device->dev;
if (dma_mapping_error(dev, dma_dst)) { dma_dst = dma_map_single(ddev, buf, len, DMA_FROM_DEVICE);
if (dma_mapping_error(ddev, dma_dst)) {
dev_err(dev, "dma mapping failed\n"); dev_err(dev, "dma mapping failed\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -948,7 +950,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata, ...@@ -948,7 +950,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
} }
err_unmap: err_unmap:
dma_unmap_single(dev, dma_dst, len, DMA_FROM_DEVICE); dma_unmap_single(ddev, dma_dst, len, DMA_FROM_DEVICE);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册