Skip to content

Commit c22b332

Browse files
Christoph Hellwigmartinkpetersen
authored andcommitted
scsi: csiostor: switch to generic DMA API
Switch from the legacy PCI DMA API to the generic DMA API. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 26a4c99 commit c22b332

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

drivers/scsi/csiostor/csio_init.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,8 @@ csio_pci_init(struct pci_dev *pdev, int *bars)
210210
pci_set_master(pdev);
211211
pci_try_set_mwi(pdev);
212212

213-
if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
214-
pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
215-
} else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
216-
pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
217-
} else {
213+
if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
214+
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
218215
dev_err(&pdev->dev, "No suitable DMA available.\n");
219216
goto err_release_regions;
220217
}

drivers/scsi/csiostor/csio_lnode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,8 +1845,8 @@ csio_ln_fdmi_init(struct csio_lnode *ln)
18451845
/* Allocate Dma buffers for FDMI response Payload */
18461846
dma_buf = &ln->mgmt_req->dma_buf;
18471847
dma_buf->len = 2048;
1848-
dma_buf->vaddr = pci_alloc_consistent(hw->pdev, dma_buf->len,
1849-
&dma_buf->paddr);
1848+
dma_buf->vaddr = dma_alloc_coherent(&hw->pdev->dev, dma_buf->len,
1849+
&dma_buf->paddr, GFP_KERNEL);
18501850
if (!dma_buf->vaddr) {
18511851
csio_err(hw, "Failed to alloc DMA buffer for FDMI!\n");
18521852
kfree(ln->mgmt_req);
@@ -1873,7 +1873,7 @@ csio_ln_fdmi_exit(struct csio_lnode *ln)
18731873

18741874
dma_buf = &ln->mgmt_req->dma_buf;
18751875
if (dma_buf->vaddr)
1876-
pci_free_consistent(hw->pdev, dma_buf->len, dma_buf->vaddr,
1876+
dma_free_coherent(&hw->pdev->dev, dma_buf->len, dma_buf->vaddr,
18771877
dma_buf->paddr);
18781878

18791879
kfree(ln->mgmt_req);

drivers/scsi/csiostor/csio_scsi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,8 +2349,8 @@ csio_scsi_alloc_ddp_bufs(struct csio_scsim *scm, struct csio_hw *hw,
23492349
}
23502350

23512351
/* Allocate Dma buffers for DDP */
2352-
ddp_desc->vaddr = pci_alloc_consistent(hw->pdev, unit_size,
2353-
&ddp_desc->paddr);
2352+
ddp_desc->vaddr = dma_alloc_coherent(&hw->pdev->dev, unit_size,
2353+
&ddp_desc->paddr, GFP_KERNEL);
23542354
if (!ddp_desc->vaddr) {
23552355
csio_err(hw,
23562356
"SCSI response DMA buffer (ddp) allocation"
@@ -2372,8 +2372,8 @@ csio_scsi_alloc_ddp_bufs(struct csio_scsim *scm, struct csio_hw *hw,
23722372
list_for_each(tmp, &scm->ddp_freelist) {
23732373
ddp_desc = (struct csio_dma_buf *) tmp;
23742374
tmp = csio_list_prev(tmp);
2375-
pci_free_consistent(hw->pdev, ddp_desc->len, ddp_desc->vaddr,
2376-
ddp_desc->paddr);
2375+
dma_free_coherent(&hw->pdev->dev, ddp_desc->len,
2376+
ddp_desc->vaddr, ddp_desc->paddr);
23772377
list_del_init(&ddp_desc->list);
23782378
kfree(ddp_desc);
23792379
}
@@ -2399,8 +2399,8 @@ csio_scsi_free_ddp_bufs(struct csio_scsim *scm, struct csio_hw *hw)
23992399
list_for_each(tmp, &scm->ddp_freelist) {
24002400
ddp_desc = (struct csio_dma_buf *) tmp;
24012401
tmp = csio_list_prev(tmp);
2402-
pci_free_consistent(hw->pdev, ddp_desc->len, ddp_desc->vaddr,
2403-
ddp_desc->paddr);
2402+
dma_free_coherent(&hw->pdev->dev, ddp_desc->len,
2403+
ddp_desc->vaddr, ddp_desc->paddr);
24042404
list_del_init(&ddp_desc->list);
24052405
kfree(ddp_desc);
24062406
}

drivers/scsi/csiostor/csio_wr.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ csio_wr_fill_fl(struct csio_hw *hw, struct csio_q *flq)
124124

125125
while (n--) {
126126
buf->len = sge->sge_fl_buf_size[sreg];
127-
buf->vaddr = pci_alloc_consistent(hw->pdev, buf->len,
128-
&buf->paddr);
127+
buf->vaddr = dma_alloc_coherent(&hw->pdev->dev, buf->len,
128+
&buf->paddr, GFP_KERNEL);
129129
if (!buf->vaddr) {
130130
csio_err(hw, "Could only fill %d buffers!\n", n + 1);
131131
return -ENOMEM;
@@ -233,7 +233,8 @@ csio_wr_alloc_q(struct csio_hw *hw, uint32_t qsize, uint32_t wrsize,
233233

234234
q = wrm->q_arr[free_idx];
235235

236-
q->vstart = pci_zalloc_consistent(hw->pdev, qsz, &q->pstart);
236+
q->vstart = dma_zalloc_coherent(&hw->pdev->dev, qsz, &q->pstart,
237+
GFP_KERNEL);
237238
if (!q->vstart) {
238239
csio_err(hw,
239240
"Failed to allocate DMA memory for "
@@ -1703,14 +1704,14 @@ csio_wrm_exit(struct csio_wrm *wrm, struct csio_hw *hw)
17031704
buf = &q->un.fl.bufs[j];
17041705
if (!buf->vaddr)
17051706
continue;
1706-
pci_free_consistent(hw->pdev, buf->len,
1707-
buf->vaddr,
1708-
buf->paddr);
1707+
dma_free_coherent(&hw->pdev->dev,
1708+
buf->len, buf->vaddr,
1709+
buf->paddr);
17091710
}
17101711
kfree(q->un.fl.bufs);
17111712
}
1712-
pci_free_consistent(hw->pdev, q->size,
1713-
q->vstart, q->pstart);
1713+
dma_free_coherent(&hw->pdev->dev, q->size,
1714+
q->vstart, q->pstart);
17141715
}
17151716
kfree(q);
17161717
}

0 commit comments

Comments
 (0)