forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/scsi/mpt3sas/mpt3sas_base.c
....@@ -74,32 +74,62 @@
7474 #define MAX_HBA_QUEUE_DEPTH 30000
7575 #define MAX_CHAIN_DEPTH 100000
7676 static int max_queue_depth = -1;
77
-module_param(max_queue_depth, int, 0);
77
+module_param(max_queue_depth, int, 0444);
7878 MODULE_PARM_DESC(max_queue_depth, " max controller queue depth ");
7979
8080 static int max_sgl_entries = -1;
81
-module_param(max_sgl_entries, int, 0);
81
+module_param(max_sgl_entries, int, 0444);
8282 MODULE_PARM_DESC(max_sgl_entries, " max sg entries ");
8383
8484 static int msix_disable = -1;
85
-module_param(msix_disable, int, 0);
85
+module_param(msix_disable, int, 0444);
8686 MODULE_PARM_DESC(msix_disable, " disable msix routed interrupts (default=0)");
8787
8888 static int smp_affinity_enable = 1;
89
-module_param(smp_affinity_enable, int, S_IRUGO);
89
+module_param(smp_affinity_enable, int, 0444);
9090 MODULE_PARM_DESC(smp_affinity_enable, "SMP affinity feature enable/disable Default: enable(1)");
9191
9292 static int max_msix_vectors = -1;
93
-module_param(max_msix_vectors, int, 0);
93
+module_param(max_msix_vectors, int, 0444);
9494 MODULE_PARM_DESC(max_msix_vectors,
9595 " max msix vectors");
96
+
97
+static int irqpoll_weight = -1;
98
+module_param(irqpoll_weight, int, 0444);
99
+MODULE_PARM_DESC(irqpoll_weight,
100
+ "irq poll weight (default= one fourth of HBA queue depth)");
96101
97102 static int mpt3sas_fwfault_debug;
98103 MODULE_PARM_DESC(mpt3sas_fwfault_debug,
99104 " enable detection of firmware fault and halt firmware - (default=0)");
100105
106
+static int perf_mode = -1;
107
+module_param(perf_mode, int, 0444);
108
+MODULE_PARM_DESC(perf_mode,
109
+ "Performance mode (only for Aero/Sea Generation), options:\n\t\t"
110
+ "0 - balanced: high iops mode is enabled &\n\t\t"
111
+ "interrupt coalescing is enabled only on high iops queues,\n\t\t"
112
+ "1 - iops: high iops mode is disabled &\n\t\t"
113
+ "interrupt coalescing is enabled on all queues,\n\t\t"
114
+ "2 - latency: high iops mode is disabled &\n\t\t"
115
+ "interrupt coalescing is enabled on all queues with timeout value 0xA,\n"
116
+ "\t\tdefault - default perf_mode is 'balanced'"
117
+ );
118
+
119
+enum mpt3sas_perf_mode {
120
+ MPT_PERF_MODE_DEFAULT = -1,
121
+ MPT_PERF_MODE_BALANCED = 0,
122
+ MPT_PERF_MODE_IOPS = 1,
123
+ MPT_PERF_MODE_LATENCY = 2,
124
+};
125
+
126
+static int
127
+_base_wait_on_iocstate(struct MPT3SAS_ADAPTER *ioc,
128
+ u32 ioc_state, int timeout);
101129 static int
102130 _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc);
131
+static void
132
+_base_clear_outstanding_commands(struct MPT3SAS_ADAPTER *ioc);
103133
104134 /**
105135 * mpt3sas_base_check_cmd_timeout - Function
....@@ -122,8 +152,8 @@
122152 if (!(status & MPT3_CMD_RESET))
123153 issue_reset = 1;
124154
125
- pr_err(MPT3SAS_FMT "Command %s\n", ioc->name,
126
- ((issue_reset == 0) ? "terminated due to Host Reset" : "Timeout"));
155
+ ioc_err(ioc, "Command %s\n",
156
+ issue_reset == 0 ? "terminated due to Host Reset" : "Timeout");
127157 _debug_dump_mf(mpi_request, sz);
128158
129159 return issue_reset;
....@@ -155,6 +185,32 @@
155185 }
156186 module_param_call(mpt3sas_fwfault_debug, _scsih_set_fwfault_debug,
157187 param_get_int, &mpt3sas_fwfault_debug, 0644);
188
+
189
+/**
190
+ * _base_readl_aero - retry readl for max three times.
191
+ * @addr: MPT Fusion system interface register address
192
+ *
193
+ * Retry the readl() for max three times if it gets zero value
194
+ * while reading the system interface register.
195
+ */
196
+static inline u32
197
+_base_readl_aero(const volatile void __iomem *addr)
198
+{
199
+ u32 i = 0, ret_val;
200
+
201
+ do {
202
+ ret_val = readl(addr);
203
+ i++;
204
+ } while (ret_val == 0 && i < 3);
205
+
206
+ return ret_val;
207
+}
208
+
209
+static inline u32
210
+_base_readl(const volatile void __iomem *addr)
211
+{
212
+ return readl(addr);
213
+}
158214
159215 /**
160216 * _base_clone_reply_to_sys_mem - copies reply to reply free iomem
....@@ -336,9 +392,7 @@
336392 return ct->chain_buffer;
337393 }
338394 }
339
- pr_info(MPT3SAS_FMT
340
- "Provided chain_buffer_dma address is not in the lookup list\n",
341
- ioc->name);
395
+ ioc_info(ioc, "Provided chain_buffer_dma address is not in the lookup list\n");
342396 return NULL;
343397 }
344398
....@@ -357,7 +411,7 @@
357411 {
358412 Mpi2SGESimple32_t *sgel, *sgel_next;
359413 u32 sgl_flags, sge_chain_count = 0;
360
- bool is_write = 0;
414
+ bool is_write = false;
361415 u16 i = 0;
362416 void __iomem *buffer_iomem;
363417 phys_addr_t buffer_iomem_phys;
....@@ -394,7 +448,7 @@
394448 /* Get scsi_cmd using smid */
395449 scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid);
396450 if (scmd == NULL) {
397
- pr_err(MPT3SAS_FMT "scmd is NULL\n", ioc->name);
451
+ ioc_err(ioc, "scmd is NULL\n");
398452 return;
399453 }
400454
....@@ -426,7 +480,7 @@
426480
427481 if (le32_to_cpu(sgel->FlagsLength) &
428482 (MPI2_SGE_FLAGS_HOST_TO_IOC << MPI2_SGE_FLAGS_SHIFT))
429
- is_write = 1;
483
+ is_write = true;
430484
431485 for (i = 0; i < MPT_MIN_PHYS_SEGMENTS + ioc->facts.MaxChainDepth; i++) {
432486
....@@ -532,11 +586,11 @@
532586 struct MPT3SAS_ADAPTER *ioc = (struct MPT3SAS_ADAPTER *)arg;
533587 struct pci_dev *pdev;
534588
535
- if ((ioc == NULL))
589
+ if (!ioc)
536590 return -1;
537591
538592 pdev = ioc->pdev;
539
- if ((pdev == NULL))
593
+ if (!pdev)
540594 return -1;
541595 pci_stop_and_remove_bus_device_locked(pdev);
542596 return 0;
....@@ -560,14 +614,14 @@
560614
561615
562616 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
563
- if (ioc->shost_recovery || ioc->pci_error_recovery)
617
+ if ((ioc->shost_recovery && (ioc->ioc_coredump_loop == 0)) ||
618
+ ioc->pci_error_recovery)
564619 goto rearm_timer;
565620 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
566621
567622 doorbell = mpt3sas_base_get_iocstate(ioc, 0);
568623 if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_MASK) {
569
- pr_err(MPT3SAS_FMT "SAS host is non-operational !!!!\n",
570
- ioc->name);
624
+ ioc_err(ioc, "SAS host is non-operational !!!!\n");
571625
572626 /* It may be possible that EEH recovery can resolve some of
573627 * pci bus failure issues rather removing the dead ioc function
....@@ -600,30 +654,72 @@
600654 p = kthread_run(mpt3sas_remove_dead_ioc_func, ioc,
601655 "%s_dead_ioc_%d", ioc->driver_name, ioc->id);
602656 if (IS_ERR(p))
603
- pr_err(MPT3SAS_FMT
604
- "%s: Running mpt3sas_dead_ioc thread failed !!!!\n",
605
- ioc->name, __func__);
657
+ ioc_err(ioc, "%s: Running mpt3sas_dead_ioc thread failed !!!!\n",
658
+ __func__);
606659 else
607
- pr_err(MPT3SAS_FMT
608
- "%s: Running mpt3sas_dead_ioc thread success !!!!\n",
609
- ioc->name, __func__);
660
+ ioc_err(ioc, "%s: Running mpt3sas_dead_ioc thread success !!!!\n",
661
+ __func__);
610662 return; /* don't rearm timer */
611663 }
612664
613
- ioc->non_operational_loop = 0;
665
+ if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_COREDUMP) {
666
+ u8 timeout = (ioc->manu_pg11.CoreDumpTOSec) ?
667
+ ioc->manu_pg11.CoreDumpTOSec :
668
+ MPT3SAS_DEFAULT_COREDUMP_TIMEOUT_SECONDS;
614669
670
+ timeout /= (FAULT_POLLING_INTERVAL/1000);
671
+
672
+ if (ioc->ioc_coredump_loop == 0) {
673
+ mpt3sas_print_coredump_info(ioc,
674
+ doorbell & MPI2_DOORBELL_DATA_MASK);
675
+ /* do not accept any IOs and disable the interrupts */
676
+ spin_lock_irqsave(
677
+ &ioc->ioc_reset_in_progress_lock, flags);
678
+ ioc->shost_recovery = 1;
679
+ spin_unlock_irqrestore(
680
+ &ioc->ioc_reset_in_progress_lock, flags);
681
+ mpt3sas_base_mask_interrupts(ioc);
682
+ _base_clear_outstanding_commands(ioc);
683
+ }
684
+
685
+ ioc_info(ioc, "%s: CoreDump loop %d.",
686
+ __func__, ioc->ioc_coredump_loop);
687
+
688
+ /* Wait until CoreDump completes or times out */
689
+ if (ioc->ioc_coredump_loop++ < timeout) {
690
+ spin_lock_irqsave(
691
+ &ioc->ioc_reset_in_progress_lock, flags);
692
+ goto rearm_timer;
693
+ }
694
+ }
695
+
696
+ if (ioc->ioc_coredump_loop) {
697
+ if ((doorbell & MPI2_IOC_STATE_MASK) != MPI2_IOC_STATE_COREDUMP)
698
+ ioc_err(ioc, "%s: CoreDump completed. LoopCount: %d",
699
+ __func__, ioc->ioc_coredump_loop);
700
+ else
701
+ ioc_err(ioc, "%s: CoreDump Timed out. LoopCount: %d",
702
+ __func__, ioc->ioc_coredump_loop);
703
+ ioc->ioc_coredump_loop = MPT3SAS_COREDUMP_LOOP_DONE;
704
+ }
705
+ ioc->non_operational_loop = 0;
615706 if ((doorbell & MPI2_IOC_STATE_MASK) != MPI2_IOC_STATE_OPERATIONAL) {
616707 rc = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
617
- pr_warn(MPT3SAS_FMT "%s: hard reset: %s\n", ioc->name,
618
- __func__, (rc == 0) ? "success" : "failed");
708
+ ioc_warn(ioc, "%s: hard reset: %s\n",
709
+ __func__, rc == 0 ? "success" : "failed");
619710 doorbell = mpt3sas_base_get_iocstate(ioc, 0);
620
- if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT)
621
- mpt3sas_base_fault_info(ioc, doorbell &
711
+ if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
712
+ mpt3sas_print_fault_code(ioc, doorbell &
713
+ MPI2_DOORBELL_DATA_MASK);
714
+ } else if ((doorbell & MPI2_IOC_STATE_MASK) ==
715
+ MPI2_IOC_STATE_COREDUMP)
716
+ mpt3sas_print_coredump_info(ioc, doorbell &
622717 MPI2_DOORBELL_DATA_MASK);
623718 if (rc && (doorbell & MPI2_IOC_STATE_MASK) !=
624719 MPI2_IOC_STATE_OPERATIONAL)
625720 return; /* don't rearm timer */
626721 }
722
+ ioc->ioc_coredump_loop = 0;
627723
628724 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
629725 rearm_timer:
....@@ -657,8 +753,7 @@
657753 ioc->fault_reset_work_q =
658754 create_singlethread_workqueue(ioc->fault_reset_work_q_name);
659755 if (!ioc->fault_reset_work_q) {
660
- pr_err(MPT3SAS_FMT "%s: failed (line=%d)\n",
661
- ioc->name, __func__, __LINE__);
756
+ ioc_err(ioc, "%s: failed (line=%d)\n", __func__, __LINE__);
662757 return;
663758 }
664759 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
....@@ -700,8 +795,51 @@
700795 void
701796 mpt3sas_base_fault_info(struct MPT3SAS_ADAPTER *ioc , u16 fault_code)
702797 {
703
- pr_err(MPT3SAS_FMT "fault_state(0x%04x)!\n",
704
- ioc->name, fault_code);
798
+ ioc_err(ioc, "fault_state(0x%04x)!\n", fault_code);
799
+}
800
+
801
+/**
802
+ * mpt3sas_base_coredump_info - verbose translation of firmware CoreDump state
803
+ * @ioc: per adapter object
804
+ * @fault_code: fault code
805
+ *
806
+ * Return nothing.
807
+ */
808
+void
809
+mpt3sas_base_coredump_info(struct MPT3SAS_ADAPTER *ioc, u16 fault_code)
810
+{
811
+ ioc_err(ioc, "coredump_state(0x%04x)!\n", fault_code);
812
+}
813
+
814
+/**
815
+ * mpt3sas_base_wait_for_coredump_completion - Wait until coredump
816
+ * completes or times out
817
+ * @ioc: per adapter object
818
+ * @caller: caller function name
819
+ *
820
+ * Returns 0 for success, non-zero for failure.
821
+ */
822
+int
823
+mpt3sas_base_wait_for_coredump_completion(struct MPT3SAS_ADAPTER *ioc,
824
+ const char *caller)
825
+{
826
+ u8 timeout = (ioc->manu_pg11.CoreDumpTOSec) ?
827
+ ioc->manu_pg11.CoreDumpTOSec :
828
+ MPT3SAS_DEFAULT_COREDUMP_TIMEOUT_SECONDS;
829
+
830
+ int ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_FAULT,
831
+ timeout);
832
+
833
+ if (ioc_state)
834
+ ioc_err(ioc,
835
+ "%s: CoreDump timed out. (ioc_state=0x%x)\n",
836
+ caller, ioc_state);
837
+ else
838
+ ioc_info(ioc,
839
+ "%s: CoreDump completed. (ioc_state=0x%x)\n",
840
+ caller, ioc_state);
841
+
842
+ return ioc_state;
705843 }
706844
707845 /**
....@@ -723,13 +861,17 @@
723861
724862 dump_stack();
725863
726
- doorbell = readl(&ioc->chip->Doorbell);
727
- if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT)
728
- mpt3sas_base_fault_info(ioc , doorbell);
729
- else {
864
+ doorbell = ioc->base_readl(&ioc->chip->Doorbell);
865
+ if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
866
+ mpt3sas_print_fault_code(ioc, doorbell &
867
+ MPI2_DOORBELL_DATA_MASK);
868
+ } else if ((doorbell & MPI2_IOC_STATE_MASK) ==
869
+ MPI2_IOC_STATE_COREDUMP) {
870
+ mpt3sas_print_coredump_info(ioc, doorbell &
871
+ MPI2_DOORBELL_DATA_MASK);
872
+ } else {
730873 writel(0xC0FFEE00, &ioc->chip->Doorbell);
731
- pr_err(MPT3SAS_FMT "Firmware is halted due to command timeout\n",
732
- ioc->name);
874
+ ioc_err(ioc, "Firmware is halted due to command timeout\n");
733875 }
734876
735877 if (ioc->fwfault_debug == 2)
....@@ -956,8 +1098,8 @@
9561098 break;
9571099 }
9581100
959
- pr_warn(MPT3SAS_FMT "ioc_status: %s(0x%04x), request(0x%p),(%s)\n",
960
- ioc->name, desc, ioc_status, request_hdr, func_str);
1101
+ ioc_warn(ioc, "ioc_status: %s(0x%04x), request(0x%p),(%s)\n",
1102
+ desc, ioc_status, request_hdr, func_str);
9611103
9621104 _debug_dump_mf(request_hdr, frame_sz/4);
9631105 }
....@@ -1003,9 +1145,9 @@
10031145 {
10041146 Mpi2EventDataSasDiscovery_t *event_data =
10051147 (Mpi2EventDataSasDiscovery_t *)mpi_reply->EventData;
1006
- pr_info(MPT3SAS_FMT "Discovery: (%s)", ioc->name,
1007
- (event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED) ?
1008
- "start" : "stop");
1148
+ ioc_info(ioc, "Discovery: (%s)",
1149
+ event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED ?
1150
+ "start" : "stop");
10091151 if (event_data->DiscoveryStatus)
10101152 pr_cont(" discovery_status(0x%08x)",
10111153 le32_to_cpu(event_data->DiscoveryStatus));
....@@ -1059,14 +1201,13 @@
10591201 {
10601202 Mpi26EventDataPCIeEnumeration_t *event_data =
10611203 (Mpi26EventDataPCIeEnumeration_t *)mpi_reply->EventData;
1062
- pr_info(MPT3SAS_FMT "PCIE Enumeration: (%s)", ioc->name,
1063
- (event_data->ReasonCode ==
1064
- MPI26_EVENT_PCIE_ENUM_RC_STARTED) ?
1065
- "start" : "stop");
1204
+ ioc_info(ioc, "PCIE Enumeration: (%s)",
1205
+ event_data->ReasonCode == MPI26_EVENT_PCIE_ENUM_RC_STARTED ?
1206
+ "start" : "stop");
10661207 if (event_data->EnumerationStatus)
1067
- pr_info("enumeration_status(0x%08x)",
1068
- le32_to_cpu(event_data->EnumerationStatus));
1069
- pr_info("\n");
1208
+ pr_cont("enumeration_status(0x%08x)",
1209
+ le32_to_cpu(event_data->EnumerationStatus));
1210
+ pr_cont("\n");
10701211 return;
10711212 }
10721213 case MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST:
....@@ -1077,7 +1218,7 @@
10771218 if (!desc)
10781219 return;
10791220
1080
- pr_info(MPT3SAS_FMT "%s\n", ioc->name, desc);
1221
+ ioc_info(ioc, "%s\n", desc);
10811222 }
10821223
10831224 /**
....@@ -1128,11 +1269,9 @@
11281269 break;
11291270 }
11301271
1131
- pr_warn(MPT3SAS_FMT
1132
- "log_info(0x%08x): originator(%s), code(0x%02x), sub_code(0x%04x)\n",
1133
- ioc->name, log_info,
1134
- originator_str, sas_loginfo.dw.code,
1135
- sas_loginfo.dw.subcode);
1272
+ ioc_warn(ioc, "log_info(0x%08x): originator(%s), code(0x%02x), sub_code(0x%04x)\n",
1273
+ log_info,
1274
+ originator_str, sas_loginfo.dw.code, sas_loginfo.dw.subcode);
11361275 }
11371276
11381277 /**
....@@ -1152,8 +1291,8 @@
11521291
11531292 mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
11541293 if (unlikely(!mpi_reply)) {
1155
- pr_err(MPT3SAS_FMT "mpi_reply not valid at %s:%d/%s()!\n",
1156
- ioc->name, __FILE__, __LINE__, __func__);
1294
+ ioc_err(ioc, "mpi_reply not valid at %s:%d/%s()!\n",
1295
+ __FILE__, __LINE__, __func__);
11571296 return;
11581297 }
11591298 ioc_status = le16_to_cpu(mpi_reply->IOCStatus);
....@@ -1249,9 +1388,9 @@
12491388 delayed_event_ack->EventContext = mpi_reply->EventContext;
12501389 list_add_tail(&delayed_event_ack->list,
12511390 &ioc->delayed_event_ack_list);
1252
- dewtprintk(ioc, pr_info(MPT3SAS_FMT
1253
- "DELAYED: EVENT ACK: event (0x%04x)\n",
1254
- ioc->name, le16_to_cpu(mpi_reply->Event)));
1391
+ dewtprintk(ioc,
1392
+ ioc_info(ioc, "DELAYED: EVENT ACK: event (0x%04x)\n",
1393
+ le16_to_cpu(mpi_reply->Event)));
12551394 goto out;
12561395 }
12571396
....@@ -1262,7 +1401,7 @@
12621401 ack_request->EventContext = mpi_reply->EventContext;
12631402 ack_request->VF_ID = 0; /* TODO */
12641403 ack_request->VP_ID = 0;
1265
- mpt3sas_base_put_smid_default(ioc, smid);
1404
+ ioc->put_smid_default(ioc, smid);
12661405
12671406 out:
12681407
....@@ -1325,35 +1464,35 @@
13251464 }
13261465
13271466 /**
1328
- * _base_mask_interrupts - disable interrupts
1467
+ * mpt3sas_base_mask_interrupts - disable interrupts
13291468 * @ioc: per adapter object
13301469 *
13311470 * Disabling ResetIRQ, Reply and Doorbell Interrupts
13321471 */
1333
-static void
1334
-_base_mask_interrupts(struct MPT3SAS_ADAPTER *ioc)
1472
+void
1473
+mpt3sas_base_mask_interrupts(struct MPT3SAS_ADAPTER *ioc)
13351474 {
13361475 u32 him_register;
13371476
13381477 ioc->mask_interrupts = 1;
1339
- him_register = readl(&ioc->chip->HostInterruptMask);
1478
+ him_register = ioc->base_readl(&ioc->chip->HostInterruptMask);
13401479 him_register |= MPI2_HIM_DIM + MPI2_HIM_RIM + MPI2_HIM_RESET_IRQ_MASK;
13411480 writel(him_register, &ioc->chip->HostInterruptMask);
1342
- readl(&ioc->chip->HostInterruptMask);
1481
+ ioc->base_readl(&ioc->chip->HostInterruptMask);
13431482 }
13441483
13451484 /**
1346
- * _base_unmask_interrupts - enable interrupts
1485
+ * mpt3sas_base_unmask_interrupts - enable interrupts
13471486 * @ioc: per adapter object
13481487 *
13491488 * Enabling only Reply Interrupts
13501489 */
1351
-static void
1352
-_base_unmask_interrupts(struct MPT3SAS_ADAPTER *ioc)
1490
+void
1491
+mpt3sas_base_unmask_interrupts(struct MPT3SAS_ADAPTER *ioc)
13531492 {
13541493 u32 him_register;
13551494
1356
- him_register = readl(&ioc->chip->HostInterruptMask);
1495
+ him_register = ioc->base_readl(&ioc->chip->HostInterruptMask);
13571496 him_register &= ~MPI2_HIM_RIM;
13581497 writel(him_register, &ioc->chip->HostInterruptMask);
13591498 ioc->mask_interrupts = 0;
....@@ -1367,20 +1506,30 @@
13671506 } u;
13681507 };
13691508
1370
-/**
1371
- * _base_interrupt - MPT adapter (IOC) specific interrupt handler.
1372
- * @irq: irq number (not used)
1373
- * @bus_id: bus identifier cookie == pointer to MPT_ADAPTER structure
1374
- *
1375
- * Return: IRQ_HANDLED if processed, else IRQ_NONE.
1376
- */
1377
-static irqreturn_t
1378
-_base_interrupt(int irq, void *bus_id)
1509
+static u32 base_mod64(u64 dividend, u32 divisor)
13791510 {
1380
- struct adapter_reply_queue *reply_q = bus_id;
1511
+ u32 remainder;
1512
+
1513
+ if (!divisor)
1514
+ pr_err("mpt3sas: DIVISOR is zero, in div fn\n");
1515
+ remainder = do_div(dividend, divisor);
1516
+ return remainder;
1517
+}
1518
+
1519
+/**
1520
+ * _base_process_reply_queue - Process reply descriptors from reply
1521
+ * descriptor post queue.
1522
+ * @reply_q: per IRQ's reply queue object.
1523
+ *
1524
+ * Return: number of reply descriptors processed from reply
1525
+ * descriptor queue.
1526
+ */
1527
+static int
1528
+_base_process_reply_queue(struct adapter_reply_queue *reply_q)
1529
+{
13811530 union reply_descriptor rd;
1382
- u32 completed_cmds;
1383
- u8 request_desript_type;
1531
+ u64 completed_cmds;
1532
+ u8 request_descript_type;
13841533 u16 smid;
13851534 u8 cb_idx;
13861535 u32 reply;
....@@ -1389,21 +1538,18 @@
13891538 Mpi2ReplyDescriptorsUnion_t *rpf;
13901539 u8 rc;
13911540
1392
- if (ioc->mask_interrupts)
1393
- return IRQ_NONE;
1394
-
1541
+ completed_cmds = 0;
13951542 if (!atomic_add_unless(&reply_q->busy, 1, 1))
1396
- return IRQ_NONE;
1543
+ return completed_cmds;
13971544
13981545 rpf = &reply_q->reply_post_free[reply_q->reply_post_host_index];
1399
- request_desript_type = rpf->Default.ReplyFlags
1546
+ request_descript_type = rpf->Default.ReplyFlags
14001547 & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK;
1401
- if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) {
1548
+ if (request_descript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) {
14021549 atomic_dec(&reply_q->busy);
1403
- return IRQ_NONE;
1550
+ return completed_cmds;
14041551 }
14051552
1406
- completed_cmds = 0;
14071553 cb_idx = 0xFF;
14081554 do {
14091555 rd.word = le64_to_cpu(rpf->Words);
....@@ -1411,11 +1557,11 @@
14111557 goto out;
14121558 reply = 0;
14131559 smid = le16_to_cpu(rpf->Default.DescriptorTypeDependent1);
1414
- if (request_desript_type ==
1560
+ if (request_descript_type ==
14151561 MPI25_RPY_DESCRIPT_FLAGS_FAST_PATH_SCSI_IO_SUCCESS ||
1416
- request_desript_type ==
1562
+ request_descript_type ==
14171563 MPI2_RPY_DESCRIPT_FLAGS_SCSI_IO_SUCCESS ||
1418
- request_desript_type ==
1564
+ request_descript_type ==
14191565 MPI26_RPY_DESCRIPT_FLAGS_PCIE_ENCAPSULATED_SUCCESS) {
14201566 cb_idx = _base_get_cb_idx(ioc, smid);
14211567 if ((likely(cb_idx < MPT_MAX_CALLBACKS)) &&
....@@ -1425,7 +1571,7 @@
14251571 if (rc)
14261572 mpt3sas_base_free_smid(ioc, smid);
14271573 }
1428
- } else if (request_desript_type ==
1574
+ } else if (request_descript_type ==
14291575 MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) {
14301576 reply = le32_to_cpu(
14311577 rpf->AddressReply.ReplyFrameAddress);
....@@ -1471,7 +1617,7 @@
14711617 (reply_q->reply_post_host_index ==
14721618 (ioc->reply_post_queue_depth - 1)) ? 0 :
14731619 reply_q->reply_post_host_index + 1;
1474
- request_desript_type =
1620
+ request_descript_type =
14751621 reply_q->reply_post_free[reply_q->reply_post_host_index].
14761622 Default.ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK;
14771623 completed_cmds++;
....@@ -1480,7 +1626,7 @@
14801626 * So that FW can find enough entries to post the Reply
14811627 * Descriptors in the reply descriptor post queue.
14821628 */
1483
- if (completed_cmds > ioc->hba_queue_depth/3) {
1629
+ if (completed_cmds >= ioc->thresh_hold) {
14841630 if (ioc->combined_reply_queue) {
14851631 writel(reply_q->reply_post_host_index |
14861632 ((msix_index & 7) <<
....@@ -1492,9 +1638,14 @@
14921638 MPI2_RPHI_MSIX_INDEX_SHIFT),
14931639 &ioc->chip->ReplyPostHostIndex);
14941640 }
1495
- completed_cmds = 1;
1641
+ if (!reply_q->irq_poll_scheduled) {
1642
+ reply_q->irq_poll_scheduled = true;
1643
+ irq_poll_sched(&reply_q->irqpoll);
1644
+ }
1645
+ atomic_dec(&reply_q->busy);
1646
+ return completed_cmds;
14961647 }
1497
- if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED)
1648
+ if (request_descript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED)
14981649 goto out;
14991650 if (!reply_q->reply_post_host_index)
15001651 rpf = reply_q->reply_post_free;
....@@ -1506,14 +1657,14 @@
15061657
15071658 if (!completed_cmds) {
15081659 atomic_dec(&reply_q->busy);
1509
- return IRQ_NONE;
1660
+ return completed_cmds;
15101661 }
15111662
15121663 if (ioc->is_warpdrive) {
15131664 writel(reply_q->reply_post_host_index,
15141665 ioc->reply_post_host_index[msix_index]);
15151666 atomic_dec(&reply_q->busy);
1516
- return IRQ_HANDLED;
1667
+ return completed_cmds;
15171668 }
15181669
15191670 /* Update Reply Post Host Index.
....@@ -1540,7 +1691,89 @@
15401691 MPI2_RPHI_MSIX_INDEX_SHIFT),
15411692 &ioc->chip->ReplyPostHostIndex);
15421693 atomic_dec(&reply_q->busy);
1543
- return IRQ_HANDLED;
1694
+ return completed_cmds;
1695
+}
1696
+
1697
+/**
1698
+ * _base_interrupt - MPT adapter (IOC) specific interrupt handler.
1699
+ * @irq: irq number (not used)
1700
+ * @bus_id: bus identifier cookie == pointer to MPT_ADAPTER structure
1701
+ *
1702
+ * Return: IRQ_HANDLED if processed, else IRQ_NONE.
1703
+ */
1704
+static irqreturn_t
1705
+_base_interrupt(int irq, void *bus_id)
1706
+{
1707
+ struct adapter_reply_queue *reply_q = bus_id;
1708
+ struct MPT3SAS_ADAPTER *ioc = reply_q->ioc;
1709
+
1710
+ if (ioc->mask_interrupts)
1711
+ return IRQ_NONE;
1712
+ if (reply_q->irq_poll_scheduled)
1713
+ return IRQ_HANDLED;
1714
+ return ((_base_process_reply_queue(reply_q) > 0) ?
1715
+ IRQ_HANDLED : IRQ_NONE);
1716
+}
1717
+
1718
+/**
1719
+ * _base_irqpoll - IRQ poll callback handler
1720
+ * @irqpoll: irq_poll object
1721
+ * @budget: irq poll weight
1722
+ *
1723
+ * returns number of reply descriptors processed
1724
+ */
1725
+static int
1726
+_base_irqpoll(struct irq_poll *irqpoll, int budget)
1727
+{
1728
+ struct adapter_reply_queue *reply_q;
1729
+ int num_entries = 0;
1730
+
1731
+ reply_q = container_of(irqpoll, struct adapter_reply_queue,
1732
+ irqpoll);
1733
+ if (reply_q->irq_line_enable) {
1734
+ disable_irq_nosync(reply_q->os_irq);
1735
+ reply_q->irq_line_enable = false;
1736
+ }
1737
+ num_entries = _base_process_reply_queue(reply_q);
1738
+ if (num_entries < budget) {
1739
+ irq_poll_complete(irqpoll);
1740
+ reply_q->irq_poll_scheduled = false;
1741
+ reply_q->irq_line_enable = true;
1742
+ enable_irq(reply_q->os_irq);
1743
+ /*
1744
+ * Go for one more round of processing the
1745
+ * reply descriptor post queue incase if HBA
1746
+ * Firmware has posted some reply descriptors
1747
+ * while reenabling the IRQ.
1748
+ */
1749
+ _base_process_reply_queue(reply_q);
1750
+ }
1751
+
1752
+ return num_entries;
1753
+}
1754
+
1755
+/**
1756
+ * _base_init_irqpolls - initliaze IRQ polls
1757
+ * @ioc: per adapter object
1758
+ *
1759
+ * returns nothing
1760
+ */
1761
+static void
1762
+_base_init_irqpolls(struct MPT3SAS_ADAPTER *ioc)
1763
+{
1764
+ struct adapter_reply_queue *reply_q, *next;
1765
+
1766
+ if (list_empty(&ioc->reply_queue_list))
1767
+ return;
1768
+
1769
+ list_for_each_entry_safe(reply_q, next, &ioc->reply_queue_list, list) {
1770
+ irq_poll_init(&reply_q->irqpoll,
1771
+ ioc->hba_queue_depth/4, _base_irqpoll);
1772
+ reply_q->irq_poll_scheduled = false;
1773
+ reply_q->irq_line_enable = true;
1774
+ reply_q->os_irq = pci_irq_vector(ioc->pdev,
1775
+ reply_q->msix_index);
1776
+ }
15441777 }
15451778
15461779 /**
....@@ -1559,12 +1792,14 @@
15591792 /**
15601793 * mpt3sas_base_sync_reply_irqs - flush pending MSIX interrupts
15611794 * @ioc: per adapter object
1795
+ * @poll: poll over reply descriptor pools incase interrupt for
1796
+ * timed-out SCSI command got delayed
15621797 * Context: non ISR conext
15631798 *
15641799 * Called when a Task Management request has completed.
15651800 */
15661801 void
1567
-mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc)
1802
+mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc, u8 poll)
15681803 {
15691804 struct adapter_reply_queue *reply_q;
15701805
....@@ -1582,6 +1817,24 @@
15821817 if (reply_q->msix_index == 0)
15831818 continue;
15841819 synchronize_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index));
1820
+ if (reply_q->irq_poll_scheduled) {
1821
+ /* Calling irq_poll_disable will wait for any pending
1822
+ * callbacks to have completed.
1823
+ */
1824
+ irq_poll_disable(&reply_q->irqpoll);
1825
+ irq_poll_enable(&reply_q->irqpoll);
1826
+ /* check how the scheduled poll has ended,
1827
+ * clean up only if necessary
1828
+ */
1829
+ if (reply_q->irq_poll_scheduled) {
1830
+ reply_q->irq_poll_scheduled = false;
1831
+ reply_q->irq_line_enable = true;
1832
+ enable_irq(reply_q->os_irq);
1833
+ }
1834
+ }
1835
+
1836
+ if (poll)
1837
+ _base_process_reply_queue(reply_q);
15851838 }
15861839 }
15871840
....@@ -2122,6 +2375,11 @@
21222375 bool build_prp = true;
21232376
21242377 data_length = scsi_bufflen(scmd);
2378
+ if (pcie_device &&
2379
+ (mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info))) {
2380
+ build_prp = false;
2381
+ return build_prp;
2382
+ }
21252383
21262384 /* If Datalenth is <= 16K and number of SGE’s entries are <= 2
21272385 * we built IEEE SGL
....@@ -2270,7 +2528,7 @@
22702528 sges_left = scsi_dma_map(scmd);
22712529 if (sges_left < 0) {
22722530 sdev_printk(KERN_ERR, scmd->device,
2273
- "pci_map_sg failed: request for %d bytes!\n",
2531
+ "scsi_dma_map failed: request for %d bytes!\n",
22742532 scsi_bufflen(scmd));
22752533 return -ENOMEM;
22762534 }
....@@ -2418,7 +2676,7 @@
24182676 sges_left = scsi_dma_map(scmd);
24192677 if (sges_left < 0) {
24202678 sdev_printk(KERN_ERR, scmd->device,
2421
- "pci_map_sg failed: request for %d bytes!\n",
2679
+ "scsi_dma_map failed: request for %d bytes!\n",
24222680 scsi_bufflen(scmd));
24232681 return -ENOMEM;
24242682 }
....@@ -2564,57 +2822,33 @@
25642822 _base_config_dma_addressing(struct MPT3SAS_ADAPTER *ioc, struct pci_dev *pdev)
25652823 {
25662824 struct sysinfo s;
2567
- u64 consistent_dma_mask;
2568
- /* Set 63 bit DMA mask for all SAS3 and SAS35 controllers */
2569
- int dma_mask = (ioc->hba_mpi_version_belonged > MPI2_VERSION) ? 63 : 64;
25702825
2571
- if (ioc->is_mcpu_endpoint)
2572
- goto try_32bit;
2573
-
2574
- if (ioc->dma_mask)
2575
- consistent_dma_mask = DMA_BIT_MASK(dma_mask);
2576
- else
2577
- consistent_dma_mask = DMA_BIT_MASK(32);
2578
-
2579
- if (sizeof(dma_addr_t) > 4) {
2580
- const uint64_t required_mask =
2581
- dma_get_required_mask(&pdev->dev);
2582
- if ((required_mask > DMA_BIT_MASK(32)) &&
2583
- !pci_set_dma_mask(pdev, DMA_BIT_MASK(dma_mask)) &&
2584
- !pci_set_consistent_dma_mask(pdev, consistent_dma_mask)) {
2585
- ioc->base_add_sg_single = &_base_add_sg_single_64;
2586
- ioc->sge_size = sizeof(Mpi2SGESimple64_t);
2587
- ioc->dma_mask = dma_mask;
2588
- goto out;
2589
- }
2590
- }
2591
-
2592
- try_32bit:
2593
- if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))
2594
- && !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
2595
- ioc->base_add_sg_single = &_base_add_sg_single_32;
2596
- ioc->sge_size = sizeof(Mpi2SGESimple32_t);
2826
+ if (ioc->is_mcpu_endpoint ||
2827
+ sizeof(dma_addr_t) == 4 || ioc->use_32bit_dma ||
2828
+ dma_get_required_mask(&pdev->dev) <= DMA_BIT_MASK(32))
25972829 ioc->dma_mask = 32;
2598
- } else
2830
+ /* Set 63 bit DMA mask for all SAS3 and SAS35 controllers */
2831
+ else if (ioc->hba_mpi_version_belonged > MPI2_VERSION)
2832
+ ioc->dma_mask = 63;
2833
+ else
2834
+ ioc->dma_mask = 64;
2835
+
2836
+ if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(ioc->dma_mask)) ||
2837
+ dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(ioc->dma_mask)))
25992838 return -ENODEV;
26002839
2601
- out:
2602
- si_meminfo(&s);
2603
- pr_info(MPT3SAS_FMT
2604
- "%d BIT PCI BUS DMA ADDRESSING SUPPORTED, total mem (%ld kB)\n",
2605
- ioc->name, ioc->dma_mask, convert_to_kb(s.totalram));
2606
-
2607
- return 0;
2608
-}
2609
-
2610
-static int
2611
-_base_change_consistent_dma_mask(struct MPT3SAS_ADAPTER *ioc,
2612
- struct pci_dev *pdev)
2613
-{
2614
- if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(ioc->dma_mask))) {
2615
- if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)))
2616
- return -ENODEV;
2840
+ if (ioc->dma_mask > 32) {
2841
+ ioc->base_add_sg_single = &_base_add_sg_single_64;
2842
+ ioc->sge_size = sizeof(Mpi2SGESimple64_t);
2843
+ } else {
2844
+ ioc->base_add_sg_single = &_base_add_sg_single_32;
2845
+ ioc->sge_size = sizeof(Mpi2SGESimple32_t);
26172846 }
2847
+
2848
+ si_meminfo(&s);
2849
+ ioc_info(ioc, "%d BIT PCI BUS DMA ADDRESSING SUPPORTED, total mem (%ld kB)\n",
2850
+ ioc->dma_mask, convert_to_kb(s.totalram));
2851
+
26182852 return 0;
26192853 }
26202854
....@@ -2641,8 +2875,7 @@
26412875
26422876 base = pci_find_capability(ioc->pdev, PCI_CAP_ID_MSIX);
26432877 if (!base) {
2644
- dfailprintk(ioc, pr_info(MPT3SAS_FMT "msix not supported\n",
2645
- ioc->name));
2878
+ dfailprintk(ioc, ioc_info(ioc, "msix not supported\n"));
26462879 return -EINVAL;
26472880 }
26482881
....@@ -2660,9 +2893,8 @@
26602893 pci_read_config_word(ioc->pdev, base + 2, &message_control);
26612894 ioc->msix_vector_count = (message_control & 0x3FF) + 1;
26622895 }
2663
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
2664
- "msix is supported, vector_count(%d)\n",
2665
- ioc->name, ioc->msix_vector_count));
2896
+ dinitprintk(ioc, ioc_info(ioc, "msix is supported, vector_count(%d)\n",
2897
+ ioc->msix_vector_count));
26662898 return 0;
26672899 }
26682900
....@@ -2682,6 +2914,9 @@
26822914
26832915 list_for_each_entry_safe(reply_q, next, &ioc->reply_queue_list, list) {
26842916 list_del(&reply_q->list);
2917
+ if (ioc->smp_affinity_enable)
2918
+ irq_set_affinity_hint(pci_irq_vector(ioc->pdev,
2919
+ reply_q->msix_index), NULL);
26852920 free_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index),
26862921 reply_q);
26872922 kfree(reply_q);
....@@ -2704,8 +2939,8 @@
27042939
27052940 reply_q = kzalloc(sizeof(struct adapter_reply_queue), GFP_KERNEL);
27062941 if (!reply_q) {
2707
- pr_err(MPT3SAS_FMT "unable to allocate memory %d!\n",
2708
- ioc->name, (int)sizeof(struct adapter_reply_queue));
2942
+ ioc_err(ioc, "unable to allocate memory %zu!\n",
2943
+ sizeof(struct adapter_reply_queue));
27092944 return -ENOMEM;
27102945 }
27112946 reply_q->ioc = ioc;
....@@ -2721,7 +2956,7 @@
27212956 r = request_irq(pci_irq_vector(pdev, index), _base_interrupt,
27222957 IRQF_SHARED, reply_q->name, reply_q);
27232958 if (r) {
2724
- pr_err(MPT3SAS_FMT "unable to allocate interrupt %d!\n",
2959
+ pr_err("%s: unable to allocate interrupt %d!\n",
27252960 reply_q->name, pci_irq_vector(pdev, index));
27262961 kfree(reply_q);
27272962 return -EBUSY;
....@@ -2746,8 +2981,12 @@
27462981 {
27472982 unsigned int cpu, nr_cpus, nr_msix, index = 0;
27482983 struct adapter_reply_queue *reply_q;
2984
+ int local_numa_node;
27492985
27502986 if (!_base_is_controller_msix_enabled(ioc))
2987
+ return;
2988
+
2989
+ if (ioc->msix_load_balance)
27512990 return;
27522991
27532992 memset(ioc->cpu_msix_table, 0, ioc->cpu_msix_table_sz);
....@@ -2758,14 +2997,33 @@
27582997 if (!nr_msix)
27592998 return;
27602999
2761
- if (smp_affinity_enable) {
3000
+ if (ioc->smp_affinity_enable) {
3001
+
3002
+ /*
3003
+ * set irq affinity to local numa node for those irqs
3004
+ * corresponding to high iops queues.
3005
+ */
3006
+ if (ioc->high_iops_queues) {
3007
+ local_numa_node = dev_to_node(&ioc->pdev->dev);
3008
+ for (index = 0; index < ioc->high_iops_queues;
3009
+ index++) {
3010
+ irq_set_affinity_hint(pci_irq_vector(ioc->pdev,
3011
+ index), cpumask_of_node(local_numa_node));
3012
+ }
3013
+ }
3014
+
27623015 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) {
2763
- const cpumask_t *mask = pci_irq_get_affinity(ioc->pdev,
2764
- reply_q->msix_index);
2765
- if (!mask) {
2766
- pr_warn(MPT3SAS_FMT "no affinity for msi %x\n",
2767
- ioc->name, reply_q->msix_index);
3016
+ const cpumask_t *mask;
3017
+
3018
+ if (reply_q->msix_index < ioc->high_iops_queues)
27683019 continue;
3020
+
3021
+ mask = pci_irq_get_affinity(ioc->pdev,
3022
+ reply_q->msix_index);
3023
+ if (!mask) {
3024
+ ioc_warn(ioc, "no affinity for msi %x\n",
3025
+ reply_q->msix_index);
3026
+ goto fall_back;
27693027 }
27703028
27713029 for_each_cpu_and(cpu, mask, cpu_online_mask) {
....@@ -2776,11 +3034,17 @@
27763034 }
27773035 return;
27783036 }
3037
+
3038
+fall_back:
27793039 cpu = cpumask_first(cpu_online_mask);
3040
+ nr_msix -= ioc->high_iops_queues;
3041
+ index = 0;
27803042
27813043 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) {
2782
-
27833044 unsigned int i, group = nr_cpus / nr_msix;
3045
+
3046
+ if (reply_q->msix_index < ioc->high_iops_queues)
3047
+ continue;
27843048
27853049 if (cpu >= nr_cpus)
27863050 break;
....@@ -2797,6 +3061,52 @@
27973061 }
27983062
27993063 /**
3064
+ * _base_check_and_enable_high_iops_queues - enable high iops mode
3065
+ * @ioc: per adapter object
3066
+ * @hba_msix_vector_count: msix vectors supported by HBA
3067
+ *
3068
+ * Enable high iops queues only if
3069
+ * - HBA is a SEA/AERO controller and
3070
+ * - MSI-Xs vector supported by the HBA is 128 and
3071
+ * - total CPU count in the system >=16 and
3072
+ * - loaded driver with default max_msix_vectors module parameter and
3073
+ * - system booted in non kdump mode
3074
+ *
3075
+ * returns nothing.
3076
+ */
3077
+static void
3078
+_base_check_and_enable_high_iops_queues(struct MPT3SAS_ADAPTER *ioc,
3079
+ int hba_msix_vector_count)
3080
+{
3081
+ u16 lnksta, speed;
3082
+
3083
+ if (perf_mode == MPT_PERF_MODE_IOPS ||
3084
+ perf_mode == MPT_PERF_MODE_LATENCY) {
3085
+ ioc->high_iops_queues = 0;
3086
+ return;
3087
+ }
3088
+
3089
+ if (perf_mode == MPT_PERF_MODE_DEFAULT) {
3090
+
3091
+ pcie_capability_read_word(ioc->pdev, PCI_EXP_LNKSTA, &lnksta);
3092
+ speed = lnksta & PCI_EXP_LNKSTA_CLS;
3093
+
3094
+ if (speed < 0x4) {
3095
+ ioc->high_iops_queues = 0;
3096
+ return;
3097
+ }
3098
+ }
3099
+
3100
+ if (!reset_devices && ioc->is_aero_ioc &&
3101
+ hba_msix_vector_count == MPT3SAS_GEN35_MAX_MSIX_QUEUES &&
3102
+ num_online_cpus() >= MPT3SAS_HIGH_IOPS_REPLY_QUEUES &&
3103
+ max_msix_vectors == -1)
3104
+ ioc->high_iops_queues = MPT3SAS_HIGH_IOPS_REPLY_QUEUES;
3105
+ else
3106
+ ioc->high_iops_queues = 0;
3107
+}
3108
+
3109
+/**
28003110 * _base_disable_msix - disables msix
28013111 * @ioc: per adapter object
28023112 *
....@@ -2806,8 +3116,35 @@
28063116 {
28073117 if (!ioc->msix_enable)
28083118 return;
2809
- pci_disable_msix(ioc->pdev);
3119
+ pci_free_irq_vectors(ioc->pdev);
28103120 ioc->msix_enable = 0;
3121
+}
3122
+
3123
+/**
3124
+ * _base_alloc_irq_vectors - allocate msix vectors
3125
+ * @ioc: per adapter object
3126
+ *
3127
+ */
3128
+static int
3129
+_base_alloc_irq_vectors(struct MPT3SAS_ADAPTER *ioc)
3130
+{
3131
+ int i, irq_flags = PCI_IRQ_MSIX;
3132
+ struct irq_affinity desc = { .pre_vectors = ioc->high_iops_queues };
3133
+ struct irq_affinity *descp = &desc;
3134
+
3135
+ if (ioc->smp_affinity_enable)
3136
+ irq_flags |= PCI_IRQ_AFFINITY;
3137
+ else
3138
+ descp = NULL;
3139
+
3140
+ ioc_info(ioc, " %d %d\n", ioc->high_iops_queues,
3141
+ ioc->reply_queue_count);
3142
+
3143
+ i = pci_alloc_irq_vectors_affinity(ioc->pdev,
3144
+ ioc->high_iops_queues,
3145
+ ioc->reply_queue_count, irq_flags, descp);
3146
+
3147
+ return i;
28113148 }
28123149
28133150 /**
....@@ -2821,7 +3158,8 @@
28213158 int r;
28223159 int i, local_max_msix_vectors;
28233160 u8 try_msix = 0;
2824
- unsigned int irq_flags = PCI_IRQ_MSIX;
3161
+
3162
+ ioc->msix_load_balance = false;
28253163
28263164 if (msix_disable == -1 || msix_disable == 0)
28273165 try_msix = 1;
....@@ -2832,12 +3170,15 @@
28323170 if (_base_check_enable_msix(ioc) != 0)
28333171 goto try_ioapic;
28343172
2835
- ioc->reply_queue_count = min_t(int, ioc->cpu_count,
3173
+ ioc_info(ioc, "MSI-X vectors supported: %d\n", ioc->msix_vector_count);
3174
+ pr_info("\t no of cores: %d, max_msix_vectors: %d\n",
3175
+ ioc->cpu_count, max_msix_vectors);
3176
+ if (ioc->is_aero_ioc)
3177
+ _base_check_and_enable_high_iops_queues(ioc,
3178
+ ioc->msix_vector_count);
3179
+ ioc->reply_queue_count =
3180
+ min_t(int, ioc->cpu_count + ioc->high_iops_queues,
28363181 ioc->msix_vector_count);
2837
-
2838
- printk(MPT3SAS_FMT "MSI-X vectors supported: %d, no of cores"
2839
- ": %d, max_msix_vectors: %d\n", ioc->name, ioc->msix_vector_count,
2840
- ioc->cpu_count, max_msix_vectors);
28413182
28423183 if (!ioc->rdpq_array_enable && max_msix_vectors == -1)
28433184 local_max_msix_vectors = (reset_devices) ? 1 : 8;
....@@ -2850,18 +3191,27 @@
28503191 else if (local_max_msix_vectors == 0)
28513192 goto try_ioapic;
28523193
2853
- if (ioc->msix_vector_count < ioc->cpu_count)
2854
- smp_affinity_enable = 0;
3194
+ /*
3195
+ * Enable msix_load_balance only if combined reply queue mode is
3196
+ * disabled on SAS3 & above generation HBA devices.
3197
+ */
3198
+ if (!ioc->combined_reply_queue &&
3199
+ ioc->hba_mpi_version_belonged != MPI2_VERSION) {
3200
+ ioc_info(ioc,
3201
+ "combined ReplyQueue is off, Enabling msix load balance\n");
3202
+ ioc->msix_load_balance = true;
3203
+ }
28553204
2856
- if (smp_affinity_enable)
2857
- irq_flags |= PCI_IRQ_AFFINITY;
3205
+ /*
3206
+ * smp affinity setting is not need when msix load balance
3207
+ * is enabled.
3208
+ */
3209
+ if (ioc->msix_load_balance)
3210
+ ioc->smp_affinity_enable = 0;
28583211
2859
- r = pci_alloc_irq_vectors(ioc->pdev, 1, ioc->reply_queue_count,
2860
- irq_flags);
3212
+ r = _base_alloc_irq_vectors(ioc);
28613213 if (r < 0) {
2862
- dfailprintk(ioc, pr_info(MPT3SAS_FMT
2863
- "pci_alloc_irq_vectors failed (r=%d) !!!\n",
2864
- ioc->name, r));
3214
+ ioc_info(ioc, "pci_alloc_irq_vectors failed (r=%d) !!!\n", r);
28653215 goto try_ioapic;
28663216 }
28673217
....@@ -2876,17 +3226,21 @@
28763226 }
28773227 }
28783228
3229
+ ioc_info(ioc, "High IOPs queues : %s\n",
3230
+ ioc->high_iops_queues ? "enabled" : "disabled");
3231
+
28793232 return 0;
28803233
28813234 /* failback to io_apic interrupt routing */
28823235 try_ioapic:
2883
-
3236
+ ioc->high_iops_queues = 0;
3237
+ ioc_info(ioc, "High IOPs queues : disabled\n");
28843238 ioc->reply_queue_count = 1;
28853239 r = pci_alloc_irq_vectors(ioc->pdev, 1, 1, PCI_IRQ_LEGACY);
28863240 if (r < 0) {
2887
- dfailprintk(ioc, pr_info(MPT3SAS_FMT
2888
- "pci_alloc_irq_vector(legacy) failed (r=%d) !!!\n",
2889
- ioc->name, r));
3241
+ dfailprintk(ioc,
3242
+ ioc_info(ioc, "pci_alloc_irq_vector(legacy) failed (r=%d) !!!\n",
3243
+ r));
28903244 } else
28913245 r = _base_request_irq(ioc, 0);
28923246
....@@ -2902,8 +3256,7 @@
29023256 {
29033257 struct pci_dev *pdev = ioc->pdev;
29043258
2905
- dexitprintk(ioc, printk(MPT3SAS_FMT "%s\n",
2906
- ioc->name, __func__));
3259
+ dexitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
29073260
29083261 _base_free_irq(ioc);
29093262 _base_disable_msix(ioc);
....@@ -2924,6 +3277,43 @@
29243277 }
29253278 }
29263279
3280
+static int
3281
+_base_diag_reset(struct MPT3SAS_ADAPTER *ioc);
3282
+
3283
+/**
3284
+ * _base_check_for_fault_and_issue_reset - check if IOC is in fault state
3285
+ * and if it is in fault state then issue diag reset.
3286
+ * @ioc: per adapter object
3287
+ *
3288
+ * Returns: 0 for success, non-zero for failure.
3289
+ */
3290
+static int
3291
+_base_check_for_fault_and_issue_reset(struct MPT3SAS_ADAPTER *ioc)
3292
+{
3293
+ u32 ioc_state;
3294
+ int rc = -EFAULT;
3295
+
3296
+ dinitprintk(ioc, pr_info("%s\n", __func__));
3297
+ if (ioc->pci_error_recovery)
3298
+ return 0;
3299
+ ioc_state = mpt3sas_base_get_iocstate(ioc, 0);
3300
+ dhsprintk(ioc, pr_info("%s: ioc_state(0x%08x)\n", __func__, ioc_state));
3301
+
3302
+ if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
3303
+ mpt3sas_print_fault_code(ioc, ioc_state &
3304
+ MPI2_DOORBELL_DATA_MASK);
3305
+ rc = _base_diag_reset(ioc);
3306
+ } else if ((ioc_state & MPI2_IOC_STATE_MASK) ==
3307
+ MPI2_IOC_STATE_COREDUMP) {
3308
+ mpt3sas_print_coredump_info(ioc, ioc_state &
3309
+ MPI2_DOORBELL_DATA_MASK);
3310
+ mpt3sas_base_wait_for_coredump_completion(ioc, __func__);
3311
+ rc = _base_diag_reset(ioc);
3312
+ }
3313
+
3314
+ return rc;
3315
+}
3316
+
29273317 /**
29283318 * mpt3sas_base_map_resources - map in controller resources (io/irq/memap)
29293319 * @ioc: per adapter object
....@@ -2936,18 +3326,16 @@
29363326 struct pci_dev *pdev = ioc->pdev;
29373327 u32 memap_sz;
29383328 u32 pio_sz;
2939
- int i, r = 0;
3329
+ int i, r = 0, rc;
29403330 u64 pio_chip = 0;
29413331 phys_addr_t chip_phys = 0;
29423332 struct adapter_reply_queue *reply_q;
29433333
2944
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n",
2945
- ioc->name, __func__));
3334
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
29463335
29473336 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM);
29483337 if (pci_enable_device_mem(pdev)) {
2949
- pr_warn(MPT3SAS_FMT "pci_enable_device_mem: failed\n",
2950
- ioc->name);
3338
+ ioc_warn(ioc, "pci_enable_device_mem: failed\n");
29513339 ioc->bars = 0;
29523340 return -ENODEV;
29533341 }
....@@ -2955,8 +3343,7 @@
29553343
29563344 if (pci_request_selected_regions(pdev, ioc->bars,
29573345 ioc->driver_name)) {
2958
- pr_warn(MPT3SAS_FMT "pci_request_selected_regions: failed\n",
2959
- ioc->name);
3346
+ ioc_warn(ioc, "pci_request_selected_regions: failed\n");
29603347 ioc->bars = 0;
29613348 r = -ENODEV;
29623349 goto out_fail;
....@@ -2969,8 +3356,7 @@
29693356
29703357
29713358 if (_base_config_dma_addressing(ioc, pdev) != 0) {
2972
- pr_warn(MPT3SAS_FMT "no suitable DMA mask for %s\n",
2973
- ioc->name, pci_name(pdev));
3359
+ ioc_warn(ioc, "no suitable DMA mask for %s\n", pci_name(pdev));
29743360 r = -ENODEV;
29753361 goto out_fail;
29763362 }
....@@ -2993,17 +3379,20 @@
29933379 }
29943380
29953381 if (ioc->chip == NULL) {
2996
- pr_err(MPT3SAS_FMT "unable to map adapter memory! "
2997
- " or resource not found\n", ioc->name);
3382
+ ioc_err(ioc,
3383
+ "unable to map adapter memory! or resource not found\n");
29983384 r = -EINVAL;
29993385 goto out_fail;
30003386 }
30013387
3002
- _base_mask_interrupts(ioc);
3388
+ mpt3sas_base_mask_interrupts(ioc);
30033389
30043390 r = _base_get_ioc_facts(ioc);
3005
- if (r)
3006
- goto out_fail;
3391
+ if (r) {
3392
+ rc = _base_check_for_fault_and_issue_reset(ioc);
3393
+ if (rc || (_base_get_ioc_facts(ioc)))
3394
+ goto out_fail;
3395
+ }
30073396
30083397 if (!ioc->rdpq_array_enable_assigned) {
30093398 ioc->rdpq_array_enable = ioc->rdpq_array_capable;
....@@ -3014,6 +3403,8 @@
30143403 if (r)
30153404 goto out_fail;
30163405
3406
+ if (!ioc->is_driver_loading)
3407
+ _base_init_irqpolls(ioc);
30173408 /* Use the Combined reply queue feature only for SAS3 C0 & higher
30183409 * revision HBAs and also only when reply queue count is greater than 8
30193410 */
....@@ -3028,9 +3419,8 @@
30283419 ioc->combined_reply_index_count,
30293420 sizeof(resource_size_t *), GFP_KERNEL);
30303421 if (!ioc->replyPostRegisterIndex) {
3031
- dfailprintk(ioc, printk(MPT3SAS_FMT
3032
- "allocation for reply Post Register Index failed!!!\n",
3033
- ioc->name));
3422
+ ioc_err(ioc,
3423
+ "allocation for replyPostRegisterIndex failed!\n");
30343424 r = -ENOMEM;
30353425 goto out_fail;
30363426 }
....@@ -3055,15 +3445,15 @@
30553445 }
30563446
30573447 list_for_each_entry(reply_q, &ioc->reply_queue_list, list)
3058
- pr_info(MPT3SAS_FMT "%s: IRQ %d\n",
3059
- reply_q->name, ((ioc->msix_enable) ? "PCI-MSI-X enabled" :
3060
- "IO-APIC enabled"),
3061
- pci_irq_vector(ioc->pdev, reply_q->msix_index));
3448
+ pr_info("%s: %s enabled: IRQ %d\n",
3449
+ reply_q->name,
3450
+ ioc->msix_enable ? "PCI-MSI-X" : "IO-APIC",
3451
+ pci_irq_vector(ioc->pdev, reply_q->msix_index));
30623452
3063
- pr_info(MPT3SAS_FMT "iomem(%pap), mapped(0x%p), size(%d)\n",
3064
- ioc->name, &chip_phys, ioc->chip, memap_sz);
3065
- pr_info(MPT3SAS_FMT "ioport(0x%016llx), size(%d)\n",
3066
- ioc->name, (unsigned long long)pio_chip, pio_sz);
3453
+ ioc_info(ioc, "iomem(%pap), mapped(0x%p), size(%d)\n",
3454
+ &chip_phys, ioc->chip, memap_sz);
3455
+ ioc_info(ioc, "ioport(0x%016llx), size(%d)\n",
3456
+ (unsigned long long)pio_chip, pio_sz);
30673457
30683458 /* Save PCI configuration state for recovery from PCI AER/EEH errors */
30693459 pci_save_state(pdev);
....@@ -3155,10 +3545,71 @@
31553545 return ioc->reply + (phys_addr - (u32)ioc->reply_dma);
31563546 }
31573547
3548
+/**
3549
+ * _base_get_msix_index - get the msix index
3550
+ * @ioc: per adapter object
3551
+ * @scmd: scsi_cmnd object
3552
+ *
3553
+ * returns msix index of general reply queues,
3554
+ * i.e. reply queue on which IO request's reply
3555
+ * should be posted by the HBA firmware.
3556
+ */
31583557 static inline u8
3159
-_base_get_msix_index(struct MPT3SAS_ADAPTER *ioc)
3558
+_base_get_msix_index(struct MPT3SAS_ADAPTER *ioc,
3559
+ struct scsi_cmnd *scmd)
31603560 {
3561
+ /* Enables reply_queue load balancing */
3562
+ if (ioc->msix_load_balance)
3563
+ return ioc->reply_queue_count ?
3564
+ base_mod64(atomic64_add_return(1,
3565
+ &ioc->total_io_cnt), ioc->reply_queue_count) : 0;
3566
+
31613567 return ioc->cpu_msix_table[raw_smp_processor_id()];
3568
+}
3569
+
3570
+/**
3571
+ * _base_sdev_nr_inflight_request -get number of inflight requests
3572
+ * of a request queue.
3573
+ * @q: request_queue object
3574
+ *
3575
+ * returns number of inflight request of a request queue.
3576
+ */
3577
+inline unsigned long
3578
+_base_sdev_nr_inflight_request(struct request_queue *q)
3579
+{
3580
+ struct blk_mq_hw_ctx *hctx = q->queue_hw_ctx[0];
3581
+
3582
+ return atomic_read(&hctx->nr_active);
3583
+}
3584
+
3585
+
3586
+/**
3587
+ * _base_get_high_iops_msix_index - get the msix index of
3588
+ * high iops queues
3589
+ * @ioc: per adapter object
3590
+ * @scmd: scsi_cmnd object
3591
+ *
3592
+ * Returns: msix index of high iops reply queues.
3593
+ * i.e. high iops reply queue on which IO request's
3594
+ * reply should be posted by the HBA firmware.
3595
+ */
3596
+static inline u8
3597
+_base_get_high_iops_msix_index(struct MPT3SAS_ADAPTER *ioc,
3598
+ struct scsi_cmnd *scmd)
3599
+{
3600
+ /**
3601
+ * Round robin the IO interrupts among the high iops
3602
+ * reply queues in terms of batch count 16 when outstanding
3603
+ * IOs on the target device is >=8.
3604
+ */
3605
+ if (_base_sdev_nr_inflight_request(scmd->device->request_queue) >
3606
+ MPT3SAS_DEVICE_HIGH_IOPS_DEPTH)
3607
+ return base_mod64((
3608
+ atomic64_add_return(1, &ioc->high_iops_outstanding) /
3609
+ MPT3SAS_HIGH_IOPS_BATCH_COUNT),
3610
+ MPT3SAS_HIGH_IOPS_REPLY_QUEUES);
3611
+
3612
+ return _base_get_msix_index(ioc, scmd);
31623613 }
31633614
31643615 /**
....@@ -3178,8 +3629,7 @@
31783629 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
31793630 if (list_empty(&ioc->internal_free_list)) {
31803631 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
3181
- pr_err(MPT3SAS_FMT "%s: smid not available\n",
3182
- ioc->name, __func__);
3632
+ ioc_err(ioc, "%s: smid not available\n", __func__);
31833633 return 0;
31843634 }
31853635
....@@ -3210,8 +3660,8 @@
32103660
32113661 smid = tag + 1;
32123662 request->cb_idx = cb_idx;
3213
- request->msix_io = _base_get_msix_index(ioc);
32143663 request->smid = smid;
3664
+ request->scmd = scmd;
32153665 INIT_LIST_HEAD(&request->chain_list);
32163666 return smid;
32173667 }
....@@ -3265,6 +3715,7 @@
32653715 return;
32663716 st->cb_idx = 0xFF;
32673717 st->direct_io = 0;
3718
+ st->scmd = NULL;
32683719 atomic_set(&ioc->chain_lookup[st->smid - 1].chain_offset, 0);
32693720 st->smid = 0;
32703721 }
....@@ -3334,7 +3785,6 @@
33343785 spin_lock_irqsave(writeq_lock, flags);
33353786 __raw_writel((u32)(b), addr);
33363787 __raw_writel((u32)(b >> 32), (addr + 4));
3337
- mmiowb();
33383788 spin_unlock_irqrestore(writeq_lock, flags);
33393789 }
33403790
....@@ -3365,13 +3815,37 @@
33653815 #endif
33663816
33673817 /**
3818
+ * _base_set_and_get_msix_index - get the msix index and assign to msix_io
3819
+ * variable of scsi tracker
3820
+ * @ioc: per adapter object
3821
+ * @smid: system request message index
3822
+ *
3823
+ * returns msix index.
3824
+ */
3825
+static u8
3826
+_base_set_and_get_msix_index(struct MPT3SAS_ADAPTER *ioc, u16 smid)
3827
+{
3828
+ struct scsiio_tracker *st = NULL;
3829
+
3830
+ if (smid < ioc->hi_priority_smid)
3831
+ st = _get_st_from_smid(ioc, smid);
3832
+
3833
+ if (st == NULL)
3834
+ return _base_get_msix_index(ioc, NULL);
3835
+
3836
+ st->msix_io = ioc->get_msix_index_for_smlio(ioc, st->scmd);
3837
+ return st->msix_io;
3838
+}
3839
+
3840
+/**
33683841 * _base_put_smid_mpi_ep_scsi_io - send SCSI_IO request to firmware
33693842 * @ioc: per adapter object
33703843 * @smid: system request message index
33713844 * @handle: device handle
33723845 */
33733846 static void
3374
-_base_put_smid_mpi_ep_scsi_io(struct MPT3SAS_ADAPTER *ioc, u16 smid, u16 handle)
3847
+_base_put_smid_mpi_ep_scsi_io(struct MPT3SAS_ADAPTER *ioc,
3848
+ u16 smid, u16 handle)
33753849 {
33763850 Mpi2RequestDescriptorUnion_t descriptor;
33773851 u64 *request = (u64 *)&descriptor;
....@@ -3384,7 +3858,7 @@
33843858 _base_clone_mpi_to_sys_mem(mpi_req_iomem, (void *)mfp,
33853859 ioc->request_sz);
33863860 descriptor.SCSIIO.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO;
3387
- descriptor.SCSIIO.MSIxIndex = _base_get_msix_index(ioc);
3861
+ descriptor.SCSIIO.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
33883862 descriptor.SCSIIO.SMID = cpu_to_le16(smid);
33893863 descriptor.SCSIIO.DevHandle = cpu_to_le16(handle);
33903864 descriptor.SCSIIO.LMID = 0;
....@@ -3406,7 +3880,7 @@
34063880
34073881
34083882 descriptor.SCSIIO.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO;
3409
- descriptor.SCSIIO.MSIxIndex = _base_get_msix_index(ioc);
3883
+ descriptor.SCSIIO.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
34103884 descriptor.SCSIIO.SMID = cpu_to_le16(smid);
34113885 descriptor.SCSIIO.DevHandle = cpu_to_le16(handle);
34123886 descriptor.SCSIIO.LMID = 0;
....@@ -3415,13 +3889,13 @@
34153889 }
34163890
34173891 /**
3418
- * mpt3sas_base_put_smid_fast_path - send fast path request to firmware
3892
+ * _base_put_smid_fast_path - send fast path request to firmware
34193893 * @ioc: per adapter object
34203894 * @smid: system request message index
34213895 * @handle: device handle
34223896 */
3423
-void
3424
-mpt3sas_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid,
3897
+static void
3898
+_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid,
34253899 u16 handle)
34263900 {
34273901 Mpi2RequestDescriptorUnion_t descriptor;
....@@ -3429,7 +3903,7 @@
34293903
34303904 descriptor.SCSIIO.RequestFlags =
34313905 MPI25_REQ_DESCRIPT_FLAGS_FAST_PATH_SCSI_IO;
3432
- descriptor.SCSIIO.MSIxIndex = _base_get_msix_index(ioc);
3906
+ descriptor.SCSIIO.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
34333907 descriptor.SCSIIO.SMID = cpu_to_le16(smid);
34343908 descriptor.SCSIIO.DevHandle = cpu_to_le16(handle);
34353909 descriptor.SCSIIO.LMID = 0;
....@@ -3438,13 +3912,13 @@
34383912 }
34393913
34403914 /**
3441
- * mpt3sas_base_put_smid_hi_priority - send Task Management request to firmware
3915
+ * _base_put_smid_hi_priority - send Task Management request to firmware
34423916 * @ioc: per adapter object
34433917 * @smid: system request message index
34443918 * @msix_task: msix_task will be same as msix of IO incase of task abort else 0.
34453919 */
3446
-void
3447
-mpt3sas_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid,
3920
+static void
3921
+_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid,
34483922 u16 msix_task)
34493923 {
34503924 Mpi2RequestDescriptorUnion_t descriptor;
....@@ -3493,7 +3967,7 @@
34933967
34943968 descriptor.Default.RequestFlags =
34953969 MPI26_REQ_DESCRIPT_FLAGS_PCIE_ENCAPSULATED;
3496
- descriptor.Default.MSIxIndex = _base_get_msix_index(ioc);
3970
+ descriptor.Default.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
34973971 descriptor.Default.SMID = cpu_to_le16(smid);
34983972 descriptor.Default.LMID = 0;
34993973 descriptor.Default.DescriptorTypeDependent = 0;
....@@ -3502,12 +3976,12 @@
35023976 }
35033977
35043978 /**
3505
- * mpt3sas_base_put_smid_default - Default, primarily used for config pages
3979
+ * _base_put_smid_default - Default, primarily used for config pages
35063980 * @ioc: per adapter object
35073981 * @smid: system request message index
35083982 */
3509
-void
3510
-mpt3sas_base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, u16 smid)
3983
+static void
3984
+_base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, u16 smid)
35113985 {
35123986 Mpi2RequestDescriptorUnion_t descriptor;
35133987 void *mpi_req_iomem;
....@@ -3525,7 +3999,7 @@
35253999 }
35264000 request = (u64 *)&descriptor;
35274001 descriptor.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
3528
- descriptor.Default.MSIxIndex = _base_get_msix_index(ioc);
4002
+ descriptor.Default.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
35294003 descriptor.Default.SMID = cpu_to_le16(smid);
35304004 descriptor.Default.LMID = 0;
35314005 descriptor.Default.DescriptorTypeDependent = 0;
....@@ -3536,6 +4010,95 @@
35364010 else
35374011 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow,
35384012 &ioc->scsi_lookup_lock);
4013
+}
4014
+
4015
+/**
4016
+ * _base_put_smid_scsi_io_atomic - send SCSI_IO request to firmware using
4017
+ * Atomic Request Descriptor
4018
+ * @ioc: per adapter object
4019
+ * @smid: system request message index
4020
+ * @handle: device handle, unused in this function, for function type match
4021
+ *
4022
+ * Return nothing.
4023
+ */
4024
+static void
4025
+_base_put_smid_scsi_io_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid,
4026
+ u16 handle)
4027
+{
4028
+ Mpi26AtomicRequestDescriptor_t descriptor;
4029
+ u32 *request = (u32 *)&descriptor;
4030
+
4031
+ descriptor.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO;
4032
+ descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
4033
+ descriptor.SMID = cpu_to_le16(smid);
4034
+
4035
+ writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
4036
+}
4037
+
4038
+/**
4039
+ * _base_put_smid_fast_path_atomic - send fast path request to firmware
4040
+ * using Atomic Request Descriptor
4041
+ * @ioc: per adapter object
4042
+ * @smid: system request message index
4043
+ * @handle: device handle, unused in this function, for function type match
4044
+ * Return nothing
4045
+ */
4046
+static void
4047
+_base_put_smid_fast_path_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid,
4048
+ u16 handle)
4049
+{
4050
+ Mpi26AtomicRequestDescriptor_t descriptor;
4051
+ u32 *request = (u32 *)&descriptor;
4052
+
4053
+ descriptor.RequestFlags = MPI25_REQ_DESCRIPT_FLAGS_FAST_PATH_SCSI_IO;
4054
+ descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
4055
+ descriptor.SMID = cpu_to_le16(smid);
4056
+
4057
+ writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
4058
+}
4059
+
4060
+/**
4061
+ * _base_put_smid_hi_priority_atomic - send Task Management request to
4062
+ * firmware using Atomic Request Descriptor
4063
+ * @ioc: per adapter object
4064
+ * @smid: system request message index
4065
+ * @msix_task: msix_task will be same as msix of IO incase of task abort else 0
4066
+ *
4067
+ * Return nothing.
4068
+ */
4069
+static void
4070
+_base_put_smid_hi_priority_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid,
4071
+ u16 msix_task)
4072
+{
4073
+ Mpi26AtomicRequestDescriptor_t descriptor;
4074
+ u32 *request = (u32 *)&descriptor;
4075
+
4076
+ descriptor.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
4077
+ descriptor.MSIxIndex = msix_task;
4078
+ descriptor.SMID = cpu_to_le16(smid);
4079
+
4080
+ writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
4081
+}
4082
+
4083
+/**
4084
+ * _base_put_smid_default - Default, primarily used for config pages
4085
+ * use Atomic Request Descriptor
4086
+ * @ioc: per adapter object
4087
+ * @smid: system request message index
4088
+ *
4089
+ * Return nothing.
4090
+ */
4091
+static void
4092
+_base_put_smid_default_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid)
4093
+{
4094
+ Mpi26AtomicRequestDescriptor_t descriptor;
4095
+ u32 *request = (u32 *)&descriptor;
4096
+
4097
+ descriptor.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
4098
+ descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
4099
+ descriptor.SMID = cpu_to_le16(smid);
4100
+
4101
+ writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
35394102 }
35404103
35414104 /**
....@@ -3554,89 +4117,87 @@
35544117 case MPI2_MFGPAGE_DEVID_SAS2008:
35554118 switch (ioc->pdev->subsystem_device) {
35564119 case MPT2SAS_INTEL_RMS2LL080_SSDID:
3557
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3558
- MPT2SAS_INTEL_RMS2LL080_BRANDING);
4120
+ ioc_info(ioc, "%s\n",
4121
+ MPT2SAS_INTEL_RMS2LL080_BRANDING);
35594122 break;
35604123 case MPT2SAS_INTEL_RMS2LL040_SSDID:
3561
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3562
- MPT2SAS_INTEL_RMS2LL040_BRANDING);
4124
+ ioc_info(ioc, "%s\n",
4125
+ MPT2SAS_INTEL_RMS2LL040_BRANDING);
35634126 break;
35644127 case MPT2SAS_INTEL_SSD910_SSDID:
3565
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3566
- MPT2SAS_INTEL_SSD910_BRANDING);
4128
+ ioc_info(ioc, "%s\n",
4129
+ MPT2SAS_INTEL_SSD910_BRANDING);
35674130 break;
35684131 default:
3569
- pr_info(MPT3SAS_FMT
3570
- "Intel(R) Controller: Subsystem ID: 0x%X\n",
3571
- ioc->name, ioc->pdev->subsystem_device);
4132
+ ioc_info(ioc, "Intel(R) Controller: Subsystem ID: 0x%X\n",
4133
+ ioc->pdev->subsystem_device);
35724134 break;
35734135 }
4136
+ break;
35744137 case MPI2_MFGPAGE_DEVID_SAS2308_2:
35754138 switch (ioc->pdev->subsystem_device) {
35764139 case MPT2SAS_INTEL_RS25GB008_SSDID:
3577
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3578
- MPT2SAS_INTEL_RS25GB008_BRANDING);
4140
+ ioc_info(ioc, "%s\n",
4141
+ MPT2SAS_INTEL_RS25GB008_BRANDING);
35794142 break;
35804143 case MPT2SAS_INTEL_RMS25JB080_SSDID:
3581
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3582
- MPT2SAS_INTEL_RMS25JB080_BRANDING);
4144
+ ioc_info(ioc, "%s\n",
4145
+ MPT2SAS_INTEL_RMS25JB080_BRANDING);
35834146 break;
35844147 case MPT2SAS_INTEL_RMS25JB040_SSDID:
3585
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3586
- MPT2SAS_INTEL_RMS25JB040_BRANDING);
4148
+ ioc_info(ioc, "%s\n",
4149
+ MPT2SAS_INTEL_RMS25JB040_BRANDING);
35874150 break;
35884151 case MPT2SAS_INTEL_RMS25KB080_SSDID:
3589
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3590
- MPT2SAS_INTEL_RMS25KB080_BRANDING);
4152
+ ioc_info(ioc, "%s\n",
4153
+ MPT2SAS_INTEL_RMS25KB080_BRANDING);
35914154 break;
35924155 case MPT2SAS_INTEL_RMS25KB040_SSDID:
3593
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3594
- MPT2SAS_INTEL_RMS25KB040_BRANDING);
4156
+ ioc_info(ioc, "%s\n",
4157
+ MPT2SAS_INTEL_RMS25KB040_BRANDING);
35954158 break;
35964159 case MPT2SAS_INTEL_RMS25LB040_SSDID:
3597
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3598
- MPT2SAS_INTEL_RMS25LB040_BRANDING);
4160
+ ioc_info(ioc, "%s\n",
4161
+ MPT2SAS_INTEL_RMS25LB040_BRANDING);
35994162 break;
36004163 case MPT2SAS_INTEL_RMS25LB080_SSDID:
3601
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3602
- MPT2SAS_INTEL_RMS25LB080_BRANDING);
4164
+ ioc_info(ioc, "%s\n",
4165
+ MPT2SAS_INTEL_RMS25LB080_BRANDING);
36034166 break;
36044167 default:
3605
- pr_info(MPT3SAS_FMT
3606
- "Intel(R) Controller: Subsystem ID: 0x%X\n",
3607
- ioc->name, ioc->pdev->subsystem_device);
4168
+ ioc_info(ioc, "Intel(R) Controller: Subsystem ID: 0x%X\n",
4169
+ ioc->pdev->subsystem_device);
36084170 break;
36094171 }
4172
+ break;
36104173 case MPI25_MFGPAGE_DEVID_SAS3008:
36114174 switch (ioc->pdev->subsystem_device) {
36124175 case MPT3SAS_INTEL_RMS3JC080_SSDID:
3613
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3614
- MPT3SAS_INTEL_RMS3JC080_BRANDING);
4176
+ ioc_info(ioc, "%s\n",
4177
+ MPT3SAS_INTEL_RMS3JC080_BRANDING);
36154178 break;
36164179
36174180 case MPT3SAS_INTEL_RS3GC008_SSDID:
3618
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3619
- MPT3SAS_INTEL_RS3GC008_BRANDING);
4181
+ ioc_info(ioc, "%s\n",
4182
+ MPT3SAS_INTEL_RS3GC008_BRANDING);
36204183 break;
36214184 case MPT3SAS_INTEL_RS3FC044_SSDID:
3622
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3623
- MPT3SAS_INTEL_RS3FC044_BRANDING);
4185
+ ioc_info(ioc, "%s\n",
4186
+ MPT3SAS_INTEL_RS3FC044_BRANDING);
36244187 break;
36254188 case MPT3SAS_INTEL_RS3UC080_SSDID:
3626
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3627
- MPT3SAS_INTEL_RS3UC080_BRANDING);
4189
+ ioc_info(ioc, "%s\n",
4190
+ MPT3SAS_INTEL_RS3UC080_BRANDING);
36284191 break;
36294192 default:
3630
- pr_info(MPT3SAS_FMT
3631
- "Intel(R) Controller: Subsystem ID: 0x%X\n",
3632
- ioc->name, ioc->pdev->subsystem_device);
4193
+ ioc_info(ioc, "Intel(R) Controller: Subsystem ID: 0x%X\n",
4194
+ ioc->pdev->subsystem_device);
36334195 break;
36344196 }
36354197 break;
36364198 default:
3637
- pr_info(MPT3SAS_FMT
3638
- "Intel(R) Controller: Subsystem ID: 0x%X\n",
3639
- ioc->name, ioc->pdev->subsystem_device);
4199
+ ioc_info(ioc, "Intel(R) Controller: Subsystem ID: 0x%X\n",
4200
+ ioc->pdev->subsystem_device);
36404201 break;
36414202 }
36424203 break;
....@@ -3645,57 +4206,54 @@
36454206 case MPI2_MFGPAGE_DEVID_SAS2008:
36464207 switch (ioc->pdev->subsystem_device) {
36474208 case MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID:
3648
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3649
- MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING);
4209
+ ioc_info(ioc, "%s\n",
4210
+ MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING);
36504211 break;
36514212 case MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID:
3652
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3653
- MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING);
4213
+ ioc_info(ioc, "%s\n",
4214
+ MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING);
36544215 break;
36554216 case MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID:
3656
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3657
- MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING);
4217
+ ioc_info(ioc, "%s\n",
4218
+ MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING);
36584219 break;
36594220 case MPT2SAS_DELL_PERC_H200_MODULAR_SSDID:
3660
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3661
- MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING);
4221
+ ioc_info(ioc, "%s\n",
4222
+ MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING);
36624223 break;
36634224 case MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID:
3664
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3665
- MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING);
4225
+ ioc_info(ioc, "%s\n",
4226
+ MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING);
36664227 break;
36674228 case MPT2SAS_DELL_PERC_H200_SSDID:
3668
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3669
- MPT2SAS_DELL_PERC_H200_BRANDING);
4229
+ ioc_info(ioc, "%s\n",
4230
+ MPT2SAS_DELL_PERC_H200_BRANDING);
36704231 break;
36714232 case MPT2SAS_DELL_6GBPS_SAS_SSDID:
3672
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3673
- MPT2SAS_DELL_6GBPS_SAS_BRANDING);
4233
+ ioc_info(ioc, "%s\n",
4234
+ MPT2SAS_DELL_6GBPS_SAS_BRANDING);
36744235 break;
36754236 default:
3676
- pr_info(MPT3SAS_FMT
3677
- "Dell 6Gbps HBA: Subsystem ID: 0x%X\n",
3678
- ioc->name, ioc->pdev->subsystem_device);
4237
+ ioc_info(ioc, "Dell 6Gbps HBA: Subsystem ID: 0x%X\n",
4238
+ ioc->pdev->subsystem_device);
36794239 break;
36804240 }
36814241 break;
36824242 case MPI25_MFGPAGE_DEVID_SAS3008:
36834243 switch (ioc->pdev->subsystem_device) {
36844244 case MPT3SAS_DELL_12G_HBA_SSDID:
3685
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3686
- MPT3SAS_DELL_12G_HBA_BRANDING);
4245
+ ioc_info(ioc, "%s\n",
4246
+ MPT3SAS_DELL_12G_HBA_BRANDING);
36874247 break;
36884248 default:
3689
- pr_info(MPT3SAS_FMT
3690
- "Dell 12Gbps HBA: Subsystem ID: 0x%X\n",
3691
- ioc->name, ioc->pdev->subsystem_device);
4249
+ ioc_info(ioc, "Dell 12Gbps HBA: Subsystem ID: 0x%X\n",
4250
+ ioc->pdev->subsystem_device);
36924251 break;
36934252 }
36944253 break;
36954254 default:
3696
- pr_info(MPT3SAS_FMT
3697
- "Dell HBA: Subsystem ID: 0x%X\n", ioc->name,
3698
- ioc->pdev->subsystem_device);
4255
+ ioc_info(ioc, "Dell HBA: Subsystem ID: 0x%X\n",
4256
+ ioc->pdev->subsystem_device);
36994257 break;
37004258 }
37014259 break;
....@@ -3704,46 +4262,42 @@
37044262 case MPI25_MFGPAGE_DEVID_SAS3008:
37054263 switch (ioc->pdev->subsystem_device) {
37064264 case MPT3SAS_CISCO_12G_8E_HBA_SSDID:
3707
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3708
- MPT3SAS_CISCO_12G_8E_HBA_BRANDING);
4265
+ ioc_info(ioc, "%s\n",
4266
+ MPT3SAS_CISCO_12G_8E_HBA_BRANDING);
37094267 break;
37104268 case MPT3SAS_CISCO_12G_8I_HBA_SSDID:
3711
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3712
- MPT3SAS_CISCO_12G_8I_HBA_BRANDING);
4269
+ ioc_info(ioc, "%s\n",
4270
+ MPT3SAS_CISCO_12G_8I_HBA_BRANDING);
37134271 break;
37144272 case MPT3SAS_CISCO_12G_AVILA_HBA_SSDID:
3715
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3716
- MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING);
4273
+ ioc_info(ioc, "%s\n",
4274
+ MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING);
37174275 break;
37184276 default:
3719
- pr_info(MPT3SAS_FMT
3720
- "Cisco 12Gbps SAS HBA: Subsystem ID: 0x%X\n",
3721
- ioc->name, ioc->pdev->subsystem_device);
4277
+ ioc_info(ioc, "Cisco 12Gbps SAS HBA: Subsystem ID: 0x%X\n",
4278
+ ioc->pdev->subsystem_device);
37224279 break;
37234280 }
37244281 break;
37254282 case MPI25_MFGPAGE_DEVID_SAS3108_1:
37264283 switch (ioc->pdev->subsystem_device) {
37274284 case MPT3SAS_CISCO_12G_AVILA_HBA_SSDID:
3728
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3729
- MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING);
4285
+ ioc_info(ioc, "%s\n",
4286
+ MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING);
37304287 break;
37314288 case MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_SSDID:
3732
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3733
- MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_BRANDING
3734
- );
4289
+ ioc_info(ioc, "%s\n",
4290
+ MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_BRANDING);
37354291 break;
37364292 default:
3737
- pr_info(MPT3SAS_FMT
3738
- "Cisco 12Gbps SAS HBA: Subsystem ID: 0x%X\n",
3739
- ioc->name, ioc->pdev->subsystem_device);
4293
+ ioc_info(ioc, "Cisco 12Gbps SAS HBA: Subsystem ID: 0x%X\n",
4294
+ ioc->pdev->subsystem_device);
37404295 break;
37414296 }
37424297 break;
37434298 default:
3744
- pr_info(MPT3SAS_FMT
3745
- "Cisco SAS HBA: Subsystem ID: 0x%X\n",
3746
- ioc->name, ioc->pdev->subsystem_device);
4299
+ ioc_info(ioc, "Cisco SAS HBA: Subsystem ID: 0x%X\n",
4300
+ ioc->pdev->subsystem_device);
37474301 break;
37484302 }
37494303 break;
....@@ -3752,43 +4306,42 @@
37524306 case MPI2_MFGPAGE_DEVID_SAS2004:
37534307 switch (ioc->pdev->subsystem_device) {
37544308 case MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_SSDID:
3755
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3756
- MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING);
4309
+ ioc_info(ioc, "%s\n",
4310
+ MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING);
37574311 break;
37584312 default:
3759
- pr_info(MPT3SAS_FMT
3760
- "HP 6Gbps SAS HBA: Subsystem ID: 0x%X\n",
3761
- ioc->name, ioc->pdev->subsystem_device);
4313
+ ioc_info(ioc, "HP 6Gbps SAS HBA: Subsystem ID: 0x%X\n",
4314
+ ioc->pdev->subsystem_device);
37624315 break;
37634316 }
4317
+ break;
37644318 case MPI2_MFGPAGE_DEVID_SAS2308_2:
37654319 switch (ioc->pdev->subsystem_device) {
37664320 case MPT2SAS_HP_2_4_INTERNAL_SSDID:
3767
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3768
- MPT2SAS_HP_2_4_INTERNAL_BRANDING);
4321
+ ioc_info(ioc, "%s\n",
4322
+ MPT2SAS_HP_2_4_INTERNAL_BRANDING);
37694323 break;
37704324 case MPT2SAS_HP_2_4_EXTERNAL_SSDID:
3771
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3772
- MPT2SAS_HP_2_4_EXTERNAL_BRANDING);
4325
+ ioc_info(ioc, "%s\n",
4326
+ MPT2SAS_HP_2_4_EXTERNAL_BRANDING);
37734327 break;
37744328 case MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_SSDID:
3775
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3776
- MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING);
4329
+ ioc_info(ioc, "%s\n",
4330
+ MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING);
37774331 break;
37784332 case MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_SSDID:
3779
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3780
- MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING);
4333
+ ioc_info(ioc, "%s\n",
4334
+ MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING);
37814335 break;
37824336 default:
3783
- pr_info(MPT3SAS_FMT
3784
- "HP 6Gbps SAS HBA: Subsystem ID: 0x%X\n",
3785
- ioc->name, ioc->pdev->subsystem_device);
4337
+ ioc_info(ioc, "HP 6Gbps SAS HBA: Subsystem ID: 0x%X\n",
4338
+ ioc->pdev->subsystem_device);
37864339 break;
37874340 }
4341
+ break;
37884342 default:
3789
- pr_info(MPT3SAS_FMT
3790
- "HP SAS HBA: Subsystem ID: 0x%X\n",
3791
- ioc->name, ioc->pdev->subsystem_device);
4343
+ ioc_info(ioc, "HP SAS HBA: Subsystem ID: 0x%X\n",
4344
+ ioc->pdev->subsystem_device);
37924345 break;
37934346 }
37944347 default:
....@@ -3806,37 +4359,37 @@
38064359 static int
38074360 _base_display_fwpkg_version(struct MPT3SAS_ADAPTER *ioc)
38084361 {
3809
- Mpi2FWImageHeader_t *FWImgHdr;
4362
+ Mpi2FWImageHeader_t *fw_img_hdr;
4363
+ Mpi26ComponentImageHeader_t *cmp_img_hdr;
38104364 Mpi25FWUploadRequest_t *mpi_request;
38114365 Mpi2FWUploadReply_t mpi_reply;
38124366 int r = 0;
4367
+ u32 package_version = 0;
38134368 void *fwpkg_data = NULL;
38144369 dma_addr_t fwpkg_data_dma;
38154370 u16 smid, ioc_status;
38164371 size_t data_length;
38174372
3818
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3819
- __func__));
4373
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
38204374
38214375 if (ioc->base_cmds.status & MPT3_CMD_PENDING) {
3822
- pr_err(MPT3SAS_FMT "%s: internal command already in use\n",
3823
- ioc->name, __func__);
4376
+ ioc_err(ioc, "%s: internal command already in use\n", __func__);
38244377 return -EAGAIN;
38254378 }
38264379
38274380 data_length = sizeof(Mpi2FWImageHeader_t);
3828
- fwpkg_data = pci_alloc_consistent(ioc->pdev, data_length,
3829
- &fwpkg_data_dma);
4381
+ fwpkg_data = dma_alloc_coherent(&ioc->pdev->dev, data_length,
4382
+ &fwpkg_data_dma, GFP_KERNEL);
38304383 if (!fwpkg_data) {
3831
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
3832
- ioc->name, __FILE__, __LINE__, __func__);
4384
+ ioc_err(ioc,
4385
+ "Memory allocation for fwpkg data failed at %s:%d/%s()!\n",
4386
+ __FILE__, __LINE__, __func__);
38334387 return -ENOMEM;
38344388 }
38354389
38364390 smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx);
38374391 if (!smid) {
3838
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
3839
- ioc->name, __func__);
4392
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
38404393 r = -EAGAIN;
38414394 goto out;
38424395 }
....@@ -3851,15 +4404,13 @@
38514404 ioc->build_sg(ioc, &mpi_request->SGL, 0, 0, fwpkg_data_dma,
38524405 data_length);
38534406 init_completion(&ioc->base_cmds.done);
3854
- mpt3sas_base_put_smid_default(ioc, smid);
4407
+ ioc->put_smid_default(ioc, smid);
38554408 /* Wait for 15 seconds */
38564409 wait_for_completion_timeout(&ioc->base_cmds.done,
38574410 FW_IMG_HDR_READ_TIMEOUT*HZ);
3858
- pr_info(MPT3SAS_FMT "%s: complete\n",
3859
- ioc->name, __func__);
4411
+ ioc_info(ioc, "%s: complete\n", __func__);
38604412 if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) {
3861
- pr_err(MPT3SAS_FMT "%s: timeout\n",
3862
- ioc->name, __func__);
4413
+ ioc_err(ioc, "%s: timeout\n", __func__);
38634414 _debug_dump_mf(mpi_request,
38644415 sizeof(Mpi25FWUploadRequest_t)/4);
38654416 r = -ETIME;
....@@ -3871,16 +4422,26 @@
38714422 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
38724423 MPI2_IOCSTATUS_MASK;
38734424 if (ioc_status == MPI2_IOCSTATUS_SUCCESS) {
3874
- FWImgHdr = (Mpi2FWImageHeader_t *)fwpkg_data;
3875
- if (FWImgHdr->PackageVersion.Word) {
3876
- pr_info(MPT3SAS_FMT "FW Package Version"
3877
- "(%02d.%02d.%02d.%02d)\n",
3878
- ioc->name,
3879
- FWImgHdr->PackageVersion.Struct.Major,
3880
- FWImgHdr->PackageVersion.Struct.Minor,
3881
- FWImgHdr->PackageVersion.Struct.Unit,
3882
- FWImgHdr->PackageVersion.Struct.Dev);
3883
- }
4425
+ fw_img_hdr = (Mpi2FWImageHeader_t *)fwpkg_data;
4426
+ if (le32_to_cpu(fw_img_hdr->Signature) ==
4427
+ MPI26_IMAGE_HEADER_SIGNATURE0_MPI26) {
4428
+ cmp_img_hdr =
4429
+ (Mpi26ComponentImageHeader_t *)
4430
+ (fwpkg_data);
4431
+ package_version =
4432
+ le32_to_cpu(
4433
+ cmp_img_hdr->ApplicationSpecific);
4434
+ } else
4435
+ package_version =
4436
+ le32_to_cpu(
4437
+ fw_img_hdr->PackageVersion.Word);
4438
+ if (package_version)
4439
+ ioc_info(ioc,
4440
+ "FW Package Ver(%02d.%02d.%02d.%02d)\n",
4441
+ ((package_version) & 0xFF000000) >> 24,
4442
+ ((package_version) & 0x00FF0000) >> 16,
4443
+ ((package_version) & 0x0000FF00) >> 8,
4444
+ (package_version) & 0x000000FF);
38844445 } else {
38854446 _debug_dump_mf(&mpi_reply,
38864447 sizeof(Mpi2FWUploadReply_t)/4);
....@@ -3890,7 +4451,7 @@
38904451 ioc->base_cmds.status = MPT3_CMD_NOT_USED;
38914452 out:
38924453 if (fwpkg_data)
3893
- pci_free_consistent(ioc->pdev, data_length, fwpkg_data,
4454
+ dma_free_coherent(&ioc->pdev->dev, data_length, fwpkg_data,
38944455 fwpkg_data_dma);
38954456 return r;
38964457 }
....@@ -3909,18 +4470,17 @@
39094470
39104471 bios_version = le32_to_cpu(ioc->bios_pg3.BiosVersion);
39114472 strncpy(desc, ioc->manu_pg0.ChipName, 16);
3912
- pr_info(MPT3SAS_FMT "%s: FWVersion(%02d.%02d.%02d.%02d), "\
3913
- "ChipRevision(0x%02x), BiosVersion(%02d.%02d.%02d.%02d)\n",
3914
- ioc->name, desc,
3915
- (ioc->facts.FWVersion.Word & 0xFF000000) >> 24,
3916
- (ioc->facts.FWVersion.Word & 0x00FF0000) >> 16,
3917
- (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8,
3918
- ioc->facts.FWVersion.Word & 0x000000FF,
3919
- ioc->pdev->revision,
3920
- (bios_version & 0xFF000000) >> 24,
3921
- (bios_version & 0x00FF0000) >> 16,
3922
- (bios_version & 0x0000FF00) >> 8,
3923
- bios_version & 0x000000FF);
4473
+ ioc_info(ioc, "%s: FWVersion(%02d.%02d.%02d.%02d), ChipRevision(0x%02x), BiosVersion(%02d.%02d.%02d.%02d)\n",
4474
+ desc,
4475
+ (ioc->facts.FWVersion.Word & 0xFF000000) >> 24,
4476
+ (ioc->facts.FWVersion.Word & 0x00FF0000) >> 16,
4477
+ (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8,
4478
+ ioc->facts.FWVersion.Word & 0x000000FF,
4479
+ ioc->pdev->revision,
4480
+ (bios_version & 0xFF000000) >> 24,
4481
+ (bios_version & 0x00FF0000) >> 16,
4482
+ (bios_version & 0x0000FF00) >> 8,
4483
+ bios_version & 0x000000FF);
39244484
39254485 _base_display_OEMs_branding(ioc);
39264486
....@@ -3929,82 +4489,81 @@
39294489 i++;
39304490 }
39314491
3932
- pr_info(MPT3SAS_FMT "Protocol=(", ioc->name);
4492
+ ioc_info(ioc, "Protocol=(");
39334493
39344494 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR) {
3935
- pr_info("Initiator");
4495
+ pr_cont("Initiator");
39364496 i++;
39374497 }
39384498
39394499 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_TARGET) {
3940
- pr_info("%sTarget", i ? "," : "");
4500
+ pr_cont("%sTarget", i ? "," : "");
39414501 i++;
39424502 }
39434503
39444504 i = 0;
3945
- pr_info("), ");
3946
- pr_info("Capabilities=(");
4505
+ pr_cont("), Capabilities=(");
39474506
39484507 if (!ioc->hide_ir_msg) {
39494508 if (ioc->facts.IOCCapabilities &
39504509 MPI2_IOCFACTS_CAPABILITY_INTEGRATED_RAID) {
3951
- pr_info("Raid");
4510
+ pr_cont("Raid");
39524511 i++;
39534512 }
39544513 }
39554514
39564515 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR) {
3957
- pr_info("%sTLR", i ? "," : "");
4516
+ pr_cont("%sTLR", i ? "," : "");
39584517 i++;
39594518 }
39604519
39614520 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_MULTICAST) {
3962
- pr_info("%sMulticast", i ? "," : "");
4521
+ pr_cont("%sMulticast", i ? "," : "");
39634522 i++;
39644523 }
39654524
39664525 if (ioc->facts.IOCCapabilities &
39674526 MPI2_IOCFACTS_CAPABILITY_BIDIRECTIONAL_TARGET) {
3968
- pr_info("%sBIDI Target", i ? "," : "");
4527
+ pr_cont("%sBIDI Target", i ? "," : "");
39694528 i++;
39704529 }
39714530
39724531 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_EEDP) {
3973
- pr_info("%sEEDP", i ? "," : "");
4532
+ pr_cont("%sEEDP", i ? "," : "");
39744533 i++;
39754534 }
39764535
39774536 if (ioc->facts.IOCCapabilities &
39784537 MPI2_IOCFACTS_CAPABILITY_SNAPSHOT_BUFFER) {
3979
- pr_info("%sSnapshot Buffer", i ? "," : "");
4538
+ pr_cont("%sSnapshot Buffer", i ? "," : "");
39804539 i++;
39814540 }
39824541
39834542 if (ioc->facts.IOCCapabilities &
39844543 MPI2_IOCFACTS_CAPABILITY_DIAG_TRACE_BUFFER) {
3985
- pr_info("%sDiag Trace Buffer", i ? "," : "");
4544
+ pr_cont("%sDiag Trace Buffer", i ? "," : "");
39864545 i++;
39874546 }
39884547
39894548 if (ioc->facts.IOCCapabilities &
39904549 MPI2_IOCFACTS_CAPABILITY_EXTENDED_BUFFER) {
3991
- pr_info("%sDiag Extended Buffer", i ? "," : "");
4550
+ pr_cont("%sDiag Extended Buffer", i ? "," : "");
39924551 i++;
39934552 }
39944553
39954554 if (ioc->facts.IOCCapabilities &
39964555 MPI2_IOCFACTS_CAPABILITY_TASK_SET_FULL_HANDLING) {
3997
- pr_info("%sTask Set Full", i ? "," : "");
4556
+ pr_cont("%sTask Set Full", i ? "," : "");
39984557 i++;
39994558 }
40004559
40014560 iounit_pg1_flags = le32_to_cpu(ioc->iounit_pg1.Flags);
40024561 if (!(iounit_pg1_flags & MPI2_IOUNITPAGE1_NATIVE_COMMAND_Q_DISABLE)) {
4003
- pr_info("%sNCQ", i ? "," : "");
4562
+ pr_cont("%sNCQ", i ? "," : "");
40044563 i++;
40054564 }
40064565
4007
- pr_info(")\n");
4566
+ pr_cont(")\n");
40084567 }
40094568
40104569 /**
....@@ -4037,21 +4596,21 @@
40374596 sizeof(Mpi2SasIOUnit1PhyData_t));
40384597 sas_iounit_pg1 = kzalloc(sz, GFP_KERNEL);
40394598 if (!sas_iounit_pg1) {
4040
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
4041
- ioc->name, __FILE__, __LINE__, __func__);
4599
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
4600
+ __FILE__, __LINE__, __func__);
40424601 goto out;
40434602 }
40444603 if ((mpt3sas_config_get_sas_iounit_pg1(ioc, &mpi_reply,
40454604 sas_iounit_pg1, sz))) {
4046
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
4047
- ioc->name, __FILE__, __LINE__, __func__);
4605
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
4606
+ __FILE__, __LINE__, __func__);
40484607 goto out;
40494608 }
40504609 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
40514610 MPI2_IOCSTATUS_MASK;
40524611 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
4053
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
4054
- ioc->name, __FILE__, __LINE__, __func__);
4612
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
4613
+ __FILE__, __LINE__, __func__);
40554614 goto out;
40564615 }
40574616
....@@ -4083,17 +4642,82 @@
40834642 else
40844643 dmd_new =
40854644 dmd & MPI2_SASIOUNIT1_REPORT_MISSING_TIMEOUT_MASK;
4086
- pr_info(MPT3SAS_FMT "device_missing_delay: old(%d), new(%d)\n",
4087
- ioc->name, dmd_orignal, dmd_new);
4088
- pr_info(MPT3SAS_FMT "ioc_missing_delay: old(%d), new(%d)\n",
4089
- ioc->name, io_missing_delay_original,
4090
- io_missing_delay);
4645
+ ioc_info(ioc, "device_missing_delay: old(%d), new(%d)\n",
4646
+ dmd_orignal, dmd_new);
4647
+ ioc_info(ioc, "ioc_missing_delay: old(%d), new(%d)\n",
4648
+ io_missing_delay_original,
4649
+ io_missing_delay);
40914650 ioc->device_missing_delay = dmd_new;
40924651 ioc->io_missing_delay = io_missing_delay;
40934652 }
40944653
40954654 out:
40964655 kfree(sas_iounit_pg1);
4656
+}
4657
+
4658
+/**
4659
+ * _base_update_ioc_page1_inlinewith_perf_mode - Update IOC Page1 fields
4660
+ * according to performance mode.
4661
+ * @ioc : per adapter object
4662
+ *
4663
+ * Return nothing.
4664
+ */
4665
+static void
4666
+_base_update_ioc_page1_inlinewith_perf_mode(struct MPT3SAS_ADAPTER *ioc)
4667
+{
4668
+ Mpi2IOCPage1_t ioc_pg1;
4669
+ Mpi2ConfigReply_t mpi_reply;
4670
+
4671
+ mpt3sas_config_get_ioc_pg1(ioc, &mpi_reply, &ioc->ioc_pg1_copy);
4672
+ memcpy(&ioc_pg1, &ioc->ioc_pg1_copy, sizeof(Mpi2IOCPage1_t));
4673
+
4674
+ switch (perf_mode) {
4675
+ case MPT_PERF_MODE_DEFAULT:
4676
+ case MPT_PERF_MODE_BALANCED:
4677
+ if (ioc->high_iops_queues) {
4678
+ ioc_info(ioc,
4679
+ "Enable interrupt coalescing only for first\t"
4680
+ "%d reply queues\n",
4681
+ MPT3SAS_HIGH_IOPS_REPLY_QUEUES);
4682
+ /*
4683
+ * If 31st bit is zero then interrupt coalescing is
4684
+ * enabled for all reply descriptor post queues.
4685
+ * If 31st bit is set to one then user can
4686
+ * enable/disable interrupt coalescing on per reply
4687
+ * descriptor post queue group(8) basis. So to enable
4688
+ * interrupt coalescing only on first reply descriptor
4689
+ * post queue group 31st bit and zero th bit is enabled.
4690
+ */
4691
+ ioc_pg1.ProductSpecific = cpu_to_le32(0x80000000 |
4692
+ ((1 << MPT3SAS_HIGH_IOPS_REPLY_QUEUES/8) - 1));
4693
+ mpt3sas_config_set_ioc_pg1(ioc, &mpi_reply, &ioc_pg1);
4694
+ ioc_info(ioc, "performance mode: balanced\n");
4695
+ return;
4696
+ }
4697
+ fallthrough;
4698
+ case MPT_PERF_MODE_LATENCY:
4699
+ /*
4700
+ * Enable interrupt coalescing on all reply queues
4701
+ * with timeout value 0xA
4702
+ */
4703
+ ioc_pg1.CoalescingTimeout = cpu_to_le32(0xa);
4704
+ ioc_pg1.Flags |= cpu_to_le32(MPI2_IOCPAGE1_REPLY_COALESCING);
4705
+ ioc_pg1.ProductSpecific = 0;
4706
+ mpt3sas_config_set_ioc_pg1(ioc, &mpi_reply, &ioc_pg1);
4707
+ ioc_info(ioc, "performance mode: latency\n");
4708
+ break;
4709
+ case MPT_PERF_MODE_IOPS:
4710
+ /*
4711
+ * Enable interrupt coalescing on all reply queues.
4712
+ */
4713
+ ioc_info(ioc,
4714
+ "performance mode: iops with coalescing timeout: 0x%x\n",
4715
+ le32_to_cpu(ioc_pg1.CoalescingTimeout));
4716
+ ioc_pg1.Flags |= cpu_to_le32(MPI2_IOCPAGE1_REPLY_COALESCING);
4717
+ ioc_pg1.ProductSpecific = 0;
4718
+ mpt3sas_config_set_ioc_pg1(ioc, &mpi_reply, &ioc_pg1);
4719
+ break;
4720
+ }
40974721 }
40984722
40994723 /**
....@@ -4163,6 +4787,8 @@
41634787
41644788 if (ioc->iounit_pg8.NumSensors)
41654789 ioc->temp_sensors_count = ioc->iounit_pg8.NumSensors;
4790
+ if (ioc->is_aero_ioc)
4791
+ _base_update_ioc_page1_inlinewith_perf_mode(ioc);
41664792 }
41674793
41684794 /**
....@@ -4195,36 +4821,36 @@
41954821 {
41964822 int i = 0;
41974823 int j = 0;
4824
+ int dma_alloc_count = 0;
41984825 struct chain_tracker *ct;
4199
- struct reply_post_struct *rps;
4826
+ int count = ioc->rdpq_array_enable ? ioc->reply_queue_count : 1;
42004827
4201
- dexitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
4202
- __func__));
4828
+ dexitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
42034829
42044830 if (ioc->request) {
4205
- pci_free_consistent(ioc->pdev, ioc->request_dma_sz,
4831
+ dma_free_coherent(&ioc->pdev->dev, ioc->request_dma_sz,
42064832 ioc->request, ioc->request_dma);
4207
- dexitprintk(ioc, pr_info(MPT3SAS_FMT
4208
- "request_pool(0x%p): free\n",
4209
- ioc->name, ioc->request));
4833
+ dexitprintk(ioc,
4834
+ ioc_info(ioc, "request_pool(0x%p): free\n",
4835
+ ioc->request));
42104836 ioc->request = NULL;
42114837 }
42124838
42134839 if (ioc->sense) {
42144840 dma_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma);
42154841 dma_pool_destroy(ioc->sense_dma_pool);
4216
- dexitprintk(ioc, pr_info(MPT3SAS_FMT
4217
- "sense_pool(0x%p): free\n",
4218
- ioc->name, ioc->sense));
4842
+ dexitprintk(ioc,
4843
+ ioc_info(ioc, "sense_pool(0x%p): free\n",
4844
+ ioc->sense));
42194845 ioc->sense = NULL;
42204846 }
42214847
42224848 if (ioc->reply) {
42234849 dma_pool_free(ioc->reply_dma_pool, ioc->reply, ioc->reply_dma);
42244850 dma_pool_destroy(ioc->reply_dma_pool);
4225
- dexitprintk(ioc, pr_info(MPT3SAS_FMT
4226
- "reply_pool(0x%p): free\n",
4227
- ioc->name, ioc->reply));
4851
+ dexitprintk(ioc,
4852
+ ioc_info(ioc, "reply_pool(0x%p): free\n",
4853
+ ioc->reply));
42284854 ioc->reply = NULL;
42294855 }
42304856
....@@ -4232,36 +4858,41 @@
42324858 dma_pool_free(ioc->reply_free_dma_pool, ioc->reply_free,
42334859 ioc->reply_free_dma);
42344860 dma_pool_destroy(ioc->reply_free_dma_pool);
4235
- dexitprintk(ioc, pr_info(MPT3SAS_FMT
4236
- "reply_free_pool(0x%p): free\n",
4237
- ioc->name, ioc->reply_free));
4861
+ dexitprintk(ioc,
4862
+ ioc_info(ioc, "reply_free_pool(0x%p): free\n",
4863
+ ioc->reply_free));
42384864 ioc->reply_free = NULL;
42394865 }
42404866
42414867 if (ioc->reply_post) {
4242
- do {
4243
- rps = &ioc->reply_post[i];
4244
- if (rps->reply_post_free) {
4245
- dma_pool_free(
4246
- ioc->reply_post_free_dma_pool,
4247
- rps->reply_post_free,
4248
- rps->reply_post_free_dma);
4249
- dexitprintk(ioc, pr_info(MPT3SAS_FMT
4250
- "reply_post_free_pool(0x%p): free\n",
4251
- ioc->name, rps->reply_post_free));
4252
- rps->reply_post_free = NULL;
4868
+ dma_alloc_count = DIV_ROUND_UP(count,
4869
+ RDPQ_MAX_INDEX_IN_ONE_CHUNK);
4870
+ for (i = 0; i < count; i++) {
4871
+ if (i % RDPQ_MAX_INDEX_IN_ONE_CHUNK == 0
4872
+ && dma_alloc_count) {
4873
+ if (ioc->reply_post[i].reply_post_free) {
4874
+ dma_pool_free(
4875
+ ioc->reply_post_free_dma_pool,
4876
+ ioc->reply_post[i].reply_post_free,
4877
+ ioc->reply_post[i].reply_post_free_dma);
4878
+ dexitprintk(ioc, ioc_info(ioc,
4879
+ "reply_post_free_pool(0x%p): free\n",
4880
+ ioc->reply_post[i].reply_post_free));
4881
+ ioc->reply_post[i].reply_post_free =
4882
+ NULL;
4883
+ }
4884
+ --dma_alloc_count;
42534885 }
4254
- } while (ioc->rdpq_array_enable &&
4255
- (++i < ioc->reply_queue_count));
4886
+ }
4887
+ dma_pool_destroy(ioc->reply_post_free_dma_pool);
42564888 if (ioc->reply_post_free_array &&
42574889 ioc->rdpq_array_enable) {
42584890 dma_pool_free(ioc->reply_post_free_array_dma_pool,
4259
- ioc->reply_post_free_array,
4260
- ioc->reply_post_free_array_dma);
4891
+ ioc->reply_post_free_array,
4892
+ ioc->reply_post_free_array_dma);
42614893 ioc->reply_post_free_array = NULL;
42624894 }
42634895 dma_pool_destroy(ioc->reply_post_free_array_dma_pool);
4264
- dma_pool_destroy(ioc->reply_post_free_dma_pool);
42654896 kfree(ioc->reply_post);
42664897 }
42674898
....@@ -4270,16 +4901,15 @@
42704901 dma_pool_free(ioc->pcie_sgl_dma_pool,
42714902 ioc->pcie_sg_lookup[i].pcie_sgl,
42724903 ioc->pcie_sg_lookup[i].pcie_sgl_dma);
4904
+ ioc->pcie_sg_lookup[i].pcie_sgl = NULL;
42734905 }
4274
- if (ioc->pcie_sgl_dma_pool)
4275
- dma_pool_destroy(ioc->pcie_sgl_dma_pool);
4906
+ dma_pool_destroy(ioc->pcie_sgl_dma_pool);
42764907 }
4277
-
42784908 if (ioc->config_page) {
4279
- dexitprintk(ioc, pr_info(MPT3SAS_FMT
4280
- "config_page(0x%p): free\n", ioc->name,
4281
- ioc->config_page));
4282
- pci_free_consistent(ioc->pdev, ioc->config_page_sz,
4909
+ dexitprintk(ioc,
4910
+ ioc_info(ioc, "config_page(0x%p): free\n",
4911
+ ioc->config_page));
4912
+ dma_free_coherent(&ioc->pdev->dev, ioc->config_page_sz,
42834913 ioc->config_page, ioc->config_page_dma);
42844914 }
42854915
....@@ -4306,7 +4936,7 @@
43064936 }
43074937
43084938 /**
4309
- * is_MSB_are_same - checks whether all reply queues in a set are
4939
+ * mpt3sas_check_same_4gb_region - checks whether all reply queues in a set are
43104940 * having same upper 32bits in their base memory address.
43114941 * @reply_pool_start_address: Base address of a reply queue set
43124942 * @pool_sz: Size of single Reply Descriptor Post Queues pool size
....@@ -4316,7 +4946,7 @@
43164946 */
43174947
43184948 static int
4319
-is_MSB_are_same(long reply_pool_start_address, u32 pool_sz)
4949
+mpt3sas_check_same_4gb_region(long reply_pool_start_address, u32 pool_sz)
43204950 {
43214951 long reply_pool_end_address;
43224952
....@@ -4327,6 +4957,168 @@
43274957 return 1;
43284958 else
43294959 return 0;
4960
+}
4961
+
4962
+/**
4963
+ * _base_reduce_hba_queue_depth- Retry with reduced queue depth
4964
+ * @ioc: Adapter object
4965
+ *
4966
+ * Return: 0 for success, non-zero for failure.
4967
+ **/
4968
+static inline int
4969
+_base_reduce_hba_queue_depth(struct MPT3SAS_ADAPTER *ioc)
4970
+{
4971
+ int reduce_sz = 64;
4972
+
4973
+ if ((ioc->hba_queue_depth - reduce_sz) >
4974
+ (ioc->internal_depth + INTERNAL_SCSIIO_CMDS_COUNT)) {
4975
+ ioc->hba_queue_depth -= reduce_sz;
4976
+ return 0;
4977
+ } else
4978
+ return -ENOMEM;
4979
+}
4980
+
4981
+/**
4982
+ * _base_allocate_pcie_sgl_pool - Allocating DMA'able memory
4983
+ * for pcie sgl pools.
4984
+ * @ioc: Adapter object
4985
+ * @sz: DMA Pool size
4986
+ * @ct: Chain tracker
4987
+ * Return: 0 for success, non-zero for failure.
4988
+ */
4989
+
4990
+static int
4991
+_base_allocate_pcie_sgl_pool(struct MPT3SAS_ADAPTER *ioc, u32 sz)
4992
+{
4993
+ int i = 0, j = 0;
4994
+ struct chain_tracker *ct;
4995
+
4996
+ ioc->pcie_sgl_dma_pool =
4997
+ dma_pool_create("PCIe SGL pool", &ioc->pdev->dev, sz,
4998
+ ioc->page_size, 0);
4999
+ if (!ioc->pcie_sgl_dma_pool) {
5000
+ ioc_err(ioc, "PCIe SGL pool: dma_pool_create failed\n");
5001
+ return -ENOMEM;
5002
+ }
5003
+
5004
+ ioc->chains_per_prp_buffer = sz/ioc->chain_segment_sz;
5005
+ ioc->chains_per_prp_buffer =
5006
+ min(ioc->chains_per_prp_buffer, ioc->chains_needed_per_io);
5007
+ for (i = 0; i < ioc->scsiio_depth; i++) {
5008
+ ioc->pcie_sg_lookup[i].pcie_sgl =
5009
+ dma_pool_alloc(ioc->pcie_sgl_dma_pool, GFP_KERNEL,
5010
+ &ioc->pcie_sg_lookup[i].pcie_sgl_dma);
5011
+ if (!ioc->pcie_sg_lookup[i].pcie_sgl) {
5012
+ ioc_err(ioc, "PCIe SGL pool: dma_pool_alloc failed\n");
5013
+ return -EAGAIN;
5014
+ }
5015
+
5016
+ if (!mpt3sas_check_same_4gb_region(
5017
+ (long)ioc->pcie_sg_lookup[i].pcie_sgl, sz)) {
5018
+ ioc_err(ioc, "PCIE SGLs are not in same 4G !! pcie sgl (0x%p) dma = (0x%llx)\n",
5019
+ ioc->pcie_sg_lookup[i].pcie_sgl,
5020
+ (unsigned long long)
5021
+ ioc->pcie_sg_lookup[i].pcie_sgl_dma);
5022
+ ioc->use_32bit_dma = true;
5023
+ return -EAGAIN;
5024
+ }
5025
+
5026
+ for (j = 0; j < ioc->chains_per_prp_buffer; j++) {
5027
+ ct = &ioc->chain_lookup[i].chains_per_smid[j];
5028
+ ct->chain_buffer =
5029
+ ioc->pcie_sg_lookup[i].pcie_sgl +
5030
+ (j * ioc->chain_segment_sz);
5031
+ ct->chain_buffer_dma =
5032
+ ioc->pcie_sg_lookup[i].pcie_sgl_dma +
5033
+ (j * ioc->chain_segment_sz);
5034
+ }
5035
+ }
5036
+ dinitprintk(ioc, ioc_info(ioc,
5037
+ "PCIe sgl pool depth(%d), element_size(%d), pool_size(%d kB)\n",
5038
+ ioc->scsiio_depth, sz, (sz * ioc->scsiio_depth)/1024));
5039
+ dinitprintk(ioc, ioc_info(ioc,
5040
+ "Number of chains can fit in a PRP page(%d)\n",
5041
+ ioc->chains_per_prp_buffer));
5042
+ return 0;
5043
+}
5044
+
5045
+/**
5046
+ * base_alloc_rdpq_dma_pool - Allocating DMA'able memory
5047
+ * for reply queues.
5048
+ * @ioc: per adapter object
5049
+ * @sz: DMA Pool size
5050
+ * Return: 0 for success, non-zero for failure.
5051
+ */
5052
+static int
5053
+base_alloc_rdpq_dma_pool(struct MPT3SAS_ADAPTER *ioc, int sz)
5054
+{
5055
+ int i = 0;
5056
+ u32 dma_alloc_count = 0;
5057
+ int reply_post_free_sz = ioc->reply_post_queue_depth *
5058
+ sizeof(Mpi2DefaultReplyDescriptor_t);
5059
+ int count = ioc->rdpq_array_enable ? ioc->reply_queue_count : 1;
5060
+
5061
+ ioc->reply_post = kcalloc(count, sizeof(struct reply_post_struct),
5062
+ GFP_KERNEL);
5063
+ if (!ioc->reply_post)
5064
+ return -ENOMEM;
5065
+ /*
5066
+ * For INVADER_SERIES each set of 8 reply queues(0-7, 8-15, ..) and
5067
+ * VENTURA_SERIES each set of 16 reply queues(0-15, 16-31, ..) should
5068
+ * be within 4GB boundary i.e reply queues in a set must have same
5069
+ * upper 32-bits in their memory address. so here driver is allocating
5070
+ * the DMA'able memory for reply queues according.
5071
+ * Driver uses limitation of
5072
+ * VENTURA_SERIES to manage INVADER_SERIES as well.
5073
+ */
5074
+ dma_alloc_count = DIV_ROUND_UP(count,
5075
+ RDPQ_MAX_INDEX_IN_ONE_CHUNK);
5076
+ ioc->reply_post_free_dma_pool =
5077
+ dma_pool_create("reply_post_free pool",
5078
+ &ioc->pdev->dev, sz, 16, 0);
5079
+ if (!ioc->reply_post_free_dma_pool)
5080
+ return -ENOMEM;
5081
+ for (i = 0; i < count; i++) {
5082
+ if ((i % RDPQ_MAX_INDEX_IN_ONE_CHUNK == 0) && dma_alloc_count) {
5083
+ ioc->reply_post[i].reply_post_free =
5084
+ dma_pool_zalloc(ioc->reply_post_free_dma_pool,
5085
+ GFP_KERNEL,
5086
+ &ioc->reply_post[i].reply_post_free_dma);
5087
+ if (!ioc->reply_post[i].reply_post_free)
5088
+ return -ENOMEM;
5089
+ /*
5090
+ * Each set of RDPQ pool must satisfy 4gb boundary
5091
+ * restriction.
5092
+ * 1) Check if allocated resources for RDPQ pool are in
5093
+ * the same 4GB range.
5094
+ * 2) If #1 is true, continue with 64 bit DMA.
5095
+ * 3) If #1 is false, return 1. which means free all the
5096
+ * resources and set DMA mask to 32 and allocate.
5097
+ */
5098
+ if (!mpt3sas_check_same_4gb_region(
5099
+ (long)ioc->reply_post[i].reply_post_free, sz)) {
5100
+ dinitprintk(ioc,
5101
+ ioc_err(ioc, "bad Replypost free pool(0x%p)"
5102
+ "reply_post_free_dma = (0x%llx)\n",
5103
+ ioc->reply_post[i].reply_post_free,
5104
+ (unsigned long long)
5105
+ ioc->reply_post[i].reply_post_free_dma));
5106
+ return -EAGAIN;
5107
+ }
5108
+ dma_alloc_count--;
5109
+
5110
+ } else {
5111
+ ioc->reply_post[i].reply_post_free =
5112
+ (Mpi2ReplyDescriptorsUnion_t *)
5113
+ ((long)ioc->reply_post[i-1].reply_post_free
5114
+ + reply_post_free_sz);
5115
+ ioc->reply_post[i].reply_post_free_dma =
5116
+ (dma_addr_t)
5117
+ (ioc->reply_post[i-1].reply_post_free_dma +
5118
+ reply_post_free_sz);
5119
+ }
5120
+ }
5121
+ return 0;
43305122 }
43315123
43325124 /**
....@@ -4343,14 +5135,15 @@
43435135 u16 chains_needed_per_io;
43445136 u32 sz, total_sz, reply_post_free_sz, reply_post_free_array_sz;
43455137 u32 retry_sz;
5138
+ u32 rdpq_sz = 0;
43465139 u16 max_request_credit, nvme_blocks_needed;
43475140 unsigned short sg_tablesize;
43485141 u16 sge_size;
43495142 int i, j;
5143
+ int ret = 0, rc = 0;
43505144 struct chain_tracker *ct;
43515145
4352
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
4353
- __func__));
5146
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
43545147
43555148
43565149 retry_sz = 0;
....@@ -4379,10 +5172,8 @@
43795172 else if (sg_tablesize > MPT_MAX_PHYS_SEGMENTS) {
43805173 sg_tablesize = min_t(unsigned short, sg_tablesize,
43815174 SG_MAX_SEGMENTS);
4382
- pr_warn(MPT3SAS_FMT
4383
- "sg_tablesize(%u) is bigger than kernel "
4384
- "defined SG_CHUNK_SIZE(%u)\n", ioc->name,
4385
- sg_tablesize, MPT_MAX_PHYS_SEGMENTS);
5175
+ ioc_warn(ioc, "sg_tablesize(%u) is bigger than kernel defined SG_CHUNK_SIZE(%u)\n",
5176
+ sg_tablesize, MPT_MAX_PHYS_SEGMENTS);
43865177 }
43875178 ioc->shost->sg_tablesize = sg_tablesize;
43885179 }
....@@ -4392,9 +5183,8 @@
43925183 if (ioc->internal_depth < INTERNAL_CMDS_COUNT) {
43935184 if (facts->RequestCredit <= (INTERNAL_CMDS_COUNT +
43945185 INTERNAL_SCSIIO_CMDS_COUNT)) {
4395
- pr_err(MPT3SAS_FMT "IOC doesn't have enough Request \
4396
- Credits, it has just %d number of credits\n",
4397
- ioc->name, facts->RequestCredit);
5186
+ ioc_err(ioc, "IOC doesn't have enough Request Credits, it has just %d number of credits\n",
5187
+ facts->RequestCredit);
43985188 return -ENOMEM;
43995189 }
44005190 ioc->internal_depth = 10;
....@@ -4493,71 +5283,39 @@
44935283 ioc->reply_free_queue_depth = ioc->hba_queue_depth + 64;
44945284 }
44955285
4496
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "scatter gather: " \
4497
- "sge_in_main_msg(%d), sge_per_chain(%d), sge_per_io(%d), "
4498
- "chains_per_io(%d)\n", ioc->name, ioc->max_sges_in_main_message,
4499
- ioc->max_sges_in_chain_message, ioc->shost->sg_tablesize,
4500
- ioc->chains_needed_per_io));
5286
+ ioc_info(ioc,
5287
+ "scatter gather: sge_in_main_msg(%d), sge_per_chain(%d), "
5288
+ "sge_per_io(%d), chains_per_io(%d)\n",
5289
+ ioc->max_sges_in_main_message,
5290
+ ioc->max_sges_in_chain_message,
5291
+ ioc->shost->sg_tablesize,
5292
+ ioc->chains_needed_per_io);
45015293
45025294 /* reply post queue, 16 byte align */
45035295 reply_post_free_sz = ioc->reply_post_queue_depth *
45045296 sizeof(Mpi2DefaultReplyDescriptor_t);
4505
-
4506
- sz = reply_post_free_sz;
5297
+ rdpq_sz = reply_post_free_sz * RDPQ_MAX_INDEX_IN_ONE_CHUNK;
45075298 if (_base_is_controller_msix_enabled(ioc) && !ioc->rdpq_array_enable)
4508
- sz *= ioc->reply_queue_count;
4509
-
4510
- ioc->reply_post = kcalloc((ioc->rdpq_array_enable) ?
4511
- (ioc->reply_queue_count):1,
4512
- sizeof(struct reply_post_struct), GFP_KERNEL);
4513
-
4514
- if (!ioc->reply_post) {
4515
- pr_err(MPT3SAS_FMT "reply_post_free pool: kcalloc failed\n",
4516
- ioc->name);
4517
- goto out;
4518
- }
4519
- ioc->reply_post_free_dma_pool = dma_pool_create("reply_post_free pool",
4520
- &ioc->pdev->dev, sz, 16, 0);
4521
- if (!ioc->reply_post_free_dma_pool) {
4522
- pr_err(MPT3SAS_FMT
4523
- "reply_post_free pool: dma_pool_create failed\n",
4524
- ioc->name);
4525
- goto out;
4526
- }
4527
- i = 0;
4528
- do {
4529
- ioc->reply_post[i].reply_post_free =
4530
- dma_pool_alloc(ioc->reply_post_free_dma_pool,
4531
- GFP_KERNEL,
4532
- &ioc->reply_post[i].reply_post_free_dma);
4533
- if (!ioc->reply_post[i].reply_post_free) {
4534
- pr_err(MPT3SAS_FMT
4535
- "reply_post_free pool: dma_pool_alloc failed\n",
4536
- ioc->name);
4537
- goto out;
5299
+ rdpq_sz = reply_post_free_sz * ioc->reply_queue_count;
5300
+ ret = base_alloc_rdpq_dma_pool(ioc, rdpq_sz);
5301
+ if (ret == -EAGAIN) {
5302
+ /*
5303
+ * Free allocated bad RDPQ memory pools.
5304
+ * Change dma coherent mask to 32 bit and reallocate RDPQ
5305
+ */
5306
+ _base_release_memory_pools(ioc);
5307
+ ioc->use_32bit_dma = true;
5308
+ if (_base_config_dma_addressing(ioc, ioc->pdev) != 0) {
5309
+ ioc_err(ioc,
5310
+ "32 DMA mask failed %s\n", pci_name(ioc->pdev));
5311
+ return -ENODEV;
45385312 }
4539
- memset(ioc->reply_post[i].reply_post_free, 0, sz);
4540
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
4541
- "reply post free pool (0x%p): depth(%d),"
4542
- "element_size(%d), pool_size(%d kB)\n", ioc->name,
4543
- ioc->reply_post[i].reply_post_free,
4544
- ioc->reply_post_queue_depth, 8, sz/1024));
4545
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
4546
- "reply_post_free_dma = (0x%llx)\n", ioc->name,
4547
- (unsigned long long)
4548
- ioc->reply_post[i].reply_post_free_dma));
4549
- total_sz += sz;
4550
- } while (ioc->rdpq_array_enable && (++i < ioc->reply_queue_count));
4551
-
4552
- if (ioc->dma_mask > 32) {
4553
- if (_base_change_consistent_dma_mask(ioc, ioc->pdev) != 0) {
4554
- pr_warn(MPT3SAS_FMT
4555
- "no suitable consistent DMA mask for %s\n",
4556
- ioc->name, pci_name(ioc->pdev));
4557
- goto out;
4558
- }
4559
- }
4560
-
5313
+ if (base_alloc_rdpq_dma_pool(ioc, rdpq_sz))
5314
+ return -ENOMEM;
5315
+ } else if (ret == -ENOMEM)
5316
+ return -ENOMEM;
5317
+ total_sz = rdpq_sz * (!ioc->rdpq_array_enable ? 1 :
5318
+ DIV_ROUND_UP(ioc->reply_queue_count, RDPQ_MAX_INDEX_IN_ONE_CHUNK));
45615319 ioc->scsiio_depth = ioc->hba_queue_depth -
45625320 ioc->hi_priority_depth - ioc->internal_depth;
45635321
....@@ -4565,10 +5323,9 @@
45655323 * with some internal commands that could be outstanding
45665324 */
45675325 ioc->shost->can_queue = ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT;
4568
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
4569
- "scsi host: can_queue depth (%d)\n",
4570
- ioc->name, ioc->shost->can_queue));
4571
-
5326
+ dinitprintk(ioc,
5327
+ ioc_info(ioc, "scsi host: can_queue depth (%d)\n",
5328
+ ioc->shost->can_queue));
45725329
45735330 /* contiguous pool for request and chains, 16 byte align, one extra "
45745331 * "frame for smid=0
....@@ -4583,12 +5340,12 @@
45835340 sz += (ioc->internal_depth * ioc->request_sz);
45845341
45855342 ioc->request_dma_sz = sz;
4586
- ioc->request = pci_alloc_consistent(ioc->pdev, sz, &ioc->request_dma);
5343
+ ioc->request = dma_alloc_coherent(&ioc->pdev->dev, sz,
5344
+ &ioc->request_dma, GFP_KERNEL);
45875345 if (!ioc->request) {
4588
- pr_err(MPT3SAS_FMT "request pool: pci_alloc_consistent " \
4589
- "failed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), "
4590
- "total(%d kB)\n", ioc->name, ioc->hba_queue_depth,
4591
- ioc->chains_needed_per_io, ioc->request_sz, sz/1024);
5346
+ ioc_err(ioc, "request pool: dma_alloc_coherent failed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), total(%d kB)\n",
5347
+ ioc->hba_queue_depth, ioc->chains_needed_per_io,
5348
+ ioc->request_sz, sz / 1024);
45925349 if (ioc->scsiio_depth < MPT3SAS_SAS_QUEUE_DEPTH)
45935350 goto out;
45945351 retry_sz = 64;
....@@ -4598,10 +5355,9 @@
45985355 }
45995356
46005357 if (retry_sz)
4601
- pr_err(MPT3SAS_FMT "request pool: pci_alloc_consistent " \
4602
- "succeed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), "
4603
- "total(%d kb)\n", ioc->name, ioc->hba_queue_depth,
4604
- ioc->chains_needed_per_io, ioc->request_sz, sz/1024);
5358
+ ioc_err(ioc, "request pool: dma_alloc_coherent succeed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), total(%d kb)\n",
5359
+ ioc->hba_queue_depth, ioc->chains_needed_per_io,
5360
+ ioc->request_sz, sz / 1024);
46055361
46065362 /* hi-priority queue */
46075363 ioc->hi_priority = ioc->request + ((ioc->scsiio_depth + 1) *
....@@ -4615,24 +5371,24 @@
46155371 ioc->internal_dma = ioc->hi_priority_dma + (ioc->hi_priority_depth *
46165372 ioc->request_sz);
46175373
4618
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
4619
- "request pool(0x%p): depth(%d), frame_size(%d), pool_size(%d kB)\n",
4620
- ioc->name, ioc->request, ioc->hba_queue_depth, ioc->request_sz,
4621
- (ioc->hba_queue_depth * ioc->request_sz)/1024));
5374
+ ioc_info(ioc,
5375
+ "request pool(0x%p) - dma(0x%llx): "
5376
+ "depth(%d), frame_size(%d), pool_size(%d kB)\n",
5377
+ ioc->request, (unsigned long long) ioc->request_dma,
5378
+ ioc->hba_queue_depth, ioc->request_sz,
5379
+ (ioc->hba_queue_depth * ioc->request_sz) / 1024);
46225380
4623
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "request pool: dma(0x%llx)\n",
4624
- ioc->name, (unsigned long long) ioc->request_dma));
46255381 total_sz += sz;
46265382
4627
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "scsiio(0x%p): depth(%d)\n",
4628
- ioc->name, ioc->request, ioc->scsiio_depth));
5383
+ dinitprintk(ioc,
5384
+ ioc_info(ioc, "scsiio(0x%p): depth(%d)\n",
5385
+ ioc->request, ioc->scsiio_depth));
46295386
46305387 ioc->chain_depth = min_t(u32, ioc->chain_depth, MAX_CHAIN_DEPTH);
46315388 sz = ioc->scsiio_depth * sizeof(struct chain_lookup);
46325389 ioc->chain_lookup = kzalloc(sz, GFP_KERNEL);
46335390 if (!ioc->chain_lookup) {
4634
- pr_err(MPT3SAS_FMT "chain_lookup: __get_free_pages "
4635
- "failed\n", ioc->name);
5391
+ ioc_err(ioc, "chain_lookup: __get_free_pages failed\n");
46365392 goto out;
46375393 }
46385394
....@@ -4640,8 +5396,7 @@
46405396 for (i = 0; i < ioc->scsiio_depth; i++) {
46415397 ioc->chain_lookup[i].chains_per_smid = kzalloc(sz, GFP_KERNEL);
46425398 if (!ioc->chain_lookup[i].chains_per_smid) {
4643
- pr_err(MPT3SAS_FMT "chain_lookup: "
4644
- " kzalloc failed\n", ioc->name);
5399
+ ioc_err(ioc, "chain_lookup: kzalloc failed\n");
46455400 goto out;
46465401 }
46475402 }
....@@ -4650,29 +5405,27 @@
46505405 ioc->hpr_lookup = kcalloc(ioc->hi_priority_depth,
46515406 sizeof(struct request_tracker), GFP_KERNEL);
46525407 if (!ioc->hpr_lookup) {
4653
- pr_err(MPT3SAS_FMT "hpr_lookup: kcalloc failed\n",
4654
- ioc->name);
5408
+ ioc_err(ioc, "hpr_lookup: kcalloc failed\n");
46555409 goto out;
46565410 }
46575411 ioc->hi_priority_smid = ioc->scsiio_depth + 1;
4658
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
4659
- "hi_priority(0x%p): depth(%d), start smid(%d)\n",
4660
- ioc->name, ioc->hi_priority,
4661
- ioc->hi_priority_depth, ioc->hi_priority_smid));
5412
+ dinitprintk(ioc,
5413
+ ioc_info(ioc, "hi_priority(0x%p): depth(%d), start smid(%d)\n",
5414
+ ioc->hi_priority,
5415
+ ioc->hi_priority_depth, ioc->hi_priority_smid));
46625416
46635417 /* initialize internal queue smid's */
46645418 ioc->internal_lookup = kcalloc(ioc->internal_depth,
46655419 sizeof(struct request_tracker), GFP_KERNEL);
46665420 if (!ioc->internal_lookup) {
4667
- pr_err(MPT3SAS_FMT "internal_lookup: kcalloc failed\n",
4668
- ioc->name);
5421
+ ioc_err(ioc, "internal_lookup: kcalloc failed\n");
46695422 goto out;
46705423 }
46715424 ioc->internal_smid = ioc->hi_priority_smid + ioc->hi_priority_depth;
4672
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
4673
- "internal(0x%p): depth(%d), start smid(%d)\n",
4674
- ioc->name, ioc->internal,
4675
- ioc->internal_depth, ioc->internal_smid));
5425
+ dinitprintk(ioc,
5426
+ ioc_info(ioc, "internal(0x%p): depth(%d), start smid(%d)\n",
5427
+ ioc->internal,
5428
+ ioc->internal_depth, ioc->internal_smid));
46765429 /*
46775430 * The number of NVMe page sized blocks needed is:
46785431 * (((sg_tablesize * 8) - 1) / (page_size - 8)) + 1
....@@ -4686,6 +5439,7 @@
46865439 * be required for NVMe PRP's, only each set of NVMe blocks will be
46875440 * contiguous, so a new set is allocated for each possible I/O.
46885441 */
5442
+
46895443 ioc->chains_per_prp_buffer = 0;
46905444 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_NVME_DEVICES) {
46915445 nvme_blocks_needed =
....@@ -4696,59 +5450,22 @@
46965450 sz = sizeof(struct pcie_sg_list) * ioc->scsiio_depth;
46975451 ioc->pcie_sg_lookup = kzalloc(sz, GFP_KERNEL);
46985452 if (!ioc->pcie_sg_lookup) {
4699
- pr_info(MPT3SAS_FMT
4700
- "PCIe SGL lookup: kzalloc failed\n", ioc->name);
5453
+ ioc_info(ioc, "PCIe SGL lookup: kzalloc failed\n");
47015454 goto out;
47025455 }
47035456 sz = nvme_blocks_needed * ioc->page_size;
4704
- ioc->pcie_sgl_dma_pool =
4705
- dma_pool_create("PCIe SGL pool", &ioc->pdev->dev, sz, 16, 0);
4706
- if (!ioc->pcie_sgl_dma_pool) {
4707
- pr_info(MPT3SAS_FMT
4708
- "PCIe SGL pool: dma_pool_create failed\n",
4709
- ioc->name);
4710
- goto out;
4711
- }
4712
-
4713
- ioc->chains_per_prp_buffer = sz/ioc->chain_segment_sz;
4714
- ioc->chains_per_prp_buffer = min(ioc->chains_per_prp_buffer,
4715
- ioc->chains_needed_per_io);
4716
-
4717
- for (i = 0; i < ioc->scsiio_depth; i++) {
4718
- ioc->pcie_sg_lookup[i].pcie_sgl = dma_pool_alloc(
4719
- ioc->pcie_sgl_dma_pool, GFP_KERNEL,
4720
- &ioc->pcie_sg_lookup[i].pcie_sgl_dma);
4721
- if (!ioc->pcie_sg_lookup[i].pcie_sgl) {
4722
- pr_info(MPT3SAS_FMT
4723
- "PCIe SGL pool: dma_pool_alloc failed\n",
4724
- ioc->name);
4725
- goto out;
4726
- }
4727
- for (j = 0; j < ioc->chains_per_prp_buffer; j++) {
4728
- ct = &ioc->chain_lookup[i].chains_per_smid[j];
4729
- ct->chain_buffer =
4730
- ioc->pcie_sg_lookup[i].pcie_sgl +
4731
- (j * ioc->chain_segment_sz);
4732
- ct->chain_buffer_dma =
4733
- ioc->pcie_sg_lookup[i].pcie_sgl_dma +
4734
- (j * ioc->chain_segment_sz);
4735
- }
4736
- }
4737
-
4738
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "PCIe sgl pool depth(%d), "
4739
- "element_size(%d), pool_size(%d kB)\n", ioc->name,
4740
- ioc->scsiio_depth, sz, (sz * ioc->scsiio_depth)/1024));
4741
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "Number of chains can "
4742
- "fit in a PRP page(%d)\n", ioc->name,
4743
- ioc->chains_per_prp_buffer));
5457
+ rc = _base_allocate_pcie_sgl_pool(ioc, sz);
5458
+ if (rc == -ENOMEM)
5459
+ return -ENOMEM;
5460
+ else if (rc == -EAGAIN)
5461
+ goto try_32bit_dma;
47445462 total_sz += sz * ioc->scsiio_depth;
47455463 }
47465464
47475465 ioc->chain_dma_pool = dma_pool_create("chain pool", &ioc->pdev->dev,
47485466 ioc->chain_segment_sz, 16, 0);
47495467 if (!ioc->chain_dma_pool) {
4750
- pr_err(MPT3SAS_FMT "chain_dma_pool: dma_pool_create failed\n",
4751
- ioc->name);
5468
+ ioc_err(ioc, "chain_dma_pool: dma_pool_create failed\n");
47525469 goto out;
47535470 }
47545471 for (i = 0; i < ioc->scsiio_depth; i++) {
....@@ -4759,34 +5476,30 @@
47595476 ioc->chain_dma_pool, GFP_KERNEL,
47605477 &ct->chain_buffer_dma);
47615478 if (!ct->chain_buffer) {
4762
- pr_err(MPT3SAS_FMT "chain_lookup: "
4763
- " pci_pool_alloc failed\n", ioc->name);
4764
- _base_release_memory_pools(ioc);
5479
+ ioc_err(ioc, "chain_lookup: pci_pool_alloc failed\n");
47655480 goto out;
47665481 }
47675482 }
47685483 total_sz += ioc->chain_segment_sz;
47695484 }
47705485
4771
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
4772
- "chain pool depth(%d), frame_size(%d), pool_size(%d kB)\n",
4773
- ioc->name, ioc->chain_depth, ioc->chain_segment_sz,
4774
- ((ioc->chain_depth * ioc->chain_segment_sz))/1024));
5486
+ dinitprintk(ioc,
5487
+ ioc_info(ioc, "chain pool depth(%d), frame_size(%d), pool_size(%d kB)\n",
5488
+ ioc->chain_depth, ioc->chain_segment_sz,
5489
+ (ioc->chain_depth * ioc->chain_segment_sz) / 1024));
47755490
47765491 /* sense buffers, 4 byte align */
47775492 sz = ioc->scsiio_depth * SCSI_SENSE_BUFFERSIZE;
47785493 ioc->sense_dma_pool = dma_pool_create("sense pool", &ioc->pdev->dev, sz,
47795494 4, 0);
47805495 if (!ioc->sense_dma_pool) {
4781
- pr_err(MPT3SAS_FMT "sense pool: dma_pool_create failed\n",
4782
- ioc->name);
5496
+ ioc_err(ioc, "sense pool: dma_pool_create failed\n");
47835497 goto out;
47845498 }
47855499 ioc->sense = dma_pool_alloc(ioc->sense_dma_pool, GFP_KERNEL,
47865500 &ioc->sense_dma);
47875501 if (!ioc->sense) {
4788
- pr_err(MPT3SAS_FMT "sense pool: dma_pool_alloc failed\n",
4789
- ioc->name);
5502
+ ioc_err(ioc, "sense pool: dma_pool_alloc failed\n");
47905503 goto out;
47915504 }
47925505 /* sense buffer requires to be in same 4 gb region.
....@@ -4798,7 +5511,7 @@
47985511 * Actual requirement is not alignment, but we need start and end of
47995512 * DMA address must have same upper 32 bit address.
48005513 */
4801
- if (!is_MSB_are_same((long)ioc->sense, sz)) {
5514
+ if (!mpt3sas_check_same_4gb_region((long)ioc->sense, sz)) {
48025515 //Release Sense pool & Reallocate
48035516 dma_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma);
48045517 dma_pool_destroy(ioc->sense_dma_pool);
....@@ -4808,24 +5521,22 @@
48085521 dma_pool_create("sense pool", &ioc->pdev->dev, sz,
48095522 roundup_pow_of_two(sz), 0);
48105523 if (!ioc->sense_dma_pool) {
4811
- pr_err(MPT3SAS_FMT "sense pool: pci_pool_create failed\n",
4812
- ioc->name);
5524
+ ioc_err(ioc, "sense pool: pci_pool_create failed\n");
48135525 goto out;
48145526 }
48155527 ioc->sense = dma_pool_alloc(ioc->sense_dma_pool, GFP_KERNEL,
48165528 &ioc->sense_dma);
48175529 if (!ioc->sense) {
4818
- pr_err(MPT3SAS_FMT "sense pool: pci_pool_alloc failed\n",
4819
- ioc->name);
5530
+ ioc_err(ioc, "sense pool: pci_pool_alloc failed\n");
48205531 goto out;
48215532 }
48225533 }
4823
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
4824
- "sense pool(0x%p): depth(%d), element_size(%d), pool_size"
4825
- "(%d kB)\n", ioc->name, ioc->sense, ioc->scsiio_depth,
4826
- SCSI_SENSE_BUFFERSIZE, sz/1024));
4827
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "sense_dma(0x%llx)\n",
4828
- ioc->name, (unsigned long long)ioc->sense_dma));
5534
+ ioc_info(ioc,
5535
+ "sense pool(0x%p)- dma(0x%llx): depth(%d),"
5536
+ "element_size(%d), pool_size(%d kB)\n",
5537
+ ioc->sense, (unsigned long long)ioc->sense_dma, ioc->scsiio_depth,
5538
+ SCSI_SENSE_BUFFERSIZE, sz / 1024);
5539
+
48295540 total_sz += sz;
48305541
48315542 /* reply pool, 4 byte align */
....@@ -4833,25 +5544,24 @@
48335544 ioc->reply_dma_pool = dma_pool_create("reply pool", &ioc->pdev->dev, sz,
48345545 4, 0);
48355546 if (!ioc->reply_dma_pool) {
4836
- pr_err(MPT3SAS_FMT "reply pool: dma_pool_create failed\n",
4837
- ioc->name);
5547
+ ioc_err(ioc, "reply pool: dma_pool_create failed\n");
48385548 goto out;
48395549 }
48405550 ioc->reply = dma_pool_alloc(ioc->reply_dma_pool, GFP_KERNEL,
48415551 &ioc->reply_dma);
48425552 if (!ioc->reply) {
4843
- pr_err(MPT3SAS_FMT "reply pool: dma_pool_alloc failed\n",
4844
- ioc->name);
5553
+ ioc_err(ioc, "reply pool: dma_pool_alloc failed\n");
48455554 goto out;
48465555 }
48475556 ioc->reply_dma_min_address = (u32)(ioc->reply_dma);
48485557 ioc->reply_dma_max_address = (u32)(ioc->reply_dma) + sz;
4849
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
4850
- "reply pool(0x%p): depth(%d), frame_size(%d), pool_size(%d kB)\n",
4851
- ioc->name, ioc->reply,
4852
- ioc->reply_free_queue_depth, ioc->reply_sz, sz/1024));
4853
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "reply_dma(0x%llx)\n",
4854
- ioc->name, (unsigned long long)ioc->reply_dma));
5558
+ dinitprintk(ioc,
5559
+ ioc_info(ioc, "reply pool(0x%p): depth(%d), frame_size(%d), pool_size(%d kB)\n",
5560
+ ioc->reply, ioc->reply_free_queue_depth,
5561
+ ioc->reply_sz, sz / 1024));
5562
+ dinitprintk(ioc,
5563
+ ioc_info(ioc, "reply_dma(0x%llx)\n",
5564
+ (unsigned long long)ioc->reply_dma));
48555565 total_sz += sz;
48565566
48575567 /* reply free queue, 16 byte align */
....@@ -4859,24 +5569,22 @@
48595569 ioc->reply_free_dma_pool = dma_pool_create("reply_free pool",
48605570 &ioc->pdev->dev, sz, 16, 0);
48615571 if (!ioc->reply_free_dma_pool) {
4862
- pr_err(MPT3SAS_FMT "reply_free pool: dma_pool_create failed\n",
4863
- ioc->name);
5572
+ ioc_err(ioc, "reply_free pool: dma_pool_create failed\n");
48645573 goto out;
48655574 }
4866
- ioc->reply_free = dma_pool_alloc(ioc->reply_free_dma_pool, GFP_KERNEL,
5575
+ ioc->reply_free = dma_pool_zalloc(ioc->reply_free_dma_pool, GFP_KERNEL,
48675576 &ioc->reply_free_dma);
48685577 if (!ioc->reply_free) {
4869
- pr_err(MPT3SAS_FMT "reply_free pool: dma_pool_alloc failed\n",
4870
- ioc->name);
5578
+ ioc_err(ioc, "reply_free pool: dma_pool_alloc failed\n");
48715579 goto out;
48725580 }
4873
- memset(ioc->reply_free, 0, sz);
4874
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "reply_free pool(0x%p): " \
4875
- "depth(%d), element_size(%d), pool_size(%d kB)\n", ioc->name,
4876
- ioc->reply_free, ioc->reply_free_queue_depth, 4, sz/1024));
4877
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
4878
- "reply_free_dma (0x%llx)\n",
4879
- ioc->name, (unsigned long long)ioc->reply_free_dma));
5581
+ dinitprintk(ioc,
5582
+ ioc_info(ioc, "reply_free pool(0x%p): depth(%d), element_size(%d), pool_size(%d kB)\n",
5583
+ ioc->reply_free, ioc->reply_free_queue_depth,
5584
+ 4, sz / 1024));
5585
+ dinitprintk(ioc,
5586
+ ioc_info(ioc, "reply_free_dma (0x%llx)\n",
5587
+ (unsigned long long)ioc->reply_free_dma));
48805588 total_sz += sz;
48815589
48825590 if (ioc->rdpq_array_enable) {
....@@ -4887,8 +5595,7 @@
48875595 &ioc->pdev->dev, reply_post_free_array_sz, 16, 0);
48885596 if (!ioc->reply_post_free_array_dma_pool) {
48895597 dinitprintk(ioc,
4890
- pr_info(MPT3SAS_FMT "reply_post_free_array pool: "
4891
- "dma_pool_create failed\n", ioc->name));
5598
+ ioc_info(ioc, "reply_post_free_array pool: dma_pool_create failed\n"));
48925599 goto out;
48935600 }
48945601 ioc->reply_post_free_array =
....@@ -4896,35 +5603,43 @@
48965603 GFP_KERNEL, &ioc->reply_post_free_array_dma);
48975604 if (!ioc->reply_post_free_array) {
48985605 dinitprintk(ioc,
4899
- pr_info(MPT3SAS_FMT "reply_post_free_array pool: "
4900
- "dma_pool_alloc failed\n", ioc->name));
5606
+ ioc_info(ioc, "reply_post_free_array pool: dma_pool_alloc failed\n"));
49015607 goto out;
49025608 }
49035609 }
49045610 ioc->config_page_sz = 512;
4905
- ioc->config_page = pci_alloc_consistent(ioc->pdev,
4906
- ioc->config_page_sz, &ioc->config_page_dma);
5611
+ ioc->config_page = dma_alloc_coherent(&ioc->pdev->dev,
5612
+ ioc->config_page_sz, &ioc->config_page_dma, GFP_KERNEL);
49075613 if (!ioc->config_page) {
4908
- pr_err(MPT3SAS_FMT
4909
- "config page: dma_pool_alloc failed\n",
4910
- ioc->name);
5614
+ ioc_err(ioc, "config page: dma_pool_alloc failed\n");
49115615 goto out;
49125616 }
4913
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
4914
- "config page(0x%p): size(%d)\n",
4915
- ioc->name, ioc->config_page, ioc->config_page_sz));
4916
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "config_page_dma(0x%llx)\n",
4917
- ioc->name, (unsigned long long)ioc->config_page_dma));
5617
+
5618
+ ioc_info(ioc, "config page(0x%p) - dma(0x%llx): size(%d)\n",
5619
+ ioc->config_page, (unsigned long long)ioc->config_page_dma,
5620
+ ioc->config_page_sz);
49185621 total_sz += ioc->config_page_sz;
49195622
4920
- pr_info(MPT3SAS_FMT "Allocated physical memory: size(%d kB)\n",
4921
- ioc->name, total_sz/1024);
4922
- pr_info(MPT3SAS_FMT
4923
- "Current Controller Queue Depth(%d),Max Controller Queue Depth(%d)\n",
4924
- ioc->name, ioc->shost->can_queue, facts->RequestCredit);
4925
- pr_info(MPT3SAS_FMT "Scatter Gather Elements per IO(%d)\n",
4926
- ioc->name, ioc->shost->sg_tablesize);
5623
+ ioc_info(ioc, "Allocated physical memory: size(%d kB)\n",
5624
+ total_sz / 1024);
5625
+ ioc_info(ioc, "Current Controller Queue Depth(%d),Max Controller Queue Depth(%d)\n",
5626
+ ioc->shost->can_queue, facts->RequestCredit);
5627
+ ioc_info(ioc, "Scatter Gather Elements per IO(%d)\n",
5628
+ ioc->shost->sg_tablesize);
49275629 return 0;
5630
+
5631
+try_32bit_dma:
5632
+ _base_release_memory_pools(ioc);
5633
+ if (ioc->use_32bit_dma && (ioc->dma_mask > 32)) {
5634
+ /* Change dma coherent mask to 32 bit and reallocate */
5635
+ if (_base_config_dma_addressing(ioc, ioc->pdev) != 0) {
5636
+ pr_err("Setting 32 bit coherent DMA mask Failed %s\n",
5637
+ pci_name(ioc->pdev));
5638
+ return -ENODEV;
5639
+ }
5640
+ } else if (_base_reduce_hba_queue_depth(ioc) != 0)
5641
+ return -ENOMEM;
5642
+ goto retry_allocation;
49285643
49295644 out:
49305645 return -ENOMEM;
....@@ -4943,7 +5658,7 @@
49435658 {
49445659 u32 s, sc;
49455660
4946
- s = readl(&ioc->chip->Doorbell);
5661
+ s = ioc->base_readl(&ioc->chip->Doorbell);
49475662 sc = s & MPI2_IOC_STATE_MASK;
49485663 return cooked ? sc : s;
49495664 }
....@@ -4970,6 +5685,8 @@
49705685 return 0;
49715686 if (count && current_state == MPI2_IOC_STATE_FAULT)
49725687 break;
5688
+ if (count && current_state == MPI2_IOC_STATE_COREDUMP)
5689
+ break;
49735690
49745691 usleep_range(1000, 1500);
49755692 count++;
....@@ -4979,16 +5696,32 @@
49795696 }
49805697
49815698 /**
5699
+ * _base_dump_reg_set - This function will print hexdump of register set.
5700
+ * @ioc: per adapter object
5701
+ *
5702
+ * Returns nothing.
5703
+ */
5704
+static inline void
5705
+_base_dump_reg_set(struct MPT3SAS_ADAPTER *ioc)
5706
+{
5707
+ unsigned int i, sz = 256;
5708
+ u32 __iomem *reg = (u32 __iomem *)ioc->chip;
5709
+
5710
+ ioc_info(ioc, "System Register set:\n");
5711
+ for (i = 0; i < (sz / sizeof(u32)); i++)
5712
+ pr_info("%08x: %08x\n", (i * 4), readl(&reg[i]));
5713
+}
5714
+
5715
+/**
49825716 * _base_wait_for_doorbell_int - waiting for controller interrupt(generated by
49835717 * a write to the doorbell)
49845718 * @ioc: per adapter object
5719
+ * @timeout: timeout in seconds
49855720 *
49865721 * Return: 0 for success, non-zero for failure.
49875722 *
49885723 * Notes: MPI2_HIS_IOC2SYS_DB_STATUS - set to one when IOC writes to doorbell.
49895724 */
4990
-static int
4991
-_base_diag_reset(struct MPT3SAS_ADAPTER *ioc);
49925725
49935726 static int
49945727 _base_wait_for_doorbell_int(struct MPT3SAS_ADAPTER *ioc, int timeout)
....@@ -4999,11 +5732,11 @@
49995732 count = 0;
50005733 cntdn = 1000 * timeout;
50015734 do {
5002
- int_status = readl(&ioc->chip->HostInterruptStatus);
5735
+ int_status = ioc->base_readl(&ioc->chip->HostInterruptStatus);
50035736 if (int_status & MPI2_HIS_IOC2SYS_DB_STATUS) {
5004
- dhsprintk(ioc, pr_info(MPT3SAS_FMT
5005
- "%s: successful count(%d), timeout(%d)\n",
5006
- ioc->name, __func__, count, timeout));
5737
+ dhsprintk(ioc,
5738
+ ioc_info(ioc, "%s: successful count(%d), timeout(%d)\n",
5739
+ __func__, count, timeout));
50075740 return 0;
50085741 }
50095742
....@@ -5011,9 +5744,8 @@
50115744 count++;
50125745 } while (--cntdn);
50135746
5014
- pr_err(MPT3SAS_FMT
5015
- "%s: failed due to timeout count(%d), int_status(%x)!\n",
5016
- ioc->name, __func__, count, int_status);
5747
+ ioc_err(ioc, "%s: failed due to timeout count(%d), int_status(%x)!\n",
5748
+ __func__, count, int_status);
50175749 return -EFAULT;
50185750 }
50195751
....@@ -5026,11 +5758,11 @@
50265758 count = 0;
50275759 cntdn = 2000 * timeout;
50285760 do {
5029
- int_status = readl(&ioc->chip->HostInterruptStatus);
5761
+ int_status = ioc->base_readl(&ioc->chip->HostInterruptStatus);
50305762 if (int_status & MPI2_HIS_IOC2SYS_DB_STATUS) {
5031
- dhsprintk(ioc, pr_info(MPT3SAS_FMT
5032
- "%s: successful count(%d), timeout(%d)\n",
5033
- ioc->name, __func__, count, timeout));
5763
+ dhsprintk(ioc,
5764
+ ioc_info(ioc, "%s: successful count(%d), timeout(%d)\n",
5765
+ __func__, count, timeout));
50345766 return 0;
50355767 }
50365768
....@@ -5038,9 +5770,8 @@
50385770 count++;
50395771 } while (--cntdn);
50405772
5041
- pr_err(MPT3SAS_FMT
5042
- "%s: failed due to timeout count(%d), int_status(%x)!\n",
5043
- ioc->name, __func__, count, int_status);
5773
+ ioc_err(ioc, "%s: failed due to timeout count(%d), int_status(%x)!\n",
5774
+ __func__, count, int_status);
50445775 return -EFAULT;
50455776
50465777 }
....@@ -5065,17 +5796,22 @@
50655796 count = 0;
50665797 cntdn = 1000 * timeout;
50675798 do {
5068
- int_status = readl(&ioc->chip->HostInterruptStatus);
5799
+ int_status = ioc->base_readl(&ioc->chip->HostInterruptStatus);
50695800 if (!(int_status & MPI2_HIS_SYS2IOC_DB_STATUS)) {
5070
- dhsprintk(ioc, pr_info(MPT3SAS_FMT
5071
- "%s: successful count(%d), timeout(%d)\n",
5072
- ioc->name, __func__, count, timeout));
5801
+ dhsprintk(ioc,
5802
+ ioc_info(ioc, "%s: successful count(%d), timeout(%d)\n",
5803
+ __func__, count, timeout));
50735804 return 0;
50745805 } else if (int_status & MPI2_HIS_IOC2SYS_DB_STATUS) {
5075
- doorbell = readl(&ioc->chip->Doorbell);
5806
+ doorbell = ioc->base_readl(&ioc->chip->Doorbell);
50765807 if ((doorbell & MPI2_IOC_STATE_MASK) ==
50775808 MPI2_IOC_STATE_FAULT) {
5078
- mpt3sas_base_fault_info(ioc , doorbell);
5809
+ mpt3sas_print_fault_code(ioc, doorbell);
5810
+ return -EFAULT;
5811
+ }
5812
+ if ((doorbell & MPI2_IOC_STATE_MASK) ==
5813
+ MPI2_IOC_STATE_COREDUMP) {
5814
+ mpt3sas_print_coredump_info(ioc, doorbell);
50795815 return -EFAULT;
50805816 }
50815817 } else if (int_status == 0xFFFFFFFF)
....@@ -5086,9 +5822,8 @@
50865822 } while (--cntdn);
50875823
50885824 out:
5089
- pr_err(MPT3SAS_FMT
5090
- "%s: failed due to timeout count(%d), int_status(%x)!\n",
5091
- ioc->name, __func__, count, int_status);
5825
+ ioc_err(ioc, "%s: failed due to timeout count(%d), int_status(%x)!\n",
5826
+ __func__, count, int_status);
50925827 return -EFAULT;
50935828 }
50945829
....@@ -5108,11 +5843,11 @@
51085843 count = 0;
51095844 cntdn = 1000 * timeout;
51105845 do {
5111
- doorbell_reg = readl(&ioc->chip->Doorbell);
5846
+ doorbell_reg = ioc->base_readl(&ioc->chip->Doorbell);
51125847 if (!(doorbell_reg & MPI2_DOORBELL_USED)) {
5113
- dhsprintk(ioc, pr_info(MPT3SAS_FMT
5114
- "%s: successful count(%d), timeout(%d)\n",
5115
- ioc->name, __func__, count, timeout));
5848
+ dhsprintk(ioc,
5849
+ ioc_info(ioc, "%s: successful count(%d), timeout(%d)\n",
5850
+ __func__, count, timeout));
51165851 return 0;
51175852 }
51185853
....@@ -5120,9 +5855,8 @@
51205855 count++;
51215856 } while (--cntdn);
51225857
5123
- pr_err(MPT3SAS_FMT
5124
- "%s: failed due to timeout count(%d), doorbell_reg(%x)!\n",
5125
- ioc->name, __func__, count, doorbell_reg);
5858
+ ioc_err(ioc, "%s: failed due to timeout count(%d), doorbell_reg(%x)!\n",
5859
+ __func__, count, doorbell_reg);
51265860 return -EFAULT;
51275861 }
51285862
....@@ -5139,10 +5873,10 @@
51395873 {
51405874 u32 ioc_state;
51415875 int r = 0;
5876
+ unsigned long flags;
51425877
51435878 if (reset_type != MPI2_FUNCTION_IOC_MESSAGE_UNIT_RESET) {
5144
- pr_err(MPT3SAS_FMT "%s: unknown reset_type\n",
5145
- ioc->name, __func__);
5879
+ ioc_err(ioc, "%s: unknown reset_type\n", __func__);
51465880 return -EFAULT;
51475881 }
51485882
....@@ -5150,7 +5884,7 @@
51505884 MPI2_IOCFACTS_CAPABILITY_EVENT_REPLAY))
51515885 return -EFAULT;
51525886
5153
- pr_info(MPT3SAS_FMT "sending message unit reset !!\n", ioc->name);
5887
+ ioc_info(ioc, "sending message unit reset !!\n");
51545888
51555889 writel(reset_type << MPI2_DOORBELL_FUNCTION_SHIFT,
51565890 &ioc->chip->Doorbell);
....@@ -5158,18 +5892,71 @@
51585892 r = -EFAULT;
51595893 goto out;
51605894 }
5895
+
51615896 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, timeout);
51625897 if (ioc_state) {
5163
- pr_err(MPT3SAS_FMT
5164
- "%s: failed going to ready state (ioc_state=0x%x)\n",
5165
- ioc->name, __func__, ioc_state);
5898
+ ioc_err(ioc, "%s: failed going to ready state (ioc_state=0x%x)\n",
5899
+ __func__, ioc_state);
51665900 r = -EFAULT;
51675901 goto out;
51685902 }
51695903 out:
5170
- pr_info(MPT3SAS_FMT "message unit reset: %s\n",
5171
- ioc->name, ((r == 0) ? "SUCCESS" : "FAILED"));
5904
+ if (r != 0) {
5905
+ ioc_state = mpt3sas_base_get_iocstate(ioc, 0);
5906
+ spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
5907
+ /*
5908
+ * Wait for IOC state CoreDump to clear only during
5909
+ * HBA initialization & release time.
5910
+ */
5911
+ if ((ioc_state & MPI2_IOC_STATE_MASK) ==
5912
+ MPI2_IOC_STATE_COREDUMP && (ioc->is_driver_loading == 1 ||
5913
+ ioc->fault_reset_work_q == NULL)) {
5914
+ spin_unlock_irqrestore(
5915
+ &ioc->ioc_reset_in_progress_lock, flags);
5916
+ mpt3sas_print_coredump_info(ioc, ioc_state);
5917
+ mpt3sas_base_wait_for_coredump_completion(ioc,
5918
+ __func__);
5919
+ spin_lock_irqsave(
5920
+ &ioc->ioc_reset_in_progress_lock, flags);
5921
+ }
5922
+ spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
5923
+ }
5924
+ ioc_info(ioc, "message unit reset: %s\n",
5925
+ r == 0 ? "SUCCESS" : "FAILED");
51725926 return r;
5927
+}
5928
+
5929
+/**
5930
+ * mpt3sas_wait_for_ioc - IOC's operational state is checked here.
5931
+ * @ioc: per adapter object
5932
+ * @timeout: timeout in seconds
5933
+ *
5934
+ * Return: Waits up to timeout seconds for the IOC to
5935
+ * become operational. Returns 0 if IOC is present
5936
+ * and operational; otherwise returns -EFAULT.
5937
+ */
5938
+
5939
+int
5940
+mpt3sas_wait_for_ioc(struct MPT3SAS_ADAPTER *ioc, int timeout)
5941
+{
5942
+ int wait_state_count = 0;
5943
+ u32 ioc_state;
5944
+
5945
+ do {
5946
+ ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
5947
+ if (ioc_state == MPI2_IOC_STATE_OPERATIONAL)
5948
+ break;
5949
+ ssleep(1);
5950
+ ioc_info(ioc, "%s: waiting for operational state(count=%d)\n",
5951
+ __func__, ++wait_state_count);
5952
+ } while (--timeout);
5953
+ if (!timeout) {
5954
+ ioc_err(ioc, "%s: failed due to ioc not operational\n", __func__);
5955
+ return -EFAULT;
5956
+ }
5957
+ if (wait_state_count)
5958
+ ioc_info(ioc, "ioc is operational\n");
5959
+ return 0;
51735960 }
51745961
51755962 /**
....@@ -5193,15 +5980,13 @@
51935980 __le32 *mfp;
51945981
51955982 /* make sure doorbell is not in use */
5196
- if ((readl(&ioc->chip->Doorbell) & MPI2_DOORBELL_USED)) {
5197
- pr_err(MPT3SAS_FMT
5198
- "doorbell is in use (line=%d)\n",
5199
- ioc->name, __LINE__);
5983
+ if ((ioc->base_readl(&ioc->chip->Doorbell) & MPI2_DOORBELL_USED)) {
5984
+ ioc_err(ioc, "doorbell is in use (line=%d)\n", __LINE__);
52005985 return -EFAULT;
52015986 }
52025987
52035988 /* clear pending doorbell interrupts from previous state changes */
5204
- if (readl(&ioc->chip->HostInterruptStatus) &
5989
+ if (ioc->base_readl(&ioc->chip->HostInterruptStatus) &
52055990 MPI2_HIS_IOC2SYS_DB_STATUS)
52065991 writel(0, &ioc->chip->HostInterruptStatus);
52075992
....@@ -5211,17 +5996,15 @@
52115996 &ioc->chip->Doorbell);
52125997
52135998 if ((_base_spin_on_doorbell_int(ioc, 5))) {
5214
- pr_err(MPT3SAS_FMT
5215
- "doorbell handshake int failed (line=%d)\n",
5216
- ioc->name, __LINE__);
5999
+ ioc_err(ioc, "doorbell handshake int failed (line=%d)\n",
6000
+ __LINE__);
52176001 return -EFAULT;
52186002 }
52196003 writel(0, &ioc->chip->HostInterruptStatus);
52206004
52216005 if ((_base_wait_for_doorbell_ack(ioc, 5))) {
5222
- pr_err(MPT3SAS_FMT
5223
- "doorbell handshake ack failed (line=%d)\n",
5224
- ioc->name, __LINE__);
6006
+ ioc_err(ioc, "doorbell handshake ack failed (line=%d)\n",
6007
+ __LINE__);
52256008 return -EFAULT;
52266009 }
52276010
....@@ -5233,53 +6016,51 @@
52336016 }
52346017
52356018 if (failed) {
5236
- pr_err(MPT3SAS_FMT
5237
- "doorbell handshake sending request failed (line=%d)\n",
5238
- ioc->name, __LINE__);
6019
+ ioc_err(ioc, "doorbell handshake sending request failed (line=%d)\n",
6020
+ __LINE__);
52396021 return -EFAULT;
52406022 }
52416023
52426024 /* now wait for the reply */
52436025 if ((_base_wait_for_doorbell_int(ioc, timeout))) {
5244
- pr_err(MPT3SAS_FMT
5245
- "doorbell handshake int failed (line=%d)\n",
5246
- ioc->name, __LINE__);
6026
+ ioc_err(ioc, "doorbell handshake int failed (line=%d)\n",
6027
+ __LINE__);
52476028 return -EFAULT;
52486029 }
52496030
52506031 /* read the first two 16-bits, it gives the total length of the reply */
5251
- reply[0] = le16_to_cpu(readl(&ioc->chip->Doorbell)
6032
+ reply[0] = le16_to_cpu(ioc->base_readl(&ioc->chip->Doorbell)
52526033 & MPI2_DOORBELL_DATA_MASK);
52536034 writel(0, &ioc->chip->HostInterruptStatus);
52546035 if ((_base_wait_for_doorbell_int(ioc, 5))) {
5255
- pr_err(MPT3SAS_FMT
5256
- "doorbell handshake int failed (line=%d)\n",
5257
- ioc->name, __LINE__);
6036
+ ioc_err(ioc, "doorbell handshake int failed (line=%d)\n",
6037
+ __LINE__);
52586038 return -EFAULT;
52596039 }
5260
- reply[1] = le16_to_cpu(readl(&ioc->chip->Doorbell)
6040
+ reply[1] = le16_to_cpu(ioc->base_readl(&ioc->chip->Doorbell)
52616041 & MPI2_DOORBELL_DATA_MASK);
52626042 writel(0, &ioc->chip->HostInterruptStatus);
52636043
52646044 for (i = 2; i < default_reply->MsgLength * 2; i++) {
52656045 if ((_base_wait_for_doorbell_int(ioc, 5))) {
5266
- pr_err(MPT3SAS_FMT
5267
- "doorbell handshake int failed (line=%d)\n",
5268
- ioc->name, __LINE__);
6046
+ ioc_err(ioc, "doorbell handshake int failed (line=%d)\n",
6047
+ __LINE__);
52696048 return -EFAULT;
52706049 }
52716050 if (i >= reply_bytes/2) /* overflow case */
5272
- readl(&ioc->chip->Doorbell);
6051
+ ioc->base_readl(&ioc->chip->Doorbell);
52736052 else
5274
- reply[i] = le16_to_cpu(readl(&ioc->chip->Doorbell)
6053
+ reply[i] = le16_to_cpu(
6054
+ ioc->base_readl(&ioc->chip->Doorbell)
52756055 & MPI2_DOORBELL_DATA_MASK);
52766056 writel(0, &ioc->chip->HostInterruptStatus);
52776057 }
52786058
52796059 _base_wait_for_doorbell_int(ioc, 5);
52806060 if (_base_wait_for_doorbell_not_used(ioc, 5) != 0) {
5281
- dhsprintk(ioc, pr_info(MPT3SAS_FMT
5282
- "doorbell is in use (line=%d)\n", ioc->name, __LINE__));
6061
+ dhsprintk(ioc,
6062
+ ioc_info(ioc, "doorbell is in use (line=%d)\n",
6063
+ __LINE__));
52836064 }
52846065 writel(0, &ioc->chip->HostInterruptStatus);
52856066
....@@ -5287,7 +6068,7 @@
52876068 mfp = (__le32 *)reply;
52886069 pr_info("\toffset:data\n");
52896070 for (i = 0; i < reply_bytes/4; i++)
5290
- pr_info("\t[0x%02x]:%08x\n", i*4,
6071
+ ioc_info(ioc, "\t[0x%02x]:%08x\n", i*4,
52916072 le32_to_cpu(mfp[i]));
52926073 }
52936074 return 0;
....@@ -5313,45 +6094,27 @@
53136094 Mpi2SasIoUnitControlRequest_t *mpi_request)
53146095 {
53156096 u16 smid;
5316
- u32 ioc_state;
53176097 u8 issue_reset = 0;
53186098 int rc;
53196099 void *request;
5320
- u16 wait_state_count;
53216100
5322
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
5323
- __func__));
6101
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
53246102
53256103 mutex_lock(&ioc->base_cmds.mutex);
53266104
53276105 if (ioc->base_cmds.status != MPT3_CMD_NOT_USED) {
5328
- pr_err(MPT3SAS_FMT "%s: base_cmd in use\n",
5329
- ioc->name, __func__);
6106
+ ioc_err(ioc, "%s: base_cmd in use\n", __func__);
53306107 rc = -EAGAIN;
53316108 goto out;
53326109 }
53336110
5334
- wait_state_count = 0;
5335
- ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
5336
- while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
5337
- if (wait_state_count++ == 10) {
5338
- pr_err(MPT3SAS_FMT
5339
- "%s: failed due to ioc not operational\n",
5340
- ioc->name, __func__);
5341
- rc = -EFAULT;
5342
- goto out;
5343
- }
5344
- ssleep(1);
5345
- ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
5346
- pr_info(MPT3SAS_FMT
5347
- "%s: waiting for operational state(count=%d)\n",
5348
- ioc->name, __func__, wait_state_count);
5349
- }
6111
+ rc = mpt3sas_wait_for_ioc(ioc, IOC_OPERATIONAL_WAIT_COUNT);
6112
+ if (rc)
6113
+ goto out;
53506114
53516115 smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx);
53526116 if (!smid) {
5353
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
5354
- ioc->name, __func__);
6117
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
53556118 rc = -EAGAIN;
53566119 goto out;
53576120 }
....@@ -5365,7 +6128,7 @@
53656128 mpi_request->Operation == MPI2_SAS_OP_PHY_LINK_RESET)
53666129 ioc->ioc_link_reset_in_progress = 1;
53676130 init_completion(&ioc->base_cmds.done);
5368
- mpt3sas_base_put_smid_default(ioc, smid);
6131
+ ioc->put_smid_default(ioc, smid);
53696132 wait_for_completion_timeout(&ioc->base_cmds.done,
53706133 msecs_to_jiffies(10000));
53716134 if ((mpi_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET ||
....@@ -5373,10 +6136,9 @@
53736136 ioc->ioc_link_reset_in_progress)
53746137 ioc->ioc_link_reset_in_progress = 0;
53756138 if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) {
5376
- issue_reset =
5377
- mpt3sas_base_check_cmd_timeout(ioc,
5378
- ioc->base_cmds.status, mpi_request,
5379
- sizeof(Mpi2SasIoUnitControlRequest_t)/4);
6139
+ mpt3sas_check_cmd_timeout(ioc, ioc->base_cmds.status,
6140
+ mpi_request, sizeof(Mpi2SasIoUnitControlRequest_t)/4,
6141
+ issue_reset);
53806142 goto issue_host_reset;
53816143 }
53826144 if (ioc->base_cmds.status & MPT3_CMD_REPLY_VALID)
....@@ -5413,46 +6175,27 @@
54136175 Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request)
54146176 {
54156177 u16 smid;
5416
- u32 ioc_state;
54176178 u8 issue_reset = 0;
54186179 int rc;
54196180 void *request;
5420
- u16 wait_state_count;
54216181
5422
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
5423
- __func__));
6182
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
54246183
54256184 mutex_lock(&ioc->base_cmds.mutex);
54266185
54276186 if (ioc->base_cmds.status != MPT3_CMD_NOT_USED) {
5428
- pr_err(MPT3SAS_FMT "%s: base_cmd in use\n",
5429
- ioc->name, __func__);
6187
+ ioc_err(ioc, "%s: base_cmd in use\n", __func__);
54306188 rc = -EAGAIN;
54316189 goto out;
54326190 }
54336191
5434
- wait_state_count = 0;
5435
- ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
5436
- while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
5437
- if (wait_state_count++ == 10) {
5438
- pr_err(MPT3SAS_FMT
5439
- "%s: failed due to ioc not operational\n",
5440
- ioc->name, __func__);
5441
- rc = -EFAULT;
5442
- goto out;
5443
- }
5444
- ssleep(1);
5445
- ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
5446
- pr_info(MPT3SAS_FMT
5447
- "%s: waiting for operational state(count=%d)\n",
5448
- ioc->name,
5449
- __func__, wait_state_count);
5450
- }
6192
+ rc = mpt3sas_wait_for_ioc(ioc, IOC_OPERATIONAL_WAIT_COUNT);
6193
+ if (rc)
6194
+ goto out;
54516195
54526196 smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx);
54536197 if (!smid) {
5454
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
5455
- ioc->name, __func__);
6198
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
54566199 rc = -EAGAIN;
54576200 goto out;
54586201 }
....@@ -5461,16 +6204,16 @@
54616204 ioc->base_cmds.status = MPT3_CMD_PENDING;
54626205 request = mpt3sas_base_get_msg_frame(ioc, smid);
54636206 ioc->base_cmds.smid = smid;
6207
+ memset(request, 0, ioc->request_sz);
54646208 memcpy(request, mpi_request, sizeof(Mpi2SepReply_t));
54656209 init_completion(&ioc->base_cmds.done);
5466
- mpt3sas_base_put_smid_default(ioc, smid);
6210
+ ioc->put_smid_default(ioc, smid);
54676211 wait_for_completion_timeout(&ioc->base_cmds.done,
54686212 msecs_to_jiffies(10000));
54696213 if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) {
5470
- issue_reset =
5471
- mpt3sas_base_check_cmd_timeout(ioc,
5472
- ioc->base_cmds.status, mpi_request,
5473
- sizeof(Mpi2SepRequest_t)/4);
6214
+ mpt3sas_check_cmd_timeout(ioc,
6215
+ ioc->base_cmds.status, mpi_request,
6216
+ sizeof(Mpi2SepRequest_t)/4, issue_reset);
54746217 goto issue_host_reset;
54756218 }
54766219 if (ioc->base_cmds.status & MPT3_CMD_REPLY_VALID)
....@@ -5506,8 +6249,7 @@
55066249 struct mpt3sas_port_facts *pfacts;
55076250 int mpi_reply_sz, mpi_request_sz, r;
55086251
5509
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
5510
- __func__));
6252
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
55116253
55126254 mpi_reply_sz = sizeof(Mpi2PortFactsReply_t);
55136255 mpi_request_sz = sizeof(Mpi2PortFactsRequest_t);
....@@ -5518,8 +6260,7 @@
55186260 (u32 *)&mpi_request, mpi_reply_sz, (u16 *)&mpi_reply, 5);
55196261
55206262 if (r != 0) {
5521
- pr_err(MPT3SAS_FMT "%s: handshake failed (r=%d)\n",
5522
- ioc->name, __func__, r);
6263
+ ioc_err(ioc, "%s: handshake failed (r=%d)\n", __func__, r);
55236264 return r;
55246265 }
55256266
....@@ -5547,40 +6288,46 @@
55476288 u32 ioc_state;
55486289 int rc;
55496290
5550
- dinitprintk(ioc, printk(MPT3SAS_FMT "%s\n", ioc->name,
5551
- __func__));
6291
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
55526292
55536293 if (ioc->pci_error_recovery) {
5554
- dfailprintk(ioc, printk(MPT3SAS_FMT
5555
- "%s: host in pci error recovery\n", ioc->name, __func__));
6294
+ dfailprintk(ioc,
6295
+ ioc_info(ioc, "%s: host in pci error recovery\n",
6296
+ __func__));
55566297 return -EFAULT;
55576298 }
55586299
55596300 ioc_state = mpt3sas_base_get_iocstate(ioc, 0);
5560
- dhsprintk(ioc, printk(MPT3SAS_FMT "%s: ioc_state(0x%08x)\n",
5561
- ioc->name, __func__, ioc_state));
6301
+ dhsprintk(ioc,
6302
+ ioc_info(ioc, "%s: ioc_state(0x%08x)\n",
6303
+ __func__, ioc_state));
55626304
55636305 if (((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_READY) ||
55646306 (ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_OPERATIONAL)
55656307 return 0;
55666308
55676309 if (ioc_state & MPI2_DOORBELL_USED) {
5568
- dhsprintk(ioc, printk(MPT3SAS_FMT
5569
- "unexpected doorbell active!\n", ioc->name));
6310
+ dhsprintk(ioc, ioc_info(ioc, "unexpected doorbell active!\n"));
55706311 goto issue_diag_reset;
55716312 }
55726313
55736314 if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
5574
- mpt3sas_base_fault_info(ioc, ioc_state &
6315
+ mpt3sas_print_fault_code(ioc, ioc_state &
55756316 MPI2_DOORBELL_DATA_MASK);
55766317 goto issue_diag_reset;
6318
+ } else if ((ioc_state & MPI2_IOC_STATE_MASK) ==
6319
+ MPI2_IOC_STATE_COREDUMP) {
6320
+ ioc_info(ioc,
6321
+ "%s: Skipping the diag reset here. (ioc_state=0x%x)\n",
6322
+ __func__, ioc_state);
6323
+ return -EFAULT;
55776324 }
55786325
55796326 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, timeout);
55806327 if (ioc_state) {
5581
- dfailprintk(ioc, printk(MPT3SAS_FMT
5582
- "%s: failed going to ready state (ioc_state=0x%x)\n",
5583
- ioc->name, __func__, ioc_state));
6328
+ dfailprintk(ioc,
6329
+ ioc_info(ioc, "%s: failed going to ready state (ioc_state=0x%x)\n",
6330
+ __func__, ioc_state));
55846331 return -EFAULT;
55856332 }
55866333
....@@ -5603,14 +6350,13 @@
56036350 struct mpt3sas_facts *facts;
56046351 int mpi_reply_sz, mpi_request_sz, r;
56056352
5606
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
5607
- __func__));
6353
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
56086354
56096355 r = _base_wait_for_iocstate(ioc, 10);
56106356 if (r) {
5611
- dfailprintk(ioc, printk(MPT3SAS_FMT
5612
- "%s: failed getting to correct state\n",
5613
- ioc->name, __func__));
6357
+ dfailprintk(ioc,
6358
+ ioc_info(ioc, "%s: failed getting to correct state\n",
6359
+ __func__));
56146360 return r;
56156361 }
56166362 mpi_reply_sz = sizeof(Mpi2IOCFactsReply_t);
....@@ -5621,8 +6367,7 @@
56216367 (u32 *)&mpi_request, mpi_reply_sz, (u16 *)&mpi_reply, 5);
56226368
56236369 if (r != 0) {
5624
- pr_err(MPT3SAS_FMT "%s: handshake failed (r=%d)\n",
5625
- ioc->name, __func__, r);
6370
+ ioc_err(ioc, "%s: handshake failed (r=%d)\n", __func__, r);
56266371 return r;
56276372 }
56286373
....@@ -5650,6 +6395,9 @@
56506395 if ((facts->IOCCapabilities &
56516396 MPI2_IOCFACTS_CAPABILITY_RDPQ_ARRAY_CAPABLE) && (!reset_devices))
56526397 ioc->rdpq_array_capable = 1;
6398
+ if ((facts->IOCCapabilities & MPI26_IOCFACTS_CAPABILITY_ATOMIC_REQ)
6399
+ && ioc->is_aero_ioc)
6400
+ ioc->atomic_desc_capable = 1;
56536401 facts->FWVersion.Word = le32_to_cpu(mpi_reply.FWVersion.Word);
56546402 facts->IOCRequestFrameSize =
56556403 le16_to_cpu(mpi_reply.IOCRequestFrameSize);
....@@ -5674,20 +6422,20 @@
56746422 */
56756423 ioc->page_size = 1 << facts->CurrentHostPageSize;
56766424 if (ioc->page_size == 1) {
5677
- pr_info(MPT3SAS_FMT "CurrentHostPageSize is 0: Setting "
5678
- "default host page size to 4k\n", ioc->name);
6425
+ ioc_info(ioc, "CurrentHostPageSize is 0: Setting default host page size to 4k\n");
56796426 ioc->page_size = 1 << MPT3SAS_HOST_PAGE_SIZE_4K;
56806427 }
5681
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "CurrentHostPageSize(%d)\n",
5682
- ioc->name, facts->CurrentHostPageSize));
6428
+ dinitprintk(ioc,
6429
+ ioc_info(ioc, "CurrentHostPageSize(%d)\n",
6430
+ facts->CurrentHostPageSize));
56836431
5684
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
5685
- "hba queue depth(%d), max chains per io(%d)\n",
5686
- ioc->name, facts->RequestCredit,
5687
- facts->MaxChainDepth));
5688
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
5689
- "request frame size(%d), reply frame size(%d)\n", ioc->name,
5690
- facts->IOCRequestFrameSize * 4, facts->ReplyFrameSize * 4));
6432
+ dinitprintk(ioc,
6433
+ ioc_info(ioc, "hba queue depth(%d), max chains per io(%d)\n",
6434
+ facts->RequestCredit, facts->MaxChainDepth));
6435
+ dinitprintk(ioc,
6436
+ ioc_info(ioc, "request frame size(%d), reply frame size(%d)\n",
6437
+ facts->IOCRequestFrameSize * 4,
6438
+ facts->ReplyFrameSize * 4));
56916439 return 0;
56926440 }
56936441
....@@ -5707,8 +6455,7 @@
57076455 u16 ioc_status;
57086456 u32 reply_post_free_array_sz = 0;
57096457
5710
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
5711
- __func__));
6458
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
57126459
57136460 memset(&mpi_request, 0, sizeof(Mpi2IOCInitRequest_t));
57146461 mpi_request.Function = MPI2_FUNCTION_IOC_INIT;
....@@ -5752,6 +6499,12 @@
57526499 cpu_to_le64((u64)ioc->reply_post[0].reply_post_free_dma);
57536500 }
57546501
6502
+ /*
6503
+ * Set the flag to enable CoreDump state feature in IOC firmware.
6504
+ */
6505
+ mpi_request.ConfigurationFlags |=
6506
+ cpu_to_le16(MPI26_IOCINIT_CFGFLAGS_COREDUMP_ENABLE);
6507
+
57556508 /* This time stamp specifies number of milliseconds
57566509 * since epoch ~ midnight January 1, 1970.
57576510 */
....@@ -5763,9 +6516,9 @@
57636516 int i;
57646517
57656518 mfp = (__le32 *)&mpi_request;
5766
- pr_info("\toffset:data\n");
6519
+ ioc_info(ioc, "\toffset:data\n");
57676520 for (i = 0; i < sizeof(Mpi2IOCInitRequest_t)/4; i++)
5768
- pr_info("\t[0x%02x]:%08x\n", i*4,
6521
+ ioc_info(ioc, "\t[0x%02x]:%08x\n", i*4,
57696522 le32_to_cpu(mfp[i]));
57706523 }
57716524
....@@ -5774,15 +6527,14 @@
57746527 sizeof(Mpi2IOCInitReply_t), (u16 *)&mpi_reply, 30);
57756528
57766529 if (r != 0) {
5777
- pr_err(MPT3SAS_FMT "%s: handshake failed (r=%d)\n",
5778
- ioc->name, __func__, r);
6530
+ ioc_err(ioc, "%s: handshake failed (r=%d)\n", __func__, r);
57796531 return r;
57806532 }
57816533
57826534 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK;
57836535 if (ioc_status != MPI2_IOCSTATUS_SUCCESS ||
57846536 mpi_reply.IOCLogInfo) {
5785
- pr_err(MPT3SAS_FMT "%s: failed\n", ioc->name, __func__);
6537
+ ioc_err(ioc, "%s: failed\n", __func__);
57866538 r = -EIO;
57876539 }
57886540
....@@ -5853,18 +6605,16 @@
58536605 u16 smid;
58546606 u16 ioc_status;
58556607
5856
- pr_info(MPT3SAS_FMT "sending port enable !!\n", ioc->name);
6608
+ ioc_info(ioc, "sending port enable !!\n");
58576609
58586610 if (ioc->port_enable_cmds.status & MPT3_CMD_PENDING) {
5859
- pr_err(MPT3SAS_FMT "%s: internal command already in use\n",
5860
- ioc->name, __func__);
6611
+ ioc_err(ioc, "%s: internal command already in use\n", __func__);
58616612 return -EAGAIN;
58626613 }
58636614
58646615 smid = mpt3sas_base_get_smid(ioc, ioc->port_enable_cb_idx);
58656616 if (!smid) {
5866
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
5867
- ioc->name, __func__);
6617
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
58686618 return -EAGAIN;
58696619 }
58706620
....@@ -5875,11 +6625,10 @@
58756625 mpi_request->Function = MPI2_FUNCTION_PORT_ENABLE;
58766626
58776627 init_completion(&ioc->port_enable_cmds.done);
5878
- mpt3sas_base_put_smid_default(ioc, smid);
6628
+ ioc->put_smid_default(ioc, smid);
58796629 wait_for_completion_timeout(&ioc->port_enable_cmds.done, 300*HZ);
58806630 if (!(ioc->port_enable_cmds.status & MPT3_CMD_COMPLETE)) {
5881
- pr_err(MPT3SAS_FMT "%s: timeout\n",
5882
- ioc->name, __func__);
6631
+ ioc_err(ioc, "%s: timeout\n", __func__);
58836632 _debug_dump_mf(mpi_request,
58846633 sizeof(Mpi2PortEnableRequest_t)/4);
58856634 if (ioc->port_enable_cmds.status & MPT3_CMD_RESET)
....@@ -5892,16 +6641,15 @@
58926641 mpi_reply = ioc->port_enable_cmds.reply;
58936642 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & MPI2_IOCSTATUS_MASK;
58946643 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
5895
- pr_err(MPT3SAS_FMT "%s: failed with (ioc_status=0x%08x)\n",
5896
- ioc->name, __func__, ioc_status);
6644
+ ioc_err(ioc, "%s: failed with (ioc_status=0x%08x)\n",
6645
+ __func__, ioc_status);
58976646 r = -EFAULT;
58986647 goto out;
58996648 }
59006649
59016650 out:
59026651 ioc->port_enable_cmds.status = MPT3_CMD_NOT_USED;
5903
- pr_info(MPT3SAS_FMT "port enable: %s\n", ioc->name, ((r == 0) ?
5904
- "SUCCESS" : "FAILED"));
6652
+ ioc_info(ioc, "port enable: %s\n", r == 0 ? "SUCCESS" : "FAILED");
59056653 return r;
59066654 }
59076655
....@@ -5917,18 +6665,16 @@
59176665 Mpi2PortEnableRequest_t *mpi_request;
59186666 u16 smid;
59196667
5920
- pr_info(MPT3SAS_FMT "sending port enable !!\n", ioc->name);
6668
+ ioc_info(ioc, "sending port enable !!\n");
59216669
59226670 if (ioc->port_enable_cmds.status & MPT3_CMD_PENDING) {
5923
- pr_err(MPT3SAS_FMT "%s: internal command already in use\n",
5924
- ioc->name, __func__);
6671
+ ioc_err(ioc, "%s: internal command already in use\n", __func__);
59256672 return -EAGAIN;
59266673 }
59276674
59286675 smid = mpt3sas_base_get_smid(ioc, ioc->port_enable_cb_idx);
59296676 if (!smid) {
5930
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
5931
- ioc->name, __func__);
6677
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
59326678 return -EAGAIN;
59336679 }
59346680
....@@ -5938,7 +6684,7 @@
59386684 memset(mpi_request, 0, sizeof(Mpi2PortEnableRequest_t));
59396685 mpi_request->Function = MPI2_FUNCTION_PORT_ENABLE;
59406686
5941
- mpt3sas_base_put_smid_default(ioc, smid);
6687
+ ioc->put_smid_default(ioc, smid);
59426688 return 0;
59436689 }
59446690
....@@ -6031,19 +6777,16 @@
60316777 int r = 0;
60326778 int i;
60336779
6034
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
6035
- __func__));
6780
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
60366781
60376782 if (ioc->base_cmds.status & MPT3_CMD_PENDING) {
6038
- pr_err(MPT3SAS_FMT "%s: internal command already in use\n",
6039
- ioc->name, __func__);
6783
+ ioc_err(ioc, "%s: internal command already in use\n", __func__);
60406784 return -EAGAIN;
60416785 }
60426786
60436787 smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx);
60446788 if (!smid) {
6045
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
6046
- ioc->name, __func__);
6789
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
60476790 return -EAGAIN;
60486791 }
60496792 ioc->base_cmds.status = MPT3_CMD_PENDING;
....@@ -6057,11 +6800,10 @@
60576800 mpi_request->EventMasks[i] =
60586801 cpu_to_le32(ioc->event_masks[i]);
60596802 init_completion(&ioc->base_cmds.done);
6060
- mpt3sas_base_put_smid_default(ioc, smid);
6803
+ ioc->put_smid_default(ioc, smid);
60616804 wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ);
60626805 if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) {
6063
- pr_err(MPT3SAS_FMT "%s: timeout\n",
6064
- ioc->name, __func__);
6806
+ ioc_err(ioc, "%s: timeout\n", __func__);
60656807 _debug_dump_mf(mpi_request,
60666808 sizeof(Mpi2EventNotificationRequest_t)/4);
60676809 if (ioc->base_cmds.status & MPT3_CMD_RESET)
....@@ -6069,8 +6811,7 @@
60696811 else
60706812 r = -ETIME;
60716813 } else
6072
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s: complete\n",
6073
- ioc->name, __func__));
6814
+ dinitprintk(ioc, ioc_info(ioc, "%s: complete\n", __func__));
60746815 ioc->base_cmds.status = MPT3_CMD_NOT_USED;
60756816 return r;
60766817 }
....@@ -6126,18 +6867,18 @@
61266867 u32 count;
61276868 u32 hcb_size;
61286869
6129
- pr_info(MPT3SAS_FMT "sending diag reset !!\n", ioc->name);
6870
+ ioc_info(ioc, "sending diag reset !!\n");
61306871
6131
- drsprintk(ioc, pr_info(MPT3SAS_FMT "clear interrupts\n",
6132
- ioc->name));
6872
+ pci_cfg_access_lock(ioc->pdev);
6873
+
6874
+ drsprintk(ioc, ioc_info(ioc, "clear interrupts\n"));
61336875
61346876 count = 0;
61356877 do {
61366878 /* Write magic sequence to WriteSequence register
61376879 * Loop until in diagnostic mode
61386880 */
6139
- drsprintk(ioc, pr_info(MPT3SAS_FMT
6140
- "write magic sequence\n", ioc->name));
6881
+ drsprintk(ioc, ioc_info(ioc, "write magic sequence\n"));
61416882 writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence);
61426883 writel(MPI2_WRSEQ_1ST_KEY_VALUE, &ioc->chip->WriteSequence);
61436884 writel(MPI2_WRSEQ_2ND_KEY_VALUE, &ioc->chip->WriteSequence);
....@@ -6149,20 +6890,23 @@
61496890 /* wait 100 msec */
61506891 msleep(100);
61516892
6152
- if (count++ > 20)
6893
+ if (count++ > 20) {
6894
+ ioc_info(ioc,
6895
+ "Stop writing magic sequence after 20 retries\n");
6896
+ _base_dump_reg_set(ioc);
61536897 goto out;
6898
+ }
61546899
6155
- host_diagnostic = readl(&ioc->chip->HostDiagnostic);
6156
- drsprintk(ioc, pr_info(MPT3SAS_FMT
6157
- "wrote magic sequence: count(%d), host_diagnostic(0x%08x)\n",
6158
- ioc->name, count, host_diagnostic));
6900
+ host_diagnostic = ioc->base_readl(&ioc->chip->HostDiagnostic);
6901
+ drsprintk(ioc,
6902
+ ioc_info(ioc, "wrote magic sequence: count(%d), host_diagnostic(0x%08x)\n",
6903
+ count, host_diagnostic));
61596904
61606905 } while ((host_diagnostic & MPI2_DIAG_DIAG_WRITE_ENABLE) == 0);
61616906
6162
- hcb_size = readl(&ioc->chip->HCBSize);
6907
+ hcb_size = ioc->base_readl(&ioc->chip->HCBSize);
61636908
6164
- drsprintk(ioc, pr_info(MPT3SAS_FMT "diag reset: issued\n",
6165
- ioc->name));
6909
+ drsprintk(ioc, ioc_info(ioc, "diag reset: issued\n"));
61666910 writel(host_diagnostic | MPI2_DIAG_RESET_ADAPTER,
61676911 &ioc->chip->HostDiagnostic);
61686912
....@@ -6173,10 +6917,14 @@
61736917 for (count = 0; count < (300000000 /
61746918 MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC); count++) {
61756919
6176
- host_diagnostic = readl(&ioc->chip->HostDiagnostic);
6920
+ host_diagnostic = ioc->base_readl(&ioc->chip->HostDiagnostic);
61776921
6178
- if (host_diagnostic == 0xFFFFFFFF)
6922
+ if (host_diagnostic == 0xFFFFFFFF) {
6923
+ ioc_info(ioc,
6924
+ "Invalid host diagnostic register value\n");
6925
+ _base_dump_reg_set(ioc);
61796926 goto out;
6927
+ }
61806928 if (!(host_diagnostic & MPI2_DIAG_RESET_ADAPTER))
61816929 break;
61826930
....@@ -6185,43 +6933,41 @@
61856933
61866934 if (host_diagnostic & MPI2_DIAG_HCB_MODE) {
61876935
6188
- drsprintk(ioc, pr_info(MPT3SAS_FMT
6189
- "restart the adapter assuming the HCB Address points to good F/W\n",
6190
- ioc->name));
6936
+ drsprintk(ioc,
6937
+ ioc_info(ioc, "restart the adapter assuming the HCB Address points to good F/W\n"));
61916938 host_diagnostic &= ~MPI2_DIAG_BOOT_DEVICE_SELECT_MASK;
61926939 host_diagnostic |= MPI2_DIAG_BOOT_DEVICE_SELECT_HCDW;
61936940 writel(host_diagnostic, &ioc->chip->HostDiagnostic);
61946941
6195
- drsprintk(ioc, pr_info(MPT3SAS_FMT
6196
- "re-enable the HCDW\n", ioc->name));
6942
+ drsprintk(ioc, ioc_info(ioc, "re-enable the HCDW\n"));
61976943 writel(hcb_size | MPI2_HCB_SIZE_HCB_ENABLE,
61986944 &ioc->chip->HCBSize);
61996945 }
62006946
6201
- drsprintk(ioc, pr_info(MPT3SAS_FMT "restart the adapter\n",
6202
- ioc->name));
6947
+ drsprintk(ioc, ioc_info(ioc, "restart the adapter\n"));
62036948 writel(host_diagnostic & ~MPI2_DIAG_HOLD_IOC_RESET,
62046949 &ioc->chip->HostDiagnostic);
62056950
6206
- drsprintk(ioc, pr_info(MPT3SAS_FMT
6207
- "disable writes to the diagnostic register\n", ioc->name));
6951
+ drsprintk(ioc,
6952
+ ioc_info(ioc, "disable writes to the diagnostic register\n"));
62086953 writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence);
62096954
6210
- drsprintk(ioc, pr_info(MPT3SAS_FMT
6211
- "Wait for FW to go to the READY state\n", ioc->name));
6955
+ drsprintk(ioc, ioc_info(ioc, "Wait for FW to go to the READY state\n"));
62126956 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, 20);
62136957 if (ioc_state) {
6214
- pr_err(MPT3SAS_FMT
6215
- "%s: failed going to ready state (ioc_state=0x%x)\n",
6216
- ioc->name, __func__, ioc_state);
6958
+ ioc_err(ioc, "%s: failed going to ready state (ioc_state=0x%x)\n",
6959
+ __func__, ioc_state);
6960
+ _base_dump_reg_set(ioc);
62176961 goto out;
62186962 }
62196963
6220
- pr_info(MPT3SAS_FMT "diag reset: SUCCESS\n", ioc->name);
6964
+ pci_cfg_access_unlock(ioc->pdev);
6965
+ ioc_info(ioc, "diag reset: SUCCESS\n");
62216966 return 0;
62226967
62236968 out:
6224
- pr_err(MPT3SAS_FMT "diag reset: FAILED\n", ioc->name);
6969
+ pci_cfg_access_unlock(ioc->pdev);
6970
+ ioc_err(ioc, "diag reset: FAILED\n");
62256971 return -EFAULT;
62266972 }
62276973
....@@ -6239,15 +6985,15 @@
62396985 int rc;
62406986 int count;
62416987
6242
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
6243
- __func__));
6988
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
62446989
62456990 if (ioc->pci_error_recovery)
62466991 return 0;
62476992
62486993 ioc_state = mpt3sas_base_get_iocstate(ioc, 0);
6249
- dhsprintk(ioc, pr_info(MPT3SAS_FMT "%s: ioc_state(0x%08x)\n",
6250
- ioc->name, __func__, ioc_state));
6994
+ dhsprintk(ioc,
6995
+ ioc_info(ioc, "%s: ioc_state(0x%08x)\n",
6996
+ __func__, ioc_state));
62516997
62526998 /* if in RESET state, it should move to READY state shortly */
62536999 count = 0;
....@@ -6255,9 +7001,8 @@
62557001 while ((ioc_state & MPI2_IOC_STATE_MASK) !=
62567002 MPI2_IOC_STATE_READY) {
62577003 if (count++ == 10) {
6258
- pr_err(MPT3SAS_FMT
6259
- "%s: failed going to ready state (ioc_state=0x%x)\n",
6260
- ioc->name, __func__, ioc_state);
7004
+ ioc_err(ioc, "%s: failed going to ready state (ioc_state=0x%x)\n",
7005
+ __func__, ioc_state);
62617006 return -EFAULT;
62627007 }
62637008 ssleep(1);
....@@ -6269,15 +7014,30 @@
62697014 return 0;
62707015
62717016 if (ioc_state & MPI2_DOORBELL_USED) {
6272
- dhsprintk(ioc, pr_info(MPT3SAS_FMT
6273
- "unexpected doorbell active!\n",
6274
- ioc->name));
7017
+ ioc_info(ioc, "unexpected doorbell active!\n");
62757018 goto issue_diag_reset;
62767019 }
62777020
62787021 if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
6279
- mpt3sas_base_fault_info(ioc, ioc_state &
7022
+ mpt3sas_print_fault_code(ioc, ioc_state &
62807023 MPI2_DOORBELL_DATA_MASK);
7024
+ goto issue_diag_reset;
7025
+ }
7026
+
7027
+ if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_COREDUMP) {
7028
+ /*
7029
+ * if host reset is invoked while watch dog thread is waiting
7030
+ * for IOC state to be changed to Fault state then driver has
7031
+ * to wait here for CoreDump state to clear otherwise reset
7032
+ * will be issued to the FW and FW move the IOC state to
7033
+ * reset state without copying the FW logs to coredump region.
7034
+ */
7035
+ if (ioc->ioc_coredump_loop != MPT3SAS_COREDUMP_LOOP_DONE) {
7036
+ mpt3sas_print_coredump_info(ioc, ioc_state &
7037
+ MPI2_DOORBELL_DATA_MASK);
7038
+ mpt3sas_base_wait_for_coredump_completion(ioc,
7039
+ __func__);
7040
+ }
62817041 goto issue_diag_reset;
62827042 }
62837043
....@@ -6304,7 +7064,7 @@
63047064 static int
63057065 _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc)
63067066 {
6307
- int r, i, index;
7067
+ int r, i, index, rc;
63087068 unsigned long flags;
63097069 u32 reply_address;
63107070 u16 smid;
....@@ -6315,8 +7075,7 @@
63157075 struct adapter_reply_queue *reply_q;
63167076 Mpi2ReplyDescriptorsUnion_t *reply_post_free_contig;
63177077
6318
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
6319
- __func__));
7078
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
63207079
63217080 /* clean the delayed target reset list */
63227081 list_for_each_entry_safe(delayed_tr, delayed_tr_next,
....@@ -6408,8 +7167,19 @@
64087167 skip_init_reply_post_free_queue:
64097168
64107169 r = _base_send_ioc_init(ioc);
6411
- if (r)
6412
- return r;
7170
+ if (r) {
7171
+ /*
7172
+ * No need to check IOC state for fault state & issue
7173
+ * diag reset during host reset. This check is need
7174
+ * only during driver load time.
7175
+ */
7176
+ if (!ioc->is_driver_loading)
7177
+ return r;
7178
+
7179
+ rc = _base_check_for_fault_and_issue_reset(ioc);
7180
+ if (rc || (_base_send_ioc_init(ioc)))
7181
+ return r;
7182
+ }
64137183
64147184 /* initialize reply free host index */
64157185 ioc->reply_free_host_index = ioc->reply_free_queue_depth - 1;
....@@ -6432,7 +7202,7 @@
64327202
64337203 skip_init_reply_post_host_index:
64347204
6435
- _base_unmask_interrupts(ioc);
7205
+ mpt3sas_base_unmask_interrupts(ioc);
64367206
64377207 if (ioc->hba_mpi_version_belonged != MPI2_VERSION) {
64387208 r = _base_display_fwpkg_version(ioc);
....@@ -6476,13 +7246,12 @@
64767246 void
64777247 mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc)
64787248 {
6479
- dexitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
6480
- __func__));
7249
+ dexitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
64817250
64827251 /* synchronizing freeing resource with pci_access_mutex lock */
64837252 mutex_lock(&ioc->pci_access_mutex);
64847253 if (ioc->chip_phys && ioc->chip) {
6485
- _base_mask_interrupts(ioc);
7254
+ mpt3sas_base_mask_interrupts(ioc);
64867255 ioc->shost_recovery = 1;
64877256 _base_make_ioc_ready(ioc, SOFT_RESET);
64887257 ioc->shost_recovery = 0;
....@@ -6502,11 +7271,10 @@
65027271 int
65037272 mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
65047273 {
6505
- int r, i;
7274
+ int r, i, rc;
65067275 int cpu_id, last_cpu_id = 0;
65077276
6508
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
6509
- __func__));
7277
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
65107278
65117279 /* setup cpu_msix_table */
65127280 ioc->cpu_count = num_online_cpus();
....@@ -6516,9 +7284,7 @@
65167284 ioc->cpu_msix_table = kzalloc(ioc->cpu_msix_table_sz, GFP_KERNEL);
65177285 ioc->reply_queue_count = 1;
65187286 if (!ioc->cpu_msix_table) {
6519
- dfailprintk(ioc, pr_info(MPT3SAS_FMT
6520
- "allocation for cpu_msix_table failed!!!\n",
6521
- ioc->name));
7287
+ ioc_info(ioc, "Allocation for cpu_msix_table failed!!!\n");
65227288 r = -ENOMEM;
65237289 goto out_free_resources;
65247290 }
....@@ -6527,30 +7293,39 @@
65277293 ioc->reply_post_host_index = kcalloc(ioc->cpu_msix_table_sz,
65287294 sizeof(resource_size_t *), GFP_KERNEL);
65297295 if (!ioc->reply_post_host_index) {
6530
- dfailprintk(ioc, pr_info(MPT3SAS_FMT "allocation "
6531
- "for reply_post_host_index failed!!!\n",
6532
- ioc->name));
7296
+ ioc_info(ioc, "Allocation for reply_post_host_index failed!!!\n");
65337297 r = -ENOMEM;
65347298 goto out_free_resources;
65357299 }
65367300 }
65377301
7302
+ ioc->smp_affinity_enable = smp_affinity_enable;
7303
+
65387304 ioc->rdpq_array_enable_assigned = 0;
6539
- ioc->dma_mask = 0;
7305
+ ioc->use_32bit_dma = false;
7306
+ ioc->dma_mask = 64;
7307
+ if (ioc->is_aero_ioc)
7308
+ ioc->base_readl = &_base_readl_aero;
7309
+ else
7310
+ ioc->base_readl = &_base_readl;
65407311 r = mpt3sas_base_map_resources(ioc);
65417312 if (r)
65427313 goto out_free_resources;
65437314
65447315 pci_set_drvdata(ioc->pdev, ioc->shost);
65457316 r = _base_get_ioc_facts(ioc);
6546
- if (r)
6547
- goto out_free_resources;
7317
+ if (r) {
7318
+ rc = _base_check_for_fault_and_issue_reset(ioc);
7319
+ if (rc || (_base_get_ioc_facts(ioc)))
7320
+ goto out_free_resources;
7321
+ }
65487322
65497323 switch (ioc->hba_mpi_version_belonged) {
65507324 case MPI2_VERSION:
65517325 ioc->build_sg_scmd = &_base_build_sg_scmd;
65527326 ioc->build_sg = &_base_build_sg;
65537327 ioc->build_zero_len_sge = &_base_build_zero_len_sge;
7328
+ ioc->get_msix_index_for_smlio = &_base_get_msix_index;
65547329 break;
65557330 case MPI25_VERSION:
65567331 case MPI26_VERSION:
....@@ -6565,15 +7340,30 @@
65657340 ioc->build_nvme_prp = &_base_build_nvme_prp;
65667341 ioc->build_zero_len_sge = &_base_build_zero_len_sge_ieee;
65677342 ioc->sge_size_ieee = sizeof(Mpi2IeeeSgeSimple64_t);
6568
-
7343
+ if (ioc->high_iops_queues)
7344
+ ioc->get_msix_index_for_smlio =
7345
+ &_base_get_high_iops_msix_index;
7346
+ else
7347
+ ioc->get_msix_index_for_smlio = &_base_get_msix_index;
65697348 break;
65707349 }
6571
-
6572
- if (ioc->is_mcpu_endpoint)
6573
- ioc->put_smid_scsi_io = &_base_put_smid_mpi_ep_scsi_io;
6574
- else
6575
- ioc->put_smid_scsi_io = &_base_put_smid_scsi_io;
6576
-
7350
+ if (ioc->atomic_desc_capable) {
7351
+ ioc->put_smid_default = &_base_put_smid_default_atomic;
7352
+ ioc->put_smid_scsi_io = &_base_put_smid_scsi_io_atomic;
7353
+ ioc->put_smid_fast_path =
7354
+ &_base_put_smid_fast_path_atomic;
7355
+ ioc->put_smid_hi_priority =
7356
+ &_base_put_smid_hi_priority_atomic;
7357
+ } else {
7358
+ ioc->put_smid_default = &_base_put_smid_default;
7359
+ ioc->put_smid_fast_path = &_base_put_smid_fast_path;
7360
+ ioc->put_smid_hi_priority = &_base_put_smid_hi_priority;
7361
+ if (ioc->is_mcpu_endpoint)
7362
+ ioc->put_smid_scsi_io =
7363
+ &_base_put_smid_mpi_ep_scsi_io;
7364
+ else
7365
+ ioc->put_smid_scsi_io = &_base_put_smid_scsi_io;
7366
+ }
65777367 /*
65787368 * These function pointers for other requests that don't
65797369 * the require IEEE scatter gather elements.
....@@ -6596,14 +7386,23 @@
65967386
65977387 for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) {
65987388 r = _base_get_port_facts(ioc, i);
6599
- if (r)
6600
- goto out_free_resources;
7389
+ if (r) {
7390
+ rc = _base_check_for_fault_and_issue_reset(ioc);
7391
+ if (rc || (_base_get_port_facts(ioc, i)))
7392
+ goto out_free_resources;
7393
+ }
66017394 }
66027395
66037396 r = _base_allocate_memory_pools(ioc);
66047397 if (r)
66057398 goto out_free_resources;
66067399
7400
+ if (irqpoll_weight > 0)
7401
+ ioc->thresh_hold = irqpoll_weight;
7402
+ else
7403
+ ioc->thresh_hold = ioc->hba_queue_depth/4;
7404
+
7405
+ _base_init_irqpolls(ioc);
66077406 init_waitqueue_head(&ioc->reset_wq);
66087407
66097408 /* allocate memory pd handle bitmask list */
....@@ -6717,7 +7516,15 @@
67177516 if (r)
67187517 goto out_free_resources;
67197518
7519
+ /*
7520
+ * Copy current copy of IOCFacts in prev_fw_facts
7521
+ * and it will be used during online firmware upgrade.
7522
+ */
7523
+ memcpy(&ioc->prev_fw_facts, &ioc->facts,
7524
+ sizeof(struct mpt3sas_facts));
7525
+
67207526 ioc->non_operational_loop = 0;
7527
+ ioc->ioc_coredump_loop = 0;
67217528 ioc->got_task_abort_from_ioctl = 0;
67227529 return 0;
67237530
....@@ -6762,8 +7569,7 @@
67627569 void
67637570 mpt3sas_base_detach(struct MPT3SAS_ADAPTER *ioc)
67647571 {
6765
- dexitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
6766
- __func__));
7572
+ dexitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
67677573
67687574 mpt3sas_base_stop_watchdog(ioc);
67697575 mpt3sas_base_free_resources(ioc);
....@@ -6796,20 +7602,18 @@
67967602 {
67977603 mpt3sas_scsih_pre_reset_handler(ioc);
67987604 mpt3sas_ctl_pre_reset_handler(ioc);
6799
- dtmprintk(ioc, pr_info(MPT3SAS_FMT
6800
- "%s: MPT3_IOC_PRE_RESET\n", ioc->name, __func__));
7605
+ dtmprintk(ioc, ioc_info(ioc, "%s: MPT3_IOC_PRE_RESET\n", __func__));
68017606 }
68027607
68037608 /**
6804
- * _base_after_reset_handler - after reset handler
7609
+ * _base_clear_outstanding_mpt_commands - clears outstanding mpt commands
68057610 * @ioc: per adapter object
68067611 */
6807
-static void _base_after_reset_handler(struct MPT3SAS_ADAPTER *ioc)
7612
+static void
7613
+_base_clear_outstanding_mpt_commands(struct MPT3SAS_ADAPTER *ioc)
68087614 {
6809
- mpt3sas_scsih_after_reset_handler(ioc);
6810
- mpt3sas_ctl_after_reset_handler(ioc);
6811
- dtmprintk(ioc, pr_info(MPT3SAS_FMT
6812
- "%s: MPT3_IOC_AFTER_RESET\n", ioc->name, __func__));
7615
+ dtmprintk(ioc,
7616
+ ioc_info(ioc, "%s: clear outstanding mpt cmds\n", __func__));
68137617 if (ioc->transport_cmds.status & MPT3_CMD_PENDING) {
68147618 ioc->transport_cmds.status |= MPT3_CMD_RESET;
68157619 mpt3sas_base_free_smid(ioc, ioc->transport_cmds.smid);
....@@ -6843,6 +7647,17 @@
68437647 }
68447648
68457649 /**
7650
+ * _base_clear_outstanding_commands - clear all outstanding commands
7651
+ * @ioc: per adapter object
7652
+ */
7653
+static void _base_clear_outstanding_commands(struct MPT3SAS_ADAPTER *ioc)
7654
+{
7655
+ mpt3sas_scsih_clear_outstanding_scsi_tm_commands(ioc);
7656
+ mpt3sas_ctl_clear_outstanding_ioctls(ioc);
7657
+ _base_clear_outstanding_mpt_commands(ioc);
7658
+}
7659
+
7660
+/**
68467661 * _base_reset_done_handler - reset done handler
68477662 * @ioc: per adapter object
68487663 */
....@@ -6850,8 +7665,7 @@
68507665 {
68517666 mpt3sas_scsih_reset_done_handler(ioc);
68527667 mpt3sas_ctl_reset_done_handler(ioc);
6853
- dtmprintk(ioc, pr_info(MPT3SAS_FMT
6854
- "%s: MPT3_IOC_DONE_RESET\n", ioc->name, __func__));
7668
+ dtmprintk(ioc, ioc_info(ioc, "%s: MPT3_IOC_DONE_RESET\n", __func__));
68557669 }
68567670
68577671 /**
....@@ -6883,6 +7697,85 @@
68837697 }
68847698
68857699 /**
7700
+ * _base_check_ioc_facts_changes - Look for increase/decrease of IOCFacts
7701
+ * attributes during online firmware upgrade and update the corresponding
7702
+ * IOC variables accordingly.
7703
+ *
7704
+ * @ioc: Pointer to MPT_ADAPTER structure
7705
+ */
7706
+static int
7707
+_base_check_ioc_facts_changes(struct MPT3SAS_ADAPTER *ioc)
7708
+{
7709
+ u16 pd_handles_sz;
7710
+ void *pd_handles = NULL, *blocking_handles = NULL;
7711
+ void *pend_os_device_add = NULL, *device_remove_in_progress = NULL;
7712
+ struct mpt3sas_facts *old_facts = &ioc->prev_fw_facts;
7713
+
7714
+ if (ioc->facts.MaxDevHandle > old_facts->MaxDevHandle) {
7715
+ pd_handles_sz = (ioc->facts.MaxDevHandle / 8);
7716
+ if (ioc->facts.MaxDevHandle % 8)
7717
+ pd_handles_sz++;
7718
+
7719
+ pd_handles = krealloc(ioc->pd_handles, pd_handles_sz,
7720
+ GFP_KERNEL);
7721
+ if (!pd_handles) {
7722
+ ioc_info(ioc,
7723
+ "Unable to allocate the memory for pd_handles of sz: %d\n",
7724
+ pd_handles_sz);
7725
+ return -ENOMEM;
7726
+ }
7727
+ memset(pd_handles + ioc->pd_handles_sz, 0,
7728
+ (pd_handles_sz - ioc->pd_handles_sz));
7729
+ ioc->pd_handles = pd_handles;
7730
+
7731
+ blocking_handles = krealloc(ioc->blocking_handles,
7732
+ pd_handles_sz, GFP_KERNEL);
7733
+ if (!blocking_handles) {
7734
+ ioc_info(ioc,
7735
+ "Unable to allocate the memory for "
7736
+ "blocking_handles of sz: %d\n",
7737
+ pd_handles_sz);
7738
+ return -ENOMEM;
7739
+ }
7740
+ memset(blocking_handles + ioc->pd_handles_sz, 0,
7741
+ (pd_handles_sz - ioc->pd_handles_sz));
7742
+ ioc->blocking_handles = blocking_handles;
7743
+ ioc->pd_handles_sz = pd_handles_sz;
7744
+
7745
+ pend_os_device_add = krealloc(ioc->pend_os_device_add,
7746
+ pd_handles_sz, GFP_KERNEL);
7747
+ if (!pend_os_device_add) {
7748
+ ioc_info(ioc,
7749
+ "Unable to allocate the memory for pend_os_device_add of sz: %d\n",
7750
+ pd_handles_sz);
7751
+ return -ENOMEM;
7752
+ }
7753
+ memset(pend_os_device_add + ioc->pend_os_device_add_sz, 0,
7754
+ (pd_handles_sz - ioc->pend_os_device_add_sz));
7755
+ ioc->pend_os_device_add = pend_os_device_add;
7756
+ ioc->pend_os_device_add_sz = pd_handles_sz;
7757
+
7758
+ device_remove_in_progress = krealloc(
7759
+ ioc->device_remove_in_progress, pd_handles_sz, GFP_KERNEL);
7760
+ if (!device_remove_in_progress) {
7761
+ ioc_info(ioc,
7762
+ "Unable to allocate the memory for "
7763
+ "device_remove_in_progress of sz: %d\n "
7764
+ , pd_handles_sz);
7765
+ return -ENOMEM;
7766
+ }
7767
+ memset(device_remove_in_progress +
7768
+ ioc->device_remove_in_progress_sz, 0,
7769
+ (pd_handles_sz - ioc->device_remove_in_progress_sz));
7770
+ ioc->device_remove_in_progress = device_remove_in_progress;
7771
+ ioc->device_remove_in_progress_sz = pd_handles_sz;
7772
+ }
7773
+
7774
+ memcpy(&ioc->prev_fw_facts, &ioc->facts, sizeof(struct mpt3sas_facts));
7775
+ return 0;
7776
+}
7777
+
7778
+/**
68867779 * mpt3sas_base_hard_reset_handler - reset controller
68877780 * @ioc: Pointer to MPT_ADAPTER structure
68887781 * @type: FORCE_BIG_HAMMER or SOFT_RESET
....@@ -6898,12 +7791,10 @@
68987791 u32 ioc_state;
68997792 u8 is_fault = 0, is_trigger = 0;
69007793
6901
- dtmprintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n", ioc->name,
6902
- __func__));
7794
+ dtmprintk(ioc, ioc_info(ioc, "%s: enter\n", __func__));
69037795
69047796 if (ioc->pci_error_recovery) {
6905
- pr_err(MPT3SAS_FMT "%s: pci error recovery reset\n",
6906
- ioc->name, __func__);
7797
+ ioc_err(ioc, "%s: pci error recovery reset\n", __func__);
69077798 r = 0;
69087799 goto out_unlocked;
69097800 }
....@@ -6924,16 +7815,18 @@
69247815 MPT3_DIAG_BUFFER_IS_RELEASED))) {
69257816 is_trigger = 1;
69267817 ioc_state = mpt3sas_base_get_iocstate(ioc, 0);
6927
- if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT)
7818
+ if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT ||
7819
+ (ioc_state & MPI2_IOC_STATE_MASK) ==
7820
+ MPI2_IOC_STATE_COREDUMP)
69287821 is_fault = 1;
69297822 }
69307823 _base_pre_reset_handler(ioc);
69317824 mpt3sas_wait_for_commands_to_complete(ioc);
6932
- _base_mask_interrupts(ioc);
7825
+ mpt3sas_base_mask_interrupts(ioc);
69337826 r = _base_make_ioc_ready(ioc, type);
69347827 if (r)
69357828 goto out;
6936
- _base_after_reset_handler(ioc);
7829
+ _base_clear_outstanding_commands(ioc);
69377830
69387831 /* If this hard reset is called while port enable is active, then
69397832 * there is no reason to call make_ioc_operational
....@@ -6947,6 +7840,13 @@
69477840 if (r)
69487841 goto out;
69497842
7843
+ r = _base_check_ioc_facts_changes(ioc);
7844
+ if (r) {
7845
+ ioc_info(ioc,
7846
+ "Some of the parameters got changed in this new firmware"
7847
+ " image and it requires system reboot\n");
7848
+ goto out;
7849
+ }
69507850 if (ioc->rdpq_array_enable && !ioc->rdpq_array_capable)
69517851 panic("%s: Issue occurred with flashing controller firmware."
69527852 "Please reboot the system and ensure that the correct"
....@@ -6957,8 +7857,7 @@
69577857 _base_reset_done_handler(ioc);
69587858
69597859 out:
6960
- dtmprintk(ioc, pr_info(MPT3SAS_FMT "%s: %s\n",
6961
- ioc->name, __func__, ((r == 0) ? "SUCCESS" : "FAILED")));
7860
+ ioc_info(ioc, "%s: %s\n", __func__, r == 0 ? "SUCCESS" : "FAILED");
69627861
69637862 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
69647863 ioc->shost_recovery = 0;
....@@ -6974,7 +7873,6 @@
69747873 mpt3sas_trigger_master(ioc,
69757874 MASTER_TRIGGER_ADAPTER_RESET);
69767875 }
6977
- dtmprintk(ioc, pr_info(MPT3SAS_FMT "%s: exit\n", ioc->name,
6978
- __func__));
7876
+ dtmprintk(ioc, ioc_info(ioc, "%s: exit\n", __func__));
69797877 return r;
69807878 }