hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/scsi/mpt3sas/mpt3sas_transport.c
....@@ -146,25 +146,22 @@
146146 u32 ioc_status;
147147
148148 if (ioc->shost_recovery || ioc->pci_error_recovery) {
149
- pr_info(MPT3SAS_FMT "%s: host reset in progress!\n",
150
- __func__, ioc->name);
149
+ ioc_info(ioc, "%s: host reset in progress!\n", __func__);
151150 return -EFAULT;
152151 }
153152
154153 if ((mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0,
155154 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) {
156
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
157
- ioc->name, __FILE__, __LINE__, __func__);
155
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
156
+ __FILE__, __LINE__, __func__);
158157 return -ENXIO;
159158 }
160159
161160 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
162161 MPI2_IOCSTATUS_MASK;
163162 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
164
- pr_err(MPT3SAS_FMT
165
- "handle(0x%04x), ioc_status(0x%04x)\nfailure at %s:%d/%s()!\n",
166
- ioc->name, handle, ioc_status,
167
- __FILE__, __LINE__, __func__);
163
+ ioc_err(ioc, "handle(0x%04x), ioc_status(0x%04x) failure at %s:%d/%s()!\n",
164
+ handle, ioc_status, __FILE__, __LINE__, __func__);
168165 return -EIO;
169166 }
170167
....@@ -299,7 +296,6 @@
299296 struct rep_manu_request *manufacture_request;
300297 int rc;
301298 u16 smid;
302
- u32 ioc_state;
303299 void *psge;
304300 u8 issue_reset = 0;
305301 void *data_out = NULL;
....@@ -307,48 +303,28 @@
307303 dma_addr_t data_in_dma;
308304 size_t data_in_sz;
309305 size_t data_out_sz;
310
- u16 wait_state_count;
311306
312307 if (ioc->shost_recovery || ioc->pci_error_recovery) {
313
- pr_info(MPT3SAS_FMT "%s: host reset in progress!\n",
314
- __func__, ioc->name);
308
+ ioc_info(ioc, "%s: host reset in progress!\n", __func__);
315309 return -EFAULT;
316310 }
317311
318312 mutex_lock(&ioc->transport_cmds.mutex);
319313
320314 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) {
321
- pr_err(MPT3SAS_FMT "%s: transport_cmds in use\n",
322
- ioc->name, __func__);
315
+ ioc_err(ioc, "%s: transport_cmds in use\n", __func__);
323316 rc = -EAGAIN;
324317 goto out;
325318 }
326319 ioc->transport_cmds.status = MPT3_CMD_PENDING;
327320
328
- wait_state_count = 0;
329
- ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
330
- while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
331
- if (wait_state_count++ == 10) {
332
- pr_err(MPT3SAS_FMT
333
- "%s: failed due to ioc not operational\n",
334
- ioc->name, __func__);
335
- rc = -EFAULT;
336
- goto out;
337
- }
338
- ssleep(1);
339
- ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
340
- pr_info(MPT3SAS_FMT
341
- "%s: waiting for operational state(count=%d)\n",
342
- ioc->name, __func__, wait_state_count);
343
- }
344
- if (wait_state_count)
345
- pr_info(MPT3SAS_FMT "%s: ioc is operational\n",
346
- ioc->name, __func__);
321
+ rc = mpt3sas_wait_for_ioc(ioc, IOC_OPERATIONAL_WAIT_COUNT);
322
+ if (rc)
323
+ goto out;
347324
348325 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx);
349326 if (!smid) {
350
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
351
- ioc->name, __func__);
327
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
352328 rc = -EAGAIN;
353329 goto out;
354330 }
....@@ -359,9 +335,8 @@
359335
360336 data_out_sz = sizeof(struct rep_manu_request);
361337 data_in_sz = sizeof(struct rep_manu_reply);
362
- data_out = pci_alloc_consistent(ioc->pdev, data_out_sz + data_in_sz,
363
- &data_out_dma);
364
-
338
+ data_out = dma_alloc_coherent(&ioc->pdev->dev, data_out_sz + data_in_sz,
339
+ &data_out_dma, GFP_KERNEL);
365340 if (!data_out) {
366341 pr_err("failure at %s:%d/%s()!\n", __FILE__,
367342 __LINE__, __func__);
....@@ -388,16 +363,15 @@
388363 ioc->build_sg(ioc, psge, data_out_dma, data_out_sz, data_in_dma,
389364 data_in_sz);
390365
391
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
392
- "report_manufacture - send to sas_addr(0x%016llx)\n",
393
- ioc->name, (unsigned long long)sas_address));
366
+ dtransportprintk(ioc,
367
+ ioc_info(ioc, "report_manufacture - send to sas_addr(0x%016llx)\n",
368
+ (u64)sas_address));
394369 init_completion(&ioc->transport_cmds.done);
395
- mpt3sas_base_put_smid_default(ioc, smid);
370
+ ioc->put_smid_default(ioc, smid);
396371 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ);
397372
398373 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) {
399
- pr_err(MPT3SAS_FMT "%s: timeout\n",
400
- ioc->name, __func__);
374
+ ioc_err(ioc, "%s: timeout\n", __func__);
401375 _debug_dump_mf(mpi_request,
402376 sizeof(Mpi2SmpPassthroughRequest_t)/4);
403377 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET))
....@@ -405,17 +379,16 @@
405379 goto issue_host_reset;
406380 }
407381
408
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
409
- "report_manufacture - complete\n", ioc->name));
382
+ dtransportprintk(ioc, ioc_info(ioc, "report_manufacture - complete\n"));
410383
411384 if (ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID) {
412385 u8 *tmp;
413386
414387 mpi_reply = ioc->transport_cmds.reply;
415388
416
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
417
- "report_manufacture - reply data transfer size(%d)\n",
418
- ioc->name, le16_to_cpu(mpi_reply->ResponseDataLength)));
389
+ dtransportprintk(ioc,
390
+ ioc_info(ioc, "report_manufacture - reply data transfer size(%d)\n",
391
+ le16_to_cpu(mpi_reply->ResponseDataLength)));
419392
420393 if (le16_to_cpu(mpi_reply->ResponseDataLength) !=
421394 sizeof(struct rep_manu_reply))
....@@ -439,8 +412,8 @@
439412 manufacture_reply->component_revision_id;
440413 }
441414 } else
442
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
443
- "report_manufacture - no reply\n", ioc->name));
415
+ dtransportprintk(ioc,
416
+ ioc_info(ioc, "report_manufacture - no reply\n"));
444417
445418 issue_host_reset:
446419 if (issue_reset)
....@@ -448,7 +421,7 @@
448421 out:
449422 ioc->transport_cmds.status = MPT3_CMD_NOT_USED;
450423 if (data_out)
451
- pci_free_consistent(ioc->pdev, data_out_sz + data_in_sz,
424
+ dma_free_coherent(&ioc->pdev->dev, data_out_sz + data_in_sz,
452425 data_out, data_out_dma);
453426
454427 mutex_unlock(&ioc->transport_cmds.mutex);
....@@ -643,8 +616,8 @@
643616 mpt3sas_port = kzalloc(sizeof(struct _sas_port),
644617 GFP_KERNEL);
645618 if (!mpt3sas_port) {
646
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
647
- ioc->name, __FILE__, __LINE__, __func__);
619
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
620
+ __FILE__, __LINE__, __func__);
648621 return NULL;
649622 }
650623
....@@ -655,22 +628,21 @@
655628 spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
656629
657630 if (!sas_node) {
658
- pr_err(MPT3SAS_FMT
659
- "%s: Could not find parent sas_address(0x%016llx)!\n",
660
- ioc->name, __func__, (unsigned long long)sas_address);
631
+ ioc_err(ioc, "%s: Could not find parent sas_address(0x%016llx)!\n",
632
+ __func__, (u64)sas_address);
661633 goto out_fail;
662634 }
663635
664636 if ((_transport_set_identify(ioc, handle,
665637 &mpt3sas_port->remote_identify))) {
666
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
667
- ioc->name, __FILE__, __LINE__, __func__);
638
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
639
+ __FILE__, __LINE__, __func__);
668640 goto out_fail;
669641 }
670642
671643 if (mpt3sas_port->remote_identify.device_type == SAS_PHY_UNUSED) {
672
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
673
- ioc->name, __FILE__, __LINE__, __func__);
644
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
645
+ __FILE__, __LINE__, __func__);
674646 goto out_fail;
675647 }
676648
....@@ -687,20 +659,20 @@
687659 }
688660
689661 if (!mpt3sas_port->num_phys) {
690
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
691
- ioc->name, __FILE__, __LINE__, __func__);
662
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
663
+ __FILE__, __LINE__, __func__);
692664 goto out_fail;
693665 }
694666
695667 if (!sas_node->parent_dev) {
696
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
697
- ioc->name, __FILE__, __LINE__, __func__);
668
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
669
+ __FILE__, __LINE__, __func__);
698670 goto out_fail;
699671 }
700672 port = sas_port_alloc_num(sas_node->parent_dev);
701673 if ((sas_port_add(port))) {
702
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
703
- ioc->name, __FILE__, __LINE__, __func__);
674
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
675
+ __FILE__, __LINE__, __func__);
704676 goto out_fail;
705677 }
706678
....@@ -729,17 +701,17 @@
729701 sas_device = mpt3sas_get_sdev_by_addr(ioc,
730702 mpt3sas_port->remote_identify.sas_address);
731703 if (!sas_device) {
732
- dfailprintk(ioc, printk(MPT3SAS_FMT
733
- "failure at %s:%d/%s()!\n",
734
- ioc->name, __FILE__, __LINE__, __func__));
704
+ dfailprintk(ioc,
705
+ ioc_info(ioc, "failure at %s:%d/%s()!\n",
706
+ __FILE__, __LINE__, __func__));
735707 goto out_fail;
736708 }
737709 sas_device->pend_sas_rphy_add = 1;
738710 }
739711
740712 if ((sas_rphy_add(rphy))) {
741
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
742
- ioc->name, __FILE__, __LINE__, __func__);
713
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
714
+ __FILE__, __LINE__, __func__);
743715 }
744716
745717 if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) {
....@@ -747,11 +719,10 @@
747719 sas_device_put(sas_device);
748720 }
749721
750
- if ((ioc->logging_level & MPT_DEBUG_TRANSPORT))
751
- dev_printk(KERN_INFO, &rphy->dev,
752
- "add: handle(0x%04x), sas_addr(0x%016llx)\n",
753
- handle, (unsigned long long)
754
- mpt3sas_port->remote_identify.sas_address);
722
+ dev_info(&rphy->dev,
723
+ "add: handle(0x%04x), sas_addr(0x%016llx)\n", handle,
724
+ (unsigned long long)mpt3sas_port->remote_identify.sas_address);
725
+
755726 mpt3sas_port->rphy = rphy;
756727 spin_lock_irqsave(&ioc->sas_node_lock, flags);
757728 list_add_tail(&mpt3sas_port->port_list, &sas_node->sas_port_list);
....@@ -841,6 +812,8 @@
841812 }
842813 if (!ioc->remove_host)
843814 sas_port_delete(mpt3sas_port->port);
815
+ ioc_info(ioc, "%s: removed: sas_addr(0x%016llx)\n",
816
+ __func__, (unsigned long long)sas_address);
844817 kfree(mpt3sas_port);
845818 }
846819
....@@ -864,14 +837,14 @@
864837 INIT_LIST_HEAD(&mpt3sas_phy->port_siblings);
865838 phy = sas_phy_alloc(parent_dev, phy_index);
866839 if (!phy) {
867
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
868
- ioc->name, __FILE__, __LINE__, __func__);
840
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
841
+ __FILE__, __LINE__, __func__);
869842 return -1;
870843 }
871844 if ((_transport_set_identify(ioc, mpt3sas_phy->handle,
872845 &mpt3sas_phy->identify))) {
873
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
874
- ioc->name, __FILE__, __LINE__, __func__);
846
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
847
+ __FILE__, __LINE__, __func__);
875848 sas_phy_free(phy);
876849 return -1;
877850 }
....@@ -893,8 +866,8 @@
893866 phy_pg0.ProgrammedLinkRate >> 4);
894867
895868 if ((sas_phy_add(phy))) {
896
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
897
- ioc->name, __FILE__, __LINE__, __func__);
869
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
870
+ __FILE__, __LINE__, __func__);
898871 sas_phy_free(phy);
899872 return -1;
900873 }
....@@ -932,14 +905,14 @@
932905 INIT_LIST_HEAD(&mpt3sas_phy->port_siblings);
933906 phy = sas_phy_alloc(parent_dev, phy_index);
934907 if (!phy) {
935
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
936
- ioc->name, __FILE__, __LINE__, __func__);
908
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
909
+ __FILE__, __LINE__, __func__);
937910 return -1;
938911 }
939912 if ((_transport_set_identify(ioc, mpt3sas_phy->handle,
940913 &mpt3sas_phy->identify))) {
941
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
942
- ioc->name, __FILE__, __LINE__, __func__);
914
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
915
+ __FILE__, __LINE__, __func__);
943916 sas_phy_free(phy);
944917 return -1;
945918 }
....@@ -963,8 +936,8 @@
963936 expander_pg1.ProgrammedLinkRate >> 4);
964937
965938 if ((sas_phy_add(phy))) {
966
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
967
- ioc->name, __FILE__, __LINE__, __func__);
939
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
940
+ __FILE__, __LINE__, __func__);
968941 sas_phy_free(phy);
969942 return -1;
970943 }
....@@ -1092,54 +1065,33 @@
10921065 struct phy_error_log_reply *phy_error_log_reply;
10931066 int rc;
10941067 u16 smid;
1095
- u32 ioc_state;
10961068 void *psge;
10971069 u8 issue_reset = 0;
10981070 void *data_out = NULL;
10991071 dma_addr_t data_out_dma;
11001072 u32 sz;
1101
- u16 wait_state_count;
11021073
11031074 if (ioc->shost_recovery || ioc->pci_error_recovery) {
1104
- pr_info(MPT3SAS_FMT "%s: host reset in progress!\n",
1105
- __func__, ioc->name);
1075
+ ioc_info(ioc, "%s: host reset in progress!\n", __func__);
11061076 return -EFAULT;
11071077 }
11081078
11091079 mutex_lock(&ioc->transport_cmds.mutex);
11101080
11111081 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) {
1112
- pr_err(MPT3SAS_FMT "%s: transport_cmds in use\n",
1113
- ioc->name, __func__);
1082
+ ioc_err(ioc, "%s: transport_cmds in use\n", __func__);
11141083 rc = -EAGAIN;
11151084 goto out;
11161085 }
11171086 ioc->transport_cmds.status = MPT3_CMD_PENDING;
11181087
1119
- wait_state_count = 0;
1120
- ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
1121
- while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
1122
- if (wait_state_count++ == 10) {
1123
- pr_err(MPT3SAS_FMT
1124
- "%s: failed due to ioc not operational\n",
1125
- ioc->name, __func__);
1126
- rc = -EFAULT;
1127
- goto out;
1128
- }
1129
- ssleep(1);
1130
- ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
1131
- pr_info(MPT3SAS_FMT
1132
- "%s: waiting for operational state(count=%d)\n",
1133
- ioc->name, __func__, wait_state_count);
1134
- }
1135
- if (wait_state_count)
1136
- pr_info(MPT3SAS_FMT "%s: ioc is operational\n",
1137
- ioc->name, __func__);
1088
+ rc = mpt3sas_wait_for_ioc(ioc, IOC_OPERATIONAL_WAIT_COUNT);
1089
+ if (rc)
1090
+ goto out;
11381091
11391092 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx);
11401093 if (!smid) {
1141
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
1142
- ioc->name, __func__);
1094
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
11431095 rc = -EAGAIN;
11441096 goto out;
11451097 }
....@@ -1149,7 +1101,8 @@
11491101
11501102 sz = sizeof(struct phy_error_log_request) +
11511103 sizeof(struct phy_error_log_reply);
1152
- data_out = pci_alloc_consistent(ioc->pdev, sz, &data_out_dma);
1104
+ data_out = dma_alloc_coherent(&ioc->pdev->dev, sz, &data_out_dma,
1105
+ GFP_KERNEL);
11531106 if (!data_out) {
11541107 pr_err("failure at %s:%d/%s()!\n", __FILE__,
11551108 __LINE__, __func__);
....@@ -1182,17 +1135,16 @@
11821135 data_out_dma + sizeof(struct phy_error_log_request),
11831136 sizeof(struct phy_error_log_reply));
11841137
1185
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
1186
- "phy_error_log - send to sas_addr(0x%016llx), phy(%d)\n",
1187
- ioc->name, (unsigned long long)phy->identify.sas_address,
1188
- phy->number));
1138
+ dtransportprintk(ioc,
1139
+ ioc_info(ioc, "phy_error_log - send to sas_addr(0x%016llx), phy(%d)\n",
1140
+ (u64)phy->identify.sas_address,
1141
+ phy->number));
11891142 init_completion(&ioc->transport_cmds.done);
1190
- mpt3sas_base_put_smid_default(ioc, smid);
1143
+ ioc->put_smid_default(ioc, smid);
11911144 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ);
11921145
11931146 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) {
1194
- pr_err(MPT3SAS_FMT "%s: timeout\n",
1195
- ioc->name, __func__);
1147
+ ioc_err(ioc, "%s: timeout\n", __func__);
11961148 _debug_dump_mf(mpi_request,
11971149 sizeof(Mpi2SmpPassthroughRequest_t)/4);
11981150 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET))
....@@ -1200,16 +1152,15 @@
12001152 goto issue_host_reset;
12011153 }
12021154
1203
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
1204
- "phy_error_log - complete\n", ioc->name));
1155
+ dtransportprintk(ioc, ioc_info(ioc, "phy_error_log - complete\n"));
12051156
12061157 if (ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID) {
12071158
12081159 mpi_reply = ioc->transport_cmds.reply;
12091160
1210
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
1211
- "phy_error_log - reply data transfer size(%d)\n",
1212
- ioc->name, le16_to_cpu(mpi_reply->ResponseDataLength)));
1161
+ dtransportprintk(ioc,
1162
+ ioc_info(ioc, "phy_error_log - reply data transfer size(%d)\n",
1163
+ le16_to_cpu(mpi_reply->ResponseDataLength)));
12131164
12141165 if (le16_to_cpu(mpi_reply->ResponseDataLength) !=
12151166 sizeof(struct phy_error_log_reply))
....@@ -1218,9 +1169,9 @@
12181169 phy_error_log_reply = data_out +
12191170 sizeof(struct phy_error_log_request);
12201171
1221
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
1222
- "phy_error_log - function_result(%d)\n",
1223
- ioc->name, phy_error_log_reply->function_result));
1172
+ dtransportprintk(ioc,
1173
+ ioc_info(ioc, "phy_error_log - function_result(%d)\n",
1174
+ phy_error_log_reply->function_result));
12241175
12251176 phy->invalid_dword_count =
12261177 be32_to_cpu(phy_error_log_reply->invalid_dword);
....@@ -1232,8 +1183,8 @@
12321183 be32_to_cpu(phy_error_log_reply->phy_reset_problem);
12331184 rc = 0;
12341185 } else
1235
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
1236
- "phy_error_log - no reply\n", ioc->name));
1186
+ dtransportprintk(ioc,
1187
+ ioc_info(ioc, "phy_error_log - no reply\n"));
12371188
12381189 issue_host_reset:
12391190 if (issue_reset)
....@@ -1241,7 +1192,7 @@
12411192 out:
12421193 ioc->transport_cmds.status = MPT3_CMD_NOT_USED;
12431194 if (data_out)
1244
- pci_free_consistent(ioc->pdev, sz, data_out, data_out_dma);
1195
+ dma_free_coherent(&ioc->pdev->dev, sz, data_out, data_out_dma);
12451196
12461197 mutex_unlock(&ioc->transport_cmds.mutex);
12471198 return rc;
....@@ -1276,17 +1227,16 @@
12761227 /* get hba phy error logs */
12771228 if ((mpt3sas_config_get_phy_pg1(ioc, &mpi_reply, &phy_pg1,
12781229 phy->number))) {
1279
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
1280
- ioc->name, __FILE__, __LINE__, __func__);
1230
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
1231
+ __FILE__, __LINE__, __func__);
12811232 return -ENXIO;
12821233 }
12831234
12841235 if (mpi_reply.IOCStatus || mpi_reply.IOCLogInfo)
1285
- pr_info(MPT3SAS_FMT
1286
- "phy(%d), ioc_status (0x%04x), loginfo(0x%08x)\n",
1287
- ioc->name, phy->number,
1288
- le16_to_cpu(mpi_reply.IOCStatus),
1289
- le32_to_cpu(mpi_reply.IOCLogInfo));
1236
+ ioc_info(ioc, "phy(%d), ioc_status (0x%04x), loginfo(0x%08x)\n",
1237
+ phy->number,
1238
+ le16_to_cpu(mpi_reply.IOCStatus),
1239
+ le32_to_cpu(mpi_reply.IOCLogInfo));
12901240
12911241 phy->invalid_dword_count = le32_to_cpu(phy_pg1.InvalidDwordCount);
12921242 phy->running_disparity_error_count =
....@@ -1405,54 +1355,33 @@
14051355 struct phy_control_reply *phy_control_reply;
14061356 int rc;
14071357 u16 smid;
1408
- u32 ioc_state;
14091358 void *psge;
14101359 u8 issue_reset = 0;
14111360 void *data_out = NULL;
14121361 dma_addr_t data_out_dma;
14131362 u32 sz;
1414
- u16 wait_state_count;
14151363
14161364 if (ioc->shost_recovery || ioc->pci_error_recovery) {
1417
- pr_info(MPT3SAS_FMT "%s: host reset in progress!\n",
1418
- __func__, ioc->name);
1365
+ ioc_info(ioc, "%s: host reset in progress!\n", __func__);
14191366 return -EFAULT;
14201367 }
14211368
14221369 mutex_lock(&ioc->transport_cmds.mutex);
14231370
14241371 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) {
1425
- pr_err(MPT3SAS_FMT "%s: transport_cmds in use\n",
1426
- ioc->name, __func__);
1372
+ ioc_err(ioc, "%s: transport_cmds in use\n", __func__);
14271373 rc = -EAGAIN;
14281374 goto out;
14291375 }
14301376 ioc->transport_cmds.status = MPT3_CMD_PENDING;
14311377
1432
- wait_state_count = 0;
1433
- ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
1434
- while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
1435
- if (wait_state_count++ == 10) {
1436
- pr_err(MPT3SAS_FMT
1437
- "%s: failed due to ioc not operational\n",
1438
- ioc->name, __func__);
1439
- rc = -EFAULT;
1440
- goto out;
1441
- }
1442
- ssleep(1);
1443
- ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
1444
- pr_info(MPT3SAS_FMT
1445
- "%s: waiting for operational state(count=%d)\n",
1446
- ioc->name, __func__, wait_state_count);
1447
- }
1448
- if (wait_state_count)
1449
- pr_info(MPT3SAS_FMT "%s: ioc is operational\n",
1450
- ioc->name, __func__);
1378
+ rc = mpt3sas_wait_for_ioc(ioc, IOC_OPERATIONAL_WAIT_COUNT);
1379
+ if (rc)
1380
+ goto out;
14511381
14521382 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx);
14531383 if (!smid) {
1454
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
1455
- ioc->name, __func__);
1384
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
14561385 rc = -EAGAIN;
14571386 goto out;
14581387 }
....@@ -1462,7 +1391,8 @@
14621391
14631392 sz = sizeof(struct phy_control_request) +
14641393 sizeof(struct phy_control_reply);
1465
- data_out = pci_alloc_consistent(ioc->pdev, sz, &data_out_dma);
1394
+ data_out = dma_alloc_coherent(&ioc->pdev->dev, sz, &data_out_dma,
1395
+ GFP_KERNEL);
14661396 if (!data_out) {
14671397 pr_err("failure at %s:%d/%s()!\n", __FILE__,
14681398 __LINE__, __func__);
....@@ -1500,17 +1430,16 @@
15001430 data_out_dma + sizeof(struct phy_control_request),
15011431 sizeof(struct phy_control_reply));
15021432
1503
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
1504
- "phy_control - send to sas_addr(0x%016llx), phy(%d), opcode(%d)\n",
1505
- ioc->name, (unsigned long long)phy->identify.sas_address,
1506
- phy->number, phy_operation));
1433
+ dtransportprintk(ioc,
1434
+ ioc_info(ioc, "phy_control - send to sas_addr(0x%016llx), phy(%d), opcode(%d)\n",
1435
+ (u64)phy->identify.sas_address,
1436
+ phy->number, phy_operation));
15071437 init_completion(&ioc->transport_cmds.done);
1508
- mpt3sas_base_put_smid_default(ioc, smid);
1438
+ ioc->put_smid_default(ioc, smid);
15091439 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ);
15101440
15111441 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) {
1512
- pr_err(MPT3SAS_FMT "%s: timeout\n",
1513
- ioc->name, __func__);
1442
+ ioc_err(ioc, "%s: timeout\n", __func__);
15141443 _debug_dump_mf(mpi_request,
15151444 sizeof(Mpi2SmpPassthroughRequest_t)/4);
15161445 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET))
....@@ -1518,16 +1447,15 @@
15181447 goto issue_host_reset;
15191448 }
15201449
1521
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
1522
- "phy_control - complete\n", ioc->name));
1450
+ dtransportprintk(ioc, ioc_info(ioc, "phy_control - complete\n"));
15231451
15241452 if (ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID) {
15251453
15261454 mpi_reply = ioc->transport_cmds.reply;
15271455
1528
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
1529
- "phy_control - reply data transfer size(%d)\n",
1530
- ioc->name, le16_to_cpu(mpi_reply->ResponseDataLength)));
1456
+ dtransportprintk(ioc,
1457
+ ioc_info(ioc, "phy_control - reply data transfer size(%d)\n",
1458
+ le16_to_cpu(mpi_reply->ResponseDataLength)));
15311459
15321460 if (le16_to_cpu(mpi_reply->ResponseDataLength) !=
15331461 sizeof(struct phy_control_reply))
....@@ -1536,14 +1464,14 @@
15361464 phy_control_reply = data_out +
15371465 sizeof(struct phy_control_request);
15381466
1539
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
1540
- "phy_control - function_result(%d)\n",
1541
- ioc->name, phy_control_reply->function_result));
1467
+ dtransportprintk(ioc,
1468
+ ioc_info(ioc, "phy_control - function_result(%d)\n",
1469
+ phy_control_reply->function_result));
15421470
15431471 rc = 0;
15441472 } else
1545
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
1546
- "phy_control - no reply\n", ioc->name));
1473
+ dtransportprintk(ioc,
1474
+ ioc_info(ioc, "phy_control - no reply\n"));
15471475
15481476 issue_host_reset:
15491477 if (issue_reset)
....@@ -1551,7 +1479,8 @@
15511479 out:
15521480 ioc->transport_cmds.status = MPT3_CMD_NOT_USED;
15531481 if (data_out)
1554
- pci_free_consistent(ioc->pdev, sz, data_out, data_out_dma);
1482
+ dma_free_coherent(&ioc->pdev->dev, sz, data_out,
1483
+ data_out_dma);
15551484
15561485 mutex_unlock(&ioc->transport_cmds.mutex);
15571486 return rc;
....@@ -1594,16 +1523,15 @@
15941523 mpi_request.PhyNum = phy->number;
15951524
15961525 if ((mpt3sas_base_sas_iounit_control(ioc, &mpi_reply, &mpi_request))) {
1597
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
1598
- ioc->name, __FILE__, __LINE__, __func__);
1526
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
1527
+ __FILE__, __LINE__, __func__);
15991528 return -ENXIO;
16001529 }
16011530
16021531 if (mpi_reply.IOCStatus || mpi_reply.IOCLogInfo)
1603
- pr_info(MPT3SAS_FMT
1604
- "phy(%d), ioc_status(0x%04x), loginfo(0x%08x)\n",
1605
- ioc->name, phy->number, le16_to_cpu(mpi_reply.IOCStatus),
1606
- le32_to_cpu(mpi_reply.IOCLogInfo));
1532
+ ioc_info(ioc, "phy(%d), ioc_status(0x%04x), loginfo(0x%08x)\n",
1533
+ phy->number, le16_to_cpu(mpi_reply.IOCStatus),
1534
+ le32_to_cpu(mpi_reply.IOCLogInfo));
16071535
16081536 return 0;
16091537 }
....@@ -1650,23 +1578,23 @@
16501578 sizeof(Mpi2SasIOUnit0PhyData_t));
16511579 sas_iounit_pg0 = kzalloc(sz, GFP_KERNEL);
16521580 if (!sas_iounit_pg0) {
1653
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
1654
- ioc->name, __FILE__, __LINE__, __func__);
1581
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
1582
+ __FILE__, __LINE__, __func__);
16551583 rc = -ENOMEM;
16561584 goto out;
16571585 }
16581586 if ((mpt3sas_config_get_sas_iounit_pg0(ioc, &mpi_reply,
16591587 sas_iounit_pg0, sz))) {
1660
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
1661
- ioc->name, __FILE__, __LINE__, __func__);
1588
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
1589
+ __FILE__, __LINE__, __func__);
16621590 rc = -ENXIO;
16631591 goto out;
16641592 }
16651593 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
16661594 MPI2_IOCSTATUS_MASK;
16671595 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
1668
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
1669
- ioc->name, __FILE__, __LINE__, __func__);
1596
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
1597
+ __FILE__, __LINE__, __func__);
16701598 rc = -EIO;
16711599 goto out;
16721600 }
....@@ -1675,10 +1603,8 @@
16751603 for (i = 0, discovery_active = 0; i < ioc->sas_hba.num_phys ; i++) {
16761604 if (sas_iounit_pg0->PhyData[i].PortFlags &
16771605 MPI2_SASIOUNIT0_PORTFLAGS_DISCOVERY_IN_PROGRESS) {
1678
- pr_err(MPT3SAS_FMT "discovery is active on " \
1679
- "port = %d, phy = %d: unable to enable/disable "
1680
- "phys, try again later!\n", ioc->name,
1681
- sas_iounit_pg0->PhyData[i].Port, i);
1606
+ ioc_err(ioc, "discovery is active on port = %d, phy = %d: unable to enable/disable phys, try again later!\n",
1607
+ sas_iounit_pg0->PhyData[i].Port, i);
16821608 discovery_active = 1;
16831609 }
16841610 }
....@@ -1693,23 +1619,23 @@
16931619 sizeof(Mpi2SasIOUnit1PhyData_t));
16941620 sas_iounit_pg1 = kzalloc(sz, GFP_KERNEL);
16951621 if (!sas_iounit_pg1) {
1696
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
1697
- ioc->name, __FILE__, __LINE__, __func__);
1622
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
1623
+ __FILE__, __LINE__, __func__);
16981624 rc = -ENOMEM;
16991625 goto out;
17001626 }
17011627 if ((mpt3sas_config_get_sas_iounit_pg1(ioc, &mpi_reply,
17021628 sas_iounit_pg1, sz))) {
1703
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
1704
- ioc->name, __FILE__, __LINE__, __func__);
1629
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
1630
+ __FILE__, __LINE__, __func__);
17051631 rc = -ENXIO;
17061632 goto out;
17071633 }
17081634 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
17091635 MPI2_IOCSTATUS_MASK;
17101636 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
1711
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
1712
- ioc->name, __FILE__, __LINE__, __func__);
1637
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
1638
+ __FILE__, __LINE__, __func__);
17131639 rc = -EIO;
17141640 goto out;
17151641 }
....@@ -1801,23 +1727,23 @@
18011727 sizeof(Mpi2SasIOUnit1PhyData_t));
18021728 sas_iounit_pg1 = kzalloc(sz, GFP_KERNEL);
18031729 if (!sas_iounit_pg1) {
1804
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
1805
- ioc->name, __FILE__, __LINE__, __func__);
1730
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
1731
+ __FILE__, __LINE__, __func__);
18061732 rc = -ENOMEM;
18071733 goto out;
18081734 }
18091735 if ((mpt3sas_config_get_sas_iounit_pg1(ioc, &mpi_reply,
18101736 sas_iounit_pg1, sz))) {
1811
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
1812
- ioc->name, __FILE__, __LINE__, __func__);
1737
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
1738
+ __FILE__, __LINE__, __func__);
18131739 rc = -ENXIO;
18141740 goto out;
18151741 }
18161742 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
18171743 MPI2_IOCSTATUS_MASK;
18181744 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
1819
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
1820
- ioc->name, __FILE__, __LINE__, __func__);
1745
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
1746
+ __FILE__, __LINE__, __func__);
18211747 rc = -EIO;
18221748 goto out;
18231749 }
....@@ -1836,8 +1762,8 @@
18361762
18371763 if (mpt3sas_config_set_sas_iounit_pg1(ioc, &mpi_reply, sas_iounit_pg1,
18381764 sz)) {
1839
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
1840
- ioc->name, __FILE__, __LINE__, __func__);
1765
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
1766
+ __FILE__, __LINE__, __func__);
18411767 rc = -ENXIO;
18421768 goto out;
18431769 }
....@@ -1913,7 +1839,6 @@
19131839 Mpi2SmpPassthroughReply_t *mpi_reply;
19141840 int rc;
19151841 u16 smid;
1916
- u32 ioc_state;
19171842 void *psge;
19181843 dma_addr_t dma_addr_in;
19191844 dma_addr_t dma_addr_out;
....@@ -1921,12 +1846,10 @@
19211846 void *addr_out = NULL;
19221847 size_t dma_len_in;
19231848 size_t dma_len_out;
1924
- u16 wait_state_count;
19251849 unsigned int reslen = 0;
19261850
19271851 if (ioc->shost_recovery || ioc->pci_error_recovery) {
1928
- pr_info(MPT3SAS_FMT "%s: host reset in progress!\n",
1929
- __func__, ioc->name);
1852
+ ioc_info(ioc, "%s: host reset in progress!\n", __func__);
19301853 rc = -EFAULT;
19311854 goto job_done;
19321855 }
....@@ -1936,8 +1859,8 @@
19361859 goto job_done;
19371860
19381861 if (ioc->transport_cmds.status != MPT3_CMD_NOT_USED) {
1939
- pr_err(MPT3SAS_FMT "%s: transport_cmds in use\n", ioc->name,
1940
- __func__);
1862
+ ioc_err(ioc, "%s: transport_cmds in use\n",
1863
+ __func__);
19411864 rc = -EAGAIN;
19421865 goto out;
19431866 }
....@@ -1958,30 +1881,13 @@
19581881 if (rc)
19591882 goto unmap_out;
19601883
1961
- wait_state_count = 0;
1962
- ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
1963
- while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
1964
- if (wait_state_count++ == 10) {
1965
- pr_err(MPT3SAS_FMT
1966
- "%s: failed due to ioc not operational\n",
1967
- ioc->name, __func__);
1968
- rc = -EFAULT;
1969
- goto unmap_in;
1970
- }
1971
- ssleep(1);
1972
- ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
1973
- pr_info(MPT3SAS_FMT
1974
- "%s: waiting for operational state(count=%d)\n",
1975
- ioc->name, __func__, wait_state_count);
1976
- }
1977
- if (wait_state_count)
1978
- pr_info(MPT3SAS_FMT "%s: ioc is operational\n",
1979
- ioc->name, __func__);
1884
+ rc = mpt3sas_wait_for_ioc(ioc, IOC_OPERATIONAL_WAIT_COUNT);
1885
+ if (rc)
1886
+ goto unmap_in;
19801887
19811888 smid = mpt3sas_base_get_smid(ioc, ioc->transport_cb_idx);
19821889 if (!smid) {
1983
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
1984
- ioc->name, __func__);
1890
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
19851891 rc = -EAGAIN;
19861892 goto unmap_in;
19871893 }
....@@ -2002,16 +1908,15 @@
20021908 ioc->build_sg(ioc, psge, dma_addr_out, dma_len_out - 4, dma_addr_in,
20031909 dma_len_in - 4);
20041910
2005
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
2006
- "%s - sending smp request\n", ioc->name, __func__));
1911
+ dtransportprintk(ioc,
1912
+ ioc_info(ioc, "%s: sending smp request\n", __func__));
20071913
20081914 init_completion(&ioc->transport_cmds.done);
2009
- mpt3sas_base_put_smid_default(ioc, smid);
1915
+ ioc->put_smid_default(ioc, smid);
20101916 wait_for_completion_timeout(&ioc->transport_cmds.done, 10*HZ);
20111917
20121918 if (!(ioc->transport_cmds.status & MPT3_CMD_COMPLETE)) {
2013
- pr_err(MPT3SAS_FMT "%s : timeout\n",
2014
- __func__, ioc->name);
1919
+ ioc_err(ioc, "%s: timeout\n", __func__);
20151920 _debug_dump_mf(mpi_request,
20161921 sizeof(Mpi2SmpPassthroughRequest_t)/4);
20171922 if (!(ioc->transport_cmds.status & MPT3_CMD_RESET)) {
....@@ -2021,12 +1926,11 @@
20211926 }
20221927 }
20231928
2024
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
2025
- "%s - complete\n", ioc->name, __func__));
1929
+ dtransportprintk(ioc, ioc_info(ioc, "%s - complete\n", __func__));
20261930
20271931 if (!(ioc->transport_cmds.status & MPT3_CMD_REPLY_VALID)) {
2028
- dtransportprintk(ioc, pr_info(MPT3SAS_FMT
2029
- "%s - no reply\n", ioc->name, __func__));
1932
+ dtransportprintk(ioc,
1933
+ ioc_info(ioc, "%s: no reply\n", __func__));
20301934 rc = -ENXIO;
20311935 goto unmap_in;
20321936 }
....@@ -2034,9 +1938,9 @@
20341938 mpi_reply = ioc->transport_cmds.reply;
20351939
20361940 dtransportprintk(ioc,
2037
- pr_info(MPT3SAS_FMT "%s - reply data transfer size(%d)\n",
2038
- ioc->name, __func__,
2039
- le16_to_cpu(mpi_reply->ResponseDataLength)));
1941
+ ioc_info(ioc, "%s: reply data transfer size(%d)\n",
1942
+ __func__,
1943
+ le16_to_cpu(mpi_reply->ResponseDataLength)));
20401944
20411945 memcpy(job->reply, mpi_reply, sizeof(*mpi_reply));
20421946 job->reply_len = sizeof(*mpi_reply);