summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-10-18 09:15:16 -0400
committerJens Axboe <axboe@kernel.dk>2018-10-18 17:14:50 -0400
commitee75fa2ae0e23f575630923bc598e7dedbb8b21c (patch)
tree6e1737475cc336e95e724571ce9f16c2d97004f6 /drivers/block
parent77a12e51fcf8c6200818e29fe1e90d944bb1af4a (diff)
mtip32xx: fully switch to the generic DMA API
The mtip32xx used an odd mix of the old PCI and the generic DMA API, so switch it over to the generic API entirely. Note that this also removes a weird fallback to just a 32-bit coherent dma mask if the 64-bit dma mask doesn't work, as that can't even happen. Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/mtip32xx/mtip32xx.c47
1 files changed, 18 insertions, 29 deletions
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 1d7d48d8a205..dfc8de6ce525 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -1862,11 +1862,9 @@ static int exec_drive_taskfile(struct driver_data *dd,
1862 if (IS_ERR(outbuf)) 1862 if (IS_ERR(outbuf))
1863 return PTR_ERR(outbuf); 1863 return PTR_ERR(outbuf);
1864 1864
1865 outbuf_dma = pci_map_single(dd->pdev, 1865 outbuf_dma = dma_map_single(&dd->pdev->dev, outbuf,
1866 outbuf, 1866 taskout, DMA_TO_DEVICE);
1867 taskout, 1867 if (dma_mapping_error(&dd->pdev->dev, outbuf_dma)) {
1868 DMA_TO_DEVICE);
1869 if (pci_dma_mapping_error(dd->pdev, outbuf_dma)) {
1870 err = -ENOMEM; 1868 err = -ENOMEM;
1871 goto abort; 1869 goto abort;
1872 } 1870 }
@@ -1880,10 +1878,9 @@ static int exec_drive_taskfile(struct driver_data *dd,
1880 inbuf = NULL; 1878 inbuf = NULL;
1881 goto abort; 1879 goto abort;
1882 } 1880 }
1883 inbuf_dma = pci_map_single(dd->pdev, 1881 inbuf_dma = dma_map_single(&dd->pdev->dev, inbuf,
1884 inbuf, 1882 taskin, DMA_FROM_DEVICE);
1885 taskin, DMA_FROM_DEVICE); 1883 if (dma_mapping_error(&dd->pdev->dev, inbuf_dma)) {
1886 if (pci_dma_mapping_error(dd->pdev, inbuf_dma)) {
1887 err = -ENOMEM; 1884 err = -ENOMEM;
1888 goto abort; 1885 goto abort;
1889 } 1886 }
@@ -2002,11 +1999,11 @@ static int exec_drive_taskfile(struct driver_data *dd,
2002 1999
2003 /* reclaim the DMA buffers.*/ 2000 /* reclaim the DMA buffers.*/
2004 if (inbuf_dma) 2001 if (inbuf_dma)
2005 pci_unmap_single(dd->pdev, inbuf_dma, 2002 dma_unmap_single(&dd->pdev->dev, inbuf_dma, taskin,
2006 taskin, DMA_FROM_DEVICE); 2003 DMA_FROM_DEVICE);
2007 if (outbuf_dma) 2004 if (outbuf_dma)
2008 pci_unmap_single(dd->pdev, outbuf_dma, 2005 dma_unmap_single(&dd->pdev->dev, outbuf_dma, taskout,
2009 taskout, DMA_TO_DEVICE); 2006 DMA_TO_DEVICE);
2010 inbuf_dma = 0; 2007 inbuf_dma = 0;
2011 outbuf_dma = 0; 2008 outbuf_dma = 0;
2012 2009
@@ -2053,11 +2050,11 @@ static int exec_drive_taskfile(struct driver_data *dd,
2053 } 2050 }
2054abort: 2051abort:
2055 if (inbuf_dma) 2052 if (inbuf_dma)
2056 pci_unmap_single(dd->pdev, inbuf_dma, 2053 dma_unmap_single(&dd->pdev->dev, inbuf_dma, taskin,
2057 taskin, DMA_FROM_DEVICE); 2054 DMA_FROM_DEVICE);
2058 if (outbuf_dma) 2055 if (outbuf_dma)
2059 pci_unmap_single(dd->pdev, outbuf_dma, 2056 dma_unmap_single(&dd->pdev->dev, outbuf_dma, taskout,
2060 taskout, DMA_TO_DEVICE); 2057 DMA_TO_DEVICE);
2061 kfree(outbuf); 2058 kfree(outbuf);
2062 kfree(inbuf); 2059 kfree(inbuf);
2063 2060
@@ -4216,18 +4213,10 @@ static int mtip_pci_probe(struct pci_dev *pdev,
4216 goto iomap_err; 4213 goto iomap_err;
4217 } 4214 }
4218 4215
4219 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { 4216 rv = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
4220 rv = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); 4217 if (rv) {
4221 4218 dev_warn(&pdev->dev, "64-bit DMA enable failed\n");
4222 if (rv) { 4219 goto setmask_err;
4223 rv = pci_set_consistent_dma_mask(pdev,
4224 DMA_BIT_MASK(32));
4225 if (rv) {
4226 dev_warn(&pdev->dev,
4227 "64-bit DMA enable failed\n");
4228 goto setmask_err;
4229 }
4230 }
4231 } 4220 }
4232 4221
4233 /* Copy the info we may need later into the private data structure. */ 4222 /* Copy the info we may need later into the private data structure. */