forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 890e1df1bec891d9203724541e81f8fbe5183388
kernel/drivers/block/rsxx/dma.c
....@@ -1,25 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Filename: dma.c
3
-*
44 *
55 * Authors: Joshua Morris <josh.h.morris@us.ibm.com>
66 * Philip Kelleher <pjk1939@linux.vnet.ibm.com>
77 *
88 * (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
239 */
2410
2511 #include <linux/slab.h>
....@@ -94,7 +80,7 @@
9480 struct dma_tracker_list {
9581 spinlock_t lock;
9682 int head;
97
- struct dma_tracker list[0];
83
+ struct dma_tracker list[];
9884 };
9985
10086
....@@ -224,12 +210,12 @@
224210 static void rsxx_free_dma(struct rsxx_dma_ctrl *ctrl, struct rsxx_dma *dma)
225211 {
226212 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,
229215 get_dma_size(dma),
230216 dma->cmd == HW_CMD_BLK_WRITE ?
231
- PCI_DMA_TODEVICE :
232
- PCI_DMA_FROMDEVICE);
217
+ DMA_TO_DEVICE :
218
+ DMA_FROM_DEVICE);
233219 }
234220 }
235221
....@@ -438,23 +424,23 @@
438424
439425 if (dma->cmd != HW_CMD_BLK_DISCARD) {
440426 if (dma->cmd == HW_CMD_BLK_WRITE)
441
- dir = PCI_DMA_TODEVICE;
427
+ dir = DMA_TO_DEVICE;
442428 else
443
- dir = PCI_DMA_FROMDEVICE;
429
+ dir = DMA_FROM_DEVICE;
444430
445431 /*
446
- * The function pci_map_page is placed here because we
432
+ * The function dma_map_page is placed here because we
447433 * can only, by design, issue up to 255 commands to the
448434 * hardware at one time per DMA channel. So the maximum
449435 * amount of mapped memory would be 255 * 4 channels *
450436 * 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
452438 * function should never fail because of a lack of
453439 * mappable memory.
454440 */
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,
456442 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)) {
458444 push_tracker(ctrl->trackers, tag);
459445 rsxx_complete_dma(ctrl, dma, DMA_CANCELLED);
460446 continue;
....@@ -776,10 +762,10 @@
776762 /*----------------- DMA Engine Initialization & Setup -------------------*/
777763 int rsxx_hw_buffers_init(struct pci_dev *dev, struct rsxx_dma_ctrl *ctrl)
778764 {
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);
783769 if (ctrl->status.buf == NULL || ctrl->cmd.buf == NULL)
784770 return -ENOMEM;
785771
....@@ -962,12 +948,12 @@
962948 vfree(ctrl->trackers);
963949
964950 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);
968954 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);
971957 }
972958
973959 return st;
....@@ -1023,10 +1009,10 @@
10231009
10241010 vfree(ctrl->trackers);
10251011
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);
10301016 }
10311017 }
10321018
....@@ -1059,11 +1045,11 @@
10591045 card->ctrl[i].stats.reads_issued--;
10601046
10611047 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,
10631049 get_dma_size(dma),
10641050 dma->cmd == HW_CMD_BLK_WRITE ?
1065
- PCI_DMA_TODEVICE :
1066
- PCI_DMA_FROMDEVICE);
1051
+ DMA_TO_DEVICE :
1052
+ DMA_FROM_DEVICE);
10671053 }
10681054
10691055 list_add_tail(&dma->list, &issued_dmas[i]);