Skip to content

Commit 1381262

Browse files
Christoph Hellwigaxboe
authored andcommitted
skd: switch to the generic DMA API
The PCI DMA API is deprecated, switch to the generic DMA API instead. Also make use of the dma_set_mask_and_coherent helper to easily set the streaming an coherent DMA masks together. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent ecb0a83 commit 1381262

File tree

1 file changed

+25
-38
lines changed

1 file changed

+25
-38
lines changed

drivers/block/skd_main.c

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ static bool skd_preop_sg_list(struct skd_device *skdev,
632632
* Map scatterlist to PCI bus addresses.
633633
* Note PCI might change the number of entries.
634634
*/
635-
n_sg = pci_map_sg(skdev->pdev, sgl, n_sg, skreq->data_dir);
635+
n_sg = dma_map_sg(&skdev->pdev->dev, sgl, n_sg, skreq->data_dir);
636636
if (n_sg <= 0)
637637
return false;
638638

@@ -682,7 +682,8 @@ static void skd_postop_sg_list(struct skd_device *skdev,
682682
skreq->sksg_list[skreq->n_sg - 1].next_desc_ptr =
683683
skreq->sksg_dma_address +
684684
((skreq->n_sg) * sizeof(struct fit_sg_descriptor));
685-
pci_unmap_sg(skdev->pdev, &skreq->sg[0], skreq->n_sg, skreq->data_dir);
685+
dma_unmap_sg(&skdev->pdev->dev, &skreq->sg[0], skreq->n_sg,
686+
skreq->data_dir);
686687
}
687688

688689
/*
@@ -2632,8 +2633,8 @@ static int skd_cons_skcomp(struct skd_device *skdev)
26322633
"comp pci_alloc, total bytes %zd entries %d\n",
26332634
SKD_SKCOMP_SIZE, SKD_N_COMPLETION_ENTRY);
26342635

2635-
skcomp = pci_zalloc_consistent(skdev->pdev, SKD_SKCOMP_SIZE,
2636-
&skdev->cq_dma_address);
2636+
skcomp = dma_zalloc_coherent(&skdev->pdev->dev, SKD_SKCOMP_SIZE,
2637+
&skdev->cq_dma_address, GFP_KERNEL);
26372638

26382639
if (skcomp == NULL) {
26392640
rc = -ENOMEM;
@@ -2674,10 +2675,10 @@ static int skd_cons_skmsg(struct skd_device *skdev)
26742675

26752676
skmsg->id = i + SKD_ID_FIT_MSG;
26762677

2677-
skmsg->msg_buf = pci_alloc_consistent(skdev->pdev,
2678-
SKD_N_FITMSG_BYTES,
2679-
&skmsg->mb_dma_address);
2680-
2678+
skmsg->msg_buf = dma_alloc_coherent(&skdev->pdev->dev,
2679+
SKD_N_FITMSG_BYTES,
2680+
&skmsg->mb_dma_address,
2681+
GFP_KERNEL);
26812682
if (skmsg->msg_buf == NULL) {
26822683
rc = -ENOMEM;
26832684
goto err_out;
@@ -2971,8 +2972,8 @@ static struct skd_device *skd_construct(struct pci_dev *pdev)
29712972
static void skd_free_skcomp(struct skd_device *skdev)
29722973
{
29732974
if (skdev->skcomp_table)
2974-
pci_free_consistent(skdev->pdev, SKD_SKCOMP_SIZE,
2975-
skdev->skcomp_table, skdev->cq_dma_address);
2975+
dma_free_coherent(&skdev->pdev->dev, SKD_SKCOMP_SIZE,
2976+
skdev->skcomp_table, skdev->cq_dma_address);
29762977

29772978
skdev->skcomp_table = NULL;
29782979
skdev->cq_dma_address = 0;
@@ -2991,8 +2992,8 @@ static void skd_free_skmsg(struct skd_device *skdev)
29912992
skmsg = &skdev->skmsg_table[i];
29922993

29932994
if (skmsg->msg_buf != NULL) {
2994-
pci_free_consistent(skdev->pdev, SKD_N_FITMSG_BYTES,
2995-
skmsg->msg_buf,
2995+
dma_free_coherent(&skdev->pdev->dev, SKD_N_FITMSG_BYTES,
2996+
skmsg->msg_buf,
29962997
skmsg->mb_dma_address);
29972998
}
29982999
skmsg->msg_buf = NULL;
@@ -3172,18 +3173,12 @@ static int skd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
31723173
rc = pci_request_regions(pdev, DRV_NAME);
31733174
if (rc)
31743175
goto err_out;
3175-
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
3176-
if (!rc) {
3177-
if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
3178-
dev_err(&pdev->dev, "consistent DMA mask error %d\n",
3179-
rc);
3180-
}
3181-
} else {
3182-
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
3183-
if (rc) {
3184-
dev_err(&pdev->dev, "DMA mask error %d\n", rc);
3185-
goto err_out_regions;
3186-
}
3176+
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
3177+
if (rc)
3178+
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
3179+
if (rc) {
3180+
dev_err(&pdev->dev, "DMA mask error %d\n", rc);
3181+
goto err_out_regions;
31873182
}
31883183

31893184
if (!skd_major) {
@@ -3367,20 +3362,12 @@ static int skd_pci_resume(struct pci_dev *pdev)
33673362
rc = pci_request_regions(pdev, DRV_NAME);
33683363
if (rc)
33693364
goto err_out;
3370-
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
3371-
if (!rc) {
3372-
if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
3373-
3374-
dev_err(&pdev->dev, "consistent DMA mask error %d\n",
3375-
rc);
3376-
}
3377-
} else {
3378-
rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
3379-
if (rc) {
3380-
3381-
dev_err(&pdev->dev, "DMA mask error %d\n", rc);
3382-
goto err_out_regions;
3383-
}
3365+
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
3366+
if (rc)
3367+
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
3368+
if (rc) {
3369+
dev_err(&pdev->dev, "DMA mask error %d\n", rc);
3370+
goto err_out_regions;
33843371
}
33853372

33863373
pci_set_master(pdev);

0 commit comments

Comments
 (0)