forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/scsi/be2iscsi/be_mgmt.c
....@@ -97,6 +97,7 @@
9797
9898 /**
9999 * mgmt_open_connection()- Establish a TCP CXN
100
+ * @phba: driver priv structure
100101 * @dst_addr: Destination Address
101102 * @beiscsi_ep: ptr to device endpoint struct
102103 * @nonemb_cmd: ptr to memory allocated for command
....@@ -209,7 +210,7 @@
209210 return tag;
210211 }
211212
212
-/*
213
+/**
213214 * beiscsi_exec_nemb_cmd()- execute non-embedded MBX cmd
214215 * @phba: driver priv structure
215216 * @nonemb_cmd: DMA address of the MBX command to be issued
....@@ -284,7 +285,7 @@
284285 return rc;
285286
286287 free_cmd:
287
- pci_free_consistent(ctrl->pdev, nonemb_cmd->size,
288
+ dma_free_coherent(&ctrl->pdev->dev, nonemb_cmd->size,
288289 nonemb_cmd->va, nonemb_cmd->dma);
289290 return rc;
290291 }
....@@ -293,7 +294,8 @@
293294 struct be_dma_mem *cmd,
294295 u8 subsystem, u8 opcode, u32 size)
295296 {
296
- cmd->va = pci_zalloc_consistent(phba->ctrl.pdev, size, &cmd->dma);
297
+ cmd->va = dma_alloc_coherent(&phba->ctrl.pdev->dev, size, &cmd->dma,
298
+ GFP_KERNEL);
297299 if (!cmd->va) {
298300 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
299301 "BG_%d : Failed to allocate memory for if info\n");
....@@ -315,7 +317,7 @@
315317 __beiscsi_mcc_compl_status(phba, tag, NULL, NULL);
316318 tag_mem = &phba->ctrl.ptag_state[tag].tag_mem_state;
317319 if (tag_mem->size) {
318
- pci_free_consistent(phba->pcidev, tag_mem->size,
320
+ dma_free_coherent(&phba->pcidev->dev, tag_mem->size,
319321 tag_mem->va, tag_mem->dma);
320322 tag_mem->size = 0;
321323 }
....@@ -761,7 +763,7 @@
761763 "BG_%d : Memory Allocation Failure\n");
762764
763765 /* Free the DMA memory for the IOCTL issuing */
764
- pci_free_consistent(phba->ctrl.pdev,
766
+ dma_free_coherent(&phba->ctrl.pdev->dev,
765767 nonemb_cmd.size,
766768 nonemb_cmd.va,
767769 nonemb_cmd.dma);
....@@ -780,7 +782,7 @@
780782 ioctl_size += sizeof(struct be_cmd_req_hdr);
781783
782784 /* Free the previous allocated DMA memory */
783
- pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
785
+ dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
784786 nonemb_cmd.va,
785787 nonemb_cmd.dma);
786788
....@@ -869,7 +871,7 @@
869871 status);
870872 boot_work = 0;
871873 }
872
- pci_free_consistent(phba->ctrl.pdev, bs->nonemb_cmd.size,
874
+ dma_free_coherent(&phba->ctrl.pdev->dev, bs->nonemb_cmd.size,
873875 bs->nonemb_cmd.va, bs->nonemb_cmd.dma);
874876 bs->nonemb_cmd.va = NULL;
875877 break;
....@@ -1012,9 +1014,10 @@
10121014
10131015 nonemb_cmd = &phba->boot_struct.nonemb_cmd;
10141016 nonemb_cmd->size = sizeof(struct be_cmd_get_session_resp);
1015
- nonemb_cmd->va = pci_alloc_consistent(phba->ctrl.pdev,
1017
+ nonemb_cmd->va = dma_alloc_coherent(&phba->ctrl.pdev->dev,
10161018 nonemb_cmd->size,
1017
- &nonemb_cmd->dma);
1019
+ &nonemb_cmd->dma,
1020
+ GFP_KERNEL);
10181021 if (!nonemb_cmd->va) {
10191022 mutex_unlock(&ctrl->mbox_lock);
10201023 return 0;
....@@ -1176,12 +1179,12 @@
11761179 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) {
11771180 avlbl_cids = BEISCSI_ULP_AVLBL_CID(phba, ulp_num);
11781181 total_cids = BEISCSI_GET_CID_COUNT(phba, ulp_num);
1179
- len += snprintf(buf+len, PAGE_SIZE - len,
1180
- "ULP%d : %d\n", ulp_num,
1181
- (total_cids - avlbl_cids));
1182
+ len += scnprintf(buf+len, PAGE_SIZE - len,
1183
+ "ULP%d : %d\n", ulp_num,
1184
+ (total_cids - avlbl_cids));
11821185 } else
1183
- len += snprintf(buf+len, PAGE_SIZE - len,
1184
- "ULP%d : %d\n", ulp_num, 0);
1186
+ len += scnprintf(buf+len, PAGE_SIZE - len,
1187
+ "ULP%d : %d\n", ulp_num, 0);
11851188 }
11861189
11871190 return len;
....@@ -1206,12 +1209,12 @@
12061209
12071210 for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
12081211 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported))
1209
- len += snprintf(buf+len, PAGE_SIZE - len,
1210
- "ULP%d : %d\n", ulp_num,
1211
- BEISCSI_ULP_AVLBL_CID(phba, ulp_num));
1212
+ len += scnprintf(buf+len, PAGE_SIZE - len,
1213
+ "ULP%d : %d\n", ulp_num,
1214
+ BEISCSI_ULP_AVLBL_CID(phba, ulp_num));
12121215 else
1213
- len += snprintf(buf+len, PAGE_SIZE - len,
1214
- "ULP%d : %d\n", ulp_num, 0);
1216
+ len += scnprintf(buf+len, PAGE_SIZE - len,
1217
+ "ULP%d : %d\n", ulp_num, 0);
12151218 }
12161219
12171220 return len;
....@@ -1508,9 +1511,9 @@
15081511 return -EINVAL;
15091512
15101513 nonemb_cmd.size = sizeof(union be_invldt_cmds_params);
1511
- nonemb_cmd.va = pci_zalloc_consistent(phba->ctrl.pdev,
1512
- nonemb_cmd.size,
1513
- &nonemb_cmd.dma);
1514
+ nonemb_cmd.va = dma_alloc_coherent(&phba->ctrl.pdev->dev,
1515
+ nonemb_cmd.size, &nonemb_cmd.dma,
1516
+ GFP_KERNEL);
15141517 if (!nonemb_cmd.va) {
15151518 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,
15161519 "BM_%d : invldt_cmds_params alloc failed\n");
....@@ -1521,7 +1524,7 @@
15211524 wrb = alloc_mcc_wrb(phba, &tag);
15221525 if (!wrb) {
15231526 mutex_unlock(&ctrl->mbox_lock);
1524
- pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
1527
+ dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
15251528 nonemb_cmd.va, nonemb_cmd.dma);
15261529 return -ENOMEM;
15271530 }
....@@ -1548,7 +1551,7 @@
15481551
15491552 rc = beiscsi_mccq_compl_wait(phba, tag, NULL, &nonemb_cmd);
15501553 if (rc != -EBUSY)
1551
- pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
1554
+ dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
15521555 nonemb_cmd.va, nonemb_cmd.dma);
15531556 return rc;
15541557 }