forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/drivers/scsi/mpt3sas/mpt3sas_base.c
....@@ -74,32 +74,65 @@
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);
133
+
134
+static u32
135
+_base_readl_ext_retry(const volatile void __iomem *addr);
103136
104137 /**
105138 * mpt3sas_base_check_cmd_timeout - Function
....@@ -122,8 +155,8 @@
122155 if (!(status & MPT3_CMD_RESET))
123156 issue_reset = 1;
124157
125
- pr_err(MPT3SAS_FMT "Command %s\n", ioc->name,
126
- ((issue_reset == 0) ? "terminated due to Host Reset" : "Timeout"));
158
+ ioc_err(ioc, "Command %s\n",
159
+ issue_reset == 0 ? "terminated due to Host Reset" : "Timeout");
127160 _debug_dump_mf(mpi_request, sz);
128161
129162 return issue_reset;
....@@ -155,6 +188,46 @@
155188 }
156189 module_param_call(mpt3sas_fwfault_debug, _scsih_set_fwfault_debug,
157190 param_get_int, &mpt3sas_fwfault_debug, 0644);
191
+
192
+/**
193
+ * _base_readl_aero - retry readl for max three times.
194
+ * @addr: MPT Fusion system interface register address
195
+ *
196
+ * Retry the readl() for max three times if it gets zero value
197
+ * while reading the system interface register.
198
+ */
199
+static inline u32
200
+_base_readl_aero(const volatile void __iomem *addr)
201
+{
202
+ u32 i = 0, ret_val;
203
+
204
+ do {
205
+ ret_val = readl(addr);
206
+ i++;
207
+ } while (ret_val == 0 && i < 3);
208
+
209
+ return ret_val;
210
+}
211
+
212
+static u32
213
+_base_readl_ext_retry(const volatile void __iomem *addr)
214
+{
215
+ u32 i, ret_val;
216
+
217
+ for (i = 0 ; i < 30 ; i++) {
218
+ ret_val = readl(addr);
219
+ if (ret_val == 0)
220
+ continue;
221
+ }
222
+
223
+ return ret_val;
224
+}
225
+
226
+static inline u32
227
+_base_readl(const volatile void __iomem *addr)
228
+{
229
+ return readl(addr);
230
+}
158231
159232 /**
160233 * _base_clone_reply_to_sys_mem - copies reply to reply free iomem
....@@ -336,9 +409,7 @@
336409 return ct->chain_buffer;
337410 }
338411 }
339
- pr_info(MPT3SAS_FMT
340
- "Provided chain_buffer_dma address is not in the lookup list\n",
341
- ioc->name);
412
+ ioc_info(ioc, "Provided chain_buffer_dma address is not in the lookup list\n");
342413 return NULL;
343414 }
344415
....@@ -357,7 +428,7 @@
357428 {
358429 Mpi2SGESimple32_t *sgel, *sgel_next;
359430 u32 sgl_flags, sge_chain_count = 0;
360
- bool is_write = 0;
431
+ bool is_write = false;
361432 u16 i = 0;
362433 void __iomem *buffer_iomem;
363434 phys_addr_t buffer_iomem_phys;
....@@ -394,7 +465,7 @@
394465 /* Get scsi_cmd using smid */
395466 scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid);
396467 if (scmd == NULL) {
397
- pr_err(MPT3SAS_FMT "scmd is NULL\n", ioc->name);
468
+ ioc_err(ioc, "scmd is NULL\n");
398469 return;
399470 }
400471
....@@ -426,7 +497,7 @@
426497
427498 if (le32_to_cpu(sgel->FlagsLength) &
428499 (MPI2_SGE_FLAGS_HOST_TO_IOC << MPI2_SGE_FLAGS_SHIFT))
429
- is_write = 1;
500
+ is_write = true;
430501
431502 for (i = 0; i < MPT_MIN_PHYS_SEGMENTS + ioc->facts.MaxChainDepth; i++) {
432503
....@@ -532,11 +603,11 @@
532603 struct MPT3SAS_ADAPTER *ioc = (struct MPT3SAS_ADAPTER *)arg;
533604 struct pci_dev *pdev;
534605
535
- if ((ioc == NULL))
606
+ if (!ioc)
536607 return -1;
537608
538609 pdev = ioc->pdev;
539
- if ((pdev == NULL))
610
+ if (!pdev)
540611 return -1;
541612 pci_stop_and_remove_bus_device_locked(pdev);
542613 return 0;
....@@ -560,14 +631,14 @@
560631
561632
562633 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
563
- if (ioc->shost_recovery || ioc->pci_error_recovery)
634
+ if ((ioc->shost_recovery && (ioc->ioc_coredump_loop == 0)) ||
635
+ ioc->pci_error_recovery)
564636 goto rearm_timer;
565637 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
566638
567639 doorbell = mpt3sas_base_get_iocstate(ioc, 0);
568640 if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_MASK) {
569
- pr_err(MPT3SAS_FMT "SAS host is non-operational !!!!\n",
570
- ioc->name);
641
+ ioc_err(ioc, "SAS host is non-operational !!!!\n");
571642
572643 /* It may be possible that EEH recovery can resolve some of
573644 * pci bus failure issues rather removing the dead ioc function
....@@ -600,30 +671,72 @@
600671 p = kthread_run(mpt3sas_remove_dead_ioc_func, ioc,
601672 "%s_dead_ioc_%d", ioc->driver_name, ioc->id);
602673 if (IS_ERR(p))
603
- pr_err(MPT3SAS_FMT
604
- "%s: Running mpt3sas_dead_ioc thread failed !!!!\n",
605
- ioc->name, __func__);
674
+ ioc_err(ioc, "%s: Running mpt3sas_dead_ioc thread failed !!!!\n",
675
+ __func__);
606676 else
607
- pr_err(MPT3SAS_FMT
608
- "%s: Running mpt3sas_dead_ioc thread success !!!!\n",
609
- ioc->name, __func__);
677
+ ioc_err(ioc, "%s: Running mpt3sas_dead_ioc thread success !!!!\n",
678
+ __func__);
610679 return; /* don't rearm timer */
611680 }
612681
613
- ioc->non_operational_loop = 0;
682
+ if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_COREDUMP) {
683
+ u8 timeout = (ioc->manu_pg11.CoreDumpTOSec) ?
684
+ ioc->manu_pg11.CoreDumpTOSec :
685
+ MPT3SAS_DEFAULT_COREDUMP_TIMEOUT_SECONDS;
614686
687
+ timeout /= (FAULT_POLLING_INTERVAL/1000);
688
+
689
+ if (ioc->ioc_coredump_loop == 0) {
690
+ mpt3sas_print_coredump_info(ioc,
691
+ doorbell & MPI2_DOORBELL_DATA_MASK);
692
+ /* do not accept any IOs and disable the interrupts */
693
+ spin_lock_irqsave(
694
+ &ioc->ioc_reset_in_progress_lock, flags);
695
+ ioc->shost_recovery = 1;
696
+ spin_unlock_irqrestore(
697
+ &ioc->ioc_reset_in_progress_lock, flags);
698
+ mpt3sas_base_mask_interrupts(ioc);
699
+ _base_clear_outstanding_commands(ioc);
700
+ }
701
+
702
+ ioc_info(ioc, "%s: CoreDump loop %d.",
703
+ __func__, ioc->ioc_coredump_loop);
704
+
705
+ /* Wait until CoreDump completes or times out */
706
+ if (ioc->ioc_coredump_loop++ < timeout) {
707
+ spin_lock_irqsave(
708
+ &ioc->ioc_reset_in_progress_lock, flags);
709
+ goto rearm_timer;
710
+ }
711
+ }
712
+
713
+ if (ioc->ioc_coredump_loop) {
714
+ if ((doorbell & MPI2_IOC_STATE_MASK) != MPI2_IOC_STATE_COREDUMP)
715
+ ioc_err(ioc, "%s: CoreDump completed. LoopCount: %d",
716
+ __func__, ioc->ioc_coredump_loop);
717
+ else
718
+ ioc_err(ioc, "%s: CoreDump Timed out. LoopCount: %d",
719
+ __func__, ioc->ioc_coredump_loop);
720
+ ioc->ioc_coredump_loop = MPT3SAS_COREDUMP_LOOP_DONE;
721
+ }
722
+ ioc->non_operational_loop = 0;
615723 if ((doorbell & MPI2_IOC_STATE_MASK) != MPI2_IOC_STATE_OPERATIONAL) {
616724 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");
725
+ ioc_warn(ioc, "%s: hard reset: %s\n",
726
+ __func__, rc == 0 ? "success" : "failed");
619727 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 &
728
+ if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
729
+ mpt3sas_print_fault_code(ioc, doorbell &
730
+ MPI2_DOORBELL_DATA_MASK);
731
+ } else if ((doorbell & MPI2_IOC_STATE_MASK) ==
732
+ MPI2_IOC_STATE_COREDUMP)
733
+ mpt3sas_print_coredump_info(ioc, doorbell &
622734 MPI2_DOORBELL_DATA_MASK);
623735 if (rc && (doorbell & MPI2_IOC_STATE_MASK) !=
624736 MPI2_IOC_STATE_OPERATIONAL)
625737 return; /* don't rearm timer */
626738 }
739
+ ioc->ioc_coredump_loop = 0;
627740
628741 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
629742 rearm_timer:
....@@ -657,8 +770,7 @@
657770 ioc->fault_reset_work_q =
658771 create_singlethread_workqueue(ioc->fault_reset_work_q_name);
659772 if (!ioc->fault_reset_work_q) {
660
- pr_err(MPT3SAS_FMT "%s: failed (line=%d)\n",
661
- ioc->name, __func__, __LINE__);
773
+ ioc_err(ioc, "%s: failed (line=%d)\n", __func__, __LINE__);
662774 return;
663775 }
664776 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
....@@ -700,8 +812,51 @@
700812 void
701813 mpt3sas_base_fault_info(struct MPT3SAS_ADAPTER *ioc , u16 fault_code)
702814 {
703
- pr_err(MPT3SAS_FMT "fault_state(0x%04x)!\n",
704
- ioc->name, fault_code);
815
+ ioc_err(ioc, "fault_state(0x%04x)!\n", fault_code);
816
+}
817
+
818
+/**
819
+ * mpt3sas_base_coredump_info - verbose translation of firmware CoreDump state
820
+ * @ioc: per adapter object
821
+ * @fault_code: fault code
822
+ *
823
+ * Return nothing.
824
+ */
825
+void
826
+mpt3sas_base_coredump_info(struct MPT3SAS_ADAPTER *ioc, u16 fault_code)
827
+{
828
+ ioc_err(ioc, "coredump_state(0x%04x)!\n", fault_code);
829
+}
830
+
831
+/**
832
+ * mpt3sas_base_wait_for_coredump_completion - Wait until coredump
833
+ * completes or times out
834
+ * @ioc: per adapter object
835
+ * @caller: caller function name
836
+ *
837
+ * Returns 0 for success, non-zero for failure.
838
+ */
839
+int
840
+mpt3sas_base_wait_for_coredump_completion(struct MPT3SAS_ADAPTER *ioc,
841
+ const char *caller)
842
+{
843
+ u8 timeout = (ioc->manu_pg11.CoreDumpTOSec) ?
844
+ ioc->manu_pg11.CoreDumpTOSec :
845
+ MPT3SAS_DEFAULT_COREDUMP_TIMEOUT_SECONDS;
846
+
847
+ int ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_FAULT,
848
+ timeout);
849
+
850
+ if (ioc_state)
851
+ ioc_err(ioc,
852
+ "%s: CoreDump timed out. (ioc_state=0x%x)\n",
853
+ caller, ioc_state);
854
+ else
855
+ ioc_info(ioc,
856
+ "%s: CoreDump completed. (ioc_state=0x%x)\n",
857
+ caller, ioc_state);
858
+
859
+ return ioc_state;
705860 }
706861
707862 /**
....@@ -723,13 +878,17 @@
723878
724879 dump_stack();
725880
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 {
881
+ doorbell = ioc->base_readl_ext_retry(&ioc->chip->Doorbell);
882
+ if ((doorbell & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
883
+ mpt3sas_print_fault_code(ioc, doorbell &
884
+ MPI2_DOORBELL_DATA_MASK);
885
+ } else if ((doorbell & MPI2_IOC_STATE_MASK) ==
886
+ MPI2_IOC_STATE_COREDUMP) {
887
+ mpt3sas_print_coredump_info(ioc, doorbell &
888
+ MPI2_DOORBELL_DATA_MASK);
889
+ } else {
730890 writel(0xC0FFEE00, &ioc->chip->Doorbell);
731
- pr_err(MPT3SAS_FMT "Firmware is halted due to command timeout\n",
732
- ioc->name);
891
+ ioc_err(ioc, "Firmware is halted due to command timeout\n");
733892 }
734893
735894 if (ioc->fwfault_debug == 2)
....@@ -956,8 +1115,8 @@
9561115 break;
9571116 }
9581117
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);
1118
+ ioc_warn(ioc, "ioc_status: %s(0x%04x), request(0x%p),(%s)\n",
1119
+ desc, ioc_status, request_hdr, func_str);
9611120
9621121 _debug_dump_mf(request_hdr, frame_sz/4);
9631122 }
....@@ -1003,9 +1162,9 @@
10031162 {
10041163 Mpi2EventDataSasDiscovery_t *event_data =
10051164 (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");
1165
+ ioc_info(ioc, "Discovery: (%s)",
1166
+ event_data->ReasonCode == MPI2_EVENT_SAS_DISC_RC_STARTED ?
1167
+ "start" : "stop");
10091168 if (event_data->DiscoveryStatus)
10101169 pr_cont(" discovery_status(0x%08x)",
10111170 le32_to_cpu(event_data->DiscoveryStatus));
....@@ -1059,14 +1218,13 @@
10591218 {
10601219 Mpi26EventDataPCIeEnumeration_t *event_data =
10611220 (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");
1221
+ ioc_info(ioc, "PCIE Enumeration: (%s)",
1222
+ event_data->ReasonCode == MPI26_EVENT_PCIE_ENUM_RC_STARTED ?
1223
+ "start" : "stop");
10661224 if (event_data->EnumerationStatus)
1067
- pr_info("enumeration_status(0x%08x)",
1068
- le32_to_cpu(event_data->EnumerationStatus));
1069
- pr_info("\n");
1225
+ pr_cont("enumeration_status(0x%08x)",
1226
+ le32_to_cpu(event_data->EnumerationStatus));
1227
+ pr_cont("\n");
10701228 return;
10711229 }
10721230 case MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST:
....@@ -1077,7 +1235,7 @@
10771235 if (!desc)
10781236 return;
10791237
1080
- pr_info(MPT3SAS_FMT "%s\n", ioc->name, desc);
1238
+ ioc_info(ioc, "%s\n", desc);
10811239 }
10821240
10831241 /**
....@@ -1128,11 +1286,9 @@
11281286 break;
11291287 }
11301288
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);
1289
+ ioc_warn(ioc, "log_info(0x%08x): originator(%s), code(0x%02x), sub_code(0x%04x)\n",
1290
+ log_info,
1291
+ originator_str, sas_loginfo.dw.code, sas_loginfo.dw.subcode);
11361292 }
11371293
11381294 /**
....@@ -1152,8 +1308,8 @@
11521308
11531309 mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
11541310 if (unlikely(!mpi_reply)) {
1155
- pr_err(MPT3SAS_FMT "mpi_reply not valid at %s:%d/%s()!\n",
1156
- ioc->name, __FILE__, __LINE__, __func__);
1311
+ ioc_err(ioc, "mpi_reply not valid at %s:%d/%s()!\n",
1312
+ __FILE__, __LINE__, __func__);
11571313 return;
11581314 }
11591315 ioc_status = le16_to_cpu(mpi_reply->IOCStatus);
....@@ -1249,9 +1405,9 @@
12491405 delayed_event_ack->EventContext = mpi_reply->EventContext;
12501406 list_add_tail(&delayed_event_ack->list,
12511407 &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)));
1408
+ dewtprintk(ioc,
1409
+ ioc_info(ioc, "DELAYED: EVENT ACK: event (0x%04x)\n",
1410
+ le16_to_cpu(mpi_reply->Event)));
12551411 goto out;
12561412 }
12571413
....@@ -1262,7 +1418,7 @@
12621418 ack_request->EventContext = mpi_reply->EventContext;
12631419 ack_request->VF_ID = 0; /* TODO */
12641420 ack_request->VP_ID = 0;
1265
- mpt3sas_base_put_smid_default(ioc, smid);
1421
+ ioc->put_smid_default(ioc, smid);
12661422
12671423 out:
12681424
....@@ -1325,35 +1481,35 @@
13251481 }
13261482
13271483 /**
1328
- * _base_mask_interrupts - disable interrupts
1484
+ * mpt3sas_base_mask_interrupts - disable interrupts
13291485 * @ioc: per adapter object
13301486 *
13311487 * Disabling ResetIRQ, Reply and Doorbell Interrupts
13321488 */
1333
-static void
1334
-_base_mask_interrupts(struct MPT3SAS_ADAPTER *ioc)
1489
+void
1490
+mpt3sas_base_mask_interrupts(struct MPT3SAS_ADAPTER *ioc)
13351491 {
13361492 u32 him_register;
13371493
13381494 ioc->mask_interrupts = 1;
1339
- him_register = readl(&ioc->chip->HostInterruptMask);
1495
+ him_register = ioc->base_readl(&ioc->chip->HostInterruptMask);
13401496 him_register |= MPI2_HIM_DIM + MPI2_HIM_RIM + MPI2_HIM_RESET_IRQ_MASK;
13411497 writel(him_register, &ioc->chip->HostInterruptMask);
1342
- readl(&ioc->chip->HostInterruptMask);
1498
+ ioc->base_readl(&ioc->chip->HostInterruptMask);
13431499 }
13441500
13451501 /**
1346
- * _base_unmask_interrupts - enable interrupts
1502
+ * mpt3sas_base_unmask_interrupts - enable interrupts
13471503 * @ioc: per adapter object
13481504 *
13491505 * Enabling only Reply Interrupts
13501506 */
1351
-static void
1352
-_base_unmask_interrupts(struct MPT3SAS_ADAPTER *ioc)
1507
+void
1508
+mpt3sas_base_unmask_interrupts(struct MPT3SAS_ADAPTER *ioc)
13531509 {
13541510 u32 him_register;
13551511
1356
- him_register = readl(&ioc->chip->HostInterruptMask);
1512
+ him_register = ioc->base_readl(&ioc->chip->HostInterruptMask);
13571513 him_register &= ~MPI2_HIM_RIM;
13581514 writel(him_register, &ioc->chip->HostInterruptMask);
13591515 ioc->mask_interrupts = 0;
....@@ -1367,20 +1523,30 @@
13671523 } u;
13681524 };
13691525
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)
1526
+static u32 base_mod64(u64 dividend, u32 divisor)
13791527 {
1380
- struct adapter_reply_queue *reply_q = bus_id;
1528
+ u32 remainder;
1529
+
1530
+ if (!divisor)
1531
+ pr_err("mpt3sas: DIVISOR is zero, in div fn\n");
1532
+ remainder = do_div(dividend, divisor);
1533
+ return remainder;
1534
+}
1535
+
1536
+/**
1537
+ * _base_process_reply_queue - Process reply descriptors from reply
1538
+ * descriptor post queue.
1539
+ * @reply_q: per IRQ's reply queue object.
1540
+ *
1541
+ * Return: number of reply descriptors processed from reply
1542
+ * descriptor queue.
1543
+ */
1544
+static int
1545
+_base_process_reply_queue(struct adapter_reply_queue *reply_q)
1546
+{
13811547 union reply_descriptor rd;
1382
- u32 completed_cmds;
1383
- u8 request_desript_type;
1548
+ u64 completed_cmds;
1549
+ u8 request_descript_type;
13841550 u16 smid;
13851551 u8 cb_idx;
13861552 u32 reply;
....@@ -1389,21 +1555,18 @@
13891555 Mpi2ReplyDescriptorsUnion_t *rpf;
13901556 u8 rc;
13911557
1392
- if (ioc->mask_interrupts)
1393
- return IRQ_NONE;
1394
-
1558
+ completed_cmds = 0;
13951559 if (!atomic_add_unless(&reply_q->busy, 1, 1))
1396
- return IRQ_NONE;
1560
+ return completed_cmds;
13971561
13981562 rpf = &reply_q->reply_post_free[reply_q->reply_post_host_index];
1399
- request_desript_type = rpf->Default.ReplyFlags
1563
+ request_descript_type = rpf->Default.ReplyFlags
14001564 & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK;
1401
- if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) {
1565
+ if (request_descript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) {
14021566 atomic_dec(&reply_q->busy);
1403
- return IRQ_NONE;
1567
+ return completed_cmds;
14041568 }
14051569
1406
- completed_cmds = 0;
14071570 cb_idx = 0xFF;
14081571 do {
14091572 rd.word = le64_to_cpu(rpf->Words);
....@@ -1411,11 +1574,11 @@
14111574 goto out;
14121575 reply = 0;
14131576 smid = le16_to_cpu(rpf->Default.DescriptorTypeDependent1);
1414
- if (request_desript_type ==
1577
+ if (request_descript_type ==
14151578 MPI25_RPY_DESCRIPT_FLAGS_FAST_PATH_SCSI_IO_SUCCESS ||
1416
- request_desript_type ==
1579
+ request_descript_type ==
14171580 MPI2_RPY_DESCRIPT_FLAGS_SCSI_IO_SUCCESS ||
1418
- request_desript_type ==
1581
+ request_descript_type ==
14191582 MPI26_RPY_DESCRIPT_FLAGS_PCIE_ENCAPSULATED_SUCCESS) {
14201583 cb_idx = _base_get_cb_idx(ioc, smid);
14211584 if ((likely(cb_idx < MPT_MAX_CALLBACKS)) &&
....@@ -1425,7 +1588,7 @@
14251588 if (rc)
14261589 mpt3sas_base_free_smid(ioc, smid);
14271590 }
1428
- } else if (request_desript_type ==
1591
+ } else if (request_descript_type ==
14291592 MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY) {
14301593 reply = le32_to_cpu(
14311594 rpf->AddressReply.ReplyFrameAddress);
....@@ -1471,7 +1634,7 @@
14711634 (reply_q->reply_post_host_index ==
14721635 (ioc->reply_post_queue_depth - 1)) ? 0 :
14731636 reply_q->reply_post_host_index + 1;
1474
- request_desript_type =
1637
+ request_descript_type =
14751638 reply_q->reply_post_free[reply_q->reply_post_host_index].
14761639 Default.ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK;
14771640 completed_cmds++;
....@@ -1480,7 +1643,7 @@
14801643 * So that FW can find enough entries to post the Reply
14811644 * Descriptors in the reply descriptor post queue.
14821645 */
1483
- if (completed_cmds > ioc->hba_queue_depth/3) {
1646
+ if (completed_cmds >= ioc->thresh_hold) {
14841647 if (ioc->combined_reply_queue) {
14851648 writel(reply_q->reply_post_host_index |
14861649 ((msix_index & 7) <<
....@@ -1492,9 +1655,14 @@
14921655 MPI2_RPHI_MSIX_INDEX_SHIFT),
14931656 &ioc->chip->ReplyPostHostIndex);
14941657 }
1495
- completed_cmds = 1;
1658
+ if (!reply_q->irq_poll_scheduled) {
1659
+ reply_q->irq_poll_scheduled = true;
1660
+ irq_poll_sched(&reply_q->irqpoll);
1661
+ }
1662
+ atomic_dec(&reply_q->busy);
1663
+ return completed_cmds;
14961664 }
1497
- if (request_desript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED)
1665
+ if (request_descript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED)
14981666 goto out;
14991667 if (!reply_q->reply_post_host_index)
15001668 rpf = reply_q->reply_post_free;
....@@ -1506,14 +1674,14 @@
15061674
15071675 if (!completed_cmds) {
15081676 atomic_dec(&reply_q->busy);
1509
- return IRQ_NONE;
1677
+ return completed_cmds;
15101678 }
15111679
15121680 if (ioc->is_warpdrive) {
15131681 writel(reply_q->reply_post_host_index,
15141682 ioc->reply_post_host_index[msix_index]);
15151683 atomic_dec(&reply_q->busy);
1516
- return IRQ_HANDLED;
1684
+ return completed_cmds;
15171685 }
15181686
15191687 /* Update Reply Post Host Index.
....@@ -1540,7 +1708,89 @@
15401708 MPI2_RPHI_MSIX_INDEX_SHIFT),
15411709 &ioc->chip->ReplyPostHostIndex);
15421710 atomic_dec(&reply_q->busy);
1543
- return IRQ_HANDLED;
1711
+ return completed_cmds;
1712
+}
1713
+
1714
+/**
1715
+ * _base_interrupt - MPT adapter (IOC) specific interrupt handler.
1716
+ * @irq: irq number (not used)
1717
+ * @bus_id: bus identifier cookie == pointer to MPT_ADAPTER structure
1718
+ *
1719
+ * Return: IRQ_HANDLED if processed, else IRQ_NONE.
1720
+ */
1721
+static irqreturn_t
1722
+_base_interrupt(int irq, void *bus_id)
1723
+{
1724
+ struct adapter_reply_queue *reply_q = bus_id;
1725
+ struct MPT3SAS_ADAPTER *ioc = reply_q->ioc;
1726
+
1727
+ if (ioc->mask_interrupts)
1728
+ return IRQ_NONE;
1729
+ if (reply_q->irq_poll_scheduled)
1730
+ return IRQ_HANDLED;
1731
+ return ((_base_process_reply_queue(reply_q) > 0) ?
1732
+ IRQ_HANDLED : IRQ_NONE);
1733
+}
1734
+
1735
+/**
1736
+ * _base_irqpoll - IRQ poll callback handler
1737
+ * @irqpoll: irq_poll object
1738
+ * @budget: irq poll weight
1739
+ *
1740
+ * returns number of reply descriptors processed
1741
+ */
1742
+static int
1743
+_base_irqpoll(struct irq_poll *irqpoll, int budget)
1744
+{
1745
+ struct adapter_reply_queue *reply_q;
1746
+ int num_entries = 0;
1747
+
1748
+ reply_q = container_of(irqpoll, struct adapter_reply_queue,
1749
+ irqpoll);
1750
+ if (reply_q->irq_line_enable) {
1751
+ disable_irq_nosync(reply_q->os_irq);
1752
+ reply_q->irq_line_enable = false;
1753
+ }
1754
+ num_entries = _base_process_reply_queue(reply_q);
1755
+ if (num_entries < budget) {
1756
+ irq_poll_complete(irqpoll);
1757
+ reply_q->irq_poll_scheduled = false;
1758
+ reply_q->irq_line_enable = true;
1759
+ enable_irq(reply_q->os_irq);
1760
+ /*
1761
+ * Go for one more round of processing the
1762
+ * reply descriptor post queue incase if HBA
1763
+ * Firmware has posted some reply descriptors
1764
+ * while reenabling the IRQ.
1765
+ */
1766
+ _base_process_reply_queue(reply_q);
1767
+ }
1768
+
1769
+ return num_entries;
1770
+}
1771
+
1772
+/**
1773
+ * _base_init_irqpolls - initliaze IRQ polls
1774
+ * @ioc: per adapter object
1775
+ *
1776
+ * returns nothing
1777
+ */
1778
+static void
1779
+_base_init_irqpolls(struct MPT3SAS_ADAPTER *ioc)
1780
+{
1781
+ struct adapter_reply_queue *reply_q, *next;
1782
+
1783
+ if (list_empty(&ioc->reply_queue_list))
1784
+ return;
1785
+
1786
+ list_for_each_entry_safe(reply_q, next, &ioc->reply_queue_list, list) {
1787
+ irq_poll_init(&reply_q->irqpoll,
1788
+ ioc->hba_queue_depth/4, _base_irqpoll);
1789
+ reply_q->irq_poll_scheduled = false;
1790
+ reply_q->irq_line_enable = true;
1791
+ reply_q->os_irq = pci_irq_vector(ioc->pdev,
1792
+ reply_q->msix_index);
1793
+ }
15441794 }
15451795
15461796 /**
....@@ -1559,12 +1809,14 @@
15591809 /**
15601810 * mpt3sas_base_sync_reply_irqs - flush pending MSIX interrupts
15611811 * @ioc: per adapter object
1812
+ * @poll: poll over reply descriptor pools incase interrupt for
1813
+ * timed-out SCSI command got delayed
15621814 * Context: non ISR conext
15631815 *
15641816 * Called when a Task Management request has completed.
15651817 */
15661818 void
1567
-mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc)
1819
+mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc, u8 poll)
15681820 {
15691821 struct adapter_reply_queue *reply_q;
15701822
....@@ -1582,6 +1834,24 @@
15821834 if (reply_q->msix_index == 0)
15831835 continue;
15841836 synchronize_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index));
1837
+ if (reply_q->irq_poll_scheduled) {
1838
+ /* Calling irq_poll_disable will wait for any pending
1839
+ * callbacks to have completed.
1840
+ */
1841
+ irq_poll_disable(&reply_q->irqpoll);
1842
+ irq_poll_enable(&reply_q->irqpoll);
1843
+ /* check how the scheduled poll has ended,
1844
+ * clean up only if necessary
1845
+ */
1846
+ if (reply_q->irq_poll_scheduled) {
1847
+ reply_q->irq_poll_scheduled = false;
1848
+ reply_q->irq_line_enable = true;
1849
+ enable_irq(reply_q->os_irq);
1850
+ }
1851
+ }
1852
+
1853
+ if (poll)
1854
+ _base_process_reply_queue(reply_q);
15851855 }
15861856 }
15871857
....@@ -2122,6 +2392,11 @@
21222392 bool build_prp = true;
21232393
21242394 data_length = scsi_bufflen(scmd);
2395
+ if (pcie_device &&
2396
+ (mpt3sas_scsih_is_pcie_scsi_device(pcie_device->device_info))) {
2397
+ build_prp = false;
2398
+ return build_prp;
2399
+ }
21252400
21262401 /* If Datalenth is <= 16K and number of SGE’s entries are <= 2
21272402 * we built IEEE SGL
....@@ -2270,7 +2545,7 @@
22702545 sges_left = scsi_dma_map(scmd);
22712546 if (sges_left < 0) {
22722547 sdev_printk(KERN_ERR, scmd->device,
2273
- "pci_map_sg failed: request for %d bytes!\n",
2548
+ "scsi_dma_map failed: request for %d bytes!\n",
22742549 scsi_bufflen(scmd));
22752550 return -ENOMEM;
22762551 }
....@@ -2418,7 +2693,7 @@
24182693 sges_left = scsi_dma_map(scmd);
24192694 if (sges_left < 0) {
24202695 sdev_printk(KERN_ERR, scmd->device,
2421
- "pci_map_sg failed: request for %d bytes!\n",
2696
+ "scsi_dma_map failed: request for %d bytes!\n",
24222697 scsi_bufflen(scmd));
24232698 return -ENOMEM;
24242699 }
....@@ -2564,57 +2839,39 @@
25642839 _base_config_dma_addressing(struct MPT3SAS_ADAPTER *ioc, struct pci_dev *pdev)
25652840 {
25662841 struct sysinfo s;
2567
- u64 consistent_dma_mask;
2842
+ u64 coherent_dma_mask, dma_mask;
2843
+
2844
+ if (ioc->is_mcpu_endpoint || sizeof(dma_addr_t) == 4) {
2845
+ ioc->dma_mask = 32;
2846
+ coherent_dma_mask = dma_mask = DMA_BIT_MASK(32);
25682847 /* Set 63 bit DMA mask for all SAS3 and SAS35 controllers */
2569
- int dma_mask = (ioc->hba_mpi_version_belonged > MPI2_VERSION) ? 63 : 64;
2570
-
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
- }
2848
+ } else if (ioc->hba_mpi_version_belonged > MPI2_VERSION) {
2849
+ ioc->dma_mask = 63;
2850
+ coherent_dma_mask = dma_mask = DMA_BIT_MASK(63);
2851
+ } else {
2852
+ ioc->dma_mask = 64;
2853
+ coherent_dma_mask = dma_mask = DMA_BIT_MASK(64);
25902854 }
25912855
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);
2597
- ioc->dma_mask = 32;
2598
- } else
2856
+ if (ioc->use_32bit_dma)
2857
+ coherent_dma_mask = DMA_BIT_MASK(32);
2858
+
2859
+ if (dma_set_mask(&pdev->dev, dma_mask) ||
2860
+ dma_set_coherent_mask(&pdev->dev, coherent_dma_mask))
25992861 return -ENODEV;
26002862
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;
2863
+ if (ioc->dma_mask > 32) {
2864
+ ioc->base_add_sg_single = &_base_add_sg_single_64;
2865
+ ioc->sge_size = sizeof(Mpi2SGESimple64_t);
2866
+ } else {
2867
+ ioc->base_add_sg_single = &_base_add_sg_single_32;
2868
+ ioc->sge_size = sizeof(Mpi2SGESimple32_t);
26172869 }
2870
+
2871
+ si_meminfo(&s);
2872
+ ioc_info(ioc, "%d BIT PCI BUS DMA ADDRESSING SUPPORTED, total mem (%ld kB)\n",
2873
+ ioc->dma_mask, convert_to_kb(s.totalram));
2874
+
26182875 return 0;
26192876 }
26202877
....@@ -2641,8 +2898,7 @@
26412898
26422899 base = pci_find_capability(ioc->pdev, PCI_CAP_ID_MSIX);
26432900 if (!base) {
2644
- dfailprintk(ioc, pr_info(MPT3SAS_FMT "msix not supported\n",
2645
- ioc->name));
2901
+ dfailprintk(ioc, ioc_info(ioc, "msix not supported\n"));
26462902 return -EINVAL;
26472903 }
26482904
....@@ -2660,9 +2916,8 @@
26602916 pci_read_config_word(ioc->pdev, base + 2, &message_control);
26612917 ioc->msix_vector_count = (message_control & 0x3FF) + 1;
26622918 }
2663
- dinitprintk(ioc, pr_info(MPT3SAS_FMT
2664
- "msix is supported, vector_count(%d)\n",
2665
- ioc->name, ioc->msix_vector_count));
2919
+ dinitprintk(ioc, ioc_info(ioc, "msix is supported, vector_count(%d)\n",
2920
+ ioc->msix_vector_count));
26662921 return 0;
26672922 }
26682923
....@@ -2682,6 +2937,9 @@
26822937
26832938 list_for_each_entry_safe(reply_q, next, &ioc->reply_queue_list, list) {
26842939 list_del(&reply_q->list);
2940
+ if (ioc->smp_affinity_enable)
2941
+ irq_set_affinity_hint(pci_irq_vector(ioc->pdev,
2942
+ reply_q->msix_index), NULL);
26852943 free_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index),
26862944 reply_q);
26872945 kfree(reply_q);
....@@ -2704,8 +2962,8 @@
27042962
27052963 reply_q = kzalloc(sizeof(struct adapter_reply_queue), GFP_KERNEL);
27062964 if (!reply_q) {
2707
- pr_err(MPT3SAS_FMT "unable to allocate memory %d!\n",
2708
- ioc->name, (int)sizeof(struct adapter_reply_queue));
2965
+ ioc_err(ioc, "unable to allocate memory %zu!\n",
2966
+ sizeof(struct adapter_reply_queue));
27092967 return -ENOMEM;
27102968 }
27112969 reply_q->ioc = ioc;
....@@ -2721,7 +2979,7 @@
27212979 r = request_irq(pci_irq_vector(pdev, index), _base_interrupt,
27222980 IRQF_SHARED, reply_q->name, reply_q);
27232981 if (r) {
2724
- pr_err(MPT3SAS_FMT "unable to allocate interrupt %d!\n",
2982
+ pr_err("%s: unable to allocate interrupt %d!\n",
27252983 reply_q->name, pci_irq_vector(pdev, index));
27262984 kfree(reply_q);
27272985 return -EBUSY;
....@@ -2746,8 +3004,12 @@
27463004 {
27473005 unsigned int cpu, nr_cpus, nr_msix, index = 0;
27483006 struct adapter_reply_queue *reply_q;
3007
+ int local_numa_node;
27493008
27503009 if (!_base_is_controller_msix_enabled(ioc))
3010
+ return;
3011
+
3012
+ if (ioc->msix_load_balance)
27513013 return;
27523014
27533015 memset(ioc->cpu_msix_table, 0, ioc->cpu_msix_table_sz);
....@@ -2758,14 +3020,33 @@
27583020 if (!nr_msix)
27593021 return;
27603022
2761
- if (smp_affinity_enable) {
3023
+ if (ioc->smp_affinity_enable) {
3024
+
3025
+ /*
3026
+ * set irq affinity to local numa node for those irqs
3027
+ * corresponding to high iops queues.
3028
+ */
3029
+ if (ioc->high_iops_queues) {
3030
+ local_numa_node = dev_to_node(&ioc->pdev->dev);
3031
+ for (index = 0; index < ioc->high_iops_queues;
3032
+ index++) {
3033
+ irq_set_affinity_hint(pci_irq_vector(ioc->pdev,
3034
+ index), cpumask_of_node(local_numa_node));
3035
+ }
3036
+ }
3037
+
27623038 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);
3039
+ const cpumask_t *mask;
3040
+
3041
+ if (reply_q->msix_index < ioc->high_iops_queues)
27683042 continue;
3043
+
3044
+ mask = pci_irq_get_affinity(ioc->pdev,
3045
+ reply_q->msix_index);
3046
+ if (!mask) {
3047
+ ioc_warn(ioc, "no affinity for msi %x\n",
3048
+ reply_q->msix_index);
3049
+ goto fall_back;
27693050 }
27703051
27713052 for_each_cpu_and(cpu, mask, cpu_online_mask) {
....@@ -2776,11 +3057,17 @@
27763057 }
27773058 return;
27783059 }
3060
+
3061
+fall_back:
27793062 cpu = cpumask_first(cpu_online_mask);
3063
+ nr_msix -= ioc->high_iops_queues;
3064
+ index = 0;
27803065
27813066 list_for_each_entry(reply_q, &ioc->reply_queue_list, list) {
2782
-
27833067 unsigned int i, group = nr_cpus / nr_msix;
3068
+
3069
+ if (reply_q->msix_index < ioc->high_iops_queues)
3070
+ continue;
27843071
27853072 if (cpu >= nr_cpus)
27863073 break;
....@@ -2797,6 +3084,52 @@
27973084 }
27983085
27993086 /**
3087
+ * _base_check_and_enable_high_iops_queues - enable high iops mode
3088
+ * @ioc: per adapter object
3089
+ * @hba_msix_vector_count: msix vectors supported by HBA
3090
+ *
3091
+ * Enable high iops queues only if
3092
+ * - HBA is a SEA/AERO controller and
3093
+ * - MSI-Xs vector supported by the HBA is 128 and
3094
+ * - total CPU count in the system >=16 and
3095
+ * - loaded driver with default max_msix_vectors module parameter and
3096
+ * - system booted in non kdump mode
3097
+ *
3098
+ * returns nothing.
3099
+ */
3100
+static void
3101
+_base_check_and_enable_high_iops_queues(struct MPT3SAS_ADAPTER *ioc,
3102
+ int hba_msix_vector_count)
3103
+{
3104
+ u16 lnksta, speed;
3105
+
3106
+ if (perf_mode == MPT_PERF_MODE_IOPS ||
3107
+ perf_mode == MPT_PERF_MODE_LATENCY) {
3108
+ ioc->high_iops_queues = 0;
3109
+ return;
3110
+ }
3111
+
3112
+ if (perf_mode == MPT_PERF_MODE_DEFAULT) {
3113
+
3114
+ pcie_capability_read_word(ioc->pdev, PCI_EXP_LNKSTA, &lnksta);
3115
+ speed = lnksta & PCI_EXP_LNKSTA_CLS;
3116
+
3117
+ if (speed < 0x4) {
3118
+ ioc->high_iops_queues = 0;
3119
+ return;
3120
+ }
3121
+ }
3122
+
3123
+ if (!reset_devices && ioc->is_aero_ioc &&
3124
+ hba_msix_vector_count == MPT3SAS_GEN35_MAX_MSIX_QUEUES &&
3125
+ num_online_cpus() >= MPT3SAS_HIGH_IOPS_REPLY_QUEUES &&
3126
+ max_msix_vectors == -1)
3127
+ ioc->high_iops_queues = MPT3SAS_HIGH_IOPS_REPLY_QUEUES;
3128
+ else
3129
+ ioc->high_iops_queues = 0;
3130
+}
3131
+
3132
+/**
28003133 * _base_disable_msix - disables msix
28013134 * @ioc: per adapter object
28023135 *
....@@ -2806,8 +3139,35 @@
28063139 {
28073140 if (!ioc->msix_enable)
28083141 return;
2809
- pci_disable_msix(ioc->pdev);
3142
+ pci_free_irq_vectors(ioc->pdev);
28103143 ioc->msix_enable = 0;
3144
+}
3145
+
3146
+/**
3147
+ * _base_alloc_irq_vectors - allocate msix vectors
3148
+ * @ioc: per adapter object
3149
+ *
3150
+ */
3151
+static int
3152
+_base_alloc_irq_vectors(struct MPT3SAS_ADAPTER *ioc)
3153
+{
3154
+ int i, irq_flags = PCI_IRQ_MSIX;
3155
+ struct irq_affinity desc = { .pre_vectors = ioc->high_iops_queues };
3156
+ struct irq_affinity *descp = &desc;
3157
+
3158
+ if (ioc->smp_affinity_enable)
3159
+ irq_flags |= PCI_IRQ_AFFINITY;
3160
+ else
3161
+ descp = NULL;
3162
+
3163
+ ioc_info(ioc, " %d %d\n", ioc->high_iops_queues,
3164
+ ioc->reply_queue_count);
3165
+
3166
+ i = pci_alloc_irq_vectors_affinity(ioc->pdev,
3167
+ ioc->high_iops_queues,
3168
+ ioc->reply_queue_count, irq_flags, descp);
3169
+
3170
+ return i;
28113171 }
28123172
28133173 /**
....@@ -2821,7 +3181,8 @@
28213181 int r;
28223182 int i, local_max_msix_vectors;
28233183 u8 try_msix = 0;
2824
- unsigned int irq_flags = PCI_IRQ_MSIX;
3184
+
3185
+ ioc->msix_load_balance = false;
28253186
28263187 if (msix_disable == -1 || msix_disable == 0)
28273188 try_msix = 1;
....@@ -2832,12 +3193,15 @@
28323193 if (_base_check_enable_msix(ioc) != 0)
28333194 goto try_ioapic;
28343195
2835
- ioc->reply_queue_count = min_t(int, ioc->cpu_count,
3196
+ ioc_info(ioc, "MSI-X vectors supported: %d\n", ioc->msix_vector_count);
3197
+ pr_info("\t no of cores: %d, max_msix_vectors: %d\n",
3198
+ ioc->cpu_count, max_msix_vectors);
3199
+ if (ioc->is_aero_ioc)
3200
+ _base_check_and_enable_high_iops_queues(ioc,
3201
+ ioc->msix_vector_count);
3202
+ ioc->reply_queue_count =
3203
+ min_t(int, ioc->cpu_count + ioc->high_iops_queues,
28363204 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);
28413205
28423206 if (!ioc->rdpq_array_enable && max_msix_vectors == -1)
28433207 local_max_msix_vectors = (reset_devices) ? 1 : 8;
....@@ -2850,18 +3214,27 @@
28503214 else if (local_max_msix_vectors == 0)
28513215 goto try_ioapic;
28523216
2853
- if (ioc->msix_vector_count < ioc->cpu_count)
2854
- smp_affinity_enable = 0;
3217
+ /*
3218
+ * Enable msix_load_balance only if combined reply queue mode is
3219
+ * disabled on SAS3 & above generation HBA devices.
3220
+ */
3221
+ if (!ioc->combined_reply_queue &&
3222
+ ioc->hba_mpi_version_belonged != MPI2_VERSION) {
3223
+ ioc_info(ioc,
3224
+ "combined ReplyQueue is off, Enabling msix load balance\n");
3225
+ ioc->msix_load_balance = true;
3226
+ }
28553227
2856
- if (smp_affinity_enable)
2857
- irq_flags |= PCI_IRQ_AFFINITY;
3228
+ /*
3229
+ * smp affinity setting is not need when msix load balance
3230
+ * is enabled.
3231
+ */
3232
+ if (ioc->msix_load_balance)
3233
+ ioc->smp_affinity_enable = 0;
28583234
2859
- r = pci_alloc_irq_vectors(ioc->pdev, 1, ioc->reply_queue_count,
2860
- irq_flags);
3235
+ r = _base_alloc_irq_vectors(ioc);
28613236 if (r < 0) {
2862
- dfailprintk(ioc, pr_info(MPT3SAS_FMT
2863
- "pci_alloc_irq_vectors failed (r=%d) !!!\n",
2864
- ioc->name, r));
3237
+ ioc_info(ioc, "pci_alloc_irq_vectors failed (r=%d) !!!\n", r);
28653238 goto try_ioapic;
28663239 }
28673240
....@@ -2876,17 +3249,21 @@
28763249 }
28773250 }
28783251
3252
+ ioc_info(ioc, "High IOPs queues : %s\n",
3253
+ ioc->high_iops_queues ? "enabled" : "disabled");
3254
+
28793255 return 0;
28803256
28813257 /* failback to io_apic interrupt routing */
28823258 try_ioapic:
2883
-
3259
+ ioc->high_iops_queues = 0;
3260
+ ioc_info(ioc, "High IOPs queues : disabled\n");
28843261 ioc->reply_queue_count = 1;
28853262 r = pci_alloc_irq_vectors(ioc->pdev, 1, 1, PCI_IRQ_LEGACY);
28863263 if (r < 0) {
2887
- dfailprintk(ioc, pr_info(MPT3SAS_FMT
2888
- "pci_alloc_irq_vector(legacy) failed (r=%d) !!!\n",
2889
- ioc->name, r));
3264
+ dfailprintk(ioc,
3265
+ ioc_info(ioc, "pci_alloc_irq_vector(legacy) failed (r=%d) !!!\n",
3266
+ r));
28903267 } else
28913268 r = _base_request_irq(ioc, 0);
28923269
....@@ -2902,8 +3279,7 @@
29023279 {
29033280 struct pci_dev *pdev = ioc->pdev;
29043281
2905
- dexitprintk(ioc, printk(MPT3SAS_FMT "%s\n",
2906
- ioc->name, __func__));
3282
+ dexitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
29073283
29083284 _base_free_irq(ioc);
29093285 _base_disable_msix(ioc);
....@@ -2924,6 +3300,43 @@
29243300 }
29253301 }
29263302
3303
+static int
3304
+_base_diag_reset(struct MPT3SAS_ADAPTER *ioc);
3305
+
3306
+/**
3307
+ * _base_check_for_fault_and_issue_reset - check if IOC is in fault state
3308
+ * and if it is in fault state then issue diag reset.
3309
+ * @ioc: per adapter object
3310
+ *
3311
+ * Returns: 0 for success, non-zero for failure.
3312
+ */
3313
+static int
3314
+_base_check_for_fault_and_issue_reset(struct MPT3SAS_ADAPTER *ioc)
3315
+{
3316
+ u32 ioc_state;
3317
+ int rc = -EFAULT;
3318
+
3319
+ dinitprintk(ioc, pr_info("%s\n", __func__));
3320
+ if (ioc->pci_error_recovery)
3321
+ return 0;
3322
+ ioc_state = mpt3sas_base_get_iocstate(ioc, 0);
3323
+ dhsprintk(ioc, pr_info("%s: ioc_state(0x%08x)\n", __func__, ioc_state));
3324
+
3325
+ if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
3326
+ mpt3sas_print_fault_code(ioc, ioc_state &
3327
+ MPI2_DOORBELL_DATA_MASK);
3328
+ rc = _base_diag_reset(ioc);
3329
+ } else if ((ioc_state & MPI2_IOC_STATE_MASK) ==
3330
+ MPI2_IOC_STATE_COREDUMP) {
3331
+ mpt3sas_print_coredump_info(ioc, ioc_state &
3332
+ MPI2_DOORBELL_DATA_MASK);
3333
+ mpt3sas_base_wait_for_coredump_completion(ioc, __func__);
3334
+ rc = _base_diag_reset(ioc);
3335
+ }
3336
+
3337
+ return rc;
3338
+}
3339
+
29273340 /**
29283341 * mpt3sas_base_map_resources - map in controller resources (io/irq/memap)
29293342 * @ioc: per adapter object
....@@ -2936,18 +3349,16 @@
29363349 struct pci_dev *pdev = ioc->pdev;
29373350 u32 memap_sz;
29383351 u32 pio_sz;
2939
- int i, r = 0;
3352
+ int i, r = 0, rc;
29403353 u64 pio_chip = 0;
29413354 phys_addr_t chip_phys = 0;
29423355 struct adapter_reply_queue *reply_q;
29433356
2944
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n",
2945
- ioc->name, __func__));
3357
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
29463358
29473359 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM);
29483360 if (pci_enable_device_mem(pdev)) {
2949
- pr_warn(MPT3SAS_FMT "pci_enable_device_mem: failed\n",
2950
- ioc->name);
3361
+ ioc_warn(ioc, "pci_enable_device_mem: failed\n");
29513362 ioc->bars = 0;
29523363 return -ENODEV;
29533364 }
....@@ -2955,8 +3366,7 @@
29553366
29563367 if (pci_request_selected_regions(pdev, ioc->bars,
29573368 ioc->driver_name)) {
2958
- pr_warn(MPT3SAS_FMT "pci_request_selected_regions: failed\n",
2959
- ioc->name);
3369
+ ioc_warn(ioc, "pci_request_selected_regions: failed\n");
29603370 ioc->bars = 0;
29613371 r = -ENODEV;
29623372 goto out_fail;
....@@ -2969,8 +3379,7 @@
29693379
29703380
29713381 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));
3382
+ ioc_warn(ioc, "no suitable DMA mask for %s\n", pci_name(pdev));
29743383 r = -ENODEV;
29753384 goto out_fail;
29763385 }
....@@ -2993,17 +3402,20 @@
29933402 }
29943403
29953404 if (ioc->chip == NULL) {
2996
- pr_err(MPT3SAS_FMT "unable to map adapter memory! "
2997
- " or resource not found\n", ioc->name);
3405
+ ioc_err(ioc,
3406
+ "unable to map adapter memory! or resource not found\n");
29983407 r = -EINVAL;
29993408 goto out_fail;
30003409 }
30013410
3002
- _base_mask_interrupts(ioc);
3411
+ mpt3sas_base_mask_interrupts(ioc);
30033412
30043413 r = _base_get_ioc_facts(ioc);
3005
- if (r)
3006
- goto out_fail;
3414
+ if (r) {
3415
+ rc = _base_check_for_fault_and_issue_reset(ioc);
3416
+ if (rc || (_base_get_ioc_facts(ioc)))
3417
+ goto out_fail;
3418
+ }
30073419
30083420 if (!ioc->rdpq_array_enable_assigned) {
30093421 ioc->rdpq_array_enable = ioc->rdpq_array_capable;
....@@ -3014,6 +3426,8 @@
30143426 if (r)
30153427 goto out_fail;
30163428
3429
+ if (!ioc->is_driver_loading)
3430
+ _base_init_irqpolls(ioc);
30173431 /* Use the Combined reply queue feature only for SAS3 C0 & higher
30183432 * revision HBAs and also only when reply queue count is greater than 8
30193433 */
....@@ -3028,9 +3442,8 @@
30283442 ioc->combined_reply_index_count,
30293443 sizeof(resource_size_t *), GFP_KERNEL);
30303444 if (!ioc->replyPostRegisterIndex) {
3031
- dfailprintk(ioc, printk(MPT3SAS_FMT
3032
- "allocation for reply Post Register Index failed!!!\n",
3033
- ioc->name));
3445
+ ioc_err(ioc,
3446
+ "allocation for replyPostRegisterIndex failed!\n");
30343447 r = -ENOMEM;
30353448 goto out_fail;
30363449 }
....@@ -3055,15 +3468,15 @@
30553468 }
30563469
30573470 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));
3471
+ pr_info("%s: %s enabled: IRQ %d\n",
3472
+ reply_q->name,
3473
+ ioc->msix_enable ? "PCI-MSI-X" : "IO-APIC",
3474
+ pci_irq_vector(ioc->pdev, reply_q->msix_index));
30623475
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);
3476
+ ioc_info(ioc, "iomem(%pap), mapped(0x%p), size(%d)\n",
3477
+ &chip_phys, ioc->chip, memap_sz);
3478
+ ioc_info(ioc, "ioport(0x%016llx), size(%d)\n",
3479
+ (unsigned long long)pio_chip, pio_sz);
30673480
30683481 /* Save PCI configuration state for recovery from PCI AER/EEH errors */
30693482 pci_save_state(pdev);
....@@ -3155,10 +3568,71 @@
31553568 return ioc->reply + (phys_addr - (u32)ioc->reply_dma);
31563569 }
31573570
3571
+/**
3572
+ * _base_get_msix_index - get the msix index
3573
+ * @ioc: per adapter object
3574
+ * @scmd: scsi_cmnd object
3575
+ *
3576
+ * returns msix index of general reply queues,
3577
+ * i.e. reply queue on which IO request's reply
3578
+ * should be posted by the HBA firmware.
3579
+ */
31583580 static inline u8
3159
-_base_get_msix_index(struct MPT3SAS_ADAPTER *ioc)
3581
+_base_get_msix_index(struct MPT3SAS_ADAPTER *ioc,
3582
+ struct scsi_cmnd *scmd)
31603583 {
3584
+ /* Enables reply_queue load balancing */
3585
+ if (ioc->msix_load_balance)
3586
+ return ioc->reply_queue_count ?
3587
+ base_mod64(atomic64_add_return(1,
3588
+ &ioc->total_io_cnt), ioc->reply_queue_count) : 0;
3589
+
31613590 return ioc->cpu_msix_table[raw_smp_processor_id()];
3591
+}
3592
+
3593
+/**
3594
+ * _base_sdev_nr_inflight_request -get number of inflight requests
3595
+ * of a request queue.
3596
+ * @q: request_queue object
3597
+ *
3598
+ * returns number of inflight request of a request queue.
3599
+ */
3600
+inline unsigned long
3601
+_base_sdev_nr_inflight_request(struct request_queue *q)
3602
+{
3603
+ struct blk_mq_hw_ctx *hctx = q->queue_hw_ctx[0];
3604
+
3605
+ return atomic_read(&hctx->nr_active);
3606
+}
3607
+
3608
+
3609
+/**
3610
+ * _base_get_high_iops_msix_index - get the msix index of
3611
+ * high iops queues
3612
+ * @ioc: per adapter object
3613
+ * @scmd: scsi_cmnd object
3614
+ *
3615
+ * Returns: msix index of high iops reply queues.
3616
+ * i.e. high iops reply queue on which IO request's
3617
+ * reply should be posted by the HBA firmware.
3618
+ */
3619
+static inline u8
3620
+_base_get_high_iops_msix_index(struct MPT3SAS_ADAPTER *ioc,
3621
+ struct scsi_cmnd *scmd)
3622
+{
3623
+ /**
3624
+ * Round robin the IO interrupts among the high iops
3625
+ * reply queues in terms of batch count 16 when outstanding
3626
+ * IOs on the target device is >=8.
3627
+ */
3628
+ if (_base_sdev_nr_inflight_request(scmd->device->request_queue) >
3629
+ MPT3SAS_DEVICE_HIGH_IOPS_DEPTH)
3630
+ return base_mod64((
3631
+ atomic64_add_return(1, &ioc->high_iops_outstanding) /
3632
+ MPT3SAS_HIGH_IOPS_BATCH_COUNT),
3633
+ MPT3SAS_HIGH_IOPS_REPLY_QUEUES);
3634
+
3635
+ return _base_get_msix_index(ioc, scmd);
31623636 }
31633637
31643638 /**
....@@ -3178,8 +3652,7 @@
31783652 spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
31793653 if (list_empty(&ioc->internal_free_list)) {
31803654 spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
3181
- pr_err(MPT3SAS_FMT "%s: smid not available\n",
3182
- ioc->name, __func__);
3655
+ ioc_err(ioc, "%s: smid not available\n", __func__);
31833656 return 0;
31843657 }
31853658
....@@ -3210,8 +3683,8 @@
32103683
32113684 smid = tag + 1;
32123685 request->cb_idx = cb_idx;
3213
- request->msix_io = _base_get_msix_index(ioc);
32143686 request->smid = smid;
3687
+ request->scmd = scmd;
32153688 INIT_LIST_HEAD(&request->chain_list);
32163689 return smid;
32173690 }
....@@ -3265,6 +3738,7 @@
32653738 return;
32663739 st->cb_idx = 0xFF;
32673740 st->direct_io = 0;
3741
+ st->scmd = NULL;
32683742 atomic_set(&ioc->chain_lookup[st->smid - 1].chain_offset, 0);
32693743 st->smid = 0;
32703744 }
....@@ -3334,7 +3808,6 @@
33343808 spin_lock_irqsave(writeq_lock, flags);
33353809 __raw_writel((u32)(b), addr);
33363810 __raw_writel((u32)(b >> 32), (addr + 4));
3337
- mmiowb();
33383811 spin_unlock_irqrestore(writeq_lock, flags);
33393812 }
33403813
....@@ -3365,13 +3838,37 @@
33653838 #endif
33663839
33673840 /**
3841
+ * _base_set_and_get_msix_index - get the msix index and assign to msix_io
3842
+ * variable of scsi tracker
3843
+ * @ioc: per adapter object
3844
+ * @smid: system request message index
3845
+ *
3846
+ * returns msix index.
3847
+ */
3848
+static u8
3849
+_base_set_and_get_msix_index(struct MPT3SAS_ADAPTER *ioc, u16 smid)
3850
+{
3851
+ struct scsiio_tracker *st = NULL;
3852
+
3853
+ if (smid < ioc->hi_priority_smid)
3854
+ st = _get_st_from_smid(ioc, smid);
3855
+
3856
+ if (st == NULL)
3857
+ return _base_get_msix_index(ioc, NULL);
3858
+
3859
+ st->msix_io = ioc->get_msix_index_for_smlio(ioc, st->scmd);
3860
+ return st->msix_io;
3861
+}
3862
+
3863
+/**
33683864 * _base_put_smid_mpi_ep_scsi_io - send SCSI_IO request to firmware
33693865 * @ioc: per adapter object
33703866 * @smid: system request message index
33713867 * @handle: device handle
33723868 */
33733869 static void
3374
-_base_put_smid_mpi_ep_scsi_io(struct MPT3SAS_ADAPTER *ioc, u16 smid, u16 handle)
3870
+_base_put_smid_mpi_ep_scsi_io(struct MPT3SAS_ADAPTER *ioc,
3871
+ u16 smid, u16 handle)
33753872 {
33763873 Mpi2RequestDescriptorUnion_t descriptor;
33773874 u64 *request = (u64 *)&descriptor;
....@@ -3384,7 +3881,7 @@
33843881 _base_clone_mpi_to_sys_mem(mpi_req_iomem, (void *)mfp,
33853882 ioc->request_sz);
33863883 descriptor.SCSIIO.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO;
3387
- descriptor.SCSIIO.MSIxIndex = _base_get_msix_index(ioc);
3884
+ descriptor.SCSIIO.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
33883885 descriptor.SCSIIO.SMID = cpu_to_le16(smid);
33893886 descriptor.SCSIIO.DevHandle = cpu_to_le16(handle);
33903887 descriptor.SCSIIO.LMID = 0;
....@@ -3406,7 +3903,7 @@
34063903
34073904
34083905 descriptor.SCSIIO.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO;
3409
- descriptor.SCSIIO.MSIxIndex = _base_get_msix_index(ioc);
3906
+ descriptor.SCSIIO.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
34103907 descriptor.SCSIIO.SMID = cpu_to_le16(smid);
34113908 descriptor.SCSIIO.DevHandle = cpu_to_le16(handle);
34123909 descriptor.SCSIIO.LMID = 0;
....@@ -3415,13 +3912,13 @@
34153912 }
34163913
34173914 /**
3418
- * mpt3sas_base_put_smid_fast_path - send fast path request to firmware
3915
+ * _base_put_smid_fast_path - send fast path request to firmware
34193916 * @ioc: per adapter object
34203917 * @smid: system request message index
34213918 * @handle: device handle
34223919 */
3423
-void
3424
-mpt3sas_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid,
3920
+static void
3921
+_base_put_smid_fast_path(struct MPT3SAS_ADAPTER *ioc, u16 smid,
34253922 u16 handle)
34263923 {
34273924 Mpi2RequestDescriptorUnion_t descriptor;
....@@ -3429,7 +3926,7 @@
34293926
34303927 descriptor.SCSIIO.RequestFlags =
34313928 MPI25_REQ_DESCRIPT_FLAGS_FAST_PATH_SCSI_IO;
3432
- descriptor.SCSIIO.MSIxIndex = _base_get_msix_index(ioc);
3929
+ descriptor.SCSIIO.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
34333930 descriptor.SCSIIO.SMID = cpu_to_le16(smid);
34343931 descriptor.SCSIIO.DevHandle = cpu_to_le16(handle);
34353932 descriptor.SCSIIO.LMID = 0;
....@@ -3438,13 +3935,13 @@
34383935 }
34393936
34403937 /**
3441
- * mpt3sas_base_put_smid_hi_priority - send Task Management request to firmware
3938
+ * _base_put_smid_hi_priority - send Task Management request to firmware
34423939 * @ioc: per adapter object
34433940 * @smid: system request message index
34443941 * @msix_task: msix_task will be same as msix of IO incase of task abort else 0.
34453942 */
3446
-void
3447
-mpt3sas_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid,
3943
+static void
3944
+_base_put_smid_hi_priority(struct MPT3SAS_ADAPTER *ioc, u16 smid,
34483945 u16 msix_task)
34493946 {
34503947 Mpi2RequestDescriptorUnion_t descriptor;
....@@ -3493,7 +3990,7 @@
34933990
34943991 descriptor.Default.RequestFlags =
34953992 MPI26_REQ_DESCRIPT_FLAGS_PCIE_ENCAPSULATED;
3496
- descriptor.Default.MSIxIndex = _base_get_msix_index(ioc);
3993
+ descriptor.Default.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
34973994 descriptor.Default.SMID = cpu_to_le16(smid);
34983995 descriptor.Default.LMID = 0;
34993996 descriptor.Default.DescriptorTypeDependent = 0;
....@@ -3502,12 +3999,12 @@
35023999 }
35034000
35044001 /**
3505
- * mpt3sas_base_put_smid_default - Default, primarily used for config pages
4002
+ * _base_put_smid_default - Default, primarily used for config pages
35064003 * @ioc: per adapter object
35074004 * @smid: system request message index
35084005 */
3509
-void
3510
-mpt3sas_base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, u16 smid)
4006
+static void
4007
+_base_put_smid_default(struct MPT3SAS_ADAPTER *ioc, u16 smid)
35114008 {
35124009 Mpi2RequestDescriptorUnion_t descriptor;
35134010 void *mpi_req_iomem;
....@@ -3525,7 +4022,7 @@
35254022 }
35264023 request = (u64 *)&descriptor;
35274024 descriptor.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
3528
- descriptor.Default.MSIxIndex = _base_get_msix_index(ioc);
4025
+ descriptor.Default.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
35294026 descriptor.Default.SMID = cpu_to_le16(smid);
35304027 descriptor.Default.LMID = 0;
35314028 descriptor.Default.DescriptorTypeDependent = 0;
....@@ -3536,6 +4033,95 @@
35364033 else
35374034 _base_writeq(*request, &ioc->chip->RequestDescriptorPostLow,
35384035 &ioc->scsi_lookup_lock);
4036
+}
4037
+
4038
+/**
4039
+ * _base_put_smid_scsi_io_atomic - send SCSI_IO request to firmware using
4040
+ * 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
+ *
4045
+ * Return nothing.
4046
+ */
4047
+static void
4048
+_base_put_smid_scsi_io_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid,
4049
+ u16 handle)
4050
+{
4051
+ Mpi26AtomicRequestDescriptor_t descriptor;
4052
+ u32 *request = (u32 *)&descriptor;
4053
+
4054
+ descriptor.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO;
4055
+ descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
4056
+ descriptor.SMID = cpu_to_le16(smid);
4057
+
4058
+ writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
4059
+}
4060
+
4061
+/**
4062
+ * _base_put_smid_fast_path_atomic - send fast path request to firmware
4063
+ * using Atomic Request Descriptor
4064
+ * @ioc: per adapter object
4065
+ * @smid: system request message index
4066
+ * @handle: device handle, unused in this function, for function type match
4067
+ * Return nothing
4068
+ */
4069
+static void
4070
+_base_put_smid_fast_path_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid,
4071
+ u16 handle)
4072
+{
4073
+ Mpi26AtomicRequestDescriptor_t descriptor;
4074
+ u32 *request = (u32 *)&descriptor;
4075
+
4076
+ descriptor.RequestFlags = MPI25_REQ_DESCRIPT_FLAGS_FAST_PATH_SCSI_IO;
4077
+ descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
4078
+ descriptor.SMID = cpu_to_le16(smid);
4079
+
4080
+ writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
4081
+}
4082
+
4083
+/**
4084
+ * _base_put_smid_hi_priority_atomic - send Task Management request to
4085
+ * firmware using Atomic Request Descriptor
4086
+ * @ioc: per adapter object
4087
+ * @smid: system request message index
4088
+ * @msix_task: msix_task will be same as msix of IO incase of task abort else 0
4089
+ *
4090
+ * Return nothing.
4091
+ */
4092
+static void
4093
+_base_put_smid_hi_priority_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid,
4094
+ u16 msix_task)
4095
+{
4096
+ Mpi26AtomicRequestDescriptor_t descriptor;
4097
+ u32 *request = (u32 *)&descriptor;
4098
+
4099
+ descriptor.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
4100
+ descriptor.MSIxIndex = msix_task;
4101
+ descriptor.SMID = cpu_to_le16(smid);
4102
+
4103
+ writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
4104
+}
4105
+
4106
+/**
4107
+ * _base_put_smid_default - Default, primarily used for config pages
4108
+ * use Atomic Request Descriptor
4109
+ * @ioc: per adapter object
4110
+ * @smid: system request message index
4111
+ *
4112
+ * Return nothing.
4113
+ */
4114
+static void
4115
+_base_put_smid_default_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid)
4116
+{
4117
+ Mpi26AtomicRequestDescriptor_t descriptor;
4118
+ u32 *request = (u32 *)&descriptor;
4119
+
4120
+ descriptor.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
4121
+ descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
4122
+ descriptor.SMID = cpu_to_le16(smid);
4123
+
4124
+ writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);
35394125 }
35404126
35414127 /**
....@@ -3554,89 +4140,87 @@
35544140 case MPI2_MFGPAGE_DEVID_SAS2008:
35554141 switch (ioc->pdev->subsystem_device) {
35564142 case MPT2SAS_INTEL_RMS2LL080_SSDID:
3557
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3558
- MPT2SAS_INTEL_RMS2LL080_BRANDING);
4143
+ ioc_info(ioc, "%s\n",
4144
+ MPT2SAS_INTEL_RMS2LL080_BRANDING);
35594145 break;
35604146 case MPT2SAS_INTEL_RMS2LL040_SSDID:
3561
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3562
- MPT2SAS_INTEL_RMS2LL040_BRANDING);
4147
+ ioc_info(ioc, "%s\n",
4148
+ MPT2SAS_INTEL_RMS2LL040_BRANDING);
35634149 break;
35644150 case MPT2SAS_INTEL_SSD910_SSDID:
3565
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3566
- MPT2SAS_INTEL_SSD910_BRANDING);
4151
+ ioc_info(ioc, "%s\n",
4152
+ MPT2SAS_INTEL_SSD910_BRANDING);
35674153 break;
35684154 default:
3569
- pr_info(MPT3SAS_FMT
3570
- "Intel(R) Controller: Subsystem ID: 0x%X\n",
3571
- ioc->name, ioc->pdev->subsystem_device);
4155
+ ioc_info(ioc, "Intel(R) Controller: Subsystem ID: 0x%X\n",
4156
+ ioc->pdev->subsystem_device);
35724157 break;
35734158 }
4159
+ break;
35744160 case MPI2_MFGPAGE_DEVID_SAS2308_2:
35754161 switch (ioc->pdev->subsystem_device) {
35764162 case MPT2SAS_INTEL_RS25GB008_SSDID:
3577
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3578
- MPT2SAS_INTEL_RS25GB008_BRANDING);
4163
+ ioc_info(ioc, "%s\n",
4164
+ MPT2SAS_INTEL_RS25GB008_BRANDING);
35794165 break;
35804166 case MPT2SAS_INTEL_RMS25JB080_SSDID:
3581
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3582
- MPT2SAS_INTEL_RMS25JB080_BRANDING);
4167
+ ioc_info(ioc, "%s\n",
4168
+ MPT2SAS_INTEL_RMS25JB080_BRANDING);
35834169 break;
35844170 case MPT2SAS_INTEL_RMS25JB040_SSDID:
3585
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3586
- MPT2SAS_INTEL_RMS25JB040_BRANDING);
4171
+ ioc_info(ioc, "%s\n",
4172
+ MPT2SAS_INTEL_RMS25JB040_BRANDING);
35874173 break;
35884174 case MPT2SAS_INTEL_RMS25KB080_SSDID:
3589
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3590
- MPT2SAS_INTEL_RMS25KB080_BRANDING);
4175
+ ioc_info(ioc, "%s\n",
4176
+ MPT2SAS_INTEL_RMS25KB080_BRANDING);
35914177 break;
35924178 case MPT2SAS_INTEL_RMS25KB040_SSDID:
3593
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3594
- MPT2SAS_INTEL_RMS25KB040_BRANDING);
4179
+ ioc_info(ioc, "%s\n",
4180
+ MPT2SAS_INTEL_RMS25KB040_BRANDING);
35954181 break;
35964182 case MPT2SAS_INTEL_RMS25LB040_SSDID:
3597
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3598
- MPT2SAS_INTEL_RMS25LB040_BRANDING);
4183
+ ioc_info(ioc, "%s\n",
4184
+ MPT2SAS_INTEL_RMS25LB040_BRANDING);
35994185 break;
36004186 case MPT2SAS_INTEL_RMS25LB080_SSDID:
3601
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3602
- MPT2SAS_INTEL_RMS25LB080_BRANDING);
4187
+ ioc_info(ioc, "%s\n",
4188
+ MPT2SAS_INTEL_RMS25LB080_BRANDING);
36034189 break;
36044190 default:
3605
- pr_info(MPT3SAS_FMT
3606
- "Intel(R) Controller: Subsystem ID: 0x%X\n",
3607
- ioc->name, ioc->pdev->subsystem_device);
4191
+ ioc_info(ioc, "Intel(R) Controller: Subsystem ID: 0x%X\n",
4192
+ ioc->pdev->subsystem_device);
36084193 break;
36094194 }
4195
+ break;
36104196 case MPI25_MFGPAGE_DEVID_SAS3008:
36114197 switch (ioc->pdev->subsystem_device) {
36124198 case MPT3SAS_INTEL_RMS3JC080_SSDID:
3613
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3614
- MPT3SAS_INTEL_RMS3JC080_BRANDING);
4199
+ ioc_info(ioc, "%s\n",
4200
+ MPT3SAS_INTEL_RMS3JC080_BRANDING);
36154201 break;
36164202
36174203 case MPT3SAS_INTEL_RS3GC008_SSDID:
3618
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3619
- MPT3SAS_INTEL_RS3GC008_BRANDING);
4204
+ ioc_info(ioc, "%s\n",
4205
+ MPT3SAS_INTEL_RS3GC008_BRANDING);
36204206 break;
36214207 case MPT3SAS_INTEL_RS3FC044_SSDID:
3622
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3623
- MPT3SAS_INTEL_RS3FC044_BRANDING);
4208
+ ioc_info(ioc, "%s\n",
4209
+ MPT3SAS_INTEL_RS3FC044_BRANDING);
36244210 break;
36254211 case MPT3SAS_INTEL_RS3UC080_SSDID:
3626
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3627
- MPT3SAS_INTEL_RS3UC080_BRANDING);
4212
+ ioc_info(ioc, "%s\n",
4213
+ MPT3SAS_INTEL_RS3UC080_BRANDING);
36284214 break;
36294215 default:
3630
- pr_info(MPT3SAS_FMT
3631
- "Intel(R) Controller: Subsystem ID: 0x%X\n",
3632
- ioc->name, ioc->pdev->subsystem_device);
4216
+ ioc_info(ioc, "Intel(R) Controller: Subsystem ID: 0x%X\n",
4217
+ ioc->pdev->subsystem_device);
36334218 break;
36344219 }
36354220 break;
36364221 default:
3637
- pr_info(MPT3SAS_FMT
3638
- "Intel(R) Controller: Subsystem ID: 0x%X\n",
3639
- ioc->name, ioc->pdev->subsystem_device);
4222
+ ioc_info(ioc, "Intel(R) Controller: Subsystem ID: 0x%X\n",
4223
+ ioc->pdev->subsystem_device);
36404224 break;
36414225 }
36424226 break;
....@@ -3645,57 +4229,54 @@
36454229 case MPI2_MFGPAGE_DEVID_SAS2008:
36464230 switch (ioc->pdev->subsystem_device) {
36474231 case MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID:
3648
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3649
- MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING);
4232
+ ioc_info(ioc, "%s\n",
4233
+ MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING);
36504234 break;
36514235 case MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID:
3652
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3653
- MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING);
4236
+ ioc_info(ioc, "%s\n",
4237
+ MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING);
36544238 break;
36554239 case MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID:
3656
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3657
- MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING);
4240
+ ioc_info(ioc, "%s\n",
4241
+ MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING);
36584242 break;
36594243 case MPT2SAS_DELL_PERC_H200_MODULAR_SSDID:
3660
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3661
- MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING);
4244
+ ioc_info(ioc, "%s\n",
4245
+ MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING);
36624246 break;
36634247 case MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID:
3664
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3665
- MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING);
4248
+ ioc_info(ioc, "%s\n",
4249
+ MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING);
36664250 break;
36674251 case MPT2SAS_DELL_PERC_H200_SSDID:
3668
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3669
- MPT2SAS_DELL_PERC_H200_BRANDING);
4252
+ ioc_info(ioc, "%s\n",
4253
+ MPT2SAS_DELL_PERC_H200_BRANDING);
36704254 break;
36714255 case MPT2SAS_DELL_6GBPS_SAS_SSDID:
3672
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3673
- MPT2SAS_DELL_6GBPS_SAS_BRANDING);
4256
+ ioc_info(ioc, "%s\n",
4257
+ MPT2SAS_DELL_6GBPS_SAS_BRANDING);
36744258 break;
36754259 default:
3676
- pr_info(MPT3SAS_FMT
3677
- "Dell 6Gbps HBA: Subsystem ID: 0x%X\n",
3678
- ioc->name, ioc->pdev->subsystem_device);
4260
+ ioc_info(ioc, "Dell 6Gbps HBA: Subsystem ID: 0x%X\n",
4261
+ ioc->pdev->subsystem_device);
36794262 break;
36804263 }
36814264 break;
36824265 case MPI25_MFGPAGE_DEVID_SAS3008:
36834266 switch (ioc->pdev->subsystem_device) {
36844267 case MPT3SAS_DELL_12G_HBA_SSDID:
3685
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3686
- MPT3SAS_DELL_12G_HBA_BRANDING);
4268
+ ioc_info(ioc, "%s\n",
4269
+ MPT3SAS_DELL_12G_HBA_BRANDING);
36874270 break;
36884271 default:
3689
- pr_info(MPT3SAS_FMT
3690
- "Dell 12Gbps HBA: Subsystem ID: 0x%X\n",
3691
- ioc->name, ioc->pdev->subsystem_device);
4272
+ ioc_info(ioc, "Dell 12Gbps HBA: Subsystem ID: 0x%X\n",
4273
+ ioc->pdev->subsystem_device);
36924274 break;
36934275 }
36944276 break;
36954277 default:
3696
- pr_info(MPT3SAS_FMT
3697
- "Dell HBA: Subsystem ID: 0x%X\n", ioc->name,
3698
- ioc->pdev->subsystem_device);
4278
+ ioc_info(ioc, "Dell HBA: Subsystem ID: 0x%X\n",
4279
+ ioc->pdev->subsystem_device);
36994280 break;
37004281 }
37014282 break;
....@@ -3704,46 +4285,42 @@
37044285 case MPI25_MFGPAGE_DEVID_SAS3008:
37054286 switch (ioc->pdev->subsystem_device) {
37064287 case MPT3SAS_CISCO_12G_8E_HBA_SSDID:
3707
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3708
- MPT3SAS_CISCO_12G_8E_HBA_BRANDING);
4288
+ ioc_info(ioc, "%s\n",
4289
+ MPT3SAS_CISCO_12G_8E_HBA_BRANDING);
37094290 break;
37104291 case MPT3SAS_CISCO_12G_8I_HBA_SSDID:
3711
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3712
- MPT3SAS_CISCO_12G_8I_HBA_BRANDING);
4292
+ ioc_info(ioc, "%s\n",
4293
+ MPT3SAS_CISCO_12G_8I_HBA_BRANDING);
37134294 break;
37144295 case MPT3SAS_CISCO_12G_AVILA_HBA_SSDID:
3715
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3716
- MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING);
4296
+ ioc_info(ioc, "%s\n",
4297
+ MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING);
37174298 break;
37184299 default:
3719
- pr_info(MPT3SAS_FMT
3720
- "Cisco 12Gbps SAS HBA: Subsystem ID: 0x%X\n",
3721
- ioc->name, ioc->pdev->subsystem_device);
4300
+ ioc_info(ioc, "Cisco 12Gbps SAS HBA: Subsystem ID: 0x%X\n",
4301
+ ioc->pdev->subsystem_device);
37224302 break;
37234303 }
37244304 break;
37254305 case MPI25_MFGPAGE_DEVID_SAS3108_1:
37264306 switch (ioc->pdev->subsystem_device) {
37274307 case MPT3SAS_CISCO_12G_AVILA_HBA_SSDID:
3728
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3729
- MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING);
4308
+ ioc_info(ioc, "%s\n",
4309
+ MPT3SAS_CISCO_12G_AVILA_HBA_BRANDING);
37304310 break;
37314311 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
- );
4312
+ ioc_info(ioc, "%s\n",
4313
+ MPT3SAS_CISCO_12G_COLUSA_MEZZANINE_HBA_BRANDING);
37354314 break;
37364315 default:
3737
- pr_info(MPT3SAS_FMT
3738
- "Cisco 12Gbps SAS HBA: Subsystem ID: 0x%X\n",
3739
- ioc->name, ioc->pdev->subsystem_device);
4316
+ ioc_info(ioc, "Cisco 12Gbps SAS HBA: Subsystem ID: 0x%X\n",
4317
+ ioc->pdev->subsystem_device);
37404318 break;
37414319 }
37424320 break;
37434321 default:
3744
- pr_info(MPT3SAS_FMT
3745
- "Cisco SAS HBA: Subsystem ID: 0x%X\n",
3746
- ioc->name, ioc->pdev->subsystem_device);
4322
+ ioc_info(ioc, "Cisco SAS HBA: Subsystem ID: 0x%X\n",
4323
+ ioc->pdev->subsystem_device);
37474324 break;
37484325 }
37494326 break;
....@@ -3752,43 +4329,42 @@
37524329 case MPI2_MFGPAGE_DEVID_SAS2004:
37534330 switch (ioc->pdev->subsystem_device) {
37544331 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);
4332
+ ioc_info(ioc, "%s\n",
4333
+ MPT2SAS_HP_DAUGHTER_2_4_INTERNAL_BRANDING);
37574334 break;
37584335 default:
3759
- pr_info(MPT3SAS_FMT
3760
- "HP 6Gbps SAS HBA: Subsystem ID: 0x%X\n",
3761
- ioc->name, ioc->pdev->subsystem_device);
4336
+ ioc_info(ioc, "HP 6Gbps SAS HBA: Subsystem ID: 0x%X\n",
4337
+ ioc->pdev->subsystem_device);
37624338 break;
37634339 }
4340
+ break;
37644341 case MPI2_MFGPAGE_DEVID_SAS2308_2:
37654342 switch (ioc->pdev->subsystem_device) {
37664343 case MPT2SAS_HP_2_4_INTERNAL_SSDID:
3767
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3768
- MPT2SAS_HP_2_4_INTERNAL_BRANDING);
4344
+ ioc_info(ioc, "%s\n",
4345
+ MPT2SAS_HP_2_4_INTERNAL_BRANDING);
37694346 break;
37704347 case MPT2SAS_HP_2_4_EXTERNAL_SSDID:
3771
- pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3772
- MPT2SAS_HP_2_4_EXTERNAL_BRANDING);
4348
+ ioc_info(ioc, "%s\n",
4349
+ MPT2SAS_HP_2_4_EXTERNAL_BRANDING);
37734350 break;
37744351 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);
4352
+ ioc_info(ioc, "%s\n",
4353
+ MPT2SAS_HP_1_4_INTERNAL_1_4_EXTERNAL_BRANDING);
37774354 break;
37784355 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);
4356
+ ioc_info(ioc, "%s\n",
4357
+ MPT2SAS_HP_EMBEDDED_2_4_INTERNAL_BRANDING);
37814358 break;
37824359 default:
3783
- pr_info(MPT3SAS_FMT
3784
- "HP 6Gbps SAS HBA: Subsystem ID: 0x%X\n",
3785
- ioc->name, ioc->pdev->subsystem_device);
4360
+ ioc_info(ioc, "HP 6Gbps SAS HBA: Subsystem ID: 0x%X\n",
4361
+ ioc->pdev->subsystem_device);
37864362 break;
37874363 }
4364
+ break;
37884365 default:
3789
- pr_info(MPT3SAS_FMT
3790
- "HP SAS HBA: Subsystem ID: 0x%X\n",
3791
- ioc->name, ioc->pdev->subsystem_device);
4366
+ ioc_info(ioc, "HP SAS HBA: Subsystem ID: 0x%X\n",
4367
+ ioc->pdev->subsystem_device);
37924368 break;
37934369 }
37944370 default:
....@@ -3806,37 +4382,37 @@
38064382 static int
38074383 _base_display_fwpkg_version(struct MPT3SAS_ADAPTER *ioc)
38084384 {
3809
- Mpi2FWImageHeader_t *FWImgHdr;
4385
+ Mpi2FWImageHeader_t *fw_img_hdr;
4386
+ Mpi26ComponentImageHeader_t *cmp_img_hdr;
38104387 Mpi25FWUploadRequest_t *mpi_request;
38114388 Mpi2FWUploadReply_t mpi_reply;
38124389 int r = 0;
4390
+ u32 package_version = 0;
38134391 void *fwpkg_data = NULL;
38144392 dma_addr_t fwpkg_data_dma;
38154393 u16 smid, ioc_status;
38164394 size_t data_length;
38174395
3818
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
3819
- __func__));
4396
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
38204397
38214398 if (ioc->base_cmds.status & MPT3_CMD_PENDING) {
3822
- pr_err(MPT3SAS_FMT "%s: internal command already in use\n",
3823
- ioc->name, __func__);
4399
+ ioc_err(ioc, "%s: internal command already in use\n", __func__);
38244400 return -EAGAIN;
38254401 }
38264402
38274403 data_length = sizeof(Mpi2FWImageHeader_t);
3828
- fwpkg_data = pci_alloc_consistent(ioc->pdev, data_length,
3829
- &fwpkg_data_dma);
4404
+ fwpkg_data = dma_alloc_coherent(&ioc->pdev->dev, data_length,
4405
+ &fwpkg_data_dma, GFP_KERNEL);
38304406 if (!fwpkg_data) {
3831
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
3832
- ioc->name, __FILE__, __LINE__, __func__);
4407
+ ioc_err(ioc,
4408
+ "Memory allocation for fwpkg data failed at %s:%d/%s()!\n",
4409
+ __FILE__, __LINE__, __func__);
38334410 return -ENOMEM;
38344411 }
38354412
38364413 smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx);
38374414 if (!smid) {
3838
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
3839
- ioc->name, __func__);
4415
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
38404416 r = -EAGAIN;
38414417 goto out;
38424418 }
....@@ -3851,15 +4427,13 @@
38514427 ioc->build_sg(ioc, &mpi_request->SGL, 0, 0, fwpkg_data_dma,
38524428 data_length);
38534429 init_completion(&ioc->base_cmds.done);
3854
- mpt3sas_base_put_smid_default(ioc, smid);
4430
+ ioc->put_smid_default(ioc, smid);
38554431 /* Wait for 15 seconds */
38564432 wait_for_completion_timeout(&ioc->base_cmds.done,
38574433 FW_IMG_HDR_READ_TIMEOUT*HZ);
3858
- pr_info(MPT3SAS_FMT "%s: complete\n",
3859
- ioc->name, __func__);
4434
+ ioc_info(ioc, "%s: complete\n", __func__);
38604435 if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) {
3861
- pr_err(MPT3SAS_FMT "%s: timeout\n",
3862
- ioc->name, __func__);
4436
+ ioc_err(ioc, "%s: timeout\n", __func__);
38634437 _debug_dump_mf(mpi_request,
38644438 sizeof(Mpi25FWUploadRequest_t)/4);
38654439 r = -ETIME;
....@@ -3871,16 +4445,26 @@
38714445 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
38724446 MPI2_IOCSTATUS_MASK;
38734447 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
- }
4448
+ fw_img_hdr = (Mpi2FWImageHeader_t *)fwpkg_data;
4449
+ if (le32_to_cpu(fw_img_hdr->Signature) ==
4450
+ MPI26_IMAGE_HEADER_SIGNATURE0_MPI26) {
4451
+ cmp_img_hdr =
4452
+ (Mpi26ComponentImageHeader_t *)
4453
+ (fwpkg_data);
4454
+ package_version =
4455
+ le32_to_cpu(
4456
+ cmp_img_hdr->ApplicationSpecific);
4457
+ } else
4458
+ package_version =
4459
+ le32_to_cpu(
4460
+ fw_img_hdr->PackageVersion.Word);
4461
+ if (package_version)
4462
+ ioc_info(ioc,
4463
+ "FW Package Ver(%02d.%02d.%02d.%02d)\n",
4464
+ ((package_version) & 0xFF000000) >> 24,
4465
+ ((package_version) & 0x00FF0000) >> 16,
4466
+ ((package_version) & 0x0000FF00) >> 8,
4467
+ (package_version) & 0x000000FF);
38844468 } else {
38854469 _debug_dump_mf(&mpi_reply,
38864470 sizeof(Mpi2FWUploadReply_t)/4);
....@@ -3890,7 +4474,7 @@
38904474 ioc->base_cmds.status = MPT3_CMD_NOT_USED;
38914475 out:
38924476 if (fwpkg_data)
3893
- pci_free_consistent(ioc->pdev, data_length, fwpkg_data,
4477
+ dma_free_coherent(&ioc->pdev->dev, data_length, fwpkg_data,
38944478 fwpkg_data_dma);
38954479 return r;
38964480 }
....@@ -3909,18 +4493,17 @@
39094493
39104494 bios_version = le32_to_cpu(ioc->bios_pg3.BiosVersion);
39114495 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);
4496
+ ioc_info(ioc, "%s: FWVersion(%02d.%02d.%02d.%02d), ChipRevision(0x%02x), BiosVersion(%02d.%02d.%02d.%02d)\n",
4497
+ desc,
4498
+ (ioc->facts.FWVersion.Word & 0xFF000000) >> 24,
4499
+ (ioc->facts.FWVersion.Word & 0x00FF0000) >> 16,
4500
+ (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8,
4501
+ ioc->facts.FWVersion.Word & 0x000000FF,
4502
+ ioc->pdev->revision,
4503
+ (bios_version & 0xFF000000) >> 24,
4504
+ (bios_version & 0x00FF0000) >> 16,
4505
+ (bios_version & 0x0000FF00) >> 8,
4506
+ bios_version & 0x000000FF);
39244507
39254508 _base_display_OEMs_branding(ioc);
39264509
....@@ -3929,82 +4512,81 @@
39294512 i++;
39304513 }
39314514
3932
- pr_info(MPT3SAS_FMT "Protocol=(", ioc->name);
4515
+ ioc_info(ioc, "Protocol=(");
39334516
39344517 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_INITIATOR) {
3935
- pr_info("Initiator");
4518
+ pr_cont("Initiator");
39364519 i++;
39374520 }
39384521
39394522 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_SCSI_TARGET) {
3940
- pr_info("%sTarget", i ? "," : "");
4523
+ pr_cont("%sTarget", i ? "," : "");
39414524 i++;
39424525 }
39434526
39444527 i = 0;
3945
- pr_info("), ");
3946
- pr_info("Capabilities=(");
4528
+ pr_cont("), Capabilities=(");
39474529
39484530 if (!ioc->hide_ir_msg) {
39494531 if (ioc->facts.IOCCapabilities &
39504532 MPI2_IOCFACTS_CAPABILITY_INTEGRATED_RAID) {
3951
- pr_info("Raid");
4533
+ pr_cont("Raid");
39524534 i++;
39534535 }
39544536 }
39554537
39564538 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_TLR) {
3957
- pr_info("%sTLR", i ? "," : "");
4539
+ pr_cont("%sTLR", i ? "," : "");
39584540 i++;
39594541 }
39604542
39614543 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_MULTICAST) {
3962
- pr_info("%sMulticast", i ? "," : "");
4544
+ pr_cont("%sMulticast", i ? "," : "");
39634545 i++;
39644546 }
39654547
39664548 if (ioc->facts.IOCCapabilities &
39674549 MPI2_IOCFACTS_CAPABILITY_BIDIRECTIONAL_TARGET) {
3968
- pr_info("%sBIDI Target", i ? "," : "");
4550
+ pr_cont("%sBIDI Target", i ? "," : "");
39694551 i++;
39704552 }
39714553
39724554 if (ioc->facts.IOCCapabilities & MPI2_IOCFACTS_CAPABILITY_EEDP) {
3973
- pr_info("%sEEDP", i ? "," : "");
4555
+ pr_cont("%sEEDP", i ? "," : "");
39744556 i++;
39754557 }
39764558
39774559 if (ioc->facts.IOCCapabilities &
39784560 MPI2_IOCFACTS_CAPABILITY_SNAPSHOT_BUFFER) {
3979
- pr_info("%sSnapshot Buffer", i ? "," : "");
4561
+ pr_cont("%sSnapshot Buffer", i ? "," : "");
39804562 i++;
39814563 }
39824564
39834565 if (ioc->facts.IOCCapabilities &
39844566 MPI2_IOCFACTS_CAPABILITY_DIAG_TRACE_BUFFER) {
3985
- pr_info("%sDiag Trace Buffer", i ? "," : "");
4567
+ pr_cont("%sDiag Trace Buffer", i ? "," : "");
39864568 i++;
39874569 }
39884570
39894571 if (ioc->facts.IOCCapabilities &
39904572 MPI2_IOCFACTS_CAPABILITY_EXTENDED_BUFFER) {
3991
- pr_info("%sDiag Extended Buffer", i ? "," : "");
4573
+ pr_cont("%sDiag Extended Buffer", i ? "," : "");
39924574 i++;
39934575 }
39944576
39954577 if (ioc->facts.IOCCapabilities &
39964578 MPI2_IOCFACTS_CAPABILITY_TASK_SET_FULL_HANDLING) {
3997
- pr_info("%sTask Set Full", i ? "," : "");
4579
+ pr_cont("%sTask Set Full", i ? "," : "");
39984580 i++;
39994581 }
40004582
40014583 iounit_pg1_flags = le32_to_cpu(ioc->iounit_pg1.Flags);
40024584 if (!(iounit_pg1_flags & MPI2_IOUNITPAGE1_NATIVE_COMMAND_Q_DISABLE)) {
4003
- pr_info("%sNCQ", i ? "," : "");
4585
+ pr_cont("%sNCQ", i ? "," : "");
40044586 i++;
40054587 }
40064588
4007
- pr_info(")\n");
4589
+ pr_cont(")\n");
40084590 }
40094591
40104592 /**
....@@ -4037,21 +4619,21 @@
40374619 sizeof(Mpi2SasIOUnit1PhyData_t));
40384620 sas_iounit_pg1 = kzalloc(sz, GFP_KERNEL);
40394621 if (!sas_iounit_pg1) {
4040
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
4041
- ioc->name, __FILE__, __LINE__, __func__);
4622
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
4623
+ __FILE__, __LINE__, __func__);
40424624 goto out;
40434625 }
40444626 if ((mpt3sas_config_get_sas_iounit_pg1(ioc, &mpi_reply,
40454627 sas_iounit_pg1, sz))) {
4046
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
4047
- ioc->name, __FILE__, __LINE__, __func__);
4628
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
4629
+ __FILE__, __LINE__, __func__);
40484630 goto out;
40494631 }
40504632 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
40514633 MPI2_IOCSTATUS_MASK;
40524634 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
4053
- pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
4054
- ioc->name, __FILE__, __LINE__, __func__);
4635
+ ioc_err(ioc, "failure at %s:%d/%s()!\n",
4636
+ __FILE__, __LINE__, __func__);
40554637 goto out;
40564638 }
40574639
....@@ -4083,17 +4665,82 @@
40834665 else
40844666 dmd_new =
40854667 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);
4668
+ ioc_info(ioc, "device_missing_delay: old(%d), new(%d)\n",
4669
+ dmd_orignal, dmd_new);
4670
+ ioc_info(ioc, "ioc_missing_delay: old(%d), new(%d)\n",
4671
+ io_missing_delay_original,
4672
+ io_missing_delay);
40914673 ioc->device_missing_delay = dmd_new;
40924674 ioc->io_missing_delay = io_missing_delay;
40934675 }
40944676
40954677 out:
40964678 kfree(sas_iounit_pg1);
4679
+}
4680
+
4681
+/**
4682
+ * _base_update_ioc_page1_inlinewith_perf_mode - Update IOC Page1 fields
4683
+ * according to performance mode.
4684
+ * @ioc : per adapter object
4685
+ *
4686
+ * Return nothing.
4687
+ */
4688
+static void
4689
+_base_update_ioc_page1_inlinewith_perf_mode(struct MPT3SAS_ADAPTER *ioc)
4690
+{
4691
+ Mpi2IOCPage1_t ioc_pg1;
4692
+ Mpi2ConfigReply_t mpi_reply;
4693
+
4694
+ mpt3sas_config_get_ioc_pg1(ioc, &mpi_reply, &ioc->ioc_pg1_copy);
4695
+ memcpy(&ioc_pg1, &ioc->ioc_pg1_copy, sizeof(Mpi2IOCPage1_t));
4696
+
4697
+ switch (perf_mode) {
4698
+ case MPT_PERF_MODE_DEFAULT:
4699
+ case MPT_PERF_MODE_BALANCED:
4700
+ if (ioc->high_iops_queues) {
4701
+ ioc_info(ioc,
4702
+ "Enable interrupt coalescing only for first\t"
4703
+ "%d reply queues\n",
4704
+ MPT3SAS_HIGH_IOPS_REPLY_QUEUES);
4705
+ /*
4706
+ * If 31st bit is zero then interrupt coalescing is
4707
+ * enabled for all reply descriptor post queues.
4708
+ * If 31st bit is set to one then user can
4709
+ * enable/disable interrupt coalescing on per reply
4710
+ * descriptor post queue group(8) basis. So to enable
4711
+ * interrupt coalescing only on first reply descriptor
4712
+ * post queue group 31st bit and zero th bit is enabled.
4713
+ */
4714
+ ioc_pg1.ProductSpecific = cpu_to_le32(0x80000000 |
4715
+ ((1 << MPT3SAS_HIGH_IOPS_REPLY_QUEUES/8) - 1));
4716
+ mpt3sas_config_set_ioc_pg1(ioc, &mpi_reply, &ioc_pg1);
4717
+ ioc_info(ioc, "performance mode: balanced\n");
4718
+ return;
4719
+ }
4720
+ fallthrough;
4721
+ case MPT_PERF_MODE_LATENCY:
4722
+ /*
4723
+ * Enable interrupt coalescing on all reply queues
4724
+ * with timeout value 0xA
4725
+ */
4726
+ ioc_pg1.CoalescingTimeout = cpu_to_le32(0xa);
4727
+ ioc_pg1.Flags |= cpu_to_le32(MPI2_IOCPAGE1_REPLY_COALESCING);
4728
+ ioc_pg1.ProductSpecific = 0;
4729
+ mpt3sas_config_set_ioc_pg1(ioc, &mpi_reply, &ioc_pg1);
4730
+ ioc_info(ioc, "performance mode: latency\n");
4731
+ break;
4732
+ case MPT_PERF_MODE_IOPS:
4733
+ /*
4734
+ * Enable interrupt coalescing on all reply queues.
4735
+ */
4736
+ ioc_info(ioc,
4737
+ "performance mode: iops with coalescing timeout: 0x%x\n",
4738
+ le32_to_cpu(ioc_pg1.CoalescingTimeout));
4739
+ ioc_pg1.Flags |= cpu_to_le32(MPI2_IOCPAGE1_REPLY_COALESCING);
4740
+ ioc_pg1.ProductSpecific = 0;
4741
+ mpt3sas_config_set_ioc_pg1(ioc, &mpi_reply, &ioc_pg1);
4742
+ break;
4743
+ }
40974744 }
40984745
40994746 /**
....@@ -4163,6 +4810,8 @@
41634810
41644811 if (ioc->iounit_pg8.NumSensors)
41654812 ioc->temp_sensors_count = ioc->iounit_pg8.NumSensors;
4813
+ if (ioc->is_aero_ioc)
4814
+ _base_update_ioc_page1_inlinewith_perf_mode(ioc);
41664815 }
41674816
41684817 /**
....@@ -4195,36 +4844,36 @@
41954844 {
41964845 int i = 0;
41974846 int j = 0;
4847
+ int dma_alloc_count = 0;
41984848 struct chain_tracker *ct;
4199
- struct reply_post_struct *rps;
4849
+ int count = ioc->rdpq_array_enable ? ioc->reply_queue_count : 1;
42004850
4201
- dexitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
4202
- __func__));
4851
+ dexitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
42034852
42044853 if (ioc->request) {
4205
- pci_free_consistent(ioc->pdev, ioc->request_dma_sz,
4854
+ dma_free_coherent(&ioc->pdev->dev, ioc->request_dma_sz,
42064855 ioc->request, ioc->request_dma);
4207
- dexitprintk(ioc, pr_info(MPT3SAS_FMT
4208
- "request_pool(0x%p): free\n",
4209
- ioc->name, ioc->request));
4856
+ dexitprintk(ioc,
4857
+ ioc_info(ioc, "request_pool(0x%p): free\n",
4858
+ ioc->request));
42104859 ioc->request = NULL;
42114860 }
42124861
42134862 if (ioc->sense) {
42144863 dma_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma);
42154864 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));
4865
+ dexitprintk(ioc,
4866
+ ioc_info(ioc, "sense_pool(0x%p): free\n",
4867
+ ioc->sense));
42194868 ioc->sense = NULL;
42204869 }
42214870
42224871 if (ioc->reply) {
42234872 dma_pool_free(ioc->reply_dma_pool, ioc->reply, ioc->reply_dma);
42244873 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));
4874
+ dexitprintk(ioc,
4875
+ ioc_info(ioc, "reply_pool(0x%p): free\n",
4876
+ ioc->reply));
42284877 ioc->reply = NULL;
42294878 }
42304879
....@@ -4232,36 +4881,41 @@
42324881 dma_pool_free(ioc->reply_free_dma_pool, ioc->reply_free,
42334882 ioc->reply_free_dma);
42344883 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));
4884
+ dexitprintk(ioc,
4885
+ ioc_info(ioc, "reply_free_pool(0x%p): free\n",
4886
+ ioc->reply_free));
42384887 ioc->reply_free = NULL;
42394888 }
42404889
42414890 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;
4891
+ dma_alloc_count = DIV_ROUND_UP(count,
4892
+ RDPQ_MAX_INDEX_IN_ONE_CHUNK);
4893
+ for (i = 0; i < count; i++) {
4894
+ if (i % RDPQ_MAX_INDEX_IN_ONE_CHUNK == 0
4895
+ && dma_alloc_count) {
4896
+ if (ioc->reply_post[i].reply_post_free) {
4897
+ dma_pool_free(
4898
+ ioc->reply_post_free_dma_pool,
4899
+ ioc->reply_post[i].reply_post_free,
4900
+ ioc->reply_post[i].reply_post_free_dma);
4901
+ dexitprintk(ioc, ioc_info(ioc,
4902
+ "reply_post_free_pool(0x%p): free\n",
4903
+ ioc->reply_post[i].reply_post_free));
4904
+ ioc->reply_post[i].reply_post_free =
4905
+ NULL;
4906
+ }
4907
+ --dma_alloc_count;
42534908 }
4254
- } while (ioc->rdpq_array_enable &&
4255
- (++i < ioc->reply_queue_count));
4909
+ }
4910
+ dma_pool_destroy(ioc->reply_post_free_dma_pool);
42564911 if (ioc->reply_post_free_array &&
42574912 ioc->rdpq_array_enable) {
42584913 dma_pool_free(ioc->reply_post_free_array_dma_pool,
4259
- ioc->reply_post_free_array,
4260
- ioc->reply_post_free_array_dma);
4914
+ ioc->reply_post_free_array,
4915
+ ioc->reply_post_free_array_dma);
42614916 ioc->reply_post_free_array = NULL;
42624917 }
42634918 dma_pool_destroy(ioc->reply_post_free_array_dma_pool);
4264
- dma_pool_destroy(ioc->reply_post_free_dma_pool);
42654919 kfree(ioc->reply_post);
42664920 }
42674921
....@@ -4270,16 +4924,18 @@
42704924 dma_pool_free(ioc->pcie_sgl_dma_pool,
42714925 ioc->pcie_sg_lookup[i].pcie_sgl,
42724926 ioc->pcie_sg_lookup[i].pcie_sgl_dma);
4927
+ ioc->pcie_sg_lookup[i].pcie_sgl = NULL;
42734928 }
4274
- if (ioc->pcie_sgl_dma_pool)
4275
- dma_pool_destroy(ioc->pcie_sgl_dma_pool);
4929
+ dma_pool_destroy(ioc->pcie_sgl_dma_pool);
42764930 }
4931
+ kfree(ioc->pcie_sg_lookup);
4932
+ ioc->pcie_sg_lookup = NULL;
42774933
42784934 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,
4935
+ dexitprintk(ioc,
4936
+ ioc_info(ioc, "config_page(0x%p): free\n",
4937
+ ioc->config_page));
4938
+ dma_free_coherent(&ioc->pdev->dev, ioc->config_page_sz,
42834939 ioc->config_page, ioc->config_page_dma);
42844940 }
42854941
....@@ -4306,7 +4962,7 @@
43064962 }
43074963
43084964 /**
4309
- * is_MSB_are_same - checks whether all reply queues in a set are
4965
+ * mpt3sas_check_same_4gb_region - checks whether all reply queues in a set are
43104966 * having same upper 32bits in their base memory address.
43114967 * @reply_pool_start_address: Base address of a reply queue set
43124968 * @pool_sz: Size of single Reply Descriptor Post Queues pool size
....@@ -4316,7 +4972,7 @@
43164972 */
43174973
43184974 static int
4319
-is_MSB_are_same(long reply_pool_start_address, u32 pool_sz)
4975
+mpt3sas_check_same_4gb_region(long reply_pool_start_address, u32 pool_sz)
43204976 {
43214977 long reply_pool_end_address;
43224978
....@@ -4327,6 +4983,168 @@
43274983 return 1;
43284984 else
43294985 return 0;
4986
+}
4987
+
4988
+/**
4989
+ * _base_reduce_hba_queue_depth- Retry with reduced queue depth
4990
+ * @ioc: Adapter object
4991
+ *
4992
+ * Return: 0 for success, non-zero for failure.
4993
+ **/
4994
+static inline int
4995
+_base_reduce_hba_queue_depth(struct MPT3SAS_ADAPTER *ioc)
4996
+{
4997
+ int reduce_sz = 64;
4998
+
4999
+ if ((ioc->hba_queue_depth - reduce_sz) >
5000
+ (ioc->internal_depth + INTERNAL_SCSIIO_CMDS_COUNT)) {
5001
+ ioc->hba_queue_depth -= reduce_sz;
5002
+ return 0;
5003
+ } else
5004
+ return -ENOMEM;
5005
+}
5006
+
5007
+/**
5008
+ * _base_allocate_pcie_sgl_pool - Allocating DMA'able memory
5009
+ * for pcie sgl pools.
5010
+ * @ioc: Adapter object
5011
+ * @sz: DMA Pool size
5012
+ * @ct: Chain tracker
5013
+ * Return: 0 for success, non-zero for failure.
5014
+ */
5015
+
5016
+static int
5017
+_base_allocate_pcie_sgl_pool(struct MPT3SAS_ADAPTER *ioc, u32 sz)
5018
+{
5019
+ int i = 0, j = 0;
5020
+ struct chain_tracker *ct;
5021
+
5022
+ ioc->pcie_sgl_dma_pool =
5023
+ dma_pool_create("PCIe SGL pool", &ioc->pdev->dev, sz,
5024
+ ioc->page_size, 0);
5025
+ if (!ioc->pcie_sgl_dma_pool) {
5026
+ ioc_err(ioc, "PCIe SGL pool: dma_pool_create failed\n");
5027
+ return -ENOMEM;
5028
+ }
5029
+
5030
+ ioc->chains_per_prp_buffer = sz/ioc->chain_segment_sz;
5031
+ ioc->chains_per_prp_buffer =
5032
+ min(ioc->chains_per_prp_buffer, ioc->chains_needed_per_io);
5033
+ for (i = 0; i < ioc->scsiio_depth; i++) {
5034
+ ioc->pcie_sg_lookup[i].pcie_sgl =
5035
+ dma_pool_alloc(ioc->pcie_sgl_dma_pool, GFP_KERNEL,
5036
+ &ioc->pcie_sg_lookup[i].pcie_sgl_dma);
5037
+ if (!ioc->pcie_sg_lookup[i].pcie_sgl) {
5038
+ ioc_err(ioc, "PCIe SGL pool: dma_pool_alloc failed\n");
5039
+ return -EAGAIN;
5040
+ }
5041
+
5042
+ if (!mpt3sas_check_same_4gb_region(
5043
+ (long)ioc->pcie_sg_lookup[i].pcie_sgl, sz)) {
5044
+ ioc_err(ioc, "PCIE SGLs are not in same 4G !! pcie sgl (0x%p) dma = (0x%llx)\n",
5045
+ ioc->pcie_sg_lookup[i].pcie_sgl,
5046
+ (unsigned long long)
5047
+ ioc->pcie_sg_lookup[i].pcie_sgl_dma);
5048
+ ioc->use_32bit_dma = true;
5049
+ return -EAGAIN;
5050
+ }
5051
+
5052
+ for (j = 0; j < ioc->chains_per_prp_buffer; j++) {
5053
+ ct = &ioc->chain_lookup[i].chains_per_smid[j];
5054
+ ct->chain_buffer =
5055
+ ioc->pcie_sg_lookup[i].pcie_sgl +
5056
+ (j * ioc->chain_segment_sz);
5057
+ ct->chain_buffer_dma =
5058
+ ioc->pcie_sg_lookup[i].pcie_sgl_dma +
5059
+ (j * ioc->chain_segment_sz);
5060
+ }
5061
+ }
5062
+ dinitprintk(ioc, ioc_info(ioc,
5063
+ "PCIe sgl pool depth(%d), element_size(%d), pool_size(%d kB)\n",
5064
+ ioc->scsiio_depth, sz, (sz * ioc->scsiio_depth)/1024));
5065
+ dinitprintk(ioc, ioc_info(ioc,
5066
+ "Number of chains can fit in a PRP page(%d)\n",
5067
+ ioc->chains_per_prp_buffer));
5068
+ return 0;
5069
+}
5070
+
5071
+/**
5072
+ * base_alloc_rdpq_dma_pool - Allocating DMA'able memory
5073
+ * for reply queues.
5074
+ * @ioc: per adapter object
5075
+ * @sz: DMA Pool size
5076
+ * Return: 0 for success, non-zero for failure.
5077
+ */
5078
+static int
5079
+base_alloc_rdpq_dma_pool(struct MPT3SAS_ADAPTER *ioc, int sz)
5080
+{
5081
+ int i = 0;
5082
+ u32 dma_alloc_count = 0;
5083
+ int reply_post_free_sz = ioc->reply_post_queue_depth *
5084
+ sizeof(Mpi2DefaultReplyDescriptor_t);
5085
+ int count = ioc->rdpq_array_enable ? ioc->reply_queue_count : 1;
5086
+
5087
+ ioc->reply_post = kcalloc(count, sizeof(struct reply_post_struct),
5088
+ GFP_KERNEL);
5089
+ if (!ioc->reply_post)
5090
+ return -ENOMEM;
5091
+ /*
5092
+ * For INVADER_SERIES each set of 8 reply queues(0-7, 8-15, ..) and
5093
+ * VENTURA_SERIES each set of 16 reply queues(0-15, 16-31, ..) should
5094
+ * be within 4GB boundary i.e reply queues in a set must have same
5095
+ * upper 32-bits in their memory address. so here driver is allocating
5096
+ * the DMA'able memory for reply queues according.
5097
+ * Driver uses limitation of
5098
+ * VENTURA_SERIES to manage INVADER_SERIES as well.
5099
+ */
5100
+ dma_alloc_count = DIV_ROUND_UP(count,
5101
+ RDPQ_MAX_INDEX_IN_ONE_CHUNK);
5102
+ ioc->reply_post_free_dma_pool =
5103
+ dma_pool_create("reply_post_free pool",
5104
+ &ioc->pdev->dev, sz, 16, 0);
5105
+ if (!ioc->reply_post_free_dma_pool)
5106
+ return -ENOMEM;
5107
+ for (i = 0; i < count; i++) {
5108
+ if ((i % RDPQ_MAX_INDEX_IN_ONE_CHUNK == 0) && dma_alloc_count) {
5109
+ ioc->reply_post[i].reply_post_free =
5110
+ dma_pool_zalloc(ioc->reply_post_free_dma_pool,
5111
+ GFP_KERNEL,
5112
+ &ioc->reply_post[i].reply_post_free_dma);
5113
+ if (!ioc->reply_post[i].reply_post_free)
5114
+ return -ENOMEM;
5115
+ /*
5116
+ * Each set of RDPQ pool must satisfy 4gb boundary
5117
+ * restriction.
5118
+ * 1) Check if allocated resources for RDPQ pool are in
5119
+ * the same 4GB range.
5120
+ * 2) If #1 is true, continue with 64 bit DMA.
5121
+ * 3) If #1 is false, return 1. which means free all the
5122
+ * resources and set DMA mask to 32 and allocate.
5123
+ */
5124
+ if (!mpt3sas_check_same_4gb_region(
5125
+ (long)ioc->reply_post[i].reply_post_free, sz)) {
5126
+ dinitprintk(ioc,
5127
+ ioc_err(ioc, "bad Replypost free pool(0x%p)"
5128
+ "reply_post_free_dma = (0x%llx)\n",
5129
+ ioc->reply_post[i].reply_post_free,
5130
+ (unsigned long long)
5131
+ ioc->reply_post[i].reply_post_free_dma));
5132
+ return -EAGAIN;
5133
+ }
5134
+ dma_alloc_count--;
5135
+
5136
+ } else {
5137
+ ioc->reply_post[i].reply_post_free =
5138
+ (Mpi2ReplyDescriptorsUnion_t *)
5139
+ ((long)ioc->reply_post[i-1].reply_post_free
5140
+ + reply_post_free_sz);
5141
+ ioc->reply_post[i].reply_post_free_dma =
5142
+ (dma_addr_t)
5143
+ (ioc->reply_post[i-1].reply_post_free_dma +
5144
+ reply_post_free_sz);
5145
+ }
5146
+ }
5147
+ return 0;
43305148 }
43315149
43325150 /**
....@@ -4343,14 +5161,15 @@
43435161 u16 chains_needed_per_io;
43445162 u32 sz, total_sz, reply_post_free_sz, reply_post_free_array_sz;
43455163 u32 retry_sz;
5164
+ u32 rdpq_sz = 0;
43465165 u16 max_request_credit, nvme_blocks_needed;
43475166 unsigned short sg_tablesize;
43485167 u16 sge_size;
43495168 int i, j;
5169
+ int ret = 0, rc = 0;
43505170 struct chain_tracker *ct;
43515171
4352
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
4353
- __func__));
5172
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
43545173
43555174
43565175 retry_sz = 0;
....@@ -4379,10 +5198,8 @@
43795198 else if (sg_tablesize > MPT_MAX_PHYS_SEGMENTS) {
43805199 sg_tablesize = min_t(unsigned short, sg_tablesize,
43815200 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);
5201
+ ioc_warn(ioc, "sg_tablesize(%u) is bigger than kernel defined SG_CHUNK_SIZE(%u)\n",
5202
+ sg_tablesize, MPT_MAX_PHYS_SEGMENTS);
43865203 }
43875204 ioc->shost->sg_tablesize = sg_tablesize;
43885205 }
....@@ -4392,9 +5209,8 @@
43925209 if (ioc->internal_depth < INTERNAL_CMDS_COUNT) {
43935210 if (facts->RequestCredit <= (INTERNAL_CMDS_COUNT +
43945211 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);
5212
+ ioc_err(ioc, "IOC doesn't have enough Request Credits, it has just %d number of credits\n",
5213
+ facts->RequestCredit);
43985214 return -ENOMEM;
43995215 }
44005216 ioc->internal_depth = 10;
....@@ -4493,71 +5309,39 @@
44935309 ioc->reply_free_queue_depth = ioc->hba_queue_depth + 64;
44945310 }
44955311
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));
5312
+ ioc_info(ioc,
5313
+ "scatter gather: sge_in_main_msg(%d), sge_per_chain(%d), "
5314
+ "sge_per_io(%d), chains_per_io(%d)\n",
5315
+ ioc->max_sges_in_main_message,
5316
+ ioc->max_sges_in_chain_message,
5317
+ ioc->shost->sg_tablesize,
5318
+ ioc->chains_needed_per_io);
45015319
45025320 /* reply post queue, 16 byte align */
45035321 reply_post_free_sz = ioc->reply_post_queue_depth *
45045322 sizeof(Mpi2DefaultReplyDescriptor_t);
4505
-
4506
- sz = reply_post_free_sz;
5323
+ rdpq_sz = reply_post_free_sz * RDPQ_MAX_INDEX_IN_ONE_CHUNK;
45075324 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;
5325
+ rdpq_sz = reply_post_free_sz * ioc->reply_queue_count;
5326
+ ret = base_alloc_rdpq_dma_pool(ioc, rdpq_sz);
5327
+ if (ret == -EAGAIN) {
5328
+ /*
5329
+ * Free allocated bad RDPQ memory pools.
5330
+ * Change dma coherent mask to 32 bit and reallocate RDPQ
5331
+ */
5332
+ _base_release_memory_pools(ioc);
5333
+ ioc->use_32bit_dma = true;
5334
+ if (_base_config_dma_addressing(ioc, ioc->pdev) != 0) {
5335
+ ioc_err(ioc,
5336
+ "32 DMA mask failed %s\n", pci_name(ioc->pdev));
5337
+ return -ENODEV;
45385338 }
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
-
5339
+ if (base_alloc_rdpq_dma_pool(ioc, rdpq_sz))
5340
+ return -ENOMEM;
5341
+ } else if (ret == -ENOMEM)
5342
+ return -ENOMEM;
5343
+ total_sz = rdpq_sz * (!ioc->rdpq_array_enable ? 1 :
5344
+ DIV_ROUND_UP(ioc->reply_queue_count, RDPQ_MAX_INDEX_IN_ONE_CHUNK));
45615345 ioc->scsiio_depth = ioc->hba_queue_depth -
45625346 ioc->hi_priority_depth - ioc->internal_depth;
45635347
....@@ -4565,10 +5349,9 @@
45655349 * with some internal commands that could be outstanding
45665350 */
45675351 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
-
5352
+ dinitprintk(ioc,
5353
+ ioc_info(ioc, "scsi host: can_queue depth (%d)\n",
5354
+ ioc->shost->can_queue));
45725355
45735356 /* contiguous pool for request and chains, 16 byte align, one extra "
45745357 * "frame for smid=0
....@@ -4583,12 +5366,12 @@
45835366 sz += (ioc->internal_depth * ioc->request_sz);
45845367
45855368 ioc->request_dma_sz = sz;
4586
- ioc->request = pci_alloc_consistent(ioc->pdev, sz, &ioc->request_dma);
5369
+ ioc->request = dma_alloc_coherent(&ioc->pdev->dev, sz,
5370
+ &ioc->request_dma, GFP_KERNEL);
45875371 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);
5372
+ ioc_err(ioc, "request pool: dma_alloc_coherent failed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), total(%d kB)\n",
5373
+ ioc->hba_queue_depth, ioc->chains_needed_per_io,
5374
+ ioc->request_sz, sz / 1024);
45925375 if (ioc->scsiio_depth < MPT3SAS_SAS_QUEUE_DEPTH)
45935376 goto out;
45945377 retry_sz = 64;
....@@ -4598,10 +5381,9 @@
45985381 }
45995382
46005383 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);
5384
+ ioc_err(ioc, "request pool: dma_alloc_coherent succeed: hba_depth(%d), chains_per_io(%d), frame_sz(%d), total(%d kb)\n",
5385
+ ioc->hba_queue_depth, ioc->chains_needed_per_io,
5386
+ ioc->request_sz, sz / 1024);
46055387
46065388 /* hi-priority queue */
46075389 ioc->hi_priority = ioc->request + ((ioc->scsiio_depth + 1) *
....@@ -4615,24 +5397,24 @@
46155397 ioc->internal_dma = ioc->hi_priority_dma + (ioc->hi_priority_depth *
46165398 ioc->request_sz);
46175399
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));
5400
+ ioc_info(ioc,
5401
+ "request pool(0x%p) - dma(0x%llx): "
5402
+ "depth(%d), frame_size(%d), pool_size(%d kB)\n",
5403
+ ioc->request, (unsigned long long) ioc->request_dma,
5404
+ ioc->hba_queue_depth, ioc->request_sz,
5405
+ (ioc->hba_queue_depth * ioc->request_sz) / 1024);
46225406
4623
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "request pool: dma(0x%llx)\n",
4624
- ioc->name, (unsigned long long) ioc->request_dma));
46255407 total_sz += sz;
46265408
4627
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "scsiio(0x%p): depth(%d)\n",
4628
- ioc->name, ioc->request, ioc->scsiio_depth));
5409
+ dinitprintk(ioc,
5410
+ ioc_info(ioc, "scsiio(0x%p): depth(%d)\n",
5411
+ ioc->request, ioc->scsiio_depth));
46295412
46305413 ioc->chain_depth = min_t(u32, ioc->chain_depth, MAX_CHAIN_DEPTH);
46315414 sz = ioc->scsiio_depth * sizeof(struct chain_lookup);
46325415 ioc->chain_lookup = kzalloc(sz, GFP_KERNEL);
46335416 if (!ioc->chain_lookup) {
4634
- pr_err(MPT3SAS_FMT "chain_lookup: __get_free_pages "
4635
- "failed\n", ioc->name);
5417
+ ioc_err(ioc, "chain_lookup: __get_free_pages failed\n");
46365418 goto out;
46375419 }
46385420
....@@ -4640,8 +5422,7 @@
46405422 for (i = 0; i < ioc->scsiio_depth; i++) {
46415423 ioc->chain_lookup[i].chains_per_smid = kzalloc(sz, GFP_KERNEL);
46425424 if (!ioc->chain_lookup[i].chains_per_smid) {
4643
- pr_err(MPT3SAS_FMT "chain_lookup: "
4644
- " kzalloc failed\n", ioc->name);
5425
+ ioc_err(ioc, "chain_lookup: kzalloc failed\n");
46455426 goto out;
46465427 }
46475428 }
....@@ -4650,29 +5431,27 @@
46505431 ioc->hpr_lookup = kcalloc(ioc->hi_priority_depth,
46515432 sizeof(struct request_tracker), GFP_KERNEL);
46525433 if (!ioc->hpr_lookup) {
4653
- pr_err(MPT3SAS_FMT "hpr_lookup: kcalloc failed\n",
4654
- ioc->name);
5434
+ ioc_err(ioc, "hpr_lookup: kcalloc failed\n");
46555435 goto out;
46565436 }
46575437 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));
5438
+ dinitprintk(ioc,
5439
+ ioc_info(ioc, "hi_priority(0x%p): depth(%d), start smid(%d)\n",
5440
+ ioc->hi_priority,
5441
+ ioc->hi_priority_depth, ioc->hi_priority_smid));
46625442
46635443 /* initialize internal queue smid's */
46645444 ioc->internal_lookup = kcalloc(ioc->internal_depth,
46655445 sizeof(struct request_tracker), GFP_KERNEL);
46665446 if (!ioc->internal_lookup) {
4667
- pr_err(MPT3SAS_FMT "internal_lookup: kcalloc failed\n",
4668
- ioc->name);
5447
+ ioc_err(ioc, "internal_lookup: kcalloc failed\n");
46695448 goto out;
46705449 }
46715450 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));
5451
+ dinitprintk(ioc,
5452
+ ioc_info(ioc, "internal(0x%p): depth(%d), start smid(%d)\n",
5453
+ ioc->internal,
5454
+ ioc->internal_depth, ioc->internal_smid));
46765455 /*
46775456 * The number of NVMe page sized blocks needed is:
46785457 * (((sg_tablesize * 8) - 1) / (page_size - 8)) + 1
....@@ -4686,6 +5465,7 @@
46865465 * be required for NVMe PRP's, only each set of NVMe blocks will be
46875466 * contiguous, so a new set is allocated for each possible I/O.
46885467 */
5468
+
46895469 ioc->chains_per_prp_buffer = 0;
46905470 if (ioc->facts.ProtocolFlags & MPI2_IOCFACTS_PROTOCOL_NVME_DEVICES) {
46915471 nvme_blocks_needed =
....@@ -4696,59 +5476,22 @@
46965476 sz = sizeof(struct pcie_sg_list) * ioc->scsiio_depth;
46975477 ioc->pcie_sg_lookup = kzalloc(sz, GFP_KERNEL);
46985478 if (!ioc->pcie_sg_lookup) {
4699
- pr_info(MPT3SAS_FMT
4700
- "PCIe SGL lookup: kzalloc failed\n", ioc->name);
5479
+ ioc_info(ioc, "PCIe SGL lookup: kzalloc failed\n");
47015480 goto out;
47025481 }
47035482 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));
5483
+ rc = _base_allocate_pcie_sgl_pool(ioc, sz);
5484
+ if (rc == -ENOMEM)
5485
+ return -ENOMEM;
5486
+ else if (rc == -EAGAIN)
5487
+ goto try_32bit_dma;
47445488 total_sz += sz * ioc->scsiio_depth;
47455489 }
47465490
47475491 ioc->chain_dma_pool = dma_pool_create("chain pool", &ioc->pdev->dev,
47485492 ioc->chain_segment_sz, 16, 0);
47495493 if (!ioc->chain_dma_pool) {
4750
- pr_err(MPT3SAS_FMT "chain_dma_pool: dma_pool_create failed\n",
4751
- ioc->name);
5494
+ ioc_err(ioc, "chain_dma_pool: dma_pool_create failed\n");
47525495 goto out;
47535496 }
47545497 for (i = 0; i < ioc->scsiio_depth; i++) {
....@@ -4759,34 +5502,30 @@
47595502 ioc->chain_dma_pool, GFP_KERNEL,
47605503 &ct->chain_buffer_dma);
47615504 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);
5505
+ ioc_err(ioc, "chain_lookup: pci_pool_alloc failed\n");
47655506 goto out;
47665507 }
47675508 }
47685509 total_sz += ioc->chain_segment_sz;
47695510 }
47705511
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));
5512
+ dinitprintk(ioc,
5513
+ ioc_info(ioc, "chain pool depth(%d), frame_size(%d), pool_size(%d kB)\n",
5514
+ ioc->chain_depth, ioc->chain_segment_sz,
5515
+ (ioc->chain_depth * ioc->chain_segment_sz) / 1024));
47755516
47765517 /* sense buffers, 4 byte align */
47775518 sz = ioc->scsiio_depth * SCSI_SENSE_BUFFERSIZE;
47785519 ioc->sense_dma_pool = dma_pool_create("sense pool", &ioc->pdev->dev, sz,
47795520 4, 0);
47805521 if (!ioc->sense_dma_pool) {
4781
- pr_err(MPT3SAS_FMT "sense pool: dma_pool_create failed\n",
4782
- ioc->name);
5522
+ ioc_err(ioc, "sense pool: dma_pool_create failed\n");
47835523 goto out;
47845524 }
47855525 ioc->sense = dma_pool_alloc(ioc->sense_dma_pool, GFP_KERNEL,
47865526 &ioc->sense_dma);
47875527 if (!ioc->sense) {
4788
- pr_err(MPT3SAS_FMT "sense pool: dma_pool_alloc failed\n",
4789
- ioc->name);
5528
+ ioc_err(ioc, "sense pool: dma_pool_alloc failed\n");
47905529 goto out;
47915530 }
47925531 /* sense buffer requires to be in same 4 gb region.
....@@ -4798,7 +5537,7 @@
47985537 * Actual requirement is not alignment, but we need start and end of
47995538 * DMA address must have same upper 32 bit address.
48005539 */
4801
- if (!is_MSB_are_same((long)ioc->sense, sz)) {
5540
+ if (!mpt3sas_check_same_4gb_region((long)ioc->sense, sz)) {
48025541 //Release Sense pool & Reallocate
48035542 dma_pool_free(ioc->sense_dma_pool, ioc->sense, ioc->sense_dma);
48045543 dma_pool_destroy(ioc->sense_dma_pool);
....@@ -4808,24 +5547,22 @@
48085547 dma_pool_create("sense pool", &ioc->pdev->dev, sz,
48095548 roundup_pow_of_two(sz), 0);
48105549 if (!ioc->sense_dma_pool) {
4811
- pr_err(MPT3SAS_FMT "sense pool: pci_pool_create failed\n",
4812
- ioc->name);
5550
+ ioc_err(ioc, "sense pool: pci_pool_create failed\n");
48135551 goto out;
48145552 }
48155553 ioc->sense = dma_pool_alloc(ioc->sense_dma_pool, GFP_KERNEL,
48165554 &ioc->sense_dma);
48175555 if (!ioc->sense) {
4818
- pr_err(MPT3SAS_FMT "sense pool: pci_pool_alloc failed\n",
4819
- ioc->name);
5556
+ ioc_err(ioc, "sense pool: pci_pool_alloc failed\n");
48205557 goto out;
48215558 }
48225559 }
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));
5560
+ ioc_info(ioc,
5561
+ "sense pool(0x%p)- dma(0x%llx): depth(%d),"
5562
+ "element_size(%d), pool_size(%d kB)\n",
5563
+ ioc->sense, (unsigned long long)ioc->sense_dma, ioc->scsiio_depth,
5564
+ SCSI_SENSE_BUFFERSIZE, sz / 1024);
5565
+
48295566 total_sz += sz;
48305567
48315568 /* reply pool, 4 byte align */
....@@ -4833,25 +5570,24 @@
48335570 ioc->reply_dma_pool = dma_pool_create("reply pool", &ioc->pdev->dev, sz,
48345571 4, 0);
48355572 if (!ioc->reply_dma_pool) {
4836
- pr_err(MPT3SAS_FMT "reply pool: dma_pool_create failed\n",
4837
- ioc->name);
5573
+ ioc_err(ioc, "reply pool: dma_pool_create failed\n");
48385574 goto out;
48395575 }
48405576 ioc->reply = dma_pool_alloc(ioc->reply_dma_pool, GFP_KERNEL,
48415577 &ioc->reply_dma);
48425578 if (!ioc->reply) {
4843
- pr_err(MPT3SAS_FMT "reply pool: dma_pool_alloc failed\n",
4844
- ioc->name);
5579
+ ioc_err(ioc, "reply pool: dma_pool_alloc failed\n");
48455580 goto out;
48465581 }
48475582 ioc->reply_dma_min_address = (u32)(ioc->reply_dma);
48485583 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));
5584
+ dinitprintk(ioc,
5585
+ ioc_info(ioc, "reply pool(0x%p): depth(%d), frame_size(%d), pool_size(%d kB)\n",
5586
+ ioc->reply, ioc->reply_free_queue_depth,
5587
+ ioc->reply_sz, sz / 1024));
5588
+ dinitprintk(ioc,
5589
+ ioc_info(ioc, "reply_dma(0x%llx)\n",
5590
+ (unsigned long long)ioc->reply_dma));
48555591 total_sz += sz;
48565592
48575593 /* reply free queue, 16 byte align */
....@@ -4859,24 +5595,22 @@
48595595 ioc->reply_free_dma_pool = dma_pool_create("reply_free pool",
48605596 &ioc->pdev->dev, sz, 16, 0);
48615597 if (!ioc->reply_free_dma_pool) {
4862
- pr_err(MPT3SAS_FMT "reply_free pool: dma_pool_create failed\n",
4863
- ioc->name);
5598
+ ioc_err(ioc, "reply_free pool: dma_pool_create failed\n");
48645599 goto out;
48655600 }
4866
- ioc->reply_free = dma_pool_alloc(ioc->reply_free_dma_pool, GFP_KERNEL,
5601
+ ioc->reply_free = dma_pool_zalloc(ioc->reply_free_dma_pool, GFP_KERNEL,
48675602 &ioc->reply_free_dma);
48685603 if (!ioc->reply_free) {
4869
- pr_err(MPT3SAS_FMT "reply_free pool: dma_pool_alloc failed\n",
4870
- ioc->name);
5604
+ ioc_err(ioc, "reply_free pool: dma_pool_alloc failed\n");
48715605 goto out;
48725606 }
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));
5607
+ dinitprintk(ioc,
5608
+ ioc_info(ioc, "reply_free pool(0x%p): depth(%d), element_size(%d), pool_size(%d kB)\n",
5609
+ ioc->reply_free, ioc->reply_free_queue_depth,
5610
+ 4, sz / 1024));
5611
+ dinitprintk(ioc,
5612
+ ioc_info(ioc, "reply_free_dma (0x%llx)\n",
5613
+ (unsigned long long)ioc->reply_free_dma));
48805614 total_sz += sz;
48815615
48825616 if (ioc->rdpq_array_enable) {
....@@ -4887,8 +5621,7 @@
48875621 &ioc->pdev->dev, reply_post_free_array_sz, 16, 0);
48885622 if (!ioc->reply_post_free_array_dma_pool) {
48895623 dinitprintk(ioc,
4890
- pr_info(MPT3SAS_FMT "reply_post_free_array pool: "
4891
- "dma_pool_create failed\n", ioc->name));
5624
+ ioc_info(ioc, "reply_post_free_array pool: dma_pool_create failed\n"));
48925625 goto out;
48935626 }
48945627 ioc->reply_post_free_array =
....@@ -4896,35 +5629,43 @@
48965629 GFP_KERNEL, &ioc->reply_post_free_array_dma);
48975630 if (!ioc->reply_post_free_array) {
48985631 dinitprintk(ioc,
4899
- pr_info(MPT3SAS_FMT "reply_post_free_array pool: "
4900
- "dma_pool_alloc failed\n", ioc->name));
5632
+ ioc_info(ioc, "reply_post_free_array pool: dma_pool_alloc failed\n"));
49015633 goto out;
49025634 }
49035635 }
49045636 ioc->config_page_sz = 512;
4905
- ioc->config_page = pci_alloc_consistent(ioc->pdev,
4906
- ioc->config_page_sz, &ioc->config_page_dma);
5637
+ ioc->config_page = dma_alloc_coherent(&ioc->pdev->dev,
5638
+ ioc->config_page_sz, &ioc->config_page_dma, GFP_KERNEL);
49075639 if (!ioc->config_page) {
4908
- pr_err(MPT3SAS_FMT
4909
- "config page: dma_pool_alloc failed\n",
4910
- ioc->name);
5640
+ ioc_err(ioc, "config page: dma_pool_alloc failed\n");
49115641 goto out;
49125642 }
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));
5643
+
5644
+ ioc_info(ioc, "config page(0x%p) - dma(0x%llx): size(%d)\n",
5645
+ ioc->config_page, (unsigned long long)ioc->config_page_dma,
5646
+ ioc->config_page_sz);
49185647 total_sz += ioc->config_page_sz;
49195648
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);
5649
+ ioc_info(ioc, "Allocated physical memory: size(%d kB)\n",
5650
+ total_sz / 1024);
5651
+ ioc_info(ioc, "Current Controller Queue Depth(%d),Max Controller Queue Depth(%d)\n",
5652
+ ioc->shost->can_queue, facts->RequestCredit);
5653
+ ioc_info(ioc, "Scatter Gather Elements per IO(%d)\n",
5654
+ ioc->shost->sg_tablesize);
49275655 return 0;
5656
+
5657
+try_32bit_dma:
5658
+ _base_release_memory_pools(ioc);
5659
+ if (ioc->use_32bit_dma && (ioc->dma_mask > 32)) {
5660
+ /* Change dma coherent mask to 32 bit and reallocate */
5661
+ if (_base_config_dma_addressing(ioc, ioc->pdev) != 0) {
5662
+ pr_err("Setting 32 bit coherent DMA mask Failed %s\n",
5663
+ pci_name(ioc->pdev));
5664
+ return -ENODEV;
5665
+ }
5666
+ } else if (_base_reduce_hba_queue_depth(ioc) != 0)
5667
+ return -ENOMEM;
5668
+ goto retry_allocation;
49285669
49295670 out:
49305671 return -ENOMEM;
....@@ -4943,7 +5684,7 @@
49435684 {
49445685 u32 s, sc;
49455686
4946
- s = readl(&ioc->chip->Doorbell);
5687
+ s = ioc->base_readl_ext_retry(&ioc->chip->Doorbell);
49475688 sc = s & MPI2_IOC_STATE_MASK;
49485689 return cooked ? sc : s;
49495690 }
....@@ -4970,6 +5711,8 @@
49705711 return 0;
49715712 if (count && current_state == MPI2_IOC_STATE_FAULT)
49725713 break;
5714
+ if (count && current_state == MPI2_IOC_STATE_COREDUMP)
5715
+ break;
49735716
49745717 usleep_range(1000, 1500);
49755718 count++;
....@@ -4979,16 +5722,32 @@
49795722 }
49805723
49815724 /**
5725
+ * _base_dump_reg_set - This function will print hexdump of register set.
5726
+ * @ioc: per adapter object
5727
+ *
5728
+ * Returns nothing.
5729
+ */
5730
+static inline void
5731
+_base_dump_reg_set(struct MPT3SAS_ADAPTER *ioc)
5732
+{
5733
+ unsigned int i, sz = 256;
5734
+ u32 __iomem *reg = (u32 __iomem *)ioc->chip;
5735
+
5736
+ ioc_info(ioc, "System Register set:\n");
5737
+ for (i = 0; i < (sz / sizeof(u32)); i++)
5738
+ pr_info("%08x: %08x\n", (i * 4), readl(&reg[i]));
5739
+}
5740
+
5741
+/**
49825742 * _base_wait_for_doorbell_int - waiting for controller interrupt(generated by
49835743 * a write to the doorbell)
49845744 * @ioc: per adapter object
5745
+ * @timeout: timeout in seconds
49855746 *
49865747 * Return: 0 for success, non-zero for failure.
49875748 *
49885749 * Notes: MPI2_HIS_IOC2SYS_DB_STATUS - set to one when IOC writes to doorbell.
49895750 */
4990
-static int
4991
-_base_diag_reset(struct MPT3SAS_ADAPTER *ioc);
49925751
49935752 static int
49945753 _base_wait_for_doorbell_int(struct MPT3SAS_ADAPTER *ioc, int timeout)
....@@ -4999,11 +5758,11 @@
49995758 count = 0;
50005759 cntdn = 1000 * timeout;
50015760 do {
5002
- int_status = readl(&ioc->chip->HostInterruptStatus);
5761
+ int_status = ioc->base_readl(&ioc->chip->HostInterruptStatus);
50035762 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));
5763
+ dhsprintk(ioc,
5764
+ ioc_info(ioc, "%s: successful count(%d), timeout(%d)\n",
5765
+ __func__, count, timeout));
50075766 return 0;
50085767 }
50095768
....@@ -5011,9 +5770,8 @@
50115770 count++;
50125771 } while (--cntdn);
50135772
5014
- pr_err(MPT3SAS_FMT
5015
- "%s: failed due to timeout count(%d), int_status(%x)!\n",
5016
- 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);
50175775 return -EFAULT;
50185776 }
50195777
....@@ -5026,11 +5784,11 @@
50265784 count = 0;
50275785 cntdn = 2000 * timeout;
50285786 do {
5029
- int_status = readl(&ioc->chip->HostInterruptStatus);
5787
+ int_status = ioc->base_readl(&ioc->chip->HostInterruptStatus);
50305788 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));
5789
+ dhsprintk(ioc,
5790
+ ioc_info(ioc, "%s: successful count(%d), timeout(%d)\n",
5791
+ __func__, count, timeout));
50345792 return 0;
50355793 }
50365794
....@@ -5038,9 +5796,8 @@
50385796 count++;
50395797 } while (--cntdn);
50405798
5041
- pr_err(MPT3SAS_FMT
5042
- "%s: failed due to timeout count(%d), int_status(%x)!\n",
5043
- ioc->name, __func__, count, int_status);
5799
+ ioc_err(ioc, "%s: failed due to timeout count(%d), int_status(%x)!\n",
5800
+ __func__, count, int_status);
50445801 return -EFAULT;
50455802
50465803 }
....@@ -5065,17 +5822,22 @@
50655822 count = 0;
50665823 cntdn = 1000 * timeout;
50675824 do {
5068
- int_status = readl(&ioc->chip->HostInterruptStatus);
5825
+ int_status = ioc->base_readl(&ioc->chip->HostInterruptStatus);
50695826 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));
5827
+ dhsprintk(ioc,
5828
+ ioc_info(ioc, "%s: successful count(%d), timeout(%d)\n",
5829
+ __func__, count, timeout));
50735830 return 0;
50745831 } else if (int_status & MPI2_HIS_IOC2SYS_DB_STATUS) {
5075
- doorbell = readl(&ioc->chip->Doorbell);
5832
+ doorbell = ioc->base_readl_ext_retry(&ioc->chip->Doorbell);
50765833 if ((doorbell & MPI2_IOC_STATE_MASK) ==
50775834 MPI2_IOC_STATE_FAULT) {
5078
- mpt3sas_base_fault_info(ioc , doorbell);
5835
+ mpt3sas_print_fault_code(ioc, doorbell);
5836
+ return -EFAULT;
5837
+ }
5838
+ if ((doorbell & MPI2_IOC_STATE_MASK) ==
5839
+ MPI2_IOC_STATE_COREDUMP) {
5840
+ mpt3sas_print_coredump_info(ioc, doorbell);
50795841 return -EFAULT;
50805842 }
50815843 } else if (int_status == 0xFFFFFFFF)
....@@ -5086,9 +5848,8 @@
50865848 } while (--cntdn);
50875849
50885850 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);
5851
+ ioc_err(ioc, "%s: failed due to timeout count(%d), int_status(%x)!\n",
5852
+ __func__, count, int_status);
50925853 return -EFAULT;
50935854 }
50945855
....@@ -5108,11 +5869,11 @@
51085869 count = 0;
51095870 cntdn = 1000 * timeout;
51105871 do {
5111
- doorbell_reg = readl(&ioc->chip->Doorbell);
5872
+ doorbell_reg = ioc->base_readl_ext_retry(&ioc->chip->Doorbell);
51125873 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));
5874
+ dhsprintk(ioc,
5875
+ ioc_info(ioc, "%s: successful count(%d), timeout(%d)\n",
5876
+ __func__, count, timeout));
51165877 return 0;
51175878 }
51185879
....@@ -5120,9 +5881,8 @@
51205881 count++;
51215882 } while (--cntdn);
51225883
5123
- pr_err(MPT3SAS_FMT
5124
- "%s: failed due to timeout count(%d), doorbell_reg(%x)!\n",
5125
- ioc->name, __func__, count, doorbell_reg);
5884
+ ioc_err(ioc, "%s: failed due to timeout count(%d), doorbell_reg(%x)!\n",
5885
+ __func__, count, doorbell_reg);
51265886 return -EFAULT;
51275887 }
51285888
....@@ -5139,10 +5899,10 @@
51395899 {
51405900 u32 ioc_state;
51415901 int r = 0;
5902
+ unsigned long flags;
51425903
51435904 if (reset_type != MPI2_FUNCTION_IOC_MESSAGE_UNIT_RESET) {
5144
- pr_err(MPT3SAS_FMT "%s: unknown reset_type\n",
5145
- ioc->name, __func__);
5905
+ ioc_err(ioc, "%s: unknown reset_type\n", __func__);
51465906 return -EFAULT;
51475907 }
51485908
....@@ -5150,7 +5910,7 @@
51505910 MPI2_IOCFACTS_CAPABILITY_EVENT_REPLAY))
51515911 return -EFAULT;
51525912
5153
- pr_info(MPT3SAS_FMT "sending message unit reset !!\n", ioc->name);
5913
+ ioc_info(ioc, "sending message unit reset !!\n");
51545914
51555915 writel(reset_type << MPI2_DOORBELL_FUNCTION_SHIFT,
51565916 &ioc->chip->Doorbell);
....@@ -5158,18 +5918,71 @@
51585918 r = -EFAULT;
51595919 goto out;
51605920 }
5921
+
51615922 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, timeout);
51625923 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);
5924
+ ioc_err(ioc, "%s: failed going to ready state (ioc_state=0x%x)\n",
5925
+ __func__, ioc_state);
51665926 r = -EFAULT;
51675927 goto out;
51685928 }
51695929 out:
5170
- pr_info(MPT3SAS_FMT "message unit reset: %s\n",
5171
- ioc->name, ((r == 0) ? "SUCCESS" : "FAILED"));
5930
+ if (r != 0) {
5931
+ ioc_state = mpt3sas_base_get_iocstate(ioc, 0);
5932
+ spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
5933
+ /*
5934
+ * Wait for IOC state CoreDump to clear only during
5935
+ * HBA initialization & release time.
5936
+ */
5937
+ if ((ioc_state & MPI2_IOC_STATE_MASK) ==
5938
+ MPI2_IOC_STATE_COREDUMP && (ioc->is_driver_loading == 1 ||
5939
+ ioc->fault_reset_work_q == NULL)) {
5940
+ spin_unlock_irqrestore(
5941
+ &ioc->ioc_reset_in_progress_lock, flags);
5942
+ mpt3sas_print_coredump_info(ioc, ioc_state);
5943
+ mpt3sas_base_wait_for_coredump_completion(ioc,
5944
+ __func__);
5945
+ spin_lock_irqsave(
5946
+ &ioc->ioc_reset_in_progress_lock, flags);
5947
+ }
5948
+ spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
5949
+ }
5950
+ ioc_info(ioc, "message unit reset: %s\n",
5951
+ r == 0 ? "SUCCESS" : "FAILED");
51725952 return r;
5953
+}
5954
+
5955
+/**
5956
+ * mpt3sas_wait_for_ioc - IOC's operational state is checked here.
5957
+ * @ioc: per adapter object
5958
+ * @timeout: timeout in seconds
5959
+ *
5960
+ * Return: Waits up to timeout seconds for the IOC to
5961
+ * become operational. Returns 0 if IOC is present
5962
+ * and operational; otherwise returns -EFAULT.
5963
+ */
5964
+
5965
+int
5966
+mpt3sas_wait_for_ioc(struct MPT3SAS_ADAPTER *ioc, int timeout)
5967
+{
5968
+ int wait_state_count = 0;
5969
+ u32 ioc_state;
5970
+
5971
+ do {
5972
+ ioc_state = mpt3sas_base_get_iocstate(ioc, 1);
5973
+ if (ioc_state == MPI2_IOC_STATE_OPERATIONAL)
5974
+ break;
5975
+ ssleep(1);
5976
+ ioc_info(ioc, "%s: waiting for operational state(count=%d)\n",
5977
+ __func__, ++wait_state_count);
5978
+ } while (--timeout);
5979
+ if (!timeout) {
5980
+ ioc_err(ioc, "%s: failed due to ioc not operational\n", __func__);
5981
+ return -EFAULT;
5982
+ }
5983
+ if (wait_state_count)
5984
+ ioc_info(ioc, "ioc is operational\n");
5985
+ return 0;
51735986 }
51745987
51755988 /**
....@@ -5193,15 +6006,13 @@
51936006 __le32 *mfp;
51946007
51956008 /* 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__);
6009
+ if ((ioc->base_readl_ext_retry(&ioc->chip->Doorbell) & MPI2_DOORBELL_USED)) {
6010
+ ioc_err(ioc, "doorbell is in use (line=%d)\n", __LINE__);
52006011 return -EFAULT;
52016012 }
52026013
52036014 /* clear pending doorbell interrupts from previous state changes */
5204
- if (readl(&ioc->chip->HostInterruptStatus) &
6015
+ if (ioc->base_readl(&ioc->chip->HostInterruptStatus) &
52056016 MPI2_HIS_IOC2SYS_DB_STATUS)
52066017 writel(0, &ioc->chip->HostInterruptStatus);
52076018
....@@ -5211,17 +6022,15 @@
52116022 &ioc->chip->Doorbell);
52126023
52136024 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__);
6025
+ ioc_err(ioc, "doorbell handshake int failed (line=%d)\n",
6026
+ __LINE__);
52176027 return -EFAULT;
52186028 }
52196029 writel(0, &ioc->chip->HostInterruptStatus);
52206030
52216031 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__);
6032
+ ioc_err(ioc, "doorbell handshake ack failed (line=%d)\n",
6033
+ __LINE__);
52256034 return -EFAULT;
52266035 }
52276036
....@@ -5233,53 +6042,51 @@
52336042 }
52346043
52356044 if (failed) {
5236
- pr_err(MPT3SAS_FMT
5237
- "doorbell handshake sending request failed (line=%d)\n",
5238
- ioc->name, __LINE__);
6045
+ ioc_err(ioc, "doorbell handshake sending request failed (line=%d)\n",
6046
+ __LINE__);
52396047 return -EFAULT;
52406048 }
52416049
52426050 /* now wait for the reply */
52436051 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__);
6052
+ ioc_err(ioc, "doorbell handshake int failed (line=%d)\n",
6053
+ __LINE__);
52476054 return -EFAULT;
52486055 }
52496056
52506057 /* read the first two 16-bits, it gives the total length of the reply */
5251
- reply[0] = le16_to_cpu(readl(&ioc->chip->Doorbell)
6058
+ reply[0] = le16_to_cpu(ioc->base_readl_ext_retry(&ioc->chip->Doorbell)
52526059 & MPI2_DOORBELL_DATA_MASK);
52536060 writel(0, &ioc->chip->HostInterruptStatus);
52546061 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__);
6062
+ ioc_err(ioc, "doorbell handshake int failed (line=%d)\n",
6063
+ __LINE__);
52586064 return -EFAULT;
52596065 }
5260
- reply[1] = le16_to_cpu(readl(&ioc->chip->Doorbell)
6066
+ reply[1] = le16_to_cpu(ioc->base_readl_ext_retry(&ioc->chip->Doorbell)
52616067 & MPI2_DOORBELL_DATA_MASK);
52626068 writel(0, &ioc->chip->HostInterruptStatus);
52636069
52646070 for (i = 2; i < default_reply->MsgLength * 2; i++) {
52656071 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__);
6072
+ ioc_err(ioc, "doorbell handshake int failed (line=%d)\n",
6073
+ __LINE__);
52696074 return -EFAULT;
52706075 }
52716076 if (i >= reply_bytes/2) /* overflow case */
5272
- readl(&ioc->chip->Doorbell);
6077
+ ioc->base_readl_ext_retry(&ioc->chip->Doorbell);
52736078 else
5274
- reply[i] = le16_to_cpu(readl(&ioc->chip->Doorbell)
6079
+ reply[i] = le16_to_cpu(
6080
+ ioc->base_readl_ext_retry(&ioc->chip->Doorbell)
52756081 & MPI2_DOORBELL_DATA_MASK);
52766082 writel(0, &ioc->chip->HostInterruptStatus);
52776083 }
52786084
52796085 _base_wait_for_doorbell_int(ioc, 5);
52806086 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__));
6087
+ dhsprintk(ioc,
6088
+ ioc_info(ioc, "doorbell is in use (line=%d)\n",
6089
+ __LINE__));
52836090 }
52846091 writel(0, &ioc->chip->HostInterruptStatus);
52856092
....@@ -5287,7 +6094,7 @@
52876094 mfp = (__le32 *)reply;
52886095 pr_info("\toffset:data\n");
52896096 for (i = 0; i < reply_bytes/4; i++)
5290
- pr_info("\t[0x%02x]:%08x\n", i*4,
6097
+ ioc_info(ioc, "\t[0x%02x]:%08x\n", i*4,
52916098 le32_to_cpu(mfp[i]));
52926099 }
52936100 return 0;
....@@ -5313,45 +6120,27 @@
53136120 Mpi2SasIoUnitControlRequest_t *mpi_request)
53146121 {
53156122 u16 smid;
5316
- u32 ioc_state;
53176123 u8 issue_reset = 0;
53186124 int rc;
53196125 void *request;
5320
- u16 wait_state_count;
53216126
5322
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
5323
- __func__));
6127
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
53246128
53256129 mutex_lock(&ioc->base_cmds.mutex);
53266130
53276131 if (ioc->base_cmds.status != MPT3_CMD_NOT_USED) {
5328
- pr_err(MPT3SAS_FMT "%s: base_cmd in use\n",
5329
- ioc->name, __func__);
6132
+ ioc_err(ioc, "%s: base_cmd in use\n", __func__);
53306133 rc = -EAGAIN;
53316134 goto out;
53326135 }
53336136
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
- }
6137
+ rc = mpt3sas_wait_for_ioc(ioc, IOC_OPERATIONAL_WAIT_COUNT);
6138
+ if (rc)
6139
+ goto out;
53506140
53516141 smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx);
53526142 if (!smid) {
5353
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
5354
- ioc->name, __func__);
6143
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
53556144 rc = -EAGAIN;
53566145 goto out;
53576146 }
....@@ -5365,7 +6154,7 @@
53656154 mpi_request->Operation == MPI2_SAS_OP_PHY_LINK_RESET)
53666155 ioc->ioc_link_reset_in_progress = 1;
53676156 init_completion(&ioc->base_cmds.done);
5368
- mpt3sas_base_put_smid_default(ioc, smid);
6157
+ ioc->put_smid_default(ioc, smid);
53696158 wait_for_completion_timeout(&ioc->base_cmds.done,
53706159 msecs_to_jiffies(10000));
53716160 if ((mpi_request->Operation == MPI2_SAS_OP_PHY_HARD_RESET ||
....@@ -5373,10 +6162,9 @@
53736162 ioc->ioc_link_reset_in_progress)
53746163 ioc->ioc_link_reset_in_progress = 0;
53756164 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);
6165
+ mpt3sas_check_cmd_timeout(ioc, ioc->base_cmds.status,
6166
+ mpi_request, sizeof(Mpi2SasIoUnitControlRequest_t)/4,
6167
+ issue_reset);
53806168 goto issue_host_reset;
53816169 }
53826170 if (ioc->base_cmds.status & MPT3_CMD_REPLY_VALID)
....@@ -5413,46 +6201,27 @@
54136201 Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request)
54146202 {
54156203 u16 smid;
5416
- u32 ioc_state;
54176204 u8 issue_reset = 0;
54186205 int rc;
54196206 void *request;
5420
- u16 wait_state_count;
54216207
5422
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
5423
- __func__));
6208
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
54246209
54256210 mutex_lock(&ioc->base_cmds.mutex);
54266211
54276212 if (ioc->base_cmds.status != MPT3_CMD_NOT_USED) {
5428
- pr_err(MPT3SAS_FMT "%s: base_cmd in use\n",
5429
- ioc->name, __func__);
6213
+ ioc_err(ioc, "%s: base_cmd in use\n", __func__);
54306214 rc = -EAGAIN;
54316215 goto out;
54326216 }
54336217
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
- }
6218
+ rc = mpt3sas_wait_for_ioc(ioc, IOC_OPERATIONAL_WAIT_COUNT);
6219
+ if (rc)
6220
+ goto out;
54516221
54526222 smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx);
54536223 if (!smid) {
5454
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
5455
- ioc->name, __func__);
6224
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
54566225 rc = -EAGAIN;
54576226 goto out;
54586227 }
....@@ -5461,16 +6230,16 @@
54616230 ioc->base_cmds.status = MPT3_CMD_PENDING;
54626231 request = mpt3sas_base_get_msg_frame(ioc, smid);
54636232 ioc->base_cmds.smid = smid;
6233
+ memset(request, 0, ioc->request_sz);
54646234 memcpy(request, mpi_request, sizeof(Mpi2SepReply_t));
54656235 init_completion(&ioc->base_cmds.done);
5466
- mpt3sas_base_put_smid_default(ioc, smid);
6236
+ ioc->put_smid_default(ioc, smid);
54676237 wait_for_completion_timeout(&ioc->base_cmds.done,
54686238 msecs_to_jiffies(10000));
54696239 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);
6240
+ mpt3sas_check_cmd_timeout(ioc,
6241
+ ioc->base_cmds.status, mpi_request,
6242
+ sizeof(Mpi2SepRequest_t)/4, issue_reset);
54746243 goto issue_host_reset;
54756244 }
54766245 if (ioc->base_cmds.status & MPT3_CMD_REPLY_VALID)
....@@ -5506,8 +6275,7 @@
55066275 struct mpt3sas_port_facts *pfacts;
55076276 int mpi_reply_sz, mpi_request_sz, r;
55086277
5509
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
5510
- __func__));
6278
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
55116279
55126280 mpi_reply_sz = sizeof(Mpi2PortFactsReply_t);
55136281 mpi_request_sz = sizeof(Mpi2PortFactsRequest_t);
....@@ -5518,8 +6286,7 @@
55186286 (u32 *)&mpi_request, mpi_reply_sz, (u16 *)&mpi_reply, 5);
55196287
55206288 if (r != 0) {
5521
- pr_err(MPT3SAS_FMT "%s: handshake failed (r=%d)\n",
5522
- ioc->name, __func__, r);
6289
+ ioc_err(ioc, "%s: handshake failed (r=%d)\n", __func__, r);
55236290 return r;
55246291 }
55256292
....@@ -5547,40 +6314,46 @@
55476314 u32 ioc_state;
55486315 int rc;
55496316
5550
- dinitprintk(ioc, printk(MPT3SAS_FMT "%s\n", ioc->name,
5551
- __func__));
6317
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
55526318
55536319 if (ioc->pci_error_recovery) {
5554
- dfailprintk(ioc, printk(MPT3SAS_FMT
5555
- "%s: host in pci error recovery\n", ioc->name, __func__));
6320
+ dfailprintk(ioc,
6321
+ ioc_info(ioc, "%s: host in pci error recovery\n",
6322
+ __func__));
55566323 return -EFAULT;
55576324 }
55586325
55596326 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));
6327
+ dhsprintk(ioc,
6328
+ ioc_info(ioc, "%s: ioc_state(0x%08x)\n",
6329
+ __func__, ioc_state));
55626330
55636331 if (((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_READY) ||
55646332 (ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_OPERATIONAL)
55656333 return 0;
55666334
55676335 if (ioc_state & MPI2_DOORBELL_USED) {
5568
- dhsprintk(ioc, printk(MPT3SAS_FMT
5569
- "unexpected doorbell active!\n", ioc->name));
6336
+ dhsprintk(ioc, ioc_info(ioc, "unexpected doorbell active!\n"));
55706337 goto issue_diag_reset;
55716338 }
55726339
55736340 if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
5574
- mpt3sas_base_fault_info(ioc, ioc_state &
6341
+ mpt3sas_print_fault_code(ioc, ioc_state &
55756342 MPI2_DOORBELL_DATA_MASK);
55766343 goto issue_diag_reset;
6344
+ } else if ((ioc_state & MPI2_IOC_STATE_MASK) ==
6345
+ MPI2_IOC_STATE_COREDUMP) {
6346
+ ioc_info(ioc,
6347
+ "%s: Skipping the diag reset here. (ioc_state=0x%x)\n",
6348
+ __func__, ioc_state);
6349
+ return -EFAULT;
55776350 }
55786351
55796352 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, timeout);
55806353 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));
6354
+ dfailprintk(ioc,
6355
+ ioc_info(ioc, "%s: failed going to ready state (ioc_state=0x%x)\n",
6356
+ __func__, ioc_state));
55846357 return -EFAULT;
55856358 }
55866359
....@@ -5603,14 +6376,13 @@
56036376 struct mpt3sas_facts *facts;
56046377 int mpi_reply_sz, mpi_request_sz, r;
56056378
5606
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
5607
- __func__));
6379
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
56086380
56096381 r = _base_wait_for_iocstate(ioc, 10);
56106382 if (r) {
5611
- dfailprintk(ioc, printk(MPT3SAS_FMT
5612
- "%s: failed getting to correct state\n",
5613
- ioc->name, __func__));
6383
+ dfailprintk(ioc,
6384
+ ioc_info(ioc, "%s: failed getting to correct state\n",
6385
+ __func__));
56146386 return r;
56156387 }
56166388 mpi_reply_sz = sizeof(Mpi2IOCFactsReply_t);
....@@ -5621,8 +6393,7 @@
56216393 (u32 *)&mpi_request, mpi_reply_sz, (u16 *)&mpi_reply, 5);
56226394
56236395 if (r != 0) {
5624
- pr_err(MPT3SAS_FMT "%s: handshake failed (r=%d)\n",
5625
- ioc->name, __func__, r);
6396
+ ioc_err(ioc, "%s: handshake failed (r=%d)\n", __func__, r);
56266397 return r;
56276398 }
56286399
....@@ -5650,6 +6421,9 @@
56506421 if ((facts->IOCCapabilities &
56516422 MPI2_IOCFACTS_CAPABILITY_RDPQ_ARRAY_CAPABLE) && (!reset_devices))
56526423 ioc->rdpq_array_capable = 1;
6424
+ if ((facts->IOCCapabilities & MPI26_IOCFACTS_CAPABILITY_ATOMIC_REQ)
6425
+ && ioc->is_aero_ioc)
6426
+ ioc->atomic_desc_capable = 1;
56536427 facts->FWVersion.Word = le32_to_cpu(mpi_reply.FWVersion.Word);
56546428 facts->IOCRequestFrameSize =
56556429 le16_to_cpu(mpi_reply.IOCRequestFrameSize);
....@@ -5674,20 +6448,20 @@
56746448 */
56756449 ioc->page_size = 1 << facts->CurrentHostPageSize;
56766450 if (ioc->page_size == 1) {
5677
- pr_info(MPT3SAS_FMT "CurrentHostPageSize is 0: Setting "
5678
- "default host page size to 4k\n", ioc->name);
6451
+ ioc_info(ioc, "CurrentHostPageSize is 0: Setting default host page size to 4k\n");
56796452 ioc->page_size = 1 << MPT3SAS_HOST_PAGE_SIZE_4K;
56806453 }
5681
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "CurrentHostPageSize(%d)\n",
5682
- ioc->name, facts->CurrentHostPageSize));
6454
+ dinitprintk(ioc,
6455
+ ioc_info(ioc, "CurrentHostPageSize(%d)\n",
6456
+ facts->CurrentHostPageSize));
56836457
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));
6458
+ dinitprintk(ioc,
6459
+ ioc_info(ioc, "hba queue depth(%d), max chains per io(%d)\n",
6460
+ facts->RequestCredit, facts->MaxChainDepth));
6461
+ dinitprintk(ioc,
6462
+ ioc_info(ioc, "request frame size(%d), reply frame size(%d)\n",
6463
+ facts->IOCRequestFrameSize * 4,
6464
+ facts->ReplyFrameSize * 4));
56916465 return 0;
56926466 }
56936467
....@@ -5707,8 +6481,7 @@
57076481 u16 ioc_status;
57086482 u32 reply_post_free_array_sz = 0;
57096483
5710
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
5711
- __func__));
6484
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
57126485
57136486 memset(&mpi_request, 0, sizeof(Mpi2IOCInitRequest_t));
57146487 mpi_request.Function = MPI2_FUNCTION_IOC_INIT;
....@@ -5752,6 +6525,12 @@
57526525 cpu_to_le64((u64)ioc->reply_post[0].reply_post_free_dma);
57536526 }
57546527
6528
+ /*
6529
+ * Set the flag to enable CoreDump state feature in IOC firmware.
6530
+ */
6531
+ mpi_request.ConfigurationFlags |=
6532
+ cpu_to_le16(MPI26_IOCINIT_CFGFLAGS_COREDUMP_ENABLE);
6533
+
57556534 /* This time stamp specifies number of milliseconds
57566535 * since epoch ~ midnight January 1, 1970.
57576536 */
....@@ -5763,9 +6542,9 @@
57636542 int i;
57646543
57656544 mfp = (__le32 *)&mpi_request;
5766
- pr_info("\toffset:data\n");
6545
+ ioc_info(ioc, "\toffset:data\n");
57676546 for (i = 0; i < sizeof(Mpi2IOCInitRequest_t)/4; i++)
5768
- pr_info("\t[0x%02x]:%08x\n", i*4,
6547
+ ioc_info(ioc, "\t[0x%02x]:%08x\n", i*4,
57696548 le32_to_cpu(mfp[i]));
57706549 }
57716550
....@@ -5774,15 +6553,14 @@
57746553 sizeof(Mpi2IOCInitReply_t), (u16 *)&mpi_reply, 30);
57756554
57766555 if (r != 0) {
5777
- pr_err(MPT3SAS_FMT "%s: handshake failed (r=%d)\n",
5778
- ioc->name, __func__, r);
6556
+ ioc_err(ioc, "%s: handshake failed (r=%d)\n", __func__, r);
57796557 return r;
57806558 }
57816559
57826560 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK;
57836561 if (ioc_status != MPI2_IOCSTATUS_SUCCESS ||
57846562 mpi_reply.IOCLogInfo) {
5785
- pr_err(MPT3SAS_FMT "%s: failed\n", ioc->name, __func__);
6563
+ ioc_err(ioc, "%s: failed\n", __func__);
57866564 r = -EIO;
57876565 }
57886566
....@@ -5853,18 +6631,16 @@
58536631 u16 smid;
58546632 u16 ioc_status;
58556633
5856
- pr_info(MPT3SAS_FMT "sending port enable !!\n", ioc->name);
6634
+ ioc_info(ioc, "sending port enable !!\n");
58576635
58586636 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__);
6637
+ ioc_err(ioc, "%s: internal command already in use\n", __func__);
58616638 return -EAGAIN;
58626639 }
58636640
58646641 smid = mpt3sas_base_get_smid(ioc, ioc->port_enable_cb_idx);
58656642 if (!smid) {
5866
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
5867
- ioc->name, __func__);
6643
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
58686644 return -EAGAIN;
58696645 }
58706646
....@@ -5875,11 +6651,10 @@
58756651 mpi_request->Function = MPI2_FUNCTION_PORT_ENABLE;
58766652
58776653 init_completion(&ioc->port_enable_cmds.done);
5878
- mpt3sas_base_put_smid_default(ioc, smid);
6654
+ ioc->put_smid_default(ioc, smid);
58796655 wait_for_completion_timeout(&ioc->port_enable_cmds.done, 300*HZ);
58806656 if (!(ioc->port_enable_cmds.status & MPT3_CMD_COMPLETE)) {
5881
- pr_err(MPT3SAS_FMT "%s: timeout\n",
5882
- ioc->name, __func__);
6657
+ ioc_err(ioc, "%s: timeout\n", __func__);
58836658 _debug_dump_mf(mpi_request,
58846659 sizeof(Mpi2PortEnableRequest_t)/4);
58856660 if (ioc->port_enable_cmds.status & MPT3_CMD_RESET)
....@@ -5892,16 +6667,15 @@
58926667 mpi_reply = ioc->port_enable_cmds.reply;
58936668 ioc_status = le16_to_cpu(mpi_reply->IOCStatus) & MPI2_IOCSTATUS_MASK;
58946669 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);
6670
+ ioc_err(ioc, "%s: failed with (ioc_status=0x%08x)\n",
6671
+ __func__, ioc_status);
58976672 r = -EFAULT;
58986673 goto out;
58996674 }
59006675
59016676 out:
59026677 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"));
6678
+ ioc_info(ioc, "port enable: %s\n", r == 0 ? "SUCCESS" : "FAILED");
59056679 return r;
59066680 }
59076681
....@@ -5917,18 +6691,16 @@
59176691 Mpi2PortEnableRequest_t *mpi_request;
59186692 u16 smid;
59196693
5920
- pr_info(MPT3SAS_FMT "sending port enable !!\n", ioc->name);
6694
+ ioc_info(ioc, "sending port enable !!\n");
59216695
59226696 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__);
6697
+ ioc_err(ioc, "%s: internal command already in use\n", __func__);
59256698 return -EAGAIN;
59266699 }
59276700
59286701 smid = mpt3sas_base_get_smid(ioc, ioc->port_enable_cb_idx);
59296702 if (!smid) {
5930
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
5931
- ioc->name, __func__);
6703
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
59326704 return -EAGAIN;
59336705 }
59346706
....@@ -5938,7 +6710,7 @@
59386710 memset(mpi_request, 0, sizeof(Mpi2PortEnableRequest_t));
59396711 mpi_request->Function = MPI2_FUNCTION_PORT_ENABLE;
59406712
5941
- mpt3sas_base_put_smid_default(ioc, smid);
6713
+ ioc->put_smid_default(ioc, smid);
59426714 return 0;
59436715 }
59446716
....@@ -6031,19 +6803,16 @@
60316803 int r = 0;
60326804 int i;
60336805
6034
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
6035
- __func__));
6806
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
60366807
60376808 if (ioc->base_cmds.status & MPT3_CMD_PENDING) {
6038
- pr_err(MPT3SAS_FMT "%s: internal command already in use\n",
6039
- ioc->name, __func__);
6809
+ ioc_err(ioc, "%s: internal command already in use\n", __func__);
60406810 return -EAGAIN;
60416811 }
60426812
60436813 smid = mpt3sas_base_get_smid(ioc, ioc->base_cb_idx);
60446814 if (!smid) {
6045
- pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
6046
- ioc->name, __func__);
6815
+ ioc_err(ioc, "%s: failed obtaining a smid\n", __func__);
60476816 return -EAGAIN;
60486817 }
60496818 ioc->base_cmds.status = MPT3_CMD_PENDING;
....@@ -6057,11 +6826,10 @@
60576826 mpi_request->EventMasks[i] =
60586827 cpu_to_le32(ioc->event_masks[i]);
60596828 init_completion(&ioc->base_cmds.done);
6060
- mpt3sas_base_put_smid_default(ioc, smid);
6829
+ ioc->put_smid_default(ioc, smid);
60616830 wait_for_completion_timeout(&ioc->base_cmds.done, 30*HZ);
60626831 if (!(ioc->base_cmds.status & MPT3_CMD_COMPLETE)) {
6063
- pr_err(MPT3SAS_FMT "%s: timeout\n",
6064
- ioc->name, __func__);
6832
+ ioc_err(ioc, "%s: timeout\n", __func__);
60656833 _debug_dump_mf(mpi_request,
60666834 sizeof(Mpi2EventNotificationRequest_t)/4);
60676835 if (ioc->base_cmds.status & MPT3_CMD_RESET)
....@@ -6069,8 +6837,7 @@
60696837 else
60706838 r = -ETIME;
60716839 } else
6072
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s: complete\n",
6073
- ioc->name, __func__));
6840
+ dinitprintk(ioc, ioc_info(ioc, "%s: complete\n", __func__));
60746841 ioc->base_cmds.status = MPT3_CMD_NOT_USED;
60756842 return r;
60766843 }
....@@ -6126,18 +6893,18 @@
61266893 u32 count;
61276894 u32 hcb_size;
61286895
6129
- pr_info(MPT3SAS_FMT "sending diag reset !!\n", ioc->name);
6896
+ ioc_info(ioc, "sending diag reset !!\n");
61306897
6131
- drsprintk(ioc, pr_info(MPT3SAS_FMT "clear interrupts\n",
6132
- ioc->name));
6898
+ pci_cfg_access_lock(ioc->pdev);
6899
+
6900
+ drsprintk(ioc, ioc_info(ioc, "clear interrupts\n"));
61336901
61346902 count = 0;
61356903 do {
61366904 /* Write magic sequence to WriteSequence register
61376905 * Loop until in diagnostic mode
61386906 */
6139
- drsprintk(ioc, pr_info(MPT3SAS_FMT
6140
- "write magic sequence\n", ioc->name));
6907
+ drsprintk(ioc, ioc_info(ioc, "write magic sequence\n"));
61416908 writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence);
61426909 writel(MPI2_WRSEQ_1ST_KEY_VALUE, &ioc->chip->WriteSequence);
61436910 writel(MPI2_WRSEQ_2ND_KEY_VALUE, &ioc->chip->WriteSequence);
....@@ -6149,20 +6916,23 @@
61496916 /* wait 100 msec */
61506917 msleep(100);
61516918
6152
- if (count++ > 20)
6919
+ if (count++ > 20) {
6920
+ ioc_info(ioc,
6921
+ "Stop writing magic sequence after 20 retries\n");
6922
+ _base_dump_reg_set(ioc);
61536923 goto out;
6924
+ }
61546925
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));
6926
+ host_diagnostic = ioc->base_readl_ext_retry(&ioc->chip->HostDiagnostic);
6927
+ drsprintk(ioc,
6928
+ ioc_info(ioc, "wrote magic sequence: count(%d), host_diagnostic(0x%08x)\n",
6929
+ count, host_diagnostic));
61596930
61606931 } while ((host_diagnostic & MPI2_DIAG_DIAG_WRITE_ENABLE) == 0);
61616932
6162
- hcb_size = readl(&ioc->chip->HCBSize);
6933
+ hcb_size = ioc->base_readl(&ioc->chip->HCBSize);
61636934
6164
- drsprintk(ioc, pr_info(MPT3SAS_FMT "diag reset: issued\n",
6165
- ioc->name));
6935
+ drsprintk(ioc, ioc_info(ioc, "diag reset: issued\n"));
61666936 writel(host_diagnostic | MPI2_DIAG_RESET_ADAPTER,
61676937 &ioc->chip->HostDiagnostic);
61686938
....@@ -6173,10 +6943,14 @@
61736943 for (count = 0; count < (300000000 /
61746944 MPI2_HARD_RESET_PCIE_SECOND_READ_DELAY_MICRO_SEC); count++) {
61756945
6176
- host_diagnostic = readl(&ioc->chip->HostDiagnostic);
6946
+ host_diagnostic = ioc->base_readl_ext_retry(&ioc->chip->HostDiagnostic);
61776947
6178
- if (host_diagnostic == 0xFFFFFFFF)
6948
+ if (host_diagnostic == 0xFFFFFFFF) {
6949
+ ioc_info(ioc,
6950
+ "Invalid host diagnostic register value\n");
6951
+ _base_dump_reg_set(ioc);
61796952 goto out;
6953
+ }
61806954 if (!(host_diagnostic & MPI2_DIAG_RESET_ADAPTER))
61816955 break;
61826956
....@@ -6185,43 +6959,41 @@
61856959
61866960 if (host_diagnostic & MPI2_DIAG_HCB_MODE) {
61876961
6188
- drsprintk(ioc, pr_info(MPT3SAS_FMT
6189
- "restart the adapter assuming the HCB Address points to good F/W\n",
6190
- ioc->name));
6962
+ drsprintk(ioc,
6963
+ ioc_info(ioc, "restart the adapter assuming the HCB Address points to good F/W\n"));
61916964 host_diagnostic &= ~MPI2_DIAG_BOOT_DEVICE_SELECT_MASK;
61926965 host_diagnostic |= MPI2_DIAG_BOOT_DEVICE_SELECT_HCDW;
61936966 writel(host_diagnostic, &ioc->chip->HostDiagnostic);
61946967
6195
- drsprintk(ioc, pr_info(MPT3SAS_FMT
6196
- "re-enable the HCDW\n", ioc->name));
6968
+ drsprintk(ioc, ioc_info(ioc, "re-enable the HCDW\n"));
61976969 writel(hcb_size | MPI2_HCB_SIZE_HCB_ENABLE,
61986970 &ioc->chip->HCBSize);
61996971 }
62006972
6201
- drsprintk(ioc, pr_info(MPT3SAS_FMT "restart the adapter\n",
6202
- ioc->name));
6973
+ drsprintk(ioc, ioc_info(ioc, "restart the adapter\n"));
62036974 writel(host_diagnostic & ~MPI2_DIAG_HOLD_IOC_RESET,
62046975 &ioc->chip->HostDiagnostic);
62056976
6206
- drsprintk(ioc, pr_info(MPT3SAS_FMT
6207
- "disable writes to the diagnostic register\n", ioc->name));
6977
+ drsprintk(ioc,
6978
+ ioc_info(ioc, "disable writes to the diagnostic register\n"));
62086979 writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, &ioc->chip->WriteSequence);
62096980
6210
- drsprintk(ioc, pr_info(MPT3SAS_FMT
6211
- "Wait for FW to go to the READY state\n", ioc->name));
6981
+ drsprintk(ioc, ioc_info(ioc, "Wait for FW to go to the READY state\n"));
62126982 ioc_state = _base_wait_on_iocstate(ioc, MPI2_IOC_STATE_READY, 20);
62136983 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);
6984
+ ioc_err(ioc, "%s: failed going to ready state (ioc_state=0x%x)\n",
6985
+ __func__, ioc_state);
6986
+ _base_dump_reg_set(ioc);
62176987 goto out;
62186988 }
62196989
6220
- pr_info(MPT3SAS_FMT "diag reset: SUCCESS\n", ioc->name);
6990
+ pci_cfg_access_unlock(ioc->pdev);
6991
+ ioc_info(ioc, "diag reset: SUCCESS\n");
62216992 return 0;
62226993
62236994 out:
6224
- pr_err(MPT3SAS_FMT "diag reset: FAILED\n", ioc->name);
6995
+ pci_cfg_access_unlock(ioc->pdev);
6996
+ ioc_err(ioc, "diag reset: FAILED\n");
62256997 return -EFAULT;
62266998 }
62276999
....@@ -6239,15 +7011,15 @@
62397011 int rc;
62407012 int count;
62417013
6242
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
6243
- __func__));
7014
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
62447015
62457016 if (ioc->pci_error_recovery)
62467017 return 0;
62477018
62487019 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));
7020
+ dhsprintk(ioc,
7021
+ ioc_info(ioc, "%s: ioc_state(0x%08x)\n",
7022
+ __func__, ioc_state));
62517023
62527024 /* if in RESET state, it should move to READY state shortly */
62537025 count = 0;
....@@ -6255,9 +7027,8 @@
62557027 while ((ioc_state & MPI2_IOC_STATE_MASK) !=
62567028 MPI2_IOC_STATE_READY) {
62577029 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);
7030
+ ioc_err(ioc, "%s: failed going to ready state (ioc_state=0x%x)\n",
7031
+ __func__, ioc_state);
62617032 return -EFAULT;
62627033 }
62637034 ssleep(1);
....@@ -6269,15 +7040,30 @@
62697040 return 0;
62707041
62717042 if (ioc_state & MPI2_DOORBELL_USED) {
6272
- dhsprintk(ioc, pr_info(MPT3SAS_FMT
6273
- "unexpected doorbell active!\n",
6274
- ioc->name));
7043
+ ioc_info(ioc, "unexpected doorbell active!\n");
62757044 goto issue_diag_reset;
62767045 }
62777046
62787047 if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) {
6279
- mpt3sas_base_fault_info(ioc, ioc_state &
7048
+ mpt3sas_print_fault_code(ioc, ioc_state &
62807049 MPI2_DOORBELL_DATA_MASK);
7050
+ goto issue_diag_reset;
7051
+ }
7052
+
7053
+ if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_COREDUMP) {
7054
+ /*
7055
+ * if host reset is invoked while watch dog thread is waiting
7056
+ * for IOC state to be changed to Fault state then driver has
7057
+ * to wait here for CoreDump state to clear otherwise reset
7058
+ * will be issued to the FW and FW move the IOC state to
7059
+ * reset state without copying the FW logs to coredump region.
7060
+ */
7061
+ if (ioc->ioc_coredump_loop != MPT3SAS_COREDUMP_LOOP_DONE) {
7062
+ mpt3sas_print_coredump_info(ioc, ioc_state &
7063
+ MPI2_DOORBELL_DATA_MASK);
7064
+ mpt3sas_base_wait_for_coredump_completion(ioc,
7065
+ __func__);
7066
+ }
62817067 goto issue_diag_reset;
62827068 }
62837069
....@@ -6304,7 +7090,7 @@
63047090 static int
63057091 _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc)
63067092 {
6307
- int r, i, index;
7093
+ int r, i, index, rc;
63087094 unsigned long flags;
63097095 u32 reply_address;
63107096 u16 smid;
....@@ -6315,8 +7101,7 @@
63157101 struct adapter_reply_queue *reply_q;
63167102 Mpi2ReplyDescriptorsUnion_t *reply_post_free_contig;
63177103
6318
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
6319
- __func__));
7104
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
63207105
63217106 /* clean the delayed target reset list */
63227107 list_for_each_entry_safe(delayed_tr, delayed_tr_next,
....@@ -6408,8 +7193,19 @@
64087193 skip_init_reply_post_free_queue:
64097194
64107195 r = _base_send_ioc_init(ioc);
6411
- if (r)
6412
- return r;
7196
+ if (r) {
7197
+ /*
7198
+ * No need to check IOC state for fault state & issue
7199
+ * diag reset during host reset. This check is need
7200
+ * only during driver load time.
7201
+ */
7202
+ if (!ioc->is_driver_loading)
7203
+ return r;
7204
+
7205
+ rc = _base_check_for_fault_and_issue_reset(ioc);
7206
+ if (rc || (_base_send_ioc_init(ioc)))
7207
+ return r;
7208
+ }
64137209
64147210 /* initialize reply free host index */
64157211 ioc->reply_free_host_index = ioc->reply_free_queue_depth - 1;
....@@ -6432,7 +7228,7 @@
64327228
64337229 skip_init_reply_post_host_index:
64347230
6435
- _base_unmask_interrupts(ioc);
7231
+ mpt3sas_base_unmask_interrupts(ioc);
64367232
64377233 if (ioc->hba_mpi_version_belonged != MPI2_VERSION) {
64387234 r = _base_display_fwpkg_version(ioc);
....@@ -6476,13 +7272,12 @@
64767272 void
64777273 mpt3sas_base_free_resources(struct MPT3SAS_ADAPTER *ioc)
64787274 {
6479
- dexitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
6480
- __func__));
7275
+ dexitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
64817276
64827277 /* synchronizing freeing resource with pci_access_mutex lock */
64837278 mutex_lock(&ioc->pci_access_mutex);
64847279 if (ioc->chip_phys && ioc->chip) {
6485
- _base_mask_interrupts(ioc);
7280
+ mpt3sas_base_mask_interrupts(ioc);
64867281 ioc->shost_recovery = 1;
64877282 _base_make_ioc_ready(ioc, SOFT_RESET);
64887283 ioc->shost_recovery = 0;
....@@ -6502,11 +7297,10 @@
65027297 int
65037298 mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
65047299 {
6505
- int r, i;
7300
+ int r, i, rc;
65067301 int cpu_id, last_cpu_id = 0;
65077302
6508
- dinitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
6509
- __func__));
7303
+ dinitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
65107304
65117305 /* setup cpu_msix_table */
65127306 ioc->cpu_count = num_online_cpus();
....@@ -6516,9 +7310,7 @@
65167310 ioc->cpu_msix_table = kzalloc(ioc->cpu_msix_table_sz, GFP_KERNEL);
65177311 ioc->reply_queue_count = 1;
65187312 if (!ioc->cpu_msix_table) {
6519
- dfailprintk(ioc, pr_info(MPT3SAS_FMT
6520
- "allocation for cpu_msix_table failed!!!\n",
6521
- ioc->name));
7313
+ ioc_info(ioc, "Allocation for cpu_msix_table failed!!!\n");
65227314 r = -ENOMEM;
65237315 goto out_free_resources;
65247316 }
....@@ -6527,30 +7319,42 @@
65277319 ioc->reply_post_host_index = kcalloc(ioc->cpu_msix_table_sz,
65287320 sizeof(resource_size_t *), GFP_KERNEL);
65297321 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));
7322
+ ioc_info(ioc, "Allocation for reply_post_host_index failed!!!\n");
65337323 r = -ENOMEM;
65347324 goto out_free_resources;
65357325 }
65367326 }
65377327
7328
+ ioc->smp_affinity_enable = smp_affinity_enable;
7329
+
65387330 ioc->rdpq_array_enable_assigned = 0;
6539
- ioc->dma_mask = 0;
7331
+ ioc->use_32bit_dma = false;
7332
+ ioc->dma_mask = 64;
7333
+ if (ioc->is_aero_ioc) {
7334
+ ioc->base_readl = &_base_readl_aero;
7335
+ ioc->base_readl_ext_retry = &_base_readl_ext_retry;
7336
+ } else {
7337
+ ioc->base_readl = &_base_readl;
7338
+ ioc->base_readl_ext_retry = &_base_readl;
7339
+ }
65407340 r = mpt3sas_base_map_resources(ioc);
65417341 if (r)
65427342 goto out_free_resources;
65437343
65447344 pci_set_drvdata(ioc->pdev, ioc->shost);
65457345 r = _base_get_ioc_facts(ioc);
6546
- if (r)
6547
- goto out_free_resources;
7346
+ if (r) {
7347
+ rc = _base_check_for_fault_and_issue_reset(ioc);
7348
+ if (rc || (_base_get_ioc_facts(ioc)))
7349
+ goto out_free_resources;
7350
+ }
65487351
65497352 switch (ioc->hba_mpi_version_belonged) {
65507353 case MPI2_VERSION:
65517354 ioc->build_sg_scmd = &_base_build_sg_scmd;
65527355 ioc->build_sg = &_base_build_sg;
65537356 ioc->build_zero_len_sge = &_base_build_zero_len_sge;
7357
+ ioc->get_msix_index_for_smlio = &_base_get_msix_index;
65547358 break;
65557359 case MPI25_VERSION:
65567360 case MPI26_VERSION:
....@@ -6565,15 +7369,30 @@
65657369 ioc->build_nvme_prp = &_base_build_nvme_prp;
65667370 ioc->build_zero_len_sge = &_base_build_zero_len_sge_ieee;
65677371 ioc->sge_size_ieee = sizeof(Mpi2IeeeSgeSimple64_t);
6568
-
7372
+ if (ioc->high_iops_queues)
7373
+ ioc->get_msix_index_for_smlio =
7374
+ &_base_get_high_iops_msix_index;
7375
+ else
7376
+ ioc->get_msix_index_for_smlio = &_base_get_msix_index;
65697377 break;
65707378 }
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
-
7379
+ if (ioc->atomic_desc_capable) {
7380
+ ioc->put_smid_default = &_base_put_smid_default_atomic;
7381
+ ioc->put_smid_scsi_io = &_base_put_smid_scsi_io_atomic;
7382
+ ioc->put_smid_fast_path =
7383
+ &_base_put_smid_fast_path_atomic;
7384
+ ioc->put_smid_hi_priority =
7385
+ &_base_put_smid_hi_priority_atomic;
7386
+ } else {
7387
+ ioc->put_smid_default = &_base_put_smid_default;
7388
+ ioc->put_smid_fast_path = &_base_put_smid_fast_path;
7389
+ ioc->put_smid_hi_priority = &_base_put_smid_hi_priority;
7390
+ if (ioc->is_mcpu_endpoint)
7391
+ ioc->put_smid_scsi_io =
7392
+ &_base_put_smid_mpi_ep_scsi_io;
7393
+ else
7394
+ ioc->put_smid_scsi_io = &_base_put_smid_scsi_io;
7395
+ }
65777396 /*
65787397 * These function pointers for other requests that don't
65797398 * the require IEEE scatter gather elements.
....@@ -6596,14 +7415,23 @@
65967415
65977416 for (i = 0 ; i < ioc->facts.NumberOfPorts; i++) {
65987417 r = _base_get_port_facts(ioc, i);
6599
- if (r)
6600
- goto out_free_resources;
7418
+ if (r) {
7419
+ rc = _base_check_for_fault_and_issue_reset(ioc);
7420
+ if (rc || (_base_get_port_facts(ioc, i)))
7421
+ goto out_free_resources;
7422
+ }
66017423 }
66027424
66037425 r = _base_allocate_memory_pools(ioc);
66047426 if (r)
66057427 goto out_free_resources;
66067428
7429
+ if (irqpoll_weight > 0)
7430
+ ioc->thresh_hold = irqpoll_weight;
7431
+ else
7432
+ ioc->thresh_hold = ioc->hba_queue_depth/4;
7433
+
7434
+ _base_init_irqpolls(ioc);
66077435 init_waitqueue_head(&ioc->reset_wq);
66087436
66097437 /* allocate memory pd handle bitmask list */
....@@ -6717,7 +7545,15 @@
67177545 if (r)
67187546 goto out_free_resources;
67197547
7548
+ /*
7549
+ * Copy current copy of IOCFacts in prev_fw_facts
7550
+ * and it will be used during online firmware upgrade.
7551
+ */
7552
+ memcpy(&ioc->prev_fw_facts, &ioc->facts,
7553
+ sizeof(struct mpt3sas_facts));
7554
+
67207555 ioc->non_operational_loop = 0;
7556
+ ioc->ioc_coredump_loop = 0;
67217557 ioc->got_task_abort_from_ioctl = 0;
67227558 return 0;
67237559
....@@ -6762,8 +7598,7 @@
67627598 void
67637599 mpt3sas_base_detach(struct MPT3SAS_ADAPTER *ioc)
67647600 {
6765
- dexitprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name,
6766
- __func__));
7601
+ dexitprintk(ioc, ioc_info(ioc, "%s\n", __func__));
67677602
67687603 mpt3sas_base_stop_watchdog(ioc);
67697604 mpt3sas_base_free_resources(ioc);
....@@ -6796,20 +7631,18 @@
67967631 {
67977632 mpt3sas_scsih_pre_reset_handler(ioc);
67987633 mpt3sas_ctl_pre_reset_handler(ioc);
6799
- dtmprintk(ioc, pr_info(MPT3SAS_FMT
6800
- "%s: MPT3_IOC_PRE_RESET\n", ioc->name, __func__));
7634
+ dtmprintk(ioc, ioc_info(ioc, "%s: MPT3_IOC_PRE_RESET\n", __func__));
68017635 }
68027636
68037637 /**
6804
- * _base_after_reset_handler - after reset handler
7638
+ * _base_clear_outstanding_mpt_commands - clears outstanding mpt commands
68057639 * @ioc: per adapter object
68067640 */
6807
-static void _base_after_reset_handler(struct MPT3SAS_ADAPTER *ioc)
7641
+static void
7642
+_base_clear_outstanding_mpt_commands(struct MPT3SAS_ADAPTER *ioc)
68087643 {
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__));
7644
+ dtmprintk(ioc,
7645
+ ioc_info(ioc, "%s: clear outstanding mpt cmds\n", __func__));
68137646 if (ioc->transport_cmds.status & MPT3_CMD_PENDING) {
68147647 ioc->transport_cmds.status |= MPT3_CMD_RESET;
68157648 mpt3sas_base_free_smid(ioc, ioc->transport_cmds.smid);
....@@ -6843,6 +7676,17 @@
68437676 }
68447677
68457678 /**
7679
+ * _base_clear_outstanding_commands - clear all outstanding commands
7680
+ * @ioc: per adapter object
7681
+ */
7682
+static void _base_clear_outstanding_commands(struct MPT3SAS_ADAPTER *ioc)
7683
+{
7684
+ mpt3sas_scsih_clear_outstanding_scsi_tm_commands(ioc);
7685
+ mpt3sas_ctl_clear_outstanding_ioctls(ioc);
7686
+ _base_clear_outstanding_mpt_commands(ioc);
7687
+}
7688
+
7689
+/**
68467690 * _base_reset_done_handler - reset done handler
68477691 * @ioc: per adapter object
68487692 */
....@@ -6850,8 +7694,7 @@
68507694 {
68517695 mpt3sas_scsih_reset_done_handler(ioc);
68527696 mpt3sas_ctl_reset_done_handler(ioc);
6853
- dtmprintk(ioc, pr_info(MPT3SAS_FMT
6854
- "%s: MPT3_IOC_DONE_RESET\n", ioc->name, __func__));
7697
+ dtmprintk(ioc, ioc_info(ioc, "%s: MPT3_IOC_DONE_RESET\n", __func__));
68557698 }
68567699
68577700 /**
....@@ -6883,6 +7726,85 @@
68837726 }
68847727
68857728 /**
7729
+ * _base_check_ioc_facts_changes - Look for increase/decrease of IOCFacts
7730
+ * attributes during online firmware upgrade and update the corresponding
7731
+ * IOC variables accordingly.
7732
+ *
7733
+ * @ioc: Pointer to MPT_ADAPTER structure
7734
+ */
7735
+static int
7736
+_base_check_ioc_facts_changes(struct MPT3SAS_ADAPTER *ioc)
7737
+{
7738
+ u16 pd_handles_sz;
7739
+ void *pd_handles = NULL, *blocking_handles = NULL;
7740
+ void *pend_os_device_add = NULL, *device_remove_in_progress = NULL;
7741
+ struct mpt3sas_facts *old_facts = &ioc->prev_fw_facts;
7742
+
7743
+ if (ioc->facts.MaxDevHandle > old_facts->MaxDevHandle) {
7744
+ pd_handles_sz = (ioc->facts.MaxDevHandle / 8);
7745
+ if (ioc->facts.MaxDevHandle % 8)
7746
+ pd_handles_sz++;
7747
+
7748
+ pd_handles = krealloc(ioc->pd_handles, pd_handles_sz,
7749
+ GFP_KERNEL);
7750
+ if (!pd_handles) {
7751
+ ioc_info(ioc,
7752
+ "Unable to allocate the memory for pd_handles of sz: %d\n",
7753
+ pd_handles_sz);
7754
+ return -ENOMEM;
7755
+ }
7756
+ memset(pd_handles + ioc->pd_handles_sz, 0,
7757
+ (pd_handles_sz - ioc->pd_handles_sz));
7758
+ ioc->pd_handles = pd_handles;
7759
+
7760
+ blocking_handles = krealloc(ioc->blocking_handles,
7761
+ pd_handles_sz, GFP_KERNEL);
7762
+ if (!blocking_handles) {
7763
+ ioc_info(ioc,
7764
+ "Unable to allocate the memory for "
7765
+ "blocking_handles of sz: %d\n",
7766
+ pd_handles_sz);
7767
+ return -ENOMEM;
7768
+ }
7769
+ memset(blocking_handles + ioc->pd_handles_sz, 0,
7770
+ (pd_handles_sz - ioc->pd_handles_sz));
7771
+ ioc->blocking_handles = blocking_handles;
7772
+ ioc->pd_handles_sz = pd_handles_sz;
7773
+
7774
+ pend_os_device_add = krealloc(ioc->pend_os_device_add,
7775
+ pd_handles_sz, GFP_KERNEL);
7776
+ if (!pend_os_device_add) {
7777
+ ioc_info(ioc,
7778
+ "Unable to allocate the memory for pend_os_device_add of sz: %d\n",
7779
+ pd_handles_sz);
7780
+ return -ENOMEM;
7781
+ }
7782
+ memset(pend_os_device_add + ioc->pend_os_device_add_sz, 0,
7783
+ (pd_handles_sz - ioc->pend_os_device_add_sz));
7784
+ ioc->pend_os_device_add = pend_os_device_add;
7785
+ ioc->pend_os_device_add_sz = pd_handles_sz;
7786
+
7787
+ device_remove_in_progress = krealloc(
7788
+ ioc->device_remove_in_progress, pd_handles_sz, GFP_KERNEL);
7789
+ if (!device_remove_in_progress) {
7790
+ ioc_info(ioc,
7791
+ "Unable to allocate the memory for "
7792
+ "device_remove_in_progress of sz: %d\n "
7793
+ , pd_handles_sz);
7794
+ return -ENOMEM;
7795
+ }
7796
+ memset(device_remove_in_progress +
7797
+ ioc->device_remove_in_progress_sz, 0,
7798
+ (pd_handles_sz - ioc->device_remove_in_progress_sz));
7799
+ ioc->device_remove_in_progress = device_remove_in_progress;
7800
+ ioc->device_remove_in_progress_sz = pd_handles_sz;
7801
+ }
7802
+
7803
+ memcpy(&ioc->prev_fw_facts, &ioc->facts, sizeof(struct mpt3sas_facts));
7804
+ return 0;
7805
+}
7806
+
7807
+/**
68867808 * mpt3sas_base_hard_reset_handler - reset controller
68877809 * @ioc: Pointer to MPT_ADAPTER structure
68887810 * @type: FORCE_BIG_HAMMER or SOFT_RESET
....@@ -6898,12 +7820,10 @@
68987820 u32 ioc_state;
68997821 u8 is_fault = 0, is_trigger = 0;
69007822
6901
- dtmprintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n", ioc->name,
6902
- __func__));
7823
+ dtmprintk(ioc, ioc_info(ioc, "%s: enter\n", __func__));
69037824
69047825 if (ioc->pci_error_recovery) {
6905
- pr_err(MPT3SAS_FMT "%s: pci error recovery reset\n",
6906
- ioc->name, __func__);
7826
+ ioc_err(ioc, "%s: pci error recovery reset\n", __func__);
69077827 r = 0;
69087828 goto out_unlocked;
69097829 }
....@@ -6924,16 +7844,18 @@
69247844 MPT3_DIAG_BUFFER_IS_RELEASED))) {
69257845 is_trigger = 1;
69267846 ioc_state = mpt3sas_base_get_iocstate(ioc, 0);
6927
- if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT)
7847
+ if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT ||
7848
+ (ioc_state & MPI2_IOC_STATE_MASK) ==
7849
+ MPI2_IOC_STATE_COREDUMP)
69287850 is_fault = 1;
69297851 }
69307852 _base_pre_reset_handler(ioc);
69317853 mpt3sas_wait_for_commands_to_complete(ioc);
6932
- _base_mask_interrupts(ioc);
7854
+ mpt3sas_base_mask_interrupts(ioc);
69337855 r = _base_make_ioc_ready(ioc, type);
69347856 if (r)
69357857 goto out;
6936
- _base_after_reset_handler(ioc);
7858
+ _base_clear_outstanding_commands(ioc);
69377859
69387860 /* If this hard reset is called while port enable is active, then
69397861 * there is no reason to call make_ioc_operational
....@@ -6947,6 +7869,13 @@
69477869 if (r)
69487870 goto out;
69497871
7872
+ r = _base_check_ioc_facts_changes(ioc);
7873
+ if (r) {
7874
+ ioc_info(ioc,
7875
+ "Some of the parameters got changed in this new firmware"
7876
+ " image and it requires system reboot\n");
7877
+ goto out;
7878
+ }
69507879 if (ioc->rdpq_array_enable && !ioc->rdpq_array_capable)
69517880 panic("%s: Issue occurred with flashing controller firmware."
69527881 "Please reboot the system and ensure that the correct"
....@@ -6957,8 +7886,7 @@
69577886 _base_reset_done_handler(ioc);
69587887
69597888 out:
6960
- dtmprintk(ioc, pr_info(MPT3SAS_FMT "%s: %s\n",
6961
- ioc->name, __func__, ((r == 0) ? "SUCCESS" : "FAILED")));
7889
+ ioc_info(ioc, "%s: %s\n", __func__, r == 0 ? "SUCCESS" : "FAILED");
69627890
69637891 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
69647892 ioc->shost_recovery = 0;
....@@ -6974,7 +7902,6 @@
69747902 mpt3sas_trigger_master(ioc,
69757903 MASTER_TRIGGER_ADAPTER_RESET);
69767904 }
6977
- dtmprintk(ioc, pr_info(MPT3SAS_FMT "%s: exit\n", ioc->name,
6978
- __func__));
7905
+ dtmprintk(ioc, ioc_info(ioc, "%s: exit\n", __func__));
69797906 return r;
69807907 }