forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/scsi/megaraid/megaraid_sas_fusion.c
....@@ -1,34 +1,20 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Linux MegaRAID driver for SAS based RAID controllers
34 *
45 * Copyright (c) 2009-2013 LSI Corporation
5
- * Copyright (c) 2013-2014 Avago Technologies
6
- *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License
9
- * as published by the Free Software Foundation; either version 2
10
- * of the License, or (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
6
+ * Copyright (c) 2013-2016 Avago Technologies
7
+ * Copyright (c) 2016-2018 Broadcom Inc.
198 *
209 * FILE: megaraid_sas_fusion.c
2110 *
22
- * Authors: Avago Technologies
11
+ * Authors: Broadcom Inc.
2312 * Sumant Patro
2413 * Adam Radford
25
- * Kashyap Desai <kashyap.desai@avagotech.com>
26
- * Sumit Saxena <sumit.saxena@avagotech.com>
14
+ * Kashyap Desai <kashyap.desai@broadcom.com>
15
+ * Sumit Saxena <sumit.saxena@broadcom.com>
2716 *
28
- * Send feedback to: megaraidlinux.pdl@avagotech.com
29
- *
30
- * Mail to: Avago Technologies, 350 West Trimble Road, Building 90,
31
- * San Jose, California 95131
17
+ * Send feedback to: megaraidlinux.pdl@broadcom.com
3218 */
3319
3420 #include <linux/kernel.h>
....@@ -48,6 +34,8 @@
4834 #include <linux/mutex.h>
4935 #include <linux/poll.h>
5036 #include <linux/vmalloc.h>
37
+#include <linux/workqueue.h>
38
+#include <linux/irq_poll.h>
5139
5240 #include <scsi/scsi.h>
5341 #include <scsi/scsi_cmnd.h>
....@@ -60,9 +48,6 @@
6048 #include "megaraid_sas.h"
6149
6250
63
-extern void megasas_free_cmds(struct megasas_instance *instance);
64
-extern struct megasas_cmd *megasas_get_cmd(struct megasas_instance
65
- *instance);
6651 extern void
6752 megasas_complete_cmd(struct megasas_instance *instance,
6853 struct megasas_cmd *cmd, u8 alt_status);
....@@ -70,24 +55,14 @@
7055 wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd,
7156 int seconds);
7257
73
-void
74
-megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd);
75
-int megasas_alloc_cmds(struct megasas_instance *instance);
7658 int
77
-megasas_clear_intr_fusion(struct megasas_register_set __iomem *regs);
78
-int
79
-megasas_issue_polled(struct megasas_instance *instance,
80
- struct megasas_cmd *cmd);
81
-void
82
-megasas_check_and_restore_queue_depth(struct megasas_instance *instance);
59
+megasas_clear_intr_fusion(struct megasas_instance *instance);
8360
8461 int megasas_transition_to_ready(struct megasas_instance *instance, int ocr);
85
-void megaraid_sas_kill_hba(struct megasas_instance *instance);
8662
8763 extern u32 megasas_dbg_lvl;
8864 int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
8965 int initial);
90
-void megasas_start_timer(struct megasas_instance *instance);
9166 extern struct megasas_mgmt_info megasas_mgmt_info;
9267 extern unsigned int resetwaittime;
9368 extern unsigned int dual_qdepth_disable;
....@@ -95,14 +70,71 @@
9570 static void megasas_free_reply_fusion(struct megasas_instance *instance);
9671 static inline
9772 void megasas_configure_queue_sizes(struct megasas_instance *instance);
73
+static void megasas_fusion_crash_dump(struct megasas_instance *instance);
74
+
75
+/**
76
+ * megasas_adp_reset_wait_for_ready - initiate chip reset and wait for
77
+ * controller to come to ready state
78
+ * @instance: adapter's soft state
79
+ * @do_adp_reset: If true, do a chip reset
80
+ * @ocr_context: If called from OCR context this will
81
+ * be set to 1, else 0
82
+ *
83
+ * This function initates a chip reset followed by a wait for controller to
84
+ * transition to ready state.
85
+ * During this, driver will block all access to PCI config space from userspace
86
+ */
87
+int
88
+megasas_adp_reset_wait_for_ready(struct megasas_instance *instance,
89
+ bool do_adp_reset,
90
+ int ocr_context)
91
+{
92
+ int ret = FAILED;
93
+
94
+ /*
95
+ * Block access to PCI config space from userspace
96
+ * when diag reset is initiated from driver
97
+ */
98
+ if (megasas_dbg_lvl & OCR_DEBUG)
99
+ dev_info(&instance->pdev->dev,
100
+ "Block access to PCI config space %s %d\n",
101
+ __func__, __LINE__);
102
+
103
+ pci_cfg_access_lock(instance->pdev);
104
+
105
+ if (do_adp_reset) {
106
+ if (instance->instancet->adp_reset
107
+ (instance, instance->reg_set))
108
+ goto out;
109
+ }
110
+
111
+ /* Wait for FW to become ready */
112
+ if (megasas_transition_to_ready(instance, ocr_context)) {
113
+ dev_warn(&instance->pdev->dev,
114
+ "Failed to transition controller to ready for scsi%d.\n",
115
+ instance->host->host_no);
116
+ goto out;
117
+ }
118
+
119
+ ret = SUCCESS;
120
+out:
121
+ if (megasas_dbg_lvl & OCR_DEBUG)
122
+ dev_info(&instance->pdev->dev,
123
+ "Unlock access to PCI config space %s %d\n",
124
+ __func__, __LINE__);
125
+
126
+ pci_cfg_access_unlock(instance->pdev);
127
+
128
+ return ret;
129
+}
98130
99131 /**
100132 * megasas_check_same_4gb_region - check if allocation
101133 * crosses same 4GB boundary or not
102
- * @instance - adapter's soft instance
103
- * start_addr - start address of DMA allocation
104
- * size - size of allocation in bytes
105
- * return - true : allocation does not cross same
134
+ * @instance: adapter's soft instance
135
+ * @start_addr: start address of DMA allocation
136
+ * @size: size of allocation in bytes
137
+ * @return: true : allocation does not cross same
106138 * 4GB boundary
107139 * false: allocation crosses same
108140 * 4GB boundary
....@@ -127,9 +159,9 @@
127159
128160 /**
129161 * megasas_enable_intr_fusion - Enables interrupts
130
- * @regs: MFI register set
162
+ * @instance: adapter's soft instance
131163 */
132
-void
164
+static void
133165 megasas_enable_intr_fusion(struct megasas_instance *instance)
134166 {
135167 struct megasas_register_set __iomem *regs;
....@@ -143,35 +175,39 @@
143175 writel(~MFI_FUSION_ENABLE_INTERRUPT_MASK, &(regs)->outbound_intr_mask);
144176
145177 /* Dummy readl to force pci flush */
146
- readl(&regs->outbound_intr_mask);
178
+ dev_info(&instance->pdev->dev, "%s is called outbound_intr_mask:0x%08x\n",
179
+ __func__, readl(&regs->outbound_intr_mask));
147180 }
148181
149182 /**
150183 * megasas_disable_intr_fusion - Disables interrupt
151
- * @regs: MFI register set
184
+ * @instance: adapter's soft instance
152185 */
153
-void
186
+static void
154187 megasas_disable_intr_fusion(struct megasas_instance *instance)
155188 {
156189 u32 mask = 0xFFFFFFFF;
157
- u32 status;
158190 struct megasas_register_set __iomem *regs;
159191 regs = instance->reg_set;
160192 instance->mask_interrupts = 1;
161193
162194 writel(mask, &regs->outbound_intr_mask);
163195 /* Dummy readl to force pci flush */
164
- status = readl(&regs->outbound_intr_mask);
196
+ dev_info(&instance->pdev->dev, "%s is called outbound_intr_mask:0x%08x\n",
197
+ __func__, readl(&regs->outbound_intr_mask));
165198 }
166199
167200 int
168
-megasas_clear_intr_fusion(struct megasas_register_set __iomem *regs)
201
+megasas_clear_intr_fusion(struct megasas_instance *instance)
169202 {
170203 u32 status;
204
+ struct megasas_register_set __iomem *regs;
205
+ regs = instance->reg_set;
171206 /*
172207 * Check if it is our interrupt
173208 */
174
- status = readl(&regs->outbound_intr_status);
209
+ status = megasas_readl(instance,
210
+ &regs->outbound_intr_status);
175211
176212 if (status & 1) {
177213 writel(status, &regs->outbound_intr_status);
....@@ -187,6 +223,7 @@
187223 /**
188224 * megasas_get_cmd_fusion - Get a command from the free pool
189225 * @instance: Adapter soft state
226
+ * @blk_tag: Command tag
190227 *
191228 * Returns a blk_tag indexed mpt frame
192229 */
....@@ -214,21 +251,17 @@
214251 }
215252
216253 /**
217
- * megasas_fire_cmd_fusion - Sends command to the FW
218
- * @instance: Adapter soft state
219
- * @req_desc: 64bit Request descriptor
220
- *
221
- * Perform PCI Write.
254
+ * megasas_write_64bit_req_desc - PCI writes 64bit request descriptor
255
+ * @instance: Adapter soft state
256
+ * @req_desc: 64bit Request descriptor
222257 */
223
-
224258 static void
225
-megasas_fire_cmd_fusion(struct megasas_instance *instance,
259
+megasas_write_64bit_req_desc(struct megasas_instance *instance,
226260 union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc)
227261 {
228262 #if defined(writeq) && defined(CONFIG_64BIT)
229263 u64 req_data = (((u64)le32_to_cpu(req_desc->u.high) << 32) |
230264 le32_to_cpu(req_desc->u.low));
231
-
232265 writeq(req_data, &instance->reg_set->inbound_low_queue_port);
233266 #else
234267 unsigned long flags;
....@@ -237,15 +270,33 @@
237270 &instance->reg_set->inbound_low_queue_port);
238271 writel(le32_to_cpu(req_desc->u.high),
239272 &instance->reg_set->inbound_high_queue_port);
240
- mmiowb();
241273 spin_unlock_irqrestore(&instance->hba_lock, flags);
242274 #endif
243275 }
244276
245277 /**
278
+ * megasas_fire_cmd_fusion - Sends command to the FW
279
+ * @instance: Adapter soft state
280
+ * @req_desc: 32bit or 64bit Request descriptor
281
+ *
282
+ * Perform PCI Write. AERO SERIES supports 32 bit Descriptor.
283
+ * Prior to AERO_SERIES support 64 bit Descriptor.
284
+ */
285
+static void
286
+megasas_fire_cmd_fusion(struct megasas_instance *instance,
287
+ union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc)
288
+{
289
+ if (instance->atomic_desc_support)
290
+ writel(le32_to_cpu(req_desc->u.low),
291
+ &instance->reg_set->inbound_single_queue_port);
292
+ else
293
+ megasas_write_64bit_req_desc(instance, req_desc);
294
+}
295
+
296
+/**
246297 * megasas_fusion_update_can_queue - Do all Adapter Queue depth related calculations here
247
- * @instance: Adapter soft state
248
- * fw_boot_context: Whether this function called during probe or after OCR
298
+ * @instance: Adapter soft state
299
+ * @fw_boot_context: Whether this function called during probe or after OCR
249300 *
250301 * This function is only for fusion controllers.
251302 * Update host can queue, if firmware downgrade max supported firmware commands.
....@@ -258,20 +309,18 @@
258309 {
259310 u16 cur_max_fw_cmds = 0;
260311 u16 ldio_threshold = 0;
261
- struct megasas_register_set __iomem *reg_set;
262312
263
- reg_set = instance->reg_set;
264
-
265
- /* ventura FW does not fill outbound_scratch_pad_3 with queue depth */
313
+ /* ventura FW does not fill outbound_scratch_pad_2 with queue depth */
266314 if (instance->adapter_type < VENTURA_SERIES)
267315 cur_max_fw_cmds =
268
- readl(&instance->reg_set->outbound_scratch_pad_3) & 0x00FFFF;
316
+ megasas_readl(instance,
317
+ &instance->reg_set->outbound_scratch_pad_2) & 0x00FFFF;
269318
270319 if (dual_qdepth_disable || !cur_max_fw_cmds)
271
- cur_max_fw_cmds = instance->instancet->read_fw_status_reg(reg_set) & 0x00FFFF;
320
+ cur_max_fw_cmds = instance->instancet->read_fw_status_reg(instance) & 0x00FFFF;
272321 else
273322 ldio_threshold =
274
- (instance->instancet->read_fw_status_reg(reg_set) & 0x00FFFF) - MEGASAS_FUSION_IOCTL_CMDS;
323
+ (instance->instancet->read_fw_status_reg(instance) & 0x00FFFF) - MEGASAS_FUSION_IOCTL_CMDS;
275324
276325 dev_info(&instance->pdev->dev,
277326 "Current firmware supports maximum commands: %d\t LDIO threshold: %d\n",
....@@ -301,6 +350,35 @@
301350 instance->max_fw_cmds = instance->max_fw_cmds-1;
302351 }
303352 }
353
+
354
+static inline void
355
+megasas_get_msix_index(struct megasas_instance *instance,
356
+ struct scsi_cmnd *scmd,
357
+ struct megasas_cmd_fusion *cmd,
358
+ u8 data_arms)
359
+{
360
+ int sdev_busy;
361
+
362
+ /* nr_hw_queue = 1 for MegaRAID */
363
+ struct blk_mq_hw_ctx *hctx =
364
+ scmd->device->request_queue->queue_hw_ctx[0];
365
+
366
+ sdev_busy = atomic_read(&hctx->nr_active);
367
+
368
+ if (instance->perf_mode == MR_BALANCED_PERF_MODE &&
369
+ sdev_busy > (data_arms * MR_DEVICE_HIGH_IOPS_DEPTH))
370
+ cmd->request_desc->SCSIIO.MSIxIndex =
371
+ mega_mod64((atomic64_add_return(1, &instance->high_iops_outstanding) /
372
+ MR_HIGH_IOPS_BATCH_COUNT), instance->low_latency_index_start);
373
+ else if (instance->msix_load_balance)
374
+ cmd->request_desc->SCSIIO.MSIxIndex =
375
+ (mega_mod64(atomic64_add_return(1, &instance->total_io_count),
376
+ instance->msix_vectors));
377
+ else
378
+ cmd->request_desc->SCSIIO.MSIxIndex =
379
+ instance->reply_map[raw_smp_processor_id()];
380
+}
381
+
304382 /**
305383 * megasas_free_cmds_fusion - Free all the cmds in the free cmd pool
306384 * @instance: Adapter soft state
....@@ -471,7 +549,7 @@
471549 return 0;
472550 }
473551
474
-int
552
+static int
475553 megasas_alloc_cmdlist_fusion(struct megasas_instance *instance)
476554 {
477555 u32 max_mpt_cmd, i, j;
....@@ -510,7 +588,8 @@
510588
511589 return 0;
512590 }
513
-int
591
+
592
+static int
514593 megasas_alloc_request_fusion(struct megasas_instance *instance)
515594 {
516595 struct fusion_context *fusion;
....@@ -592,7 +671,7 @@
592671 return 0;
593672 }
594673
595
-int
674
+static int
596675 megasas_alloc_reply_fusion(struct megasas_instance *instance)
597676 {
598677 int i, count;
....@@ -669,7 +748,7 @@
669748 return 0;
670749 }
671750
672
-int
751
+static int
673752 megasas_alloc_rdpq_fusion(struct megasas_instance *instance)
674753 {
675754 int i, j, k, msix_count;
....@@ -685,8 +764,9 @@
685764 array_size = sizeof(struct MPI2_IOC_INIT_RDPQ_ARRAY_ENTRY) *
686765 MAX_MSIX_QUEUES_FUSION;
687766
688
- fusion->rdpq_virt = pci_zalloc_consistent(instance->pdev, array_size,
689
- &fusion->rdpq_phys);
767
+ fusion->rdpq_virt = dma_alloc_coherent(&instance->pdev->dev,
768
+ array_size, &fusion->rdpq_phys,
769
+ GFP_KERNEL);
690770 if (!fusion->rdpq_virt) {
691771 dev_err(&instance->pdev->dev,
692772 "Failed from %s %d\n", __func__, __LINE__);
....@@ -808,13 +888,11 @@
808888
809889 }
810890
811
- if (fusion->reply_frames_desc_pool)
812
- dma_pool_destroy(fusion->reply_frames_desc_pool);
813
- if (fusion->reply_frames_desc_pool_align)
814
- dma_pool_destroy(fusion->reply_frames_desc_pool_align);
891
+ dma_pool_destroy(fusion->reply_frames_desc_pool);
892
+ dma_pool_destroy(fusion->reply_frames_desc_pool_align);
815893
816894 if (fusion->rdpq_virt)
817
- pci_free_consistent(instance->pdev,
895
+ dma_free_coherent(&instance->pdev->dev,
818896 sizeof(struct MPI2_IOC_INIT_RDPQ_ARRAY_ENTRY) * MAX_MSIX_QUEUES_FUSION,
819897 fusion->rdpq_virt, fusion->rdpq_phys);
820898 }
....@@ -831,8 +909,7 @@
831909 fusion->reply_frames_desc[0],
832910 fusion->reply_frames_desc_phys[0]);
833911
834
- if (fusion->reply_frames_desc_pool)
835
- dma_pool_destroy(fusion->reply_frames_desc_pool);
912
+ dma_pool_destroy(fusion->reply_frames_desc_pool);
836913
837914 }
838915
....@@ -853,7 +930,7 @@
853930 * and is used as SMID of the cmd.
854931 * SMID value range is from 1 to max_fw_cmds.
855932 */
856
-int
933
+static int
857934 megasas_alloc_cmds_fusion(struct megasas_instance *instance)
858935 {
859936 int i;
....@@ -925,6 +1002,7 @@
9251002 * wait_and_poll - Issues a polling command
9261003 * @instance: Adapter soft state
9271004 * @cmd: Command packet to be issued
1005
+ * @seconds: Maximum poll time
9281006 *
9291007 * For polling, MFI requires the cmd_status to be set to 0xFF before posting.
9301008 */
....@@ -934,17 +1012,22 @@
9341012 {
9351013 int i;
9361014 struct megasas_header *frame_hdr = &cmd->frame->hdr;
937
- struct fusion_context *fusion;
1015
+ u32 status_reg;
9381016
9391017 u32 msecs = seconds * 1000;
9401018
941
- fusion = instance->ctrl_context;
9421019 /*
9431020 * Wait for cmd_status to change
9441021 */
9451022 for (i = 0; (i < msecs) && (frame_hdr->cmd_status == 0xff); i += 20) {
9461023 rmb();
9471024 msleep(20);
1025
+ if (!(i % 5000)) {
1026
+ status_reg = instance->instancet->read_fw_status_reg(instance)
1027
+ & MFI_STATE_MASK;
1028
+ if (status_reg == MFI_STATE_FAULT)
1029
+ break;
1030
+ }
9481031 }
9491032
9501033 if (frame_hdr->cmd_status == MFI_STAT_INVALID_STATUS)
....@@ -975,9 +1058,10 @@
9751058 struct megasas_header *frame_hdr;
9761059 const char *sys_info;
9771060 MFI_CAPABILITIES *drv_ops;
978
- u32 scratch_pad_2;
1061
+ u32 scratch_pad_1;
9791062 ktime_t time;
9801063 bool cur_fw_64bit_dma_capable;
1064
+ bool cur_intr_coalescing;
9811065
9821066 fusion = instance->ctrl_context;
9831067
....@@ -986,14 +1070,14 @@
9861070
9871071 cmd = fusion->ioc_init_cmd;
9881072
989
- scratch_pad_2 = readl
990
- (&instance->reg_set->outbound_scratch_pad_2);
1073
+ scratch_pad_1 = megasas_readl
1074
+ (instance, &instance->reg_set->outbound_scratch_pad_1);
9911075
992
- cur_rdpq_mode = (scratch_pad_2 & MR_RDPQ_MODE_OFFSET) ? 1 : 0;
1076
+ cur_rdpq_mode = (scratch_pad_1 & MR_RDPQ_MODE_OFFSET) ? 1 : 0;
9931077
9941078 if (instance->adapter_type == INVADER_SERIES) {
9951079 cur_fw_64bit_dma_capable =
996
- (scratch_pad_2 & MR_CAN_HANDLE_64_BIT_DMA_OFFSET) ? true : false;
1080
+ (scratch_pad_1 & MR_CAN_HANDLE_64_BIT_DMA_OFFSET) ? true : false;
9971081
9981082 if (instance->consistent_mask_64bit && !cur_fw_64bit_dma_capable) {
9991083 dev_err(&instance->pdev->dev, "Driver was operating on 64bit "
....@@ -1011,7 +1095,17 @@
10111095 goto fail_fw_init;
10121096 }
10131097
1014
- instance->fw_sync_cache_support = (scratch_pad_2 &
1098
+ cur_intr_coalescing = (scratch_pad_1 & MR_INTR_COALESCING_SUPPORT_OFFSET) ?
1099
+ true : false;
1100
+
1101
+ if ((instance->low_latency_index_start ==
1102
+ MR_HIGH_IOPS_QUEUE_COUNT) && cur_intr_coalescing)
1103
+ instance->perf_mode = MR_BALANCED_PERF_MODE;
1104
+
1105
+ dev_info(&instance->pdev->dev, "Performance mode :%s\n",
1106
+ MEGASAS_PERF_MODE_2STR(instance->perf_mode));
1107
+
1108
+ instance->fw_sync_cache_support = (scratch_pad_1 &
10151109 MR_CAN_HANDLE_SYNC_CACHE_OFFSET) ? 1 : 0;
10161110 dev_info(&instance->pdev->dev, "FW supports sync cache\t: %s\n",
10171111 instance->fw_sync_cache_support ? "Yes" : "No");
....@@ -1044,9 +1138,7 @@
10441138
10451139 frame_hdr = &cmd->frame->hdr;
10461140 frame_hdr->cmd_status = 0xFF;
1047
- frame_hdr->flags = cpu_to_le16(
1048
- le16_to_cpu(frame_hdr->flags) |
1049
- MFI_FRAME_DONT_POST_IN_REPLY_QUEUE);
1141
+ frame_hdr->flags |= cpu_to_le16(MFI_FRAME_DONT_POST_IN_REPLY_QUEUE);
10501142
10511143 init_frame->cmd = MFI_CMD_INIT;
10521144 init_frame->cmd_status = 0xFF;
....@@ -1073,6 +1165,7 @@
10731165 drv_ops->mfi_capabilities.support_qd_throttling = 1;
10741166 drv_ops->mfi_capabilities.support_pd_map_target_id = 1;
10751167 drv_ops->mfi_capabilities.support_nvme_passthru = 1;
1168
+ drv_ops->mfi_capabilities.support_fw_exposed_dev_list = 1;
10761169
10771170 if (instance->consistent_mask_64bit)
10781171 drv_ops->mfi_capabilities.support_64bit_mode = 1;
....@@ -1096,6 +1189,22 @@
10961189 cpu_to_le32(lower_32_bits(ioc_init_handle));
10971190 init_frame->data_xfer_len = cpu_to_le32(sizeof(struct MPI2_IOC_INIT_REQUEST));
10981191
1192
+ /*
1193
+ * Each bit in replyqueue_mask represents one group of MSI-x vectors
1194
+ * (each group has 8 vectors)
1195
+ */
1196
+ switch (instance->perf_mode) {
1197
+ case MR_BALANCED_PERF_MODE:
1198
+ init_frame->replyqueue_mask =
1199
+ cpu_to_le16(~(~0 << instance->low_latency_index_start/8));
1200
+ break;
1201
+ case MR_IOPS_PERF_MODE:
1202
+ init_frame->replyqueue_mask =
1203
+ cpu_to_le16(~(~0 << instance->msix_vectors/8));
1204
+ break;
1205
+ }
1206
+
1207
+
10991208 req_desc.u.low = cpu_to_le32(lower_32_bits(cmd->frame_phys_addr));
11001209 req_desc.u.high = cpu_to_le32(upper_32_bits(cmd->frame_phys_addr));
11011210 req_desc.MFAIo.RequestFlags =
....@@ -1108,20 +1217,32 @@
11081217 instance->instancet->disable_intr(instance);
11091218
11101219 for (i = 0; i < (10 * 1000); i += 20) {
1111
- if (readl(&instance->reg_set->doorbell) & 1)
1220
+ if (megasas_readl(instance, &instance->reg_set->doorbell) & 1)
11121221 msleep(20);
11131222 else
11141223 break;
11151224 }
11161225
1117
- megasas_fire_cmd_fusion(instance, &req_desc);
1226
+ /* For AERO also, IOC_INIT requires 64 bit descriptor write */
1227
+ megasas_write_64bit_req_desc(instance, &req_desc);
11181228
1119
- wait_and_poll(instance, cmd, MFI_POLL_TIMEOUT_SECS);
1229
+ wait_and_poll(instance, cmd, MFI_IO_TIMEOUT_SECS);
11201230
11211231 frame_hdr = &cmd->frame->hdr;
11221232 if (frame_hdr->cmd_status != 0) {
11231233 ret = 1;
11241234 goto fail_fw_init;
1235
+ }
1236
+
1237
+ if (instance->adapter_type >= AERO_SERIES) {
1238
+ scratch_pad_1 = megasas_readl
1239
+ (instance, &instance->reg_set->outbound_scratch_pad_1);
1240
+
1241
+ instance->atomic_desc_support =
1242
+ (scratch_pad_1 & MR_ATOMIC_DESCRIPTOR_SUPPORT_OFFSET) ? 1 : 0;
1243
+
1244
+ dev_info(&instance->pdev->dev, "FW supports atomic descriptor\t: %s\n",
1245
+ instance->atomic_desc_support ? "Yes" : "No");
11251246 }
11261247
11271248 return 0;
....@@ -1146,7 +1267,7 @@
11461267 int
11471268 megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend) {
11481269 int ret = 0;
1149
- u32 pd_seq_map_sz;
1270
+ size_t pd_seq_map_sz;
11501271 struct megasas_cmd *cmd;
11511272 struct megasas_dcmd_frame *dcmd;
11521273 struct fusion_context *fusion = instance->ctrl_context;
....@@ -1155,9 +1276,7 @@
11551276
11561277 pd_sync = (void *)fusion->pd_seq_sync[(instance->pd_seq_map_id & 1)];
11571278 pd_seq_h = fusion->pd_seq_phys[(instance->pd_seq_map_id & 1)];
1158
- pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
1159
- (sizeof(struct MR_PD_CFG_SEQ) *
1160
- (MAX_PHYSICAL_DEVICES - 1));
1279
+ pd_seq_map_sz = struct_size(pd_sync, seq, MAX_PHYSICAL_DEVICES - 1);
11611280
11621281 cmd = megasas_get_cmd(instance);
11631282 if (!cmd) {
....@@ -1210,7 +1329,9 @@
12101329 }
12111330
12121331 if (ret == DCMD_TIMEOUT)
1213
- megaraid_sas_kill_hba(instance);
1332
+ dev_warn(&instance->pdev->dev,
1333
+ "%s DCMD timed out, continue without JBOD sequence map\n",
1334
+ __func__);
12141335
12151336 if (ret == DCMD_SUCCESS)
12161337 instance->pd_seq_map_id++;
....@@ -1292,7 +1413,9 @@
12921413 ret = megasas_issue_polled(instance, cmd);
12931414
12941415 if (ret == DCMD_TIMEOUT)
1295
- megaraid_sas_kill_hba(instance);
1416
+ dev_warn(&instance->pdev->dev,
1417
+ "%s DCMD timed out, RAID map is disabled\n",
1418
+ __func__);
12961419
12971420 megasas_return_cmd(instance, cmd);
12981421
....@@ -1329,7 +1452,6 @@
13291452 struct megasas_cmd *cmd;
13301453 struct megasas_dcmd_frame *dcmd;
13311454 u16 num_lds;
1332
- u32 size_sync_info;
13331455 struct fusion_context *fusion;
13341456 struct MR_LD_TARGET_SYNC *ci = NULL;
13351457 struct MR_DRV_RAID_MAP_ALL *map;
....@@ -1357,8 +1479,6 @@
13571479 num_lds = le16_to_cpu(map->raidMap.ldCount);
13581480
13591481 dcmd = &cmd->frame->dcmd;
1360
-
1361
- size_sync_info = sizeof(struct MR_LD_TARGET_SYNC) *num_lds;
13621482
13631483 memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
13641484
....@@ -1560,14 +1680,12 @@
15601680 fusion = instance->ctrl_context;
15611681 max_cmd = instance->max_fw_cmds;
15621682
1563
- if (instance->adapter_type == VENTURA_SERIES)
1683
+ if (instance->adapter_type >= VENTURA_SERIES)
15641684 instance->max_mpt_cmds = instance->max_fw_cmds * RAID_1_PEER_CMDS;
15651685 else
15661686 instance->max_mpt_cmds = instance->max_fw_cmds;
15671687
1568
- instance->max_scsi_cmds = instance->max_fw_cmds -
1569
- (MEGASAS_FUSION_INTERNAL_CMDS +
1570
- MEGASAS_FUSION_IOCTL_CMDS);
1688
+ instance->max_scsi_cmds = instance->max_fw_cmds - instance->max_mfi_cmds;
15711689 instance->cur_can_queue = instance->max_scsi_cmds;
15721690 instance->host->can_queue = instance->cur_can_queue;
15731691
....@@ -1628,8 +1746,7 @@
16281746 fusion->ioc_init_cmd->frame,
16291747 fusion->ioc_init_cmd->frame_phys_addr);
16301748
1631
- if (fusion->ioc_init_cmd)
1632
- kfree(fusion->ioc_init_cmd);
1749
+ kfree(fusion->ioc_init_cmd);
16331750 }
16341751
16351752 /**
....@@ -1638,17 +1755,15 @@
16381755 *
16391756 * This is the main function for initializing firmware.
16401757 */
1641
-u32
1758
+static u32
16421759 megasas_init_adapter_fusion(struct megasas_instance *instance)
16431760 {
1644
- struct megasas_register_set __iomem *reg_set;
16451761 struct fusion_context *fusion;
1646
- u32 scratch_pad_2;
1762
+ u32 scratch_pad_1;
16471763 int i = 0, count;
1764
+ u32 status_reg;
16481765
16491766 fusion = instance->ctrl_context;
1650
-
1651
- reg_set = instance->reg_set;
16521767
16531768 megasas_fusion_update_can_queue(instance, PROBE_CONTEXT);
16541769
....@@ -1660,20 +1775,21 @@
16601775
16611776 megasas_configure_queue_sizes(instance);
16621777
1663
- scratch_pad_2 = readl(&instance->reg_set->outbound_scratch_pad_2);
1664
- /* If scratch_pad_2 & MEGASAS_MAX_CHAIN_SIZE_UNITS_MASK is set,
1778
+ scratch_pad_1 = megasas_readl(instance,
1779
+ &instance->reg_set->outbound_scratch_pad_1);
1780
+ /* If scratch_pad_1 & MEGASAS_MAX_CHAIN_SIZE_UNITS_MASK is set,
16651781 * Firmware support extended IO chain frame which is 4 times more than
16661782 * legacy Firmware.
16671783 * Legacy Firmware - Frame size is (8 * 128) = 1K
16681784 * 1M IO Firmware - Frame size is (8 * 128 * 4) = 4K
16691785 */
1670
- if (scratch_pad_2 & MEGASAS_MAX_CHAIN_SIZE_UNITS_MASK)
1786
+ if (scratch_pad_1 & MEGASAS_MAX_CHAIN_SIZE_UNITS_MASK)
16711787 instance->max_chain_frame_sz =
1672
- ((scratch_pad_2 & MEGASAS_MAX_CHAIN_SIZE_MASK) >>
1788
+ ((scratch_pad_1 & MEGASAS_MAX_CHAIN_SIZE_MASK) >>
16731789 MEGASAS_MAX_CHAIN_SHIFT) * MEGASAS_1MB_IO;
16741790 else
16751791 instance->max_chain_frame_sz =
1676
- ((scratch_pad_2 & MEGASAS_MAX_CHAIN_SIZE_MASK) >>
1792
+ ((scratch_pad_1 & MEGASAS_MAX_CHAIN_SIZE_MASK) >>
16771793 MEGASAS_MAX_CHAIN_SHIFT) * MEGASAS_256K_IO;
16781794
16791795 if (instance->max_chain_frame_sz < MEGASAS_CHAIN_FRAME_SZ_MIN) {
....@@ -1728,8 +1844,21 @@
17281844 if (megasas_alloc_cmds_fusion(instance))
17291845 goto fail_alloc_cmds;
17301846
1731
- if (megasas_ioc_init_fusion(instance))
1732
- goto fail_ioc_init;
1847
+ if (megasas_ioc_init_fusion(instance)) {
1848
+ status_reg = instance->instancet->read_fw_status_reg(instance);
1849
+ if (((status_reg & MFI_STATE_MASK) == MFI_STATE_FAULT) &&
1850
+ (status_reg & MFI_RESET_ADAPTER)) {
1851
+ /* Do a chip reset and then retry IOC INIT once */
1852
+ if (megasas_adp_reset_wait_for_ready
1853
+ (instance, true, 0) == FAILED)
1854
+ goto fail_ioc_init;
1855
+
1856
+ if (megasas_ioc_init_fusion(instance))
1857
+ goto fail_ioc_init;
1858
+ } else {
1859
+ goto fail_ioc_init;
1860
+ }
1861
+ }
17331862
17341863 megasas_display_intel_branding(instance);
17351864 if (megasas_get_ctrl_info(instance)) {
....@@ -1741,6 +1870,7 @@
17411870
17421871 instance->flag_ieee = 1;
17431872 instance->r1_ldio_hint_default = MR_R1_LDIO_PIGGYBACK_DEFAULT;
1873
+ instance->threshold_reply_count = instance->max_fw_cmds / 4;
17441874 fusion->fast_path_io = 0;
17451875
17461876 if (megasas_allocate_raid_maps(instance))
....@@ -1761,13 +1891,100 @@
17611891 }
17621892
17631893 /**
1764
- * map_cmd_status - Maps FW cmd status to OS cmd status
1765
- * @cmd : Pointer to cmd
1766
- * @status : status of cmd returned by FW
1767
- * @ext_status : ext status of cmd returned by FW
1894
+ * megasas_fault_detect_work - Worker function of
1895
+ * FW fault handling workqueue.
1896
+ * @work: FW fault work struct
17681897 */
1898
+static void
1899
+megasas_fault_detect_work(struct work_struct *work)
1900
+{
1901
+ struct megasas_instance *instance =
1902
+ container_of(work, struct megasas_instance,
1903
+ fw_fault_work.work);
1904
+ u32 fw_state, dma_state, status;
1905
+
1906
+ /* Check the fw state */
1907
+ fw_state = instance->instancet->read_fw_status_reg(instance) &
1908
+ MFI_STATE_MASK;
1909
+
1910
+ if (fw_state == MFI_STATE_FAULT) {
1911
+ dma_state = instance->instancet->read_fw_status_reg(instance) &
1912
+ MFI_STATE_DMADONE;
1913
+ /* Start collecting crash, if DMA bit is done */
1914
+ if (instance->crash_dump_drv_support &&
1915
+ instance->crash_dump_app_support && dma_state) {
1916
+ megasas_fusion_crash_dump(instance);
1917
+ } else {
1918
+ if (instance->unload == 0) {
1919
+ status = megasas_reset_fusion(instance->host, 0);
1920
+ if (status != SUCCESS) {
1921
+ dev_err(&instance->pdev->dev,
1922
+ "Failed from %s %d, do not re-arm timer\n",
1923
+ __func__, __LINE__);
1924
+ return;
1925
+ }
1926
+ }
1927
+ }
1928
+ }
1929
+
1930
+ if (instance->fw_fault_work_q)
1931
+ queue_delayed_work(instance->fw_fault_work_q,
1932
+ &instance->fw_fault_work,
1933
+ msecs_to_jiffies(MEGASAS_WATCHDOG_THREAD_INTERVAL));
1934
+}
1935
+
1936
+int
1937
+megasas_fusion_start_watchdog(struct megasas_instance *instance)
1938
+{
1939
+ /* Check if the Fault WQ is already started */
1940
+ if (instance->fw_fault_work_q)
1941
+ return SUCCESS;
1942
+
1943
+ INIT_DELAYED_WORK(&instance->fw_fault_work, megasas_fault_detect_work);
1944
+
1945
+ snprintf(instance->fault_handler_work_q_name,
1946
+ sizeof(instance->fault_handler_work_q_name),
1947
+ "poll_megasas%d_status", instance->host->host_no);
1948
+
1949
+ instance->fw_fault_work_q =
1950
+ create_singlethread_workqueue(instance->fault_handler_work_q_name);
1951
+ if (!instance->fw_fault_work_q) {
1952
+ dev_err(&instance->pdev->dev, "Failed from %s %d\n",
1953
+ __func__, __LINE__);
1954
+ return FAILED;
1955
+ }
1956
+
1957
+ queue_delayed_work(instance->fw_fault_work_q,
1958
+ &instance->fw_fault_work,
1959
+ msecs_to_jiffies(MEGASAS_WATCHDOG_THREAD_INTERVAL));
1960
+
1961
+ return SUCCESS;
1962
+}
17691963
17701964 void
1965
+megasas_fusion_stop_watchdog(struct megasas_instance *instance)
1966
+{
1967
+ struct workqueue_struct *wq;
1968
+
1969
+ if (instance->fw_fault_work_q) {
1970
+ wq = instance->fw_fault_work_q;
1971
+ instance->fw_fault_work_q = NULL;
1972
+ if (!cancel_delayed_work_sync(&instance->fw_fault_work))
1973
+ flush_workqueue(wq);
1974
+ destroy_workqueue(wq);
1975
+ }
1976
+}
1977
+
1978
+/**
1979
+ * map_cmd_status - Maps FW cmd status to OS cmd status
1980
+ * @fusion: fusion context
1981
+ * @scmd: Pointer to cmd
1982
+ * @status: status of cmd returned by FW
1983
+ * @ext_status: ext status of cmd returned by FW
1984
+ * @data_length: command data length
1985
+ * @sense: command sense data
1986
+ */
1987
+static void
17711988 map_cmd_status(struct fusion_context *fusion,
17721989 struct scsi_cmnd *scmd, u8 status, u8 ext_status,
17731990 u32 data_length, u8 *sense)
....@@ -1843,8 +2060,6 @@
18432060 megasas_is_prp_possible(struct megasas_instance *instance,
18442061 struct scsi_cmnd *scmd, int sge_count)
18452062 {
1846
- struct fusion_context *fusion;
1847
- int i;
18482063 u32 data_length = 0;
18492064 struct scatterlist *sg_scmd;
18502065 bool build_prp = false;
....@@ -1852,7 +2067,6 @@
18522067
18532068 mr_nvme_pg_size = max_t(u32, instance->nvme_page_size,
18542069 MR_DEFAULT_NVME_PAGE_SIZE);
1855
- fusion = instance->ctrl_context;
18562070 data_length = scsi_bufflen(scmd);
18572071 sg_scmd = scsi_sglist(scmd);
18582072
....@@ -1872,66 +2086,6 @@
18722086 /* check if 1st SG entry size is < residual beyond 4 pages */
18732087 if (sg_dma_len(sg_scmd) < (data_length - (mr_nvme_pg_size * 4)))
18742088 build_prp = true;
1875
- }
1876
-
1877
-/*
1878
- * Below code detects gaps/holes in IO data buffers.
1879
- * What does holes/gaps mean?
1880
- * Any SGE except first one in a SGL starts at non NVME page size
1881
- * aligned address OR Any SGE except last one in a SGL ends at
1882
- * non NVME page size boundary.
1883
- *
1884
- * Driver has already informed block layer by setting boundary rules for
1885
- * bio merging done at NVME page size boundary calling kernel API
1886
- * blk_queue_virt_boundary inside slave_config.
1887
- * Still there is possibility of IO coming with holes to driver because of
1888
- * IO merging done by IO scheduler.
1889
- *
1890
- * With SCSI BLK MQ enabled, there will be no IO with holes as there is no
1891
- * IO scheduling so no IO merging.
1892
- *
1893
- * With SCSI BLK MQ disabled, IO scheduler may attempt to merge IOs and
1894
- * then sending IOs with holes.
1895
- *
1896
- * Though driver can request block layer to disable IO merging by calling-
1897
- * blk_queue_flag_set(QUEUE_FLAG_NOMERGES, sdev->request_queue) but
1898
- * user may tune sysfs parameter- nomerges again to 0 or 1.
1899
- *
1900
- * If in future IO scheduling is enabled with SCSI BLK MQ,
1901
- * this algorithm to detect holes will be required in driver
1902
- * for SCSI BLK MQ enabled case as well.
1903
- *
1904
- *
1905
- */
1906
- scsi_for_each_sg(scmd, sg_scmd, sge_count, i) {
1907
- if ((i != 0) && (i != (sge_count - 1))) {
1908
- if (mega_mod64(sg_dma_len(sg_scmd), mr_nvme_pg_size) ||
1909
- mega_mod64(sg_dma_address(sg_scmd),
1910
- mr_nvme_pg_size)) {
1911
- build_prp = false;
1912
- atomic_inc(&instance->sge_holes_type1);
1913
- break;
1914
- }
1915
- }
1916
-
1917
- if ((sge_count > 1) && (i == 0)) {
1918
- if ((mega_mod64((sg_dma_address(sg_scmd) +
1919
- sg_dma_len(sg_scmd)),
1920
- mr_nvme_pg_size))) {
1921
- build_prp = false;
1922
- atomic_inc(&instance->sge_holes_type2);
1923
- break;
1924
- }
1925
- }
1926
-
1927
- if ((sge_count > 1) && (i == (sge_count - 1))) {
1928
- if (mega_mod64(sg_dma_address(sg_scmd),
1929
- mr_nvme_pg_size)) {
1930
- build_prp = false;
1931
- atomic_inc(&instance->sge_holes_type3);
1932
- break;
1933
- }
1934
- }
19352089 }
19362090
19372091 return build_prp;
....@@ -1965,11 +2119,8 @@
19652119 u32 first_prp_len;
19662120 bool build_prp = false;
19672121 int data_len = scsi_bufflen(scmd);
1968
- struct fusion_context *fusion;
19692122 u32 mr_nvme_pg_size = max_t(u32, instance->nvme_page_size,
19702123 MR_DEFAULT_NVME_PAGE_SIZE);
1971
-
1972
- fusion = instance->ctrl_context;
19732124
19742125 build_prp = megasas_is_prp_possible(instance, scmd, sge_count);
19752126
....@@ -2064,7 +2215,6 @@
20642215 main_chain_element->Length =
20652216 cpu_to_le32(num_prp_in_chain * sizeof(u64));
20662217
2067
- atomic_inc(&instance->prp_sgl);
20682218 return build_prp;
20692219 }
20702220
....@@ -2074,7 +2224,7 @@
20742224 * @scp: SCSI command from the mid-layer
20752225 * @sgl_ptr: SGL to be filled in
20762226 * @cmd: cmd we are working on
2077
- * @sge_count sge count
2227
+ * @sge_count: sge count
20782228 *
20792229 */
20802230 static void
....@@ -2139,7 +2289,6 @@
21392289 memset(sgl_ptr, 0, instance->max_chain_frame_sz);
21402290 }
21412291 }
2142
- atomic_inc(&instance->ieee_sgl);
21432292 }
21442293
21452294 /**
....@@ -2184,13 +2333,16 @@
21842333
21852334 /**
21862335 * megasas_set_pd_lba - Sets PD LBA
2187
- * @cdb: CDB
2336
+ * @io_request: IO request
21882337 * @cdb_len: cdb length
2189
- * @start_blk: Start block of IO
2338
+ * @io_info: IO information
2339
+ * @scp: SCSI command
2340
+ * @local_map_ptr: Raid map
2341
+ * @ref_tag: Primary reference tag
21902342 *
21912343 * Used to set the PD LBA in CDB for FP IOs
21922344 */
2193
-void
2345
+static void
21942346 megasas_set_pd_lba(struct MPI2_RAID_SCSI_IO_REQUEST *io_request, u8 cdb_len,
21952347 struct IO_REQUEST_INFO *io_info, struct scsi_cmnd *scp,
21962348 struct MR_DRV_RAID_MAP_ALL *local_map_ptr, u32 ref_tag)
....@@ -2210,7 +2362,7 @@
22102362 cdb[0] = MEGASAS_SCSI_VARIABLE_LENGTH_CMD;
22112363 cdb[7] = MEGASAS_SCSI_ADDL_CDB_LEN;
22122364
2213
- if (scp->sc_data_direction == PCI_DMA_FROMDEVICE)
2365
+ if (scp->sc_data_direction == DMA_FROM_DEVICE)
22142366 cdb[9] = MEGASAS_SCSI_SERVICE_ACTION_READ32;
22152367 else
22162368 cdb[9] = MEGASAS_SCSI_SERVICE_ACTION_WRITE32;
....@@ -2239,7 +2391,7 @@
22392391 cdb[31] = (u8)(num_blocks & 0xff);
22402392
22412393 /* set SCSI IO EEDPFlags */
2242
- if (scp->sc_data_direction == PCI_DMA_FROMDEVICE) {
2394
+ if (scp->sc_data_direction == DMA_FROM_DEVICE) {
22432395 io_request->EEDPFlags = cpu_to_le16(
22442396 MPI2_SCSIIO_EEDPFLAGS_INC_PRI_REFTAG |
22452397 MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG |
....@@ -2444,16 +2596,19 @@
24442596 * affinity (cpu of the controller) and raid_flags in the raid context
24452597 * based on IO type.
24462598 *
2599
+ * @fusion: Fusion context
24472600 * @praid_context: IO RAID context
24482601 * @raid: LD raid map
24492602 * @fp_possible: Is fast path possible?
24502603 * @is_read: Is read IO?
2604
+ * @scsi_buff_len: SCSI command buffer length
24512605 *
24522606 */
24532607 static void
2454
-megasas_set_raidflag_cpu_affinity(union RAID_CONTEXT_UNION *praid_context,
2455
- struct MR_LD_RAID *raid, bool fp_possible,
2456
- u8 is_read, u32 scsi_buff_len)
2608
+megasas_set_raidflag_cpu_affinity(struct fusion_context *fusion,
2609
+ union RAID_CONTEXT_UNION *praid_context,
2610
+ struct MR_LD_RAID *raid, bool fp_possible,
2611
+ u8 is_read, u32 scsi_buff_len)
24572612 {
24582613 u8 cpu_sel = MR_RAID_CTX_CPUSEL_0;
24592614 struct RAID_CONTEXT_G35 *rctx_g35;
....@@ -2511,11 +2666,11 @@
25112666 * vs MR_RAID_FLAGS_IO_SUB_TYPE_CACHE_BYPASS.
25122667 * IO Subtype is not bitmap.
25132668 */
2514
- if ((raid->level == 1) && (!is_read)) {
2515
- if (scsi_buff_len > MR_LARGE_IO_MIN_SIZE)
2516
- praid_context->raid_context_g35.raid_flags =
2517
- (MR_RAID_FLAGS_IO_SUB_TYPE_LDIO_BW_LIMIT
2518
- << MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT);
2669
+ if ((fusion->pcie_bw_limitation) && (raid->level == 1) && (!is_read) &&
2670
+ (scsi_buff_len > MR_LARGE_IO_MIN_SIZE)) {
2671
+ praid_context->raid_context_g35.raid_flags =
2672
+ (MR_RAID_FLAGS_IO_SUB_TYPE_LDIO_BW_LIMIT
2673
+ << MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT);
25192674 }
25202675 }
25212676
....@@ -2528,7 +2683,7 @@
25282683 * Prepares the io_request and chain elements (sg_frame) for IO
25292684 * The IO can be for PD (Fast Path) or LD
25302685 */
2531
-void
2686
+static void
25322687 megasas_build_ldio_fusion(struct megasas_instance *instance,
25332688 struct scsi_cmnd *scp,
25342689 struct megasas_cmd_fusion *cmd)
....@@ -2538,27 +2693,27 @@
25382693 u32 start_lba_lo, start_lba_hi, device_id, datalength = 0;
25392694 u32 scsi_buff_len;
25402695 struct MPI2_RAID_SCSI_IO_REQUEST *io_request;
2541
- union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc;
25422696 struct IO_REQUEST_INFO io_info;
25432697 struct fusion_context *fusion;
25442698 struct MR_DRV_RAID_MAP_ALL *local_map_ptr;
25452699 u8 *raidLUN;
25462700 unsigned long spinlock_flags;
2547
- union RAID_CONTEXT_UNION *praid_context;
25482701 struct MR_LD_RAID *raid = NULL;
25492702 struct MR_PRIV_DEVICE *mrdev_priv;
2703
+ struct RAID_CONTEXT *rctx;
2704
+ struct RAID_CONTEXT_G35 *rctx_g35;
25502705
25512706 device_id = MEGASAS_DEV_INDEX(scp);
25522707
25532708 fusion = instance->ctrl_context;
25542709
25552710 io_request = cmd->io_request;
2556
- io_request->RaidContext.raid_context.virtual_disk_tgt_id =
2557
- cpu_to_le16(device_id);
2558
- io_request->RaidContext.raid_context.status = 0;
2559
- io_request->RaidContext.raid_context.ex_status = 0;
2711
+ rctx = &io_request->RaidContext.raid_context;
2712
+ rctx_g35 = &io_request->RaidContext.raid_context_g35;
25602713
2561
- req_desc = (union MEGASAS_REQUEST_DESCRIPTOR_UNION *)cmd->request_desc;
2714
+ rctx->virtual_disk_tgt_id = cpu_to_le16(device_id);
2715
+ rctx->status = 0;
2716
+ rctx->ex_status = 0;
25622717
25632718 start_lba_lo = 0;
25642719 start_lba_hi = 0;
....@@ -2621,8 +2776,9 @@
26212776 io_info.r1_alt_dev_handle = MR_DEVHANDLE_INVALID;
26222777 scsi_buff_len = scsi_bufflen(scp);
26232778 io_request->DataLength = cpu_to_le32(scsi_buff_len);
2779
+ io_info.data_arms = 1;
26242780
2625
- if (scp->sc_data_direction == PCI_DMA_FROMDEVICE)
2781
+ if (scp->sc_data_direction == DMA_FROM_DEVICE)
26262782 io_info.isRead = 1;
26272783
26282784 local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)];
....@@ -2632,21 +2788,17 @@
26322788 raid = MR_LdRaidGet(ld, local_map_ptr);
26332789
26342790 if (!raid || (!fusion->fast_path_io)) {
2635
- io_request->RaidContext.raid_context.reg_lock_flags = 0;
2791
+ rctx->reg_lock_flags = 0;
26362792 fp_possible = false;
26372793 } else {
2638
- if (MR_BuildRaidContext(instance, &io_info,
2639
- &io_request->RaidContext.raid_context,
2794
+ if (MR_BuildRaidContext(instance, &io_info, rctx,
26402795 local_map_ptr, &raidLUN))
26412796 fp_possible = (io_info.fpOkForIo > 0) ? true : false;
26422797 }
26432798
2644
- cmd->request_desc->SCSIIO.MSIxIndex =
2645
- instance->reply_map[raw_smp_processor_id()];
2799
+ megasas_get_msix_index(instance, scp, cmd, io_info.data_arms);
26462800
2647
- praid_context = &io_request->RaidContext;
2648
-
2649
- if (instance->adapter_type == VENTURA_SERIES) {
2801
+ if (instance->adapter_type >= VENTURA_SERIES) {
26502802 /* FP for Optimal raid level 1.
26512803 * All large RAID-1 writes (> 32 KiB, both WT and WB modes)
26522804 * are built by the driver as LD I/Os.
....@@ -2662,8 +2814,9 @@
26622814 (instance->host->can_queue)) {
26632815 fp_possible = false;
26642816 atomic_dec(&instance->fw_outstanding);
2665
- } else if ((scsi_buff_len > MR_LARGE_IO_MIN_SIZE) ||
2666
- (atomic_dec_if_positive(&mrdev_priv->r1_ldio_hint) > 0)) {
2817
+ } else if (fusion->pcie_bw_limitation &&
2818
+ ((scsi_buff_len > MR_LARGE_IO_MIN_SIZE) ||
2819
+ (atomic_dec_if_positive(&mrdev_priv->r1_ldio_hint) > 0))) {
26672820 fp_possible = false;
26682821 atomic_dec(&instance->fw_outstanding);
26692822 if (scsi_buff_len > MR_LARGE_IO_MIN_SIZE)
....@@ -2682,17 +2835,17 @@
26822835 /* In ventura if stream detected for a read and it is
26832836 * read ahead capable make this IO as LDIO
26842837 */
2685
- if (is_stream_detected(&io_request->RaidContext.raid_context_g35))
2838
+ if (is_stream_detected(rctx_g35))
26862839 fp_possible = false;
26872840 }
26882841
26892842 /* If raid is NULL, set CPU affinity to default CPU0 */
26902843 if (raid)
2691
- megasas_set_raidflag_cpu_affinity(praid_context,
2844
+ megasas_set_raidflag_cpu_affinity(fusion, &io_request->RaidContext,
26922845 raid, fp_possible, io_info.isRead,
26932846 scsi_buff_len);
26942847 else
2695
- praid_context->raid_context_g35.routing_flags |=
2848
+ rctx_g35->routing_flags |=
26962849 (MR_RAID_CTX_CPUSEL_0 << MR_RAID_CTX_ROUTINGFLAGS_CPUSEL_SHIFT);
26972850 }
26982851
....@@ -2704,25 +2857,16 @@
27042857 (MPI2_REQ_DESCRIPT_FLAGS_FP_IO
27052858 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
27062859 if (instance->adapter_type == INVADER_SERIES) {
2707
- if (io_request->RaidContext.raid_context.reg_lock_flags ==
2708
- REGION_TYPE_UNUSED)
2709
- cmd->request_desc->SCSIIO.RequestFlags =
2710
- (MEGASAS_REQ_DESCRIPT_FLAGS_NO_LOCK <<
2711
- MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
2712
- io_request->RaidContext.raid_context.type
2713
- = MPI2_TYPE_CUDA;
2714
- io_request->RaidContext.raid_context.nseg = 0x1;
2860
+ rctx->type = MPI2_TYPE_CUDA;
2861
+ rctx->nseg = 0x1;
27152862 io_request->IoFlags |= cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH);
2716
- io_request->RaidContext.raid_context.reg_lock_flags |=
2863
+ rctx->reg_lock_flags |=
27172864 (MR_RL_FLAGS_GRANT_DESTINATION_CUDA |
27182865 MR_RL_FLAGS_SEQ_NUM_ENABLE);
2719
- } else if (instance->adapter_type == VENTURA_SERIES) {
2720
- io_request->RaidContext.raid_context_g35.nseg_type |=
2721
- (1 << RAID_CONTEXT_NSEG_SHIFT);
2722
- io_request->RaidContext.raid_context_g35.nseg_type |=
2723
- (MPI2_TYPE_CUDA << RAID_CONTEXT_TYPE_SHIFT);
2724
- io_request->RaidContext.raid_context_g35.routing_flags |=
2725
- (1 << MR_RAID_CTX_ROUTINGFLAGS_SQN_SHIFT);
2866
+ } else if (instance->adapter_type >= VENTURA_SERIES) {
2867
+ rctx_g35->nseg_type |= (1 << RAID_CONTEXT_NSEG_SHIFT);
2868
+ rctx_g35->nseg_type |= (MPI2_TYPE_CUDA << RAID_CONTEXT_TYPE_SHIFT);
2869
+ rctx_g35->routing_flags |= (1 << MR_RAID_CTX_ROUTINGFLAGS_SQN_SHIFT);
27262870 io_request->IoFlags |=
27272871 cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH);
27282872 }
....@@ -2735,17 +2879,15 @@
27352879 &io_info, local_map_ptr);
27362880 scp->SCp.Status |= MEGASAS_LOAD_BALANCE_FLAG;
27372881 cmd->pd_r1_lb = io_info.pd_after_lb;
2738
- if (instance->adapter_type == VENTURA_SERIES)
2739
- io_request->RaidContext.raid_context_g35.span_arm
2740
- = io_info.span_arm;
2882
+ if (instance->adapter_type >= VENTURA_SERIES)
2883
+ rctx_g35->span_arm = io_info.span_arm;
27412884 else
2742
- io_request->RaidContext.raid_context.span_arm
2743
- = io_info.span_arm;
2885
+ rctx->span_arm = io_info.span_arm;
27442886
27452887 } else
27462888 scp->SCp.Status &= ~MEGASAS_LOAD_BALANCE_FLAG;
27472889
2748
- if (instance->adapter_type == VENTURA_SERIES)
2890
+ if (instance->adapter_type >= VENTURA_SERIES)
27492891 cmd->r1_alt_dev_handle = io_info.r1_alt_dev_handle;
27502892 else
27512893 cmd->r1_alt_dev_handle = MR_DEVHANDLE_INVALID;
....@@ -2763,31 +2905,26 @@
27632905 /* populate the LUN field */
27642906 memcpy(io_request->LUN, raidLUN, 8);
27652907 } else {
2766
- io_request->RaidContext.raid_context.timeout_value =
2908
+ rctx->timeout_value =
27672909 cpu_to_le16(local_map_ptr->raidMap.fpPdIoTimeoutSec);
27682910 cmd->request_desc->SCSIIO.RequestFlags =
27692911 (MEGASAS_REQ_DESCRIPT_FLAGS_LD_IO
27702912 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
27712913 if (instance->adapter_type == INVADER_SERIES) {
27722914 if (io_info.do_fp_rlbypass ||
2773
- (io_request->RaidContext.raid_context.reg_lock_flags
2774
- == REGION_TYPE_UNUSED))
2915
+ (rctx->reg_lock_flags == REGION_TYPE_UNUSED))
27752916 cmd->request_desc->SCSIIO.RequestFlags =
27762917 (MEGASAS_REQ_DESCRIPT_FLAGS_NO_LOCK <<
27772918 MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
2778
- io_request->RaidContext.raid_context.type
2779
- = MPI2_TYPE_CUDA;
2780
- io_request->RaidContext.raid_context.reg_lock_flags |=
2919
+ rctx->type = MPI2_TYPE_CUDA;
2920
+ rctx->reg_lock_flags |=
27812921 (MR_RL_FLAGS_GRANT_DESTINATION_CPU0 |
2782
- MR_RL_FLAGS_SEQ_NUM_ENABLE);
2783
- io_request->RaidContext.raid_context.nseg = 0x1;
2784
- } else if (instance->adapter_type == VENTURA_SERIES) {
2785
- io_request->RaidContext.raid_context_g35.routing_flags |=
2786
- (1 << MR_RAID_CTX_ROUTINGFLAGS_SQN_SHIFT);
2787
- io_request->RaidContext.raid_context_g35.nseg_type |=
2788
- (1 << RAID_CONTEXT_NSEG_SHIFT);
2789
- io_request->RaidContext.raid_context_g35.nseg_type |=
2790
- (MPI2_TYPE_CUDA << RAID_CONTEXT_TYPE_SHIFT);
2922
+ MR_RL_FLAGS_SEQ_NUM_ENABLE);
2923
+ rctx->nseg = 0x1;
2924
+ } else if (instance->adapter_type >= VENTURA_SERIES) {
2925
+ rctx_g35->routing_flags |= (1 << MR_RAID_CTX_ROUTINGFLAGS_SQN_SHIFT);
2926
+ rctx_g35->nseg_type |= (1 << RAID_CONTEXT_NSEG_SHIFT);
2927
+ rctx_g35->nseg_type |= (MPI2_TYPE_CUDA << RAID_CONTEXT_TYPE_SHIFT);
27912928 }
27922929 io_request->Function = MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST;
27932930 io_request->DevHandle = cpu_to_le16(device_id);
....@@ -2798,7 +2935,7 @@
27982935 /**
27992936 * megasas_build_ld_nonrw_fusion - prepares non rw ios for virtual disk
28002937 * @instance: Adapter soft state
2801
- * @scp: SCSI command
2938
+ * @scmd: SCSI command
28022939 * @cmd: Command to be prepared
28032940 *
28042941 * Prepares the io_request frame for non-rw io cmds for vd.
....@@ -2856,7 +2993,7 @@
28562993
28572994 /* set RAID context values */
28582995 pRAID_Context->config_seq_num = raid->seqNum;
2859
- if (instance->adapter_type != VENTURA_SERIES)
2996
+ if (instance->adapter_type < VENTURA_SERIES)
28602997 pRAID_Context->reg_lock_flags = REGION_TYPE_SHARED_READ;
28612998 pRAID_Context->timeout_value =
28622999 cpu_to_le16(raid->fpIoTimeoutForLd);
....@@ -2886,7 +3023,7 @@
28863023 /**
28873024 * megasas_build_syspd_fusion - prepares rw/non-rw ios for syspd
28883025 * @instance: Adapter soft state
2889
- * @scp: SCSI command
3026
+ * @scmd: SCSI command
28903027 * @cmd: Command to be prepared
28913028 * @fp_possible: parameter to detect fast path or firmware path io.
28923029 *
....@@ -2927,50 +3064,60 @@
29273064 << MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT;
29283065
29293066 /* If FW supports PD sequence number */
2930
- if (instance->use_seqnum_jbod_fp &&
2931
- instance->pd_list[pd_index].driveType == TYPE_DISK) {
2932
- /* TgtId must be incremented by 255 as jbod seq number is index
2933
- * below raid map
2934
- */
2935
- /* More than 256 PD/JBOD support for Ventura */
2936
- if (instance->support_morethan256jbod)
2937
- pRAID_Context->virtual_disk_tgt_id =
2938
- pd_sync->seq[pd_index].pd_target_id;
2939
- else
2940
- pRAID_Context->virtual_disk_tgt_id =
2941
- cpu_to_le16(device_id + (MAX_PHYSICAL_DEVICES - 1));
2942
- pRAID_Context->config_seq_num = pd_sync->seq[pd_index].seqNum;
2943
- io_request->DevHandle = pd_sync->seq[pd_index].devHandle;
2944
- if (instance->adapter_type == VENTURA_SERIES) {
2945
- io_request->RaidContext.raid_context_g35.routing_flags |=
2946
- (1 << MR_RAID_CTX_ROUTINGFLAGS_SQN_SHIFT);
2947
- io_request->RaidContext.raid_context_g35.nseg_type |=
2948
- (1 << RAID_CONTEXT_NSEG_SHIFT);
2949
- io_request->RaidContext.raid_context_g35.nseg_type |=
2950
- (MPI2_TYPE_CUDA << RAID_CONTEXT_TYPE_SHIFT);
3067
+ if (instance->support_seqnum_jbod_fp) {
3068
+ if (instance->use_seqnum_jbod_fp &&
3069
+ instance->pd_list[pd_index].driveType == TYPE_DISK) {
3070
+
3071
+ /* More than 256 PD/JBOD support for Ventura */
3072
+ if (instance->support_morethan256jbod)
3073
+ pRAID_Context->virtual_disk_tgt_id =
3074
+ pd_sync->seq[pd_index].pd_target_id;
3075
+ else
3076
+ pRAID_Context->virtual_disk_tgt_id =
3077
+ cpu_to_le16(device_id +
3078
+ (MAX_PHYSICAL_DEVICES - 1));
3079
+ pRAID_Context->config_seq_num =
3080
+ pd_sync->seq[pd_index].seqNum;
3081
+ io_request->DevHandle =
3082
+ pd_sync->seq[pd_index].devHandle;
3083
+ if (instance->adapter_type >= VENTURA_SERIES) {
3084
+ io_request->RaidContext.raid_context_g35.routing_flags |=
3085
+ (1 << MR_RAID_CTX_ROUTINGFLAGS_SQN_SHIFT);
3086
+ io_request->RaidContext.raid_context_g35.nseg_type |=
3087
+ (1 << RAID_CONTEXT_NSEG_SHIFT);
3088
+ io_request->RaidContext.raid_context_g35.nseg_type |=
3089
+ (MPI2_TYPE_CUDA << RAID_CONTEXT_TYPE_SHIFT);
3090
+ } else {
3091
+ pRAID_Context->type = MPI2_TYPE_CUDA;
3092
+ pRAID_Context->nseg = 0x1;
3093
+ pRAID_Context->reg_lock_flags |=
3094
+ (MR_RL_FLAGS_SEQ_NUM_ENABLE |
3095
+ MR_RL_FLAGS_GRANT_DESTINATION_CUDA);
3096
+ }
29513097 } else {
2952
- pRAID_Context->type = MPI2_TYPE_CUDA;
2953
- pRAID_Context->nseg = 0x1;
2954
- pRAID_Context->reg_lock_flags |=
2955
- (MR_RL_FLAGS_SEQ_NUM_ENABLE|MR_RL_FLAGS_GRANT_DESTINATION_CUDA);
3098
+ pRAID_Context->virtual_disk_tgt_id =
3099
+ cpu_to_le16(device_id +
3100
+ (MAX_PHYSICAL_DEVICES - 1));
3101
+ pRAID_Context->config_seq_num = 0;
3102
+ io_request->DevHandle = cpu_to_le16(0xFFFF);
29563103 }
2957
- } else if (fusion->fast_path_io) {
2958
- pRAID_Context->virtual_disk_tgt_id = cpu_to_le16(device_id);
2959
- pRAID_Context->config_seq_num = 0;
2960
- local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)];
2961
- io_request->DevHandle =
2962
- local_map_ptr->raidMap.devHndlInfo[device_id].curDevHdl;
29633104 } else {
2964
- /* Want to send all IO via FW path */
29653105 pRAID_Context->virtual_disk_tgt_id = cpu_to_le16(device_id);
29663106 pRAID_Context->config_seq_num = 0;
2967
- io_request->DevHandle = cpu_to_le16(0xFFFF);
3107
+
3108
+ if (fusion->fast_path_io) {
3109
+ local_map_ptr =
3110
+ fusion->ld_drv_map[(instance->map_id & 1)];
3111
+ io_request->DevHandle =
3112
+ local_map_ptr->raidMap.devHndlInfo[device_id].curDevHdl;
3113
+ } else {
3114
+ io_request->DevHandle = cpu_to_le16(0xFFFF);
3115
+ }
29683116 }
29693117
29703118 cmd->request_desc->SCSIIO.DevHandle = io_request->DevHandle;
29713119
2972
- cmd->request_desc->SCSIIO.MSIxIndex =
2973
- instance->reply_map[raw_smp_processor_id()];
3120
+ megasas_get_msix_index(instance, scmd, cmd, 1);
29743121
29753122 if (!fp_possible) {
29763123 /* system pd firmware path */
....@@ -3010,7 +3157,7 @@
30103157 * Invokes helper functions to prepare request frames
30113158 * and sets flags appropriate for IO/Non-IO cmd
30123159 */
3013
-int
3160
+static int
30143161 megasas_build_io_fusion(struct megasas_instance *instance,
30153162 struct scsi_cmnd *scp,
30163163 struct megasas_cmd_fusion *cmd)
....@@ -3074,7 +3221,7 @@
30743221 return 1;
30753222 }
30763223
3077
- if (instance->adapter_type == VENTURA_SERIES) {
3224
+ if (instance->adapter_type >= VENTURA_SERIES) {
30783225 set_num_sge(&io_request->RaidContext.raid_context_g35, sge_count);
30793226 cpu_to_le16s(&io_request->RaidContext.raid_context_g35.routing_flags);
30803227 cpu_to_le16s(&io_request->RaidContext.raid_context_g35.nseg_type);
....@@ -3089,9 +3236,9 @@
30893236
30903237 io_request->SGLFlags = cpu_to_le16(MPI2_SGE_FLAGS_64_BIT_ADDRESSING);
30913238
3092
- if (scp->sc_data_direction == PCI_DMA_TODEVICE)
3239
+ if (scp->sc_data_direction == DMA_TO_DEVICE)
30933240 io_request->Control |= cpu_to_le32(MPI2_SCSIIO_CONTROL_WRITE);
3094
- else if (scp->sc_data_direction == PCI_DMA_FROMDEVICE)
3241
+ else if (scp->sc_data_direction == DMA_FROM_DEVICE)
30953242 io_request->Control |= cpu_to_le32(MPI2_SCSIIO_CONTROL_READ);
30963243
30973244 io_request->SGLOffset0 =
....@@ -3124,9 +3271,9 @@
31243271 /* megasas_prepate_secondRaid1_IO
31253272 * It prepares the raid 1 second IO
31263273 */
3127
-void megasas_prepare_secondRaid1_IO(struct megasas_instance *instance,
3128
- struct megasas_cmd_fusion *cmd,
3129
- struct megasas_cmd_fusion *r1_cmd)
3274
+static void megasas_prepare_secondRaid1_IO(struct megasas_instance *instance,
3275
+ struct megasas_cmd_fusion *cmd,
3276
+ struct megasas_cmd_fusion *r1_cmd)
31303277 {
31313278 union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc, *req_desc2 = NULL;
31323279 struct fusion_context *fusion;
....@@ -3150,9 +3297,9 @@
31503297 r1_cmd->request_desc->SCSIIO.DevHandle = cmd->r1_alt_dev_handle;
31513298 r1_cmd->io_request->DevHandle = cmd->r1_alt_dev_handle;
31523299 r1_cmd->r1_alt_dev_handle = cmd->io_request->DevHandle;
3153
- cmd->io_request->RaidContext.raid_context_g35.smid.peer_smid =
3300
+ cmd->io_request->RaidContext.raid_context_g35.flow_specific.peer_smid =
31543301 cpu_to_le16(r1_cmd->index);
3155
- r1_cmd->io_request->RaidContext.raid_context_g35.smid.peer_smid =
3302
+ r1_cmd->io_request->RaidContext.raid_context_g35.flow_specific.peer_smid =
31563303 cpu_to_le16(cmd->index);
31573304 /*MSIxIndex of both commands request descriptors should be same*/
31583305 r1_cmd->request_desc->SCSIIO.MSIxIndex =
....@@ -3175,9 +3322,6 @@
31753322 struct megasas_cmd_fusion *cmd, *r1_cmd = NULL;
31763323 union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc;
31773324 u32 index;
3178
- struct fusion_context *fusion;
3179
-
3180
- fusion = instance->ctrl_context;
31813325
31823326 if ((megasas_cmd_type(scmd) == READ_WRITE_LDIO) &&
31833327 instance->ldio_threshold &&
....@@ -3256,7 +3400,7 @@
32563400 * megasas_complete_r1_command -
32573401 * completes R1 FP write commands which has valid peer smid
32583402 * @instance: Adapter soft state
3259
- * @cmd_fusion: MPT command frame
3403
+ * @cmd: MPT command frame
32603404 *
32613405 */
32623406 static inline void
....@@ -3273,7 +3417,7 @@
32733417
32743418 rctx_g35 = &cmd->io_request->RaidContext.raid_context_g35;
32753419 fusion = instance->ctrl_context;
3276
- peer_smid = le16_to_cpu(rctx_g35->smid.peer_smid);
3420
+ peer_smid = le16_to_cpu(rctx_g35->flow_specific.peer_smid);
32773421
32783422 r1_cmd = fusion->cmd_list[peer_smid - 1];
32793423 scmd_local = cmd->scmd;
....@@ -3310,10 +3454,14 @@
33103454 /**
33113455 * complete_cmd_fusion - Completes command
33123456 * @instance: Adapter soft state
3457
+ * @MSIxIndex: MSI number
3458
+ * @irq_context: IRQ context
3459
+ *
33133460 * Completes all commands that is in reply descriptor queue
33143461 */
3315
-int
3316
-complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
3462
+static int
3463
+complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex,
3464
+ struct megasas_irq_context *irq_context)
33173465 {
33183466 union MPI2_REPLY_DESCRIPTORS_UNION *desc;
33193467 struct MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR *reply_desc;
....@@ -3386,7 +3534,7 @@
33863534 atomic_dec(&lbinfo->scsi_pending_cmds[cmd_fusion->pd_r1_lb]);
33873535 cmd_fusion->scmd->SCp.Status &= ~MEGASAS_LOAD_BALANCE_FLAG;
33883536 }
3389
- //Fall thru and complete IO
3537
+ fallthrough; /* and complete IO */
33903538 case MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST: /* LD-IO Path */
33913539 atomic_dec(&instance->fw_outstanding);
33923540 if (cmd_fusion->r1_alt_dev_handle == MR_DEVHANDLE_INVALID) {
....@@ -3446,7 +3594,7 @@
34463594 * number of reply counts and still there are more replies in reply queue
34473595 * pending to be completed
34483596 */
3449
- if (threshold_reply_count >= THRESHOLD_REPLY_COUNT) {
3597
+ if (threshold_reply_count >= instance->threshold_reply_count) {
34503598 if (instance->msix_combined)
34513599 writel(((MSIxIndex & 0x7) << 24) |
34523600 fusion->last_reply_idx[MSIxIndex],
....@@ -3456,127 +3604,173 @@
34563604 fusion->last_reply_idx[MSIxIndex],
34573605 instance->reply_post_host_index_addr[0]);
34583606 threshold_reply_count = 0;
3607
+ if (irq_context) {
3608
+ if (!irq_context->irq_poll_scheduled) {
3609
+ irq_context->irq_poll_scheduled = true;
3610
+ irq_context->irq_line_enable = true;
3611
+ irq_poll_sched(&irq_context->irqpoll);
3612
+ }
3613
+ return num_completed;
3614
+ }
34593615 }
34603616 }
34613617
3462
- if (!num_completed)
3463
- return IRQ_NONE;
3618
+ if (num_completed) {
3619
+ wmb();
3620
+ if (instance->msix_combined)
3621
+ writel(((MSIxIndex & 0x7) << 24) |
3622
+ fusion->last_reply_idx[MSIxIndex],
3623
+ instance->reply_post_host_index_addr[MSIxIndex/8]);
3624
+ else
3625
+ writel((MSIxIndex << 24) |
3626
+ fusion->last_reply_idx[MSIxIndex],
3627
+ instance->reply_post_host_index_addr[0]);
3628
+ megasas_check_and_restore_queue_depth(instance);
3629
+ }
3630
+ return num_completed;
3631
+}
34643632
3465
- wmb();
3466
- if (instance->msix_combined)
3467
- writel(((MSIxIndex & 0x7) << 24) |
3468
- fusion->last_reply_idx[MSIxIndex],
3469
- instance->reply_post_host_index_addr[MSIxIndex/8]);
3470
- else
3471
- writel((MSIxIndex << 24) |
3472
- fusion->last_reply_idx[MSIxIndex],
3473
- instance->reply_post_host_index_addr[0]);
3474
- megasas_check_and_restore_queue_depth(instance);
3475
- return IRQ_HANDLED;
3633
+/**
3634
+ * megasas_enable_irq_poll() - enable irqpoll
3635
+ * @instance: Adapter soft state
3636
+ */
3637
+static void megasas_enable_irq_poll(struct megasas_instance *instance)
3638
+{
3639
+ u32 count, i;
3640
+ struct megasas_irq_context *irq_ctx;
3641
+
3642
+ count = instance->msix_vectors > 0 ? instance->msix_vectors : 1;
3643
+
3644
+ for (i = 0; i < count; i++) {
3645
+ irq_ctx = &instance->irq_context[i];
3646
+ irq_poll_enable(&irq_ctx->irqpoll);
3647
+ }
34763648 }
34773649
34783650 /**
34793651 * megasas_sync_irqs - Synchronizes all IRQs owned by adapter
3480
- * @instance: Adapter soft state
3652
+ * @instance_addr: Adapter soft state address
34813653 */
3482
-void megasas_sync_irqs(unsigned long instance_addr)
3654
+static void megasas_sync_irqs(unsigned long instance_addr)
34833655 {
34843656 u32 count, i;
34853657 struct megasas_instance *instance =
34863658 (struct megasas_instance *)instance_addr;
3659
+ struct megasas_irq_context *irq_ctx;
34873660
34883661 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1;
34893662
3490
- for (i = 0; i < count; i++)
3663
+ for (i = 0; i < count; i++) {
34913664 synchronize_irq(pci_irq_vector(instance->pdev, i));
3665
+ irq_ctx = &instance->irq_context[i];
3666
+ irq_poll_disable(&irq_ctx->irqpoll);
3667
+ if (irq_ctx->irq_poll_scheduled) {
3668
+ irq_ctx->irq_poll_scheduled = false;
3669
+ enable_irq(irq_ctx->os_irq);
3670
+ complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx);
3671
+ }
3672
+ }
3673
+}
3674
+
3675
+/**
3676
+ * megasas_irqpoll() - process a queue for completed reply descriptors
3677
+ * @irqpoll: IRQ poll structure associated with queue to poll.
3678
+ * @budget: Threshold of reply descriptors to process per poll.
3679
+ *
3680
+ * Return: The number of entries processed.
3681
+ */
3682
+
3683
+int megasas_irqpoll(struct irq_poll *irqpoll, int budget)
3684
+{
3685
+ struct megasas_irq_context *irq_ctx;
3686
+ struct megasas_instance *instance;
3687
+ int num_entries;
3688
+
3689
+ irq_ctx = container_of(irqpoll, struct megasas_irq_context, irqpoll);
3690
+ instance = irq_ctx->instance;
3691
+
3692
+ if (irq_ctx->irq_line_enable) {
3693
+ disable_irq_nosync(irq_ctx->os_irq);
3694
+ irq_ctx->irq_line_enable = false;
3695
+ }
3696
+
3697
+ num_entries = complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx);
3698
+ if (num_entries < budget) {
3699
+ irq_poll_complete(irqpoll);
3700
+ irq_ctx->irq_poll_scheduled = false;
3701
+ enable_irq(irq_ctx->os_irq);
3702
+ complete_cmd_fusion(instance, irq_ctx->MSIxIndex, irq_ctx);
3703
+ }
3704
+
3705
+ return num_entries;
34923706 }
34933707
34943708 /**
34953709 * megasas_complete_cmd_dpc_fusion - Completes command
3496
- * @instance: Adapter soft state
3710
+ * @instance_addr: Adapter soft state address
34973711 *
34983712 * Tasklet to complete cmds
34993713 */
3500
-void
3714
+static void
35013715 megasas_complete_cmd_dpc_fusion(unsigned long instance_addr)
35023716 {
35033717 struct megasas_instance *instance =
35043718 (struct megasas_instance *)instance_addr;
3505
- unsigned long flags;
3719
+ struct megasas_irq_context *irq_ctx = NULL;
35063720 u32 count, MSIxIndex;
35073721
35083722 count = instance->msix_vectors > 0 ? instance->msix_vectors : 1;
35093723
35103724 /* If we have already declared adapter dead, donot complete cmds */
3511
- spin_lock_irqsave(&instance->hba_lock, flags);
3512
- if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
3513
- spin_unlock_irqrestore(&instance->hba_lock, flags);
3725
+ if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR)
35143726 return;
3515
- }
3516
- spin_unlock_irqrestore(&instance->hba_lock, flags);
35173727
3518
- for (MSIxIndex = 0 ; MSIxIndex < count; MSIxIndex++)
3519
- complete_cmd_fusion(instance, MSIxIndex);
3728
+ for (MSIxIndex = 0 ; MSIxIndex < count; MSIxIndex++) {
3729
+ irq_ctx = &instance->irq_context[MSIxIndex];
3730
+ complete_cmd_fusion(instance, MSIxIndex, irq_ctx);
3731
+ }
35203732 }
35213733
35223734 /**
35233735 * megasas_isr_fusion - isr entry point
3736
+ * @irq: IRQ number
3737
+ * @devp: IRQ context
35243738 */
3525
-irqreturn_t megasas_isr_fusion(int irq, void *devp)
3739
+static irqreturn_t megasas_isr_fusion(int irq, void *devp)
35263740 {
35273741 struct megasas_irq_context *irq_context = devp;
35283742 struct megasas_instance *instance = irq_context->instance;
3529
- u32 mfiStatus, fw_state, dma_state;
3743
+ u32 mfiStatus;
35303744
35313745 if (instance->mask_interrupts)
35323746 return IRQ_NONE;
35333747
3748
+ if (irq_context->irq_poll_scheduled)
3749
+ return IRQ_HANDLED;
3750
+
35343751 if (!instance->msix_vectors) {
3535
- mfiStatus = instance->instancet->clear_intr(instance->reg_set);
3752
+ mfiStatus = instance->instancet->clear_intr(instance);
35363753 if (!mfiStatus)
35373754 return IRQ_NONE;
35383755 }
35393756
35403757 /* If we are resetting, bail */
35413758 if (test_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags)) {
3542
- instance->instancet->clear_intr(instance->reg_set);
3759
+ instance->instancet->clear_intr(instance);
35433760 return IRQ_HANDLED;
35443761 }
35453762
3546
- if (!complete_cmd_fusion(instance, irq_context->MSIxIndex)) {
3547
- instance->instancet->clear_intr(instance->reg_set);
3548
- /* If we didn't complete any commands, check for FW fault */
3549
- fw_state = instance->instancet->read_fw_status_reg(
3550
- instance->reg_set) & MFI_STATE_MASK;
3551
- dma_state = instance->instancet->read_fw_status_reg
3552
- (instance->reg_set) & MFI_STATE_DMADONE;
3553
- if (instance->crash_dump_drv_support &&
3554
- instance->crash_dump_app_support) {
3555
- /* Start collecting crash, if DMA bit is done */
3556
- if ((fw_state == MFI_STATE_FAULT) && dma_state)
3557
- schedule_work(&instance->crash_init);
3558
- else if (fw_state == MFI_STATE_FAULT) {
3559
- if (instance->unload == 0)
3560
- schedule_work(&instance->work_init);
3561
- }
3562
- } else if (fw_state == MFI_STATE_FAULT) {
3563
- dev_warn(&instance->pdev->dev, "Iop2SysDoorbellInt"
3564
- "for scsi%d\n", instance->host->host_no);
3565
- if (instance->unload == 0)
3566
- schedule_work(&instance->work_init);
3567
- }
3568
- }
3569
-
3570
- return IRQ_HANDLED;
3763
+ return complete_cmd_fusion(instance, irq_context->MSIxIndex, irq_context)
3764
+ ? IRQ_HANDLED : IRQ_NONE;
35713765 }
35723766
35733767 /**
35743768 * build_mpt_mfi_pass_thru - builds a cmd fo MFI Pass thru
35753769 * @instance: Adapter soft state
3576
- * mfi_cmd: megasas_cmd pointer
3770
+ * @mfi_cmd: megasas_cmd pointer
35773771 *
35783772 */
3579
-void
3773
+static void
35803774 build_mpt_mfi_pass_thru(struct megasas_instance *instance,
35813775 struct megasas_cmd *mfi_cmd)
35823776 {
....@@ -3634,7 +3828,7 @@
36343828 * @cmd: mfi cmd to build
36353829 *
36363830 */
3637
-union MEGASAS_REQUEST_DESCRIPTOR_UNION *
3831
+static union MEGASAS_REQUEST_DESCRIPTOR_UNION *
36383832 build_mpt_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
36393833 {
36403834 union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc = NULL;
....@@ -3660,7 +3854,7 @@
36603854 * @cmd: mfi cmd pointer
36613855 *
36623856 */
3663
-void
3857
+static void
36643858 megasas_issue_dcmd_fusion(struct megasas_instance *instance,
36653859 struct megasas_cmd *cmd)
36663860 {
....@@ -3690,18 +3884,18 @@
36903884
36913885 /**
36923886 * megasas_read_fw_status_reg_fusion - returns the current FW status value
3693
- * @regs: MFI register set
3887
+ * @instance: Adapter soft state
36943888 */
36953889 static u32
3696
-megasas_read_fw_status_reg_fusion(struct megasas_register_set __iomem *regs)
3890
+megasas_read_fw_status_reg_fusion(struct megasas_instance *instance)
36973891 {
3698
- return readl(&(regs)->outbound_scratch_pad);
3892
+ return megasas_readl(instance, &instance->reg_set->outbound_scratch_pad_0);
36993893 }
37003894
37013895 /**
37023896 * megasas_alloc_host_crash_buffer - Host buffers for Crash dump collection from Firmware
37033897 * @instance: Controller's soft instance
3704
- * return: Number of allocated host crash buffers
3898
+ * @return: Number of allocated host crash buffers
37053899 */
37063900 static void
37073901 megasas_alloc_host_crash_buffer(struct megasas_instance *instance)
....@@ -3739,6 +3933,7 @@
37393933
37403934 /**
37413935 * megasas_adp_reset_fusion - For controller reset
3936
+ * @instance: Controller's soft instance
37423937 * @regs: MFI register set
37433938 */
37443939 static int
....@@ -3757,11 +3952,12 @@
37573952 writel(MPI2_WRSEQ_6TH_KEY_VALUE, &instance->reg_set->fusion_seq_offset);
37583953
37593954 /* Check that the diag write enable (DRWE) bit is on */
3760
- host_diag = readl(&instance->reg_set->fusion_host_diag);
3955
+ host_diag = megasas_readl(instance, &instance->reg_set->fusion_host_diag);
37613956 retry = 0;
37623957 while (!(host_diag & HOST_DIAG_WRITE_ENABLE)) {
37633958 msleep(100);
3764
- host_diag = readl(&instance->reg_set->fusion_host_diag);
3959
+ host_diag = megasas_readl(instance,
3960
+ &instance->reg_set->fusion_host_diag);
37653961 if (retry++ == 100) {
37663962 dev_warn(&instance->pdev->dev,
37673963 "Host diag unlock failed from %s %d\n",
....@@ -3778,11 +3974,12 @@
37783974 msleep(3000);
37793975
37803976 /* Make sure reset adapter bit is cleared */
3781
- host_diag = readl(&instance->reg_set->fusion_host_diag);
3977
+ host_diag = megasas_readl(instance, &instance->reg_set->fusion_host_diag);
37823978 retry = 0;
37833979 while (host_diag & HOST_DIAG_RESET_ADAPTER) {
37843980 msleep(100);
3785
- host_diag = readl(&instance->reg_set->fusion_host_diag);
3981
+ host_diag = megasas_readl(instance,
3982
+ &instance->reg_set->fusion_host_diag);
37863983 if (retry++ == 1000) {
37873984 dev_warn(&instance->pdev->dev,
37883985 "Diag reset adapter never cleared %s %d\n",
....@@ -3793,14 +3990,14 @@
37933990 if (host_diag & HOST_DIAG_RESET_ADAPTER)
37943991 return -1;
37953992
3796
- abs_state = instance->instancet->read_fw_status_reg(instance->reg_set)
3993
+ abs_state = instance->instancet->read_fw_status_reg(instance)
37973994 & MFI_STATE_MASK;
37983995 retry = 0;
37993996
38003997 while ((abs_state <= MFI_STATE_FW_INIT) && (retry++ < 1000)) {
38013998 msleep(100);
38023999 abs_state = instance->instancet->
3803
- read_fw_status_reg(instance->reg_set) & MFI_STATE_MASK;
4000
+ read_fw_status_reg(instance) & MFI_STATE_MASK;
38044001 }
38054002 if (abs_state <= MFI_STATE_FW_INIT) {
38064003 dev_warn(&instance->pdev->dev,
....@@ -3814,6 +4011,7 @@
38144011
38154012 /**
38164013 * megasas_check_reset_fusion - For controller reset check
4014
+ * @instance: Controller's soft instance
38174015 * @regs: MFI register set
38184016 */
38194017 static int
....@@ -3823,21 +4021,68 @@
38234021 return 0;
38244022 }
38254023
4024
+/**
4025
+ * megasas_trigger_snap_dump - Trigger snap dump in FW
4026
+ * @instance: Soft instance of adapter
4027
+ */
4028
+static inline void megasas_trigger_snap_dump(struct megasas_instance *instance)
4029
+{
4030
+ int j;
4031
+ u32 fw_state, abs_state;
4032
+
4033
+ if (!instance->disableOnlineCtrlReset) {
4034
+ dev_info(&instance->pdev->dev, "Trigger snap dump\n");
4035
+ writel(MFI_ADP_TRIGGER_SNAP_DUMP,
4036
+ &instance->reg_set->doorbell);
4037
+ readl(&instance->reg_set->doorbell);
4038
+ }
4039
+
4040
+ for (j = 0; j < instance->snapdump_wait_time; j++) {
4041
+ abs_state = instance->instancet->read_fw_status_reg(instance);
4042
+ fw_state = abs_state & MFI_STATE_MASK;
4043
+ if (fw_state == MFI_STATE_FAULT) {
4044
+ dev_printk(KERN_ERR, &instance->pdev->dev,
4045
+ "FW in FAULT state Fault code:0x%x subcode:0x%x func:%s\n",
4046
+ abs_state & MFI_STATE_FAULT_CODE,
4047
+ abs_state & MFI_STATE_FAULT_SUBCODE, __func__);
4048
+ return;
4049
+ }
4050
+ msleep(1000);
4051
+ }
4052
+}
4053
+
38264054 /* This function waits for outstanding commands on fusion to complete */
3827
-int megasas_wait_for_outstanding_fusion(struct megasas_instance *instance,
3828
- int reason, int *convert)
4055
+static int
4056
+megasas_wait_for_outstanding_fusion(struct megasas_instance *instance,
4057
+ int reason, int *convert)
38294058 {
38304059 int i, outstanding, retval = 0, hb_seconds_missed = 0;
3831
- u32 fw_state;
4060
+ u32 fw_state, abs_state;
4061
+ u32 waittime_for_io_completion;
38324062
3833
- for (i = 0; i < resetwaittime; i++) {
4063
+ waittime_for_io_completion =
4064
+ min_t(u32, resetwaittime,
4065
+ (resetwaittime - instance->snapdump_wait_time));
4066
+
4067
+ if (reason == MFI_IO_TIMEOUT_OCR) {
4068
+ dev_info(&instance->pdev->dev,
4069
+ "MFI command is timed out\n");
4070
+ megasas_complete_cmd_dpc_fusion((unsigned long)instance);
4071
+ if (instance->snapdump_wait_time)
4072
+ megasas_trigger_snap_dump(instance);
4073
+ retval = 1;
4074
+ goto out;
4075
+ }
4076
+
4077
+ for (i = 0; i < waittime_for_io_completion; i++) {
38344078 /* Check if firmware is in fault state */
3835
- fw_state = instance->instancet->read_fw_status_reg(
3836
- instance->reg_set) & MFI_STATE_MASK;
4079
+ abs_state = instance->instancet->read_fw_status_reg(instance);
4080
+ fw_state = abs_state & MFI_STATE_MASK;
38374081 if (fw_state == MFI_STATE_FAULT) {
3838
- dev_warn(&instance->pdev->dev, "Found FW in FAULT state,"
3839
- " will reset adapter scsi%d.\n",
3840
- instance->host->host_no);
4082
+ dev_printk(KERN_ERR, &instance->pdev->dev,
4083
+ "FW in FAULT state Fault code:0x%x subcode:0x%x func:%s\n",
4084
+ abs_state & MFI_STATE_FAULT_CODE,
4085
+ abs_state & MFI_STATE_FAULT_SUBCODE, __func__);
38414086 megasas_complete_cmd_dpc_fusion((unsigned long)instance);
38424087 if (instance->requestorId && reason) {
38434088 dev_warn(&instance->pdev->dev, "SR-IOV Found FW in FAULT"
....@@ -3851,13 +4096,6 @@
38514096 goto out;
38524097 }
38534098
3854
- if (reason == MFI_IO_TIMEOUT_OCR) {
3855
- dev_info(&instance->pdev->dev,
3856
- "MFI IO is timed out, initiating OCR\n");
3857
- megasas_complete_cmd_dpc_fusion((unsigned long)instance);
3858
- retval = 1;
3859
- goto out;
3860
- }
38614099
38624100 /* If SR-IOV VF mode & heartbeat timeout, don't wait */
38634101 if (instance->requestorId && !reason) {
....@@ -3902,6 +4140,12 @@
39024140 msleep(1000);
39034141 }
39044142
4143
+ if (instance->snapdump_wait_time) {
4144
+ megasas_trigger_snap_dump(instance);
4145
+ retval = 1;
4146
+ goto out;
4147
+ }
4148
+
39054149 if (atomic_read(&instance->fw_outstanding)) {
39064150 dev_err(&instance->pdev->dev, "pending commands remain after waiting, "
39074151 "will reset adapter scsi%d.\n",
....@@ -3909,6 +4153,7 @@
39094153 *convert = 1;
39104154 retval = 1;
39114155 }
4156
+
39124157 out:
39134158 return retval;
39144159 }
....@@ -3933,7 +4178,8 @@
39334178 * megasas_refire_mgmt_cmd : Re-fire management commands
39344179 * @instance: Controller's soft instance
39354180 */
3936
-void megasas_refire_mgmt_cmd(struct megasas_instance *instance)
4181
+static void megasas_refire_mgmt_cmd(struct megasas_instance *instance,
4182
+ bool return_ioctl)
39374183 {
39384184 int j;
39394185 struct megasas_cmd_fusion *cmd_fusion;
....@@ -3942,7 +4188,7 @@
39424188 union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc;
39434189 struct MPI2_RAID_SCSI_IO_REQUEST *scsi_io_req;
39444190 u16 smid;
3945
- bool refire_cmd = 0;
4191
+ bool refire_cmd = false;
39464192 u8 result;
39474193 u32 opcode = 0;
39484194
....@@ -3987,8 +4233,25 @@
39874233 }
39884234
39894235 break;
4236
+ case MFI_CMD_TOOLBOX:
4237
+ if (!instance->support_pci_lane_margining) {
4238
+ cmd_mfi->frame->hdr.cmd_status = MFI_STAT_INVALID_CMD;
4239
+ result = COMPLETE_CMD;
4240
+ }
4241
+
4242
+ break;
39904243 default:
39914244 break;
4245
+ }
4246
+
4247
+ if (return_ioctl && cmd_mfi->sync_cmd &&
4248
+ cmd_mfi->frame->hdr.cmd != MFI_CMD_ABORT) {
4249
+ dev_err(&instance->pdev->dev,
4250
+ "return -EBUSY from %s %d cmd 0x%x opcode 0x%x\n",
4251
+ __func__, __LINE__, cmd_mfi->frame->hdr.cmd,
4252
+ le32_to_cpu(cmd_mfi->frame->dcmd.opcode));
4253
+ cmd_mfi->cmd_status_drv = DCMD_BUSY;
4254
+ result = COMPLETE_CMD;
39924255 }
39934256
39944257 scsi_io_req = (struct MPI2_RAID_SCSI_IO_REQUEST *)
....@@ -4006,6 +4269,37 @@
40064269 case COMPLETE_CMD:
40074270 megasas_complete_cmd(instance, cmd_mfi, DID_OK);
40084271 break;
4272
+ }
4273
+ }
4274
+}
4275
+
4276
+/*
4277
+ * megasas_return_polled_cmds: Return polled mode commands back to the pool
4278
+ * before initiating an OCR.
4279
+ * @instance: Controller's soft instance
4280
+ */
4281
+static void
4282
+megasas_return_polled_cmds(struct megasas_instance *instance)
4283
+{
4284
+ int i;
4285
+ struct megasas_cmd_fusion *cmd_fusion;
4286
+ struct fusion_context *fusion;
4287
+ struct megasas_cmd *cmd_mfi;
4288
+
4289
+ fusion = instance->ctrl_context;
4290
+
4291
+ for (i = instance->max_scsi_cmds; i < instance->max_fw_cmds; i++) {
4292
+ cmd_fusion = fusion->cmd_list[i];
4293
+ cmd_mfi = instance->cmd_list[cmd_fusion->sync_cmd_idx];
4294
+
4295
+ if (cmd_mfi->flags & DRV_DCMD_POLLED_MODE) {
4296
+ if (megasas_dbg_lvl & OCR_DEBUG)
4297
+ dev_info(&instance->pdev->dev,
4298
+ "%s %d return cmd 0x%x opcode 0x%x\n",
4299
+ __func__, __LINE__, cmd_mfi->frame->hdr.cmd,
4300
+ le32_to_cpu(cmd_mfi->frame->dcmd.opcode));
4301
+ cmd_mfi->flags &= ~DRV_DCMD_POLLED_MODE;
4302
+ megasas_return_cmd(instance, cmd_mfi);
40094303 }
40104304 }
40114305 }
....@@ -4047,8 +4341,8 @@
40474341
40484342 /**
40494343 * megasas_tm_response_code - translation of device response code
4050
- * @ioc: per adapter object
4051
- * @mpi_reply: MPI reply returned by firmware
4344
+ * @instance: Controller's soft instance
4345
+ * @mpi_reply: MPI reply returned by firmware
40524346 *
40534347 * Return nothing.
40544348 */
....@@ -4103,9 +4397,9 @@
41034397 * @device_handle: device handle
41044398 * @channel: the channel assigned by the OS
41054399 * @id: the id assigned by the OS
4106
- * @type: MPI2_SCSITASKMGMT_TASKTYPE__XXX (defined in megaraid_sas_fusion.c)
41074400 * @smid_task: smid assigned to the task
4108
- * @m_type: TM_MUTEX_ON or TM_MUTEX_OFF
4401
+ * @type: MPI2_SCSITASKMGMT_TASKTYPE__XXX (defined in megaraid_sas_fusion.c)
4402
+ * @mr_device_priv_data: private data
41094403 * Context: user
41104404 *
41114405 * MegaRaid use MPT interface for Task Magement request.
....@@ -4214,6 +4508,7 @@
42144508 instance->instancet->disable_intr(instance);
42154509 megasas_sync_irqs((unsigned long)instance);
42164510 instance->instancet->enable_intr(instance);
4511
+ megasas_enable_irq_poll(instance);
42174512 if (scsi_lookup->scmd == NULL)
42184513 break;
42194514 }
....@@ -4227,6 +4522,7 @@
42274522 megasas_sync_irqs((unsigned long)instance);
42284523 rc = megasas_track_scsiio(instance, id, channel);
42294524 instance->instancet->enable_intr(instance);
4525
+ megasas_enable_irq_poll(instance);
42304526
42314527 break;
42324528 case MPI2_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET:
....@@ -4319,17 +4615,11 @@
43194615 {
43204616 struct megasas_instance *instance;
43214617 u16 smid, devhandle;
4322
- struct fusion_context *fusion;
43234618 int ret;
43244619 struct MR_PRIV_DEVICE *mr_device_priv_data;
43254620 mr_device_priv_data = scmd->device->hostdata;
43264621
4327
-
43284622 instance = (struct megasas_instance *)scmd->device->host->hostdata;
4329
- fusion = instance->ctrl_context;
4330
-
4331
- scmd_printk(KERN_INFO, scmd, "task abort called for scmd(%p)\n", scmd);
4332
- scsi_print_command(scmd);
43334623
43344624 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
43354625 dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL,"
....@@ -4346,7 +4636,6 @@
43464636 goto out;
43474637 }
43484638
4349
-
43504639 if (!mr_device_priv_data->is_tm_capable) {
43514640 ret = FAILED;
43524641 goto out;
....@@ -4359,7 +4648,7 @@
43594648 if (!smid) {
43604649 ret = SUCCESS;
43614650 scmd_printk(KERN_NOTICE, scmd, "Command for which abort is"
4362
- " issued is not found in oustanding commands\n");
4651
+ " issued is not found in outstanding commands\n");
43634652 mutex_unlock(&instance->reset_mutex);
43644653 goto out;
43654654 }
....@@ -4374,20 +4663,23 @@
43744663 goto out;
43754664 }
43764665 sdev_printk(KERN_INFO, scmd->device,
4377
- "attempting task abort! scmd(%p) tm_dev_handle 0x%x\n",
4666
+ "attempting task abort! scmd(0x%p) tm_dev_handle 0x%x\n",
43784667 scmd, devhandle);
43794668
4380
- mr_device_priv_data->tm_busy = 1;
4669
+ mr_device_priv_data->tm_busy = true;
43814670 ret = megasas_issue_tm(instance, devhandle,
43824671 scmd->device->channel, scmd->device->id, smid,
43834672 MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK,
43844673 mr_device_priv_data);
4385
- mr_device_priv_data->tm_busy = 0;
4674
+ mr_device_priv_data->tm_busy = false;
43864675
43874676 mutex_unlock(&instance->reset_mutex);
4388
-out:
4389
- sdev_printk(KERN_INFO, scmd->device, "task abort: %s scmd(%p)\n",
4677
+ scmd_printk(KERN_INFO, scmd, "task abort %s!! scmd(0x%p)\n",
43904678 ((ret == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
4679
+out:
4680
+ scsi_print_command(scmd);
4681
+ if (megasas_dbg_lvl & TM_DEBUG)
4682
+ megasas_dump_fusion_io(scmd);
43914683
43924684 return ret;
43934685 }
....@@ -4405,15 +4697,10 @@
44054697 struct megasas_instance *instance;
44064698 int ret = FAILED;
44074699 u16 devhandle;
4408
- struct fusion_context *fusion;
44094700 struct MR_PRIV_DEVICE *mr_device_priv_data;
44104701 mr_device_priv_data = scmd->device->hostdata;
44114702
44124703 instance = (struct megasas_instance *)scmd->device->host->hostdata;
4413
- fusion = instance->ctrl_context;
4414
-
4415
- sdev_printk(KERN_INFO, scmd->device,
4416
- "target reset called for scmd(%p)\n", scmd);
44174704
44184705 if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
44194706 dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL,"
....@@ -4423,13 +4710,12 @@
44234710 }
44244711
44254712 if (!mr_device_priv_data) {
4426
- sdev_printk(KERN_INFO, scmd->device, "device been deleted! "
4427
- "scmd(%p)\n", scmd);
4713
+ sdev_printk(KERN_INFO, scmd->device,
4714
+ "device been deleted! scmd: (0x%p)\n", scmd);
44284715 scmd->result = DID_NO_CONNECT << 16;
44294716 ret = SUCCESS;
44304717 goto out;
44314718 }
4432
-
44334719
44344720 if (!mr_device_priv_data->is_tm_capable) {
44354721 ret = FAILED;
....@@ -4448,24 +4734,25 @@
44484734 }
44494735
44504736 sdev_printk(KERN_INFO, scmd->device,
4451
- "attempting target reset! scmd(%p) tm_dev_handle 0x%x\n",
4737
+ "attempting target reset! scmd(0x%p) tm_dev_handle: 0x%x\n",
44524738 scmd, devhandle);
4453
- mr_device_priv_data->tm_busy = 1;
4739
+ mr_device_priv_data->tm_busy = true;
44544740 ret = megasas_issue_tm(instance, devhandle,
44554741 scmd->device->channel, scmd->device->id, 0,
44564742 MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
44574743 mr_device_priv_data);
4458
- mr_device_priv_data->tm_busy = 0;
4744
+ mr_device_priv_data->tm_busy = false;
44594745 mutex_unlock(&instance->reset_mutex);
4460
-out:
4461
- scmd_printk(KERN_NOTICE, scmd, "megasas: target reset %s!!\n",
4746
+ scmd_printk(KERN_NOTICE, scmd, "target reset %s!!\n",
44624747 (ret == SUCCESS) ? "SUCCESS" : "FAILED");
44634748
4749
+out:
44644750 return ret;
44654751 }
44664752
44674753 /*SRIOV get other instance in cluster if any*/
4468
-struct megasas_instance *megasas_get_peer_instance(struct megasas_instance *instance)
4754
+static struct
4755
+megasas_instance *megasas_get_peer_instance(struct megasas_instance *instance)
44694756 {
44704757 int i;
44714758
....@@ -4505,12 +4792,14 @@
45054792 struct megasas_instance *instance;
45064793 struct megasas_cmd_fusion *cmd_fusion, *r1_cmd;
45074794 struct fusion_context *fusion;
4508
- u32 abs_state, status_reg, reset_adapter;
4795
+ u32 abs_state, status_reg, reset_adapter, fpio_count = 0;
45094796 u32 io_timeout_in_crash_mode = 0;
45104797 struct scsi_cmnd *scmd_local = NULL;
45114798 struct scsi_device *sdev;
45124799 int ret_target_prop = DCMD_FAILED;
45134800 bool is_target_prop = false;
4801
+ bool do_adp_reset = true;
4802
+ int max_reset_tries = MEGASAS_FUSION_MAX_RESET_TRIES;
45144803
45154804 instance = (struct megasas_instance *)shost->hostdata;
45164805 fusion = instance->ctrl_context;
....@@ -4524,7 +4813,7 @@
45244813 mutex_unlock(&instance->reset_mutex);
45254814 return FAILED;
45264815 }
4527
- status_reg = instance->instancet->read_fw_status_reg(instance->reg_set);
4816
+ status_reg = instance->instancet->read_fw_status_reg(instance);
45284817 abs_state = status_reg & MFI_STATE_MASK;
45294818
45304819 /* IO timeout detected, forcibly put FW in FAULT state */
....@@ -4533,7 +4822,7 @@
45334822 dev_info(&instance->pdev->dev, "IO/DCMD timeout is detected, "
45344823 "forcibly FAULT Firmware\n");
45354824 atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT);
4536
- status_reg = readl(&instance->reg_set->doorbell);
4825
+ status_reg = megasas_readl(instance, &instance->reg_set->doorbell);
45374826 writel(status_reg | MFI_STATE_FORCE_OCR,
45384827 &instance->reg_set->doorbell);
45394828 readl(&instance->reg_set->doorbell);
....@@ -4578,25 +4867,29 @@
45784867 if (convert)
45794868 reason = 0;
45804869
4581
- if (megasas_dbg_lvl & OCR_LOGS)
4870
+ if (megasas_dbg_lvl & OCR_DEBUG)
45824871 dev_info(&instance->pdev->dev, "\nPending SCSI commands:\n");
45834872
45844873 /* Now return commands back to the OS */
45854874 for (i = 0 ; i < instance->max_scsi_cmds; i++) {
45864875 cmd_fusion = fusion->cmd_list[i];
45874876 /*check for extra commands issued by driver*/
4588
- if (instance->adapter_type == VENTURA_SERIES) {
4877
+ if (instance->adapter_type >= VENTURA_SERIES) {
45894878 r1_cmd = fusion->cmd_list[i + instance->max_fw_cmds];
45904879 megasas_return_cmd_fusion(instance, r1_cmd);
45914880 }
45924881 scmd_local = cmd_fusion->scmd;
45934882 if (cmd_fusion->scmd) {
4594
- if (megasas_dbg_lvl & OCR_LOGS) {
4883
+ if (megasas_dbg_lvl & OCR_DEBUG) {
45954884 sdev_printk(KERN_INFO,
45964885 cmd_fusion->scmd->device, "SMID: 0x%x\n",
45974886 cmd_fusion->index);
4598
- scsi_print_command(cmd_fusion->scmd);
4887
+ megasas_dump_fusion_io(cmd_fusion->scmd);
45994888 }
4889
+
4890
+ if (cmd_fusion->io_request->Function ==
4891
+ MPI2_FUNCTION_SCSI_IO_REQUEST)
4892
+ fpio_count++;
46004893
46014894 scmd_local->result =
46024895 megasas_check_mpio_paths(instance,
....@@ -4610,10 +4903,12 @@
46104903 }
46114904 }
46124905
4906
+ dev_info(&instance->pdev->dev, "Outstanding fastpath IOs: %d\n",
4907
+ fpio_count);
4908
+
46134909 atomic_set(&instance->fw_outstanding, 0);
46144910
4615
- status_reg = instance->instancet->read_fw_status_reg(
4616
- instance->reg_set);
4911
+ status_reg = instance->instancet->read_fw_status_reg(instance);
46174912 abs_state = status_reg & MFI_STATE_MASK;
46184913 reset_adapter = status_reg & MFI_RESET_ADAPTER;
46194914 if (instance->disableOnlineCtrlReset ||
....@@ -4622,55 +4917,50 @@
46224917 dev_warn(&instance->pdev->dev, "Reset not supported"
46234918 ", killing adapter scsi%d.\n",
46244919 instance->host->host_no);
4625
- megaraid_sas_kill_hba(instance);
4626
- instance->skip_heartbeat_timer_del = 1;
4627
- retval = FAILED;
4628
- goto out;
4920
+ goto kill_hba;
46294921 }
46304922
46314923 /* Let SR-IOV VF & PF sync up if there was a HB failure */
46324924 if (instance->requestorId && !reason) {
46334925 msleep(MEGASAS_OCR_SETTLE_TIME_VF);
4634
- goto transition_to_ready;
4926
+ do_adp_reset = false;
4927
+ max_reset_tries = MEGASAS_SRIOV_MAX_RESET_TRIES_VF;
46354928 }
46364929
46374930 /* Now try to reset the chip */
4638
- for (i = 0; i < MEGASAS_FUSION_MAX_RESET_TRIES; i++) {
4639
-
4640
- if (instance->instancet->adp_reset
4641
- (instance, instance->reg_set))
4931
+ for (i = 0; i < max_reset_tries; i++) {
4932
+ /*
4933
+ * Do adp reset and wait for
4934
+ * controller to transition to ready
4935
+ */
4936
+ if (megasas_adp_reset_wait_for_ready(instance,
4937
+ do_adp_reset, 1) == FAILED)
46424938 continue;
4643
-transition_to_ready:
4939
+
46444940 /* Wait for FW to become ready */
46454941 if (megasas_transition_to_ready(instance, 1)) {
46464942 dev_warn(&instance->pdev->dev,
46474943 "Failed to transition controller to ready for "
46484944 "scsi%d.\n", instance->host->host_no);
4649
- if (instance->requestorId && !reason)
4650
- goto fail_kill_adapter;
4651
- else
4652
- continue;
4945
+ continue;
46534946 }
46544947 megasas_reset_reply_desc(instance);
46554948 megasas_fusion_update_can_queue(instance, OCR_CONTEXT);
46564949
46574950 if (megasas_ioc_init_fusion(instance)) {
4658
- if (instance->requestorId && !reason)
4659
- goto fail_kill_adapter;
4660
- else
4661
- continue;
4951
+ continue;
46624952 }
46634953
46644954 if (megasas_get_ctrl_info(instance)) {
46654955 dev_info(&instance->pdev->dev,
46664956 "Failed from %s %d\n",
46674957 __func__, __LINE__);
4668
- megaraid_sas_kill_hba(instance);
4669
- retval = FAILED;
4670
- goto out;
4958
+ goto kill_hba;
46714959 }
46724960
4673
- megasas_refire_mgmt_cmd(instance);
4961
+ megasas_refire_mgmt_cmd(instance,
4962
+ (i == (MEGASAS_FUSION_MAX_RESET_TRIES - 1)
4963
+ ? 1 : 0));
46744964
46754965 /* Reset load balance info */
46764966 if (fusion->load_balance_info)
....@@ -4678,13 +4968,21 @@
46784968 (sizeof(struct LD_LOAD_BALANCE_INFO) *
46794969 MAX_LOGICAL_DRIVES_EXT));
46804970
4681
- if (!megasas_get_map_info(instance))
4971
+ if (!megasas_get_map_info(instance)) {
46824972 megasas_sync_map_info(instance);
4973
+ } else {
4974
+ /*
4975
+ * Return pending polled mode cmds before
4976
+ * retrying OCR
4977
+ */
4978
+ megasas_return_polled_cmds(instance);
4979
+ continue;
4980
+ }
46834981
46844982 megasas_setup_jbod_map(instance);
46854983
46864984 /* reset stream detection array */
4687
- if (instance->adapter_type == VENTURA_SERIES) {
4985
+ if (instance->adapter_type >= VENTURA_SERIES) {
46884986 for (j = 0; j < MAX_LOGICAL_DRIVES_EXT; ++j) {
46894987 memset(fusion->stream_detect_by_ld[j],
46904988 0, sizeof(struct LD_STREAM_DETECT));
....@@ -4696,7 +4994,7 @@
46964994 clear_bit(MEGASAS_FUSION_IN_RESET,
46974995 &instance->reset_flags);
46984996 instance->instancet->enable_intr(instance);
4699
-
4997
+ megasas_enable_irq_poll(instance);
47004998 shost_for_each_device(sdev, shost) {
47014999 if ((instance->tgt_prop) &&
47025000 (instance->nvme_page_size))
....@@ -4706,11 +5004,20 @@
47065004 megasas_set_dynamic_target_properties(sdev, is_target_prop);
47075005 }
47085006
5007
+ status_reg = instance->instancet->read_fw_status_reg
5008
+ (instance);
5009
+ abs_state = status_reg & MFI_STATE_MASK;
5010
+ if (abs_state != MFI_STATE_OPERATIONAL) {
5011
+ dev_info(&instance->pdev->dev,
5012
+ "Adapter is not OPERATIONAL, state 0x%x for scsi:%d\n",
5013
+ abs_state, instance->host->host_no);
5014
+ goto out;
5015
+ }
47095016 atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL);
47105017
4711
- dev_info(&instance->pdev->dev, "Interrupts are enabled and"
4712
- " controller is OPERATIONAL for scsi:%d\n",
4713
- instance->host->host_no);
5018
+ dev_info(&instance->pdev->dev,
5019
+ "Adapter is OPERATIONAL for scsi:%d\n",
5020
+ instance->host->host_no);
47145021
47155022 /* Restart SR-IOV heartbeat */
47165023 if (instance->requestorId) {
....@@ -4728,6 +5035,13 @@
47285035 megasas_set_crash_dump_params(instance,
47295036 MR_CRASH_BUF_TURN_OFF);
47305037
5038
+ if (instance->snapdump_wait_time) {
5039
+ megasas_get_snapdump_properties(instance);
5040
+ dev_info(&instance->pdev->dev,
5041
+ "Snap dump wait time\t: %d\n",
5042
+ instance->snapdump_wait_time);
5043
+ }
5044
+
47315045 retval = SUCCESS;
47325046
47335047 /* Adapter reset completed successfully */
....@@ -4737,13 +5051,10 @@
47375051
47385052 goto out;
47395053 }
4740
-fail_kill_adapter:
47415054 /* Reset failed, kill the adapter */
47425055 dev_warn(&instance->pdev->dev, "Reset failed, killing "
47435056 "adapter scsi%d.\n", instance->host->host_no);
4744
- megaraid_sas_kill_hba(instance);
4745
- instance->skip_heartbeat_timer_del = 1;
4746
- retval = FAILED;
5057
+ goto kill_hba;
47475058 } else {
47485059 /* For VF: Restart HB timer if we didn't OCR */
47495060 if (instance->requestorId) {
....@@ -4751,24 +5062,30 @@
47515062 }
47525063 clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags);
47535064 instance->instancet->enable_intr(instance);
5065
+ megasas_enable_irq_poll(instance);
47545066 atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL);
5067
+ goto out;
47555068 }
5069
+kill_hba:
5070
+ megaraid_sas_kill_hba(instance);
5071
+ megasas_enable_irq_poll(instance);
5072
+ instance->skip_heartbeat_timer_del = 1;
5073
+ retval = FAILED;
47565074 out:
47575075 clear_bit(MEGASAS_FUSION_OCR_NOT_POSSIBLE, &instance->reset_flags);
47585076 mutex_unlock(&instance->reset_mutex);
47595077 return retval;
47605078 }
47615079
4762
-/* Fusion Crash dump collection work queue */
4763
-void megasas_fusion_crash_dump_wq(struct work_struct *work)
5080
+/* Fusion Crash dump collection */
5081
+static void megasas_fusion_crash_dump(struct megasas_instance *instance)
47645082 {
4765
- struct megasas_instance *instance =
4766
- container_of(work, struct megasas_instance, crash_init);
47675083 u32 status_reg;
47685084 u8 partial_copy = 0;
5085
+ int wait = 0;
47695086
47705087
4771
- status_reg = instance->instancet->read_fw_status_reg(instance->reg_set);
5088
+ status_reg = instance->instancet->read_fw_status_reg(instance);
47725089
47735090 /*
47745091 * Allocate host crash buffers to copy data from 1 MB DMA crash buffer
....@@ -4784,8 +5101,8 @@
47845101 "crash dump and initiating OCR\n");
47855102 status_reg |= MFI_STATE_CRASH_DUMP_DONE;
47865103 writel(status_reg,
4787
- &instance->reg_set->outbound_scratch_pad);
4788
- readl(&instance->reg_set->outbound_scratch_pad);
5104
+ &instance->reg_set->outbound_scratch_pad_0);
5105
+ readl(&instance->reg_set->outbound_scratch_pad_0);
47895106 return;
47905107 }
47915108 megasas_alloc_host_crash_buffer(instance);
....@@ -4793,21 +5110,41 @@
47935110 "allocated: %d\n", instance->drv_buf_alloc);
47945111 }
47955112
4796
- /*
4797
- * Driver has allocated max buffers, which can be allocated
4798
- * and FW has more crash dump data, then driver will
4799
- * ignore the data.
4800
- */
4801
- if (instance->drv_buf_index >= (instance->drv_buf_alloc)) {
4802
- dev_info(&instance->pdev->dev, "Driver is done copying "
4803
- "the buffer: %d\n", instance->drv_buf_alloc);
4804
- status_reg |= MFI_STATE_CRASH_DUMP_DONE;
4805
- partial_copy = 1;
4806
- } else {
4807
- memcpy(instance->crash_buf[instance->drv_buf_index],
4808
- instance->crash_dump_buf, CRASH_DMA_BUF_SIZE);
4809
- instance->drv_buf_index++;
4810
- status_reg &= ~MFI_STATE_DMADONE;
5113
+ while (!(status_reg & MFI_STATE_CRASH_DUMP_DONE) &&
5114
+ (wait < MEGASAS_WATCHDOG_WAIT_COUNT)) {
5115
+ if (!(status_reg & MFI_STATE_DMADONE)) {
5116
+ /*
5117
+ * Next crash dump buffer is not yet DMA'd by FW
5118
+ * Check after 10ms. Wait for 1 second for FW to
5119
+ * post the next buffer. If not bail out.
5120
+ */
5121
+ wait++;
5122
+ msleep(MEGASAS_WAIT_FOR_NEXT_DMA_MSECS);
5123
+ status_reg = instance->instancet->read_fw_status_reg(
5124
+ instance);
5125
+ continue;
5126
+ }
5127
+
5128
+ wait = 0;
5129
+ if (instance->drv_buf_index >= instance->drv_buf_alloc) {
5130
+ dev_info(&instance->pdev->dev,
5131
+ "Driver is done copying the buffer: %d\n",
5132
+ instance->drv_buf_alloc);
5133
+ status_reg |= MFI_STATE_CRASH_DUMP_DONE;
5134
+ partial_copy = 1;
5135
+ break;
5136
+ } else {
5137
+ memcpy(instance->crash_buf[instance->drv_buf_index],
5138
+ instance->crash_dump_buf, CRASH_DMA_BUF_SIZE);
5139
+ instance->drv_buf_index++;
5140
+ status_reg &= ~MFI_STATE_DMADONE;
5141
+ }
5142
+
5143
+ writel(status_reg, &instance->reg_set->outbound_scratch_pad_0);
5144
+ readl(&instance->reg_set->outbound_scratch_pad_0);
5145
+
5146
+ msleep(MEGASAS_WAIT_FOR_NEXT_DMA_MSECS);
5147
+ status_reg = instance->instancet->read_fw_status_reg(instance);
48115148 }
48125149
48135150 if (status_reg & MFI_STATE_CRASH_DUMP_DONE) {
....@@ -4816,13 +5153,10 @@
48165153 instance->fw_crash_buffer_size = instance->drv_buf_index;
48175154 instance->fw_crash_state = AVAILABLE;
48185155 instance->drv_buf_index = 0;
4819
- writel(status_reg, &instance->reg_set->outbound_scratch_pad);
4820
- readl(&instance->reg_set->outbound_scratch_pad);
5156
+ writel(status_reg, &instance->reg_set->outbound_scratch_pad_0);
5157
+ readl(&instance->reg_set->outbound_scratch_pad_0);
48215158 if (!partial_copy)
48225159 megasas_reset_fusion(instance->host, 0);
4823
- } else {
4824
- writel(status_reg, &instance->reg_set->outbound_scratch_pad);
4825
- readl(&instance->reg_set->outbound_scratch_pad);
48265160 }
48275161 }
48285162