.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Filename: dma.c |
---|
3 | | -* |
---|
4 | 4 | * |
---|
5 | 5 | * Authors: Joshua Morris <josh.h.morris@us.ibm.com> |
---|
6 | 6 | * Philip Kelleher <pjk1939@linux.vnet.ibm.com> |
---|
7 | 7 | * |
---|
8 | 8 | * (C) Copyright 2013 IBM Corporation |
---|
9 | | -* |
---|
10 | | -* This program is free software; you can redistribute it and/or |
---|
11 | | -* modify it under the terms of the GNU General Public License as |
---|
12 | | -* published by the Free Software Foundation; either version 2 of the |
---|
13 | | -* License, or (at your option) any later version. |
---|
14 | | -* |
---|
15 | | -* This program is distributed in the hope that it will be useful, but |
---|
16 | | -* WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | | -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
18 | | -* General Public License for more details. |
---|
19 | | -* |
---|
20 | | -* You should have received a copy of the GNU General Public License |
---|
21 | | -* along with this program; if not, write to the Free Software Foundation, |
---|
22 | | -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
23 | 9 | */ |
---|
24 | 10 | |
---|
25 | 11 | #include <linux/slab.h> |
---|
.. | .. |
---|
94 | 80 | struct dma_tracker_list { |
---|
95 | 81 | spinlock_t lock; |
---|
96 | 82 | int head; |
---|
97 | | - struct dma_tracker list[0]; |
---|
| 83 | + struct dma_tracker list[]; |
---|
98 | 84 | }; |
---|
99 | 85 | |
---|
100 | 86 | |
---|
.. | .. |
---|
224 | 210 | static void rsxx_free_dma(struct rsxx_dma_ctrl *ctrl, struct rsxx_dma *dma) |
---|
225 | 211 | { |
---|
226 | 212 | if (dma->cmd != HW_CMD_BLK_DISCARD) { |
---|
227 | | - if (!pci_dma_mapping_error(ctrl->card->dev, dma->dma_addr)) { |
---|
228 | | - pci_unmap_page(ctrl->card->dev, dma->dma_addr, |
---|
| 213 | + if (!dma_mapping_error(&ctrl->card->dev->dev, dma->dma_addr)) { |
---|
| 214 | + dma_unmap_page(&ctrl->card->dev->dev, dma->dma_addr, |
---|
229 | 215 | get_dma_size(dma), |
---|
230 | 216 | dma->cmd == HW_CMD_BLK_WRITE ? |
---|
231 | | - PCI_DMA_TODEVICE : |
---|
232 | | - PCI_DMA_FROMDEVICE); |
---|
| 217 | + DMA_TO_DEVICE : |
---|
| 218 | + DMA_FROM_DEVICE); |
---|
233 | 219 | } |
---|
234 | 220 | } |
---|
235 | 221 | |
---|
.. | .. |
---|
438 | 424 | |
---|
439 | 425 | if (dma->cmd != HW_CMD_BLK_DISCARD) { |
---|
440 | 426 | if (dma->cmd == HW_CMD_BLK_WRITE) |
---|
441 | | - dir = PCI_DMA_TODEVICE; |
---|
| 427 | + dir = DMA_TO_DEVICE; |
---|
442 | 428 | else |
---|
443 | | - dir = PCI_DMA_FROMDEVICE; |
---|
| 429 | + dir = DMA_FROM_DEVICE; |
---|
444 | 430 | |
---|
445 | 431 | /* |
---|
446 | | - * The function pci_map_page is placed here because we |
---|
| 432 | + * The function dma_map_page is placed here because we |
---|
447 | 433 | * can only, by design, issue up to 255 commands to the |
---|
448 | 434 | * hardware at one time per DMA channel. So the maximum |
---|
449 | 435 | * amount of mapped memory would be 255 * 4 channels * |
---|
450 | 436 | * 4096 Bytes which is less than 2GB, the limit of a x8 |
---|
451 | | - * Non-HWWD PCIe slot. This way the pci_map_page |
---|
| 437 | + * Non-HWWD PCIe slot. This way the dma_map_page |
---|
452 | 438 | * function should never fail because of a lack of |
---|
453 | 439 | * mappable memory. |
---|
454 | 440 | */ |
---|
455 | | - dma->dma_addr = pci_map_page(ctrl->card->dev, dma->page, |
---|
| 441 | + dma->dma_addr = dma_map_page(&ctrl->card->dev->dev, dma->page, |
---|
456 | 442 | dma->pg_off, dma->sub_page.cnt << 9, dir); |
---|
457 | | - if (pci_dma_mapping_error(ctrl->card->dev, dma->dma_addr)) { |
---|
| 443 | + if (dma_mapping_error(&ctrl->card->dev->dev, dma->dma_addr)) { |
---|
458 | 444 | push_tracker(ctrl->trackers, tag); |
---|
459 | 445 | rsxx_complete_dma(ctrl, dma, DMA_CANCELLED); |
---|
460 | 446 | continue; |
---|
.. | .. |
---|
776 | 762 | /*----------------- DMA Engine Initialization & Setup -------------------*/ |
---|
777 | 763 | int rsxx_hw_buffers_init(struct pci_dev *dev, struct rsxx_dma_ctrl *ctrl) |
---|
778 | 764 | { |
---|
779 | | - ctrl->status.buf = pci_alloc_consistent(dev, STATUS_BUFFER_SIZE8, |
---|
780 | | - &ctrl->status.dma_addr); |
---|
781 | | - ctrl->cmd.buf = pci_alloc_consistent(dev, COMMAND_BUFFER_SIZE8, |
---|
782 | | - &ctrl->cmd.dma_addr); |
---|
| 765 | + ctrl->status.buf = dma_alloc_coherent(&dev->dev, STATUS_BUFFER_SIZE8, |
---|
| 766 | + &ctrl->status.dma_addr, GFP_KERNEL); |
---|
| 767 | + ctrl->cmd.buf = dma_alloc_coherent(&dev->dev, COMMAND_BUFFER_SIZE8, |
---|
| 768 | + &ctrl->cmd.dma_addr, GFP_KERNEL); |
---|
783 | 769 | if (ctrl->status.buf == NULL || ctrl->cmd.buf == NULL) |
---|
784 | 770 | return -ENOMEM; |
---|
785 | 771 | |
---|
.. | .. |
---|
962 | 948 | vfree(ctrl->trackers); |
---|
963 | 949 | |
---|
964 | 950 | if (ctrl->status.buf) |
---|
965 | | - pci_free_consistent(card->dev, STATUS_BUFFER_SIZE8, |
---|
966 | | - ctrl->status.buf, |
---|
967 | | - ctrl->status.dma_addr); |
---|
| 951 | + dma_free_coherent(&card->dev->dev, STATUS_BUFFER_SIZE8, |
---|
| 952 | + ctrl->status.buf, |
---|
| 953 | + ctrl->status.dma_addr); |
---|
968 | 954 | if (ctrl->cmd.buf) |
---|
969 | | - pci_free_consistent(card->dev, COMMAND_BUFFER_SIZE8, |
---|
970 | | - ctrl->cmd.buf, ctrl->cmd.dma_addr); |
---|
| 955 | + dma_free_coherent(&card->dev->dev, COMMAND_BUFFER_SIZE8, |
---|
| 956 | + ctrl->cmd.buf, ctrl->cmd.dma_addr); |
---|
971 | 957 | } |
---|
972 | 958 | |
---|
973 | 959 | return st; |
---|
.. | .. |
---|
1023 | 1009 | |
---|
1024 | 1010 | vfree(ctrl->trackers); |
---|
1025 | 1011 | |
---|
1026 | | - pci_free_consistent(card->dev, STATUS_BUFFER_SIZE8, |
---|
1027 | | - ctrl->status.buf, ctrl->status.dma_addr); |
---|
1028 | | - pci_free_consistent(card->dev, COMMAND_BUFFER_SIZE8, |
---|
1029 | | - ctrl->cmd.buf, ctrl->cmd.dma_addr); |
---|
| 1012 | + dma_free_coherent(&card->dev->dev, STATUS_BUFFER_SIZE8, |
---|
| 1013 | + ctrl->status.buf, ctrl->status.dma_addr); |
---|
| 1014 | + dma_free_coherent(&card->dev->dev, COMMAND_BUFFER_SIZE8, |
---|
| 1015 | + ctrl->cmd.buf, ctrl->cmd.dma_addr); |
---|
1030 | 1016 | } |
---|
1031 | 1017 | } |
---|
1032 | 1018 | |
---|
.. | .. |
---|
1059 | 1045 | card->ctrl[i].stats.reads_issued--; |
---|
1060 | 1046 | |
---|
1061 | 1047 | if (dma->cmd != HW_CMD_BLK_DISCARD) { |
---|
1062 | | - pci_unmap_page(card->dev, dma->dma_addr, |
---|
| 1048 | + dma_unmap_page(&card->dev->dev, dma->dma_addr, |
---|
1063 | 1049 | get_dma_size(dma), |
---|
1064 | 1050 | dma->cmd == HW_CMD_BLK_WRITE ? |
---|
1065 | | - PCI_DMA_TODEVICE : |
---|
1066 | | - PCI_DMA_FROMDEVICE); |
---|
| 1051 | + DMA_TO_DEVICE : |
---|
| 1052 | + DMA_FROM_DEVICE); |
---|
1067 | 1053 | } |
---|
1068 | 1054 | |
---|
1069 | 1055 | list_add_tail(&dma->list, &issued_dmas[i]); |
---|