Skip to content

Commit ee75fa2

Browse files
Christoph Hellwigaxboe
authored andcommitted
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>
1 parent 77a12e5 commit ee75fa2

File tree

1 file changed

+18
-29
lines changed

1 file changed

+18
-29
lines changed

drivers/block/mtip32xx/mtip32xx.c

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,11 +1862,9 @@ static int exec_drive_taskfile(struct driver_data *dd,
18621862
if (IS_ERR(outbuf))
18631863
return PTR_ERR(outbuf);
18641864

1865-
outbuf_dma = pci_map_single(dd->pdev,
1866-
outbuf,
1867-
taskout,
1868-
DMA_TO_DEVICE);
1869-
if (pci_dma_mapping_error(dd->pdev, outbuf_dma)) {
1865+
outbuf_dma = dma_map_single(&dd->pdev->dev, outbuf,
1866+
taskout, DMA_TO_DEVICE);
1867+
if (dma_mapping_error(&dd->pdev->dev, outbuf_dma)) {
18701868
err = -ENOMEM;
18711869
goto abort;
18721870
}
@@ -1880,10 +1878,9 @@ static int exec_drive_taskfile(struct driver_data *dd,
18801878
inbuf = NULL;
18811879
goto abort;
18821880
}
1883-
inbuf_dma = pci_map_single(dd->pdev,
1884-
inbuf,
1885-
taskin, DMA_FROM_DEVICE);
1886-
if (pci_dma_mapping_error(dd->pdev, inbuf_dma)) {
1881+
inbuf_dma = dma_map_single(&dd->pdev->dev, inbuf,
1882+
taskin, DMA_FROM_DEVICE);
1883+
if (dma_mapping_error(&dd->pdev->dev, inbuf_dma)) {
18871884
err = -ENOMEM;
18881885
goto abort;
18891886
}
@@ -2002,11 +1999,11 @@ static int exec_drive_taskfile(struct driver_data *dd,
20021999

20032000
/* reclaim the DMA buffers.*/
20042001
if (inbuf_dma)
2005-
pci_unmap_single(dd->pdev, inbuf_dma,
2006-
taskin, DMA_FROM_DEVICE);
2002+
dma_unmap_single(&dd->pdev->dev, inbuf_dma, taskin,
2003+
DMA_FROM_DEVICE);
20072004
if (outbuf_dma)
2008-
pci_unmap_single(dd->pdev, outbuf_dma,
2009-
taskout, DMA_TO_DEVICE);
2005+
dma_unmap_single(&dd->pdev->dev, outbuf_dma, taskout,
2006+
DMA_TO_DEVICE);
20102007
inbuf_dma = 0;
20112008
outbuf_dma = 0;
20122009

@@ -2053,11 +2050,11 @@ static int exec_drive_taskfile(struct driver_data *dd,
20532050
}
20542051
abort:
20552052
if (inbuf_dma)
2056-
pci_unmap_single(dd->pdev, inbuf_dma,
2057-
taskin, DMA_FROM_DEVICE);
2053+
dma_unmap_single(&dd->pdev->dev, inbuf_dma, taskin,
2054+
DMA_FROM_DEVICE);
20582055
if (outbuf_dma)
2059-
pci_unmap_single(dd->pdev, outbuf_dma,
2060-
taskout, DMA_TO_DEVICE);
2056+
dma_unmap_single(&dd->pdev->dev, outbuf_dma, taskout,
2057+
DMA_TO_DEVICE);
20612058
kfree(outbuf);
20622059
kfree(inbuf);
20632060

@@ -4216,18 +4213,10 @@ static int mtip_pci_probe(struct pci_dev *pdev,
42164213
goto iomap_err;
42174214
}
42184215

4219-
if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
4220-
rv = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
4221-
4222-
if (rv) {
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-
}
4216+
rv = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
4217+
if (rv) {
4218+
dev_warn(&pdev->dev, "64-bit DMA enable failed\n");
4219+
goto setmask_err;
42314220
}
42324221

42334222
/* Copy the info we may need later into the private data structure. */

0 commit comments

Comments
 (0)