.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Aic94xx SAS/SATA Tasks |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2005 Adaptec, Inc. All rights reserved. |
---|
5 | 6 | * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com> |
---|
6 | | - * |
---|
7 | | - * This file is licensed under GPLv2. |
---|
8 | | - * |
---|
9 | | - * This file is part of the aic94xx driver. |
---|
10 | | - * |
---|
11 | | - * The aic94xx driver is free software; you can redistribute it and/or |
---|
12 | | - * modify it under the terms of the GNU General Public License as |
---|
13 | | - * published by the Free Software Foundation; version 2 of the |
---|
14 | | - * License. |
---|
15 | | - * |
---|
16 | | - * The aic94xx driver is distributed in the hope that it will be useful, |
---|
17 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
19 | | - * General Public License for more details. |
---|
20 | | - * |
---|
21 | | - * You should have received a copy of the GNU General Public License |
---|
22 | | - * along with the aic94xx driver; if not, write to the Free Software |
---|
23 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
24 | | - * |
---|
25 | 7 | */ |
---|
26 | 8 | |
---|
27 | 9 | #include <linux/spinlock.h> |
---|
.. | .. |
---|
42 | 24 | spin_unlock_irqrestore(&asd_ha->seq.pend_q_lock, flags); |
---|
43 | 25 | } |
---|
44 | 26 | |
---|
45 | | -/* PCI_DMA_... to our direction translation. |
---|
| 27 | +/* DMA_... to our direction translation. |
---|
46 | 28 | */ |
---|
47 | 29 | static const u8 data_dir_flags[] = { |
---|
48 | | - [PCI_DMA_BIDIRECTIONAL] = DATA_DIR_BYRECIPIENT, /* UNSPECIFIED */ |
---|
49 | | - [PCI_DMA_TODEVICE] = DATA_DIR_OUT, /* OUTBOUND */ |
---|
50 | | - [PCI_DMA_FROMDEVICE] = DATA_DIR_IN, /* INBOUND */ |
---|
51 | | - [PCI_DMA_NONE] = DATA_DIR_NONE, /* NO TRANSFER */ |
---|
| 30 | + [DMA_BIDIRECTIONAL] = DATA_DIR_BYRECIPIENT, /* UNSPECIFIED */ |
---|
| 31 | + [DMA_TO_DEVICE] = DATA_DIR_OUT, /* OUTBOUND */ |
---|
| 32 | + [DMA_FROM_DEVICE] = DATA_DIR_IN, /* INBOUND */ |
---|
| 33 | + [DMA_NONE] = DATA_DIR_NONE, /* NO TRANSFER */ |
---|
52 | 34 | }; |
---|
53 | 35 | |
---|
54 | 36 | static int asd_map_scatterlist(struct sas_task *task, |
---|
.. | .. |
---|
60 | 42 | struct scatterlist *sc; |
---|
61 | 43 | int num_sg, res; |
---|
62 | 44 | |
---|
63 | | - if (task->data_dir == PCI_DMA_NONE) |
---|
| 45 | + if (task->data_dir == DMA_NONE) |
---|
64 | 46 | return 0; |
---|
65 | 47 | |
---|
66 | 48 | if (task->num_scatter == 0) { |
---|
67 | 49 | void *p = task->scatter; |
---|
68 | | - dma_addr_t dma = pci_map_single(asd_ha->pcidev, p, |
---|
| 50 | + dma_addr_t dma = dma_map_single(&asd_ha->pcidev->dev, p, |
---|
69 | 51 | task->total_xfer_len, |
---|
70 | 52 | task->data_dir); |
---|
| 53 | + if (dma_mapping_error(&asd_ha->pcidev->dev, dma)) |
---|
| 54 | + return -ENOMEM; |
---|
| 55 | + |
---|
71 | 56 | sg_arr[0].bus_addr = cpu_to_le64((u64)dma); |
---|
72 | 57 | sg_arr[0].size = cpu_to_le32(task->total_xfer_len); |
---|
73 | 58 | sg_arr[0].flags |= ASD_SG_EL_LIST_EOL; |
---|
.. | .. |
---|
79 | 64 | if (sas_protocol_ata(task->task_proto)) |
---|
80 | 65 | num_sg = task->num_scatter; |
---|
81 | 66 | else |
---|
82 | | - num_sg = pci_map_sg(asd_ha->pcidev, task->scatter, |
---|
| 67 | + num_sg = dma_map_sg(&asd_ha->pcidev->dev, task->scatter, |
---|
83 | 68 | task->num_scatter, task->data_dir); |
---|
84 | 69 | if (num_sg == 0) |
---|
85 | 70 | return -ENOMEM; |
---|
.. | .. |
---|
126 | 111 | return 0; |
---|
127 | 112 | err_unmap: |
---|
128 | 113 | if (sas_protocol_ata(task->task_proto)) |
---|
129 | | - pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter, |
---|
130 | | - task->data_dir); |
---|
| 114 | + dma_unmap_sg(&asd_ha->pcidev->dev, task->scatter, |
---|
| 115 | + task->num_scatter, task->data_dir); |
---|
131 | 116 | return res; |
---|
132 | 117 | } |
---|
133 | 118 | |
---|
.. | .. |
---|
136 | 121 | struct asd_ha_struct *asd_ha = ascb->ha; |
---|
137 | 122 | struct sas_task *task = ascb->uldd_task; |
---|
138 | 123 | |
---|
139 | | - if (task->data_dir == PCI_DMA_NONE) |
---|
| 124 | + if (task->data_dir == DMA_NONE) |
---|
140 | 125 | return; |
---|
141 | 126 | |
---|
142 | 127 | if (task->num_scatter == 0) { |
---|
143 | 128 | dma_addr_t dma = (dma_addr_t) |
---|
144 | 129 | le64_to_cpu(ascb->scb->ssp_task.sg_element[0].bus_addr); |
---|
145 | | - pci_unmap_single(ascb->ha->pcidev, dma, task->total_xfer_len, |
---|
146 | | - task->data_dir); |
---|
| 130 | + dma_unmap_single(&ascb->ha->pcidev->dev, dma, |
---|
| 131 | + task->total_xfer_len, task->data_dir); |
---|
147 | 132 | return; |
---|
148 | 133 | } |
---|
149 | 134 | |
---|
150 | 135 | asd_free_coherent(asd_ha, ascb->sg_arr); |
---|
151 | 136 | if (task->task_proto != SAS_PROTOCOL_STP) |
---|
152 | | - pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter, |
---|
153 | | - task->data_dir); |
---|
| 137 | + dma_unmap_sg(&asd_ha->pcidev->dev, task->scatter, |
---|
| 138 | + task->num_scatter, task->data_dir); |
---|
154 | 139 | } |
---|
155 | 140 | |
---|
156 | 141 | /* ---------- Task complete tasklet ---------- */ |
---|
.. | .. |
---|
223 | 208 | switch (opcode) { |
---|
224 | 209 | case TC_NO_ERROR: |
---|
225 | 210 | ts->resp = SAS_TASK_COMPLETE; |
---|
226 | | - ts->stat = SAM_STAT_GOOD; |
---|
| 211 | + ts->stat = SAS_SAM_STAT_GOOD; |
---|
227 | 212 | break; |
---|
228 | 213 | case TC_UNDERRUN: |
---|
229 | 214 | ts->resp = SAS_TASK_COMPLETE; |
---|
.. | .. |
---|
436 | 421 | struct domain_device *dev = task->dev; |
---|
437 | 422 | struct scb *scb; |
---|
438 | 423 | |
---|
439 | | - pci_map_sg(asd_ha->pcidev, &task->smp_task.smp_req, 1, |
---|
440 | | - PCI_DMA_TODEVICE); |
---|
441 | | - pci_map_sg(asd_ha->pcidev, &task->smp_task.smp_resp, 1, |
---|
442 | | - PCI_DMA_FROMDEVICE); |
---|
| 424 | + dma_map_sg(&asd_ha->pcidev->dev, &task->smp_task.smp_req, 1, |
---|
| 425 | + DMA_TO_DEVICE); |
---|
| 426 | + dma_map_sg(&asd_ha->pcidev->dev, &task->smp_task.smp_resp, 1, |
---|
| 427 | + DMA_FROM_DEVICE); |
---|
443 | 428 | |
---|
444 | 429 | scb = ascb->scb; |
---|
445 | 430 | |
---|
.. | .. |
---|
471 | 456 | struct sas_task *task = a->uldd_task; |
---|
472 | 457 | |
---|
473 | 458 | BUG_ON(!task); |
---|
474 | | - pci_unmap_sg(a->ha->pcidev, &task->smp_task.smp_req, 1, |
---|
475 | | - PCI_DMA_TODEVICE); |
---|
476 | | - pci_unmap_sg(a->ha->pcidev, &task->smp_task.smp_resp, 1, |
---|
477 | | - PCI_DMA_FROMDEVICE); |
---|
| 459 | + dma_unmap_sg(&a->ha->pcidev->dev, &task->smp_task.smp_req, 1, |
---|
| 460 | + DMA_TO_DEVICE); |
---|
| 461 | + dma_unmap_sg(&a->ha->pcidev->dev, &task->smp_task.smp_resp, 1, |
---|
| 462 | + DMA_FROM_DEVICE); |
---|
478 | 463 | } |
---|
479 | 464 | |
---|
480 | 465 | /* ---------- SSP ---------- */ |
---|