aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/megaraid/megaraid_sas_base.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/megaraid/megaraid_sas_base.c')
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_base.c466
1 files changed, 318 insertions, 148 deletions
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index eaa81e552fd2..97a1c1c33b05 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -135,6 +135,12 @@ static struct pci_device_id megasas_pci_table[] = {
135 /* Invader */ 135 /* Invader */
136 {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FURY)}, 136 {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_FURY)},
137 /* Fury */ 137 /* Fury */
138 {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_INTRUDER)},
139 /* Intruder */
140 {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_INTRUDER_24)},
141 /* Intruder 24 port*/
142 {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_CUTLASS_52)},
143 {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_CUTLASS_53)},
138 {} 144 {}
139}; 145};
140 146
@@ -260,6 +266,66 @@ megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd)
260 266
261} 267}
262 268
269static const char *
270format_timestamp(uint32_t timestamp)
271{
272 static char buffer[32];
273
274 if ((timestamp & 0xff000000) == 0xff000000)
275 snprintf(buffer, sizeof(buffer), "boot + %us", timestamp &
276 0x00ffffff);
277 else
278 snprintf(buffer, sizeof(buffer), "%us", timestamp);
279 return buffer;
280}
281
282static const char *
283format_class(int8_t class)
284{
285 static char buffer[6];
286
287 switch (class) {
288 case MFI_EVT_CLASS_DEBUG:
289 return "debug";
290 case MFI_EVT_CLASS_PROGRESS:
291 return "progress";
292 case MFI_EVT_CLASS_INFO:
293 return "info";
294 case MFI_EVT_CLASS_WARNING:
295 return "WARN";
296 case MFI_EVT_CLASS_CRITICAL:
297 return "CRIT";
298 case MFI_EVT_CLASS_FATAL:
299 return "FATAL";
300 case MFI_EVT_CLASS_DEAD:
301 return "DEAD";
302 default:
303 snprintf(buffer, sizeof(buffer), "%d", class);
304 return buffer;
305 }
306}
307
308/**
309 * megasas_decode_evt: Decode FW AEN event and print critical event
310 * for information.
311 * @instance: Adapter soft state
312 */
313static void
314megasas_decode_evt(struct megasas_instance *instance)
315{
316 struct megasas_evt_detail *evt_detail = instance->evt_detail;
317 union megasas_evt_class_locale class_locale;
318 class_locale.word = le32_to_cpu(evt_detail->cl.word);
319
320 if (class_locale.members.class >= MFI_EVT_CLASS_CRITICAL)
321 dev_info(&instance->pdev->dev, "%d (%s/0x%04x/%s) - %s\n",
322 le32_to_cpu(evt_detail->seq_num),
323 format_timestamp(le32_to_cpu(evt_detail->time_stamp)),
324 (class_locale.members.locale),
325 format_class(class_locale.members.class),
326 evt_detail->description);
327}
328
263/** 329/**
264* The following functions are defined for xscale 330* The following functions are defined for xscale
265* (deviceid : 1064R, PERC5) controllers 331* (deviceid : 1064R, PERC5) controllers
@@ -1659,8 +1725,56 @@ static struct megasas_instance *megasas_lookup_instance(u16 host_no)
1659 return NULL; 1725 return NULL;
1660} 1726}
1661 1727
1728/*
1729* megasas_set_dma_alignment - Set DMA alignment for PI enabled VD
1730*
1731* @sdev: OS provided scsi device
1732*
1733* Returns void
1734*/
1735static void megasas_set_dma_alignment(struct scsi_device *sdev)
1736{
1737 u32 device_id, ld;
1738 struct megasas_instance *instance;
1739 struct fusion_context *fusion;
1740 struct MR_LD_RAID *raid;
1741 struct MR_DRV_RAID_MAP_ALL *local_map_ptr;
1742
1743 instance = megasas_lookup_instance(sdev->host->host_no);
1744 fusion = instance->ctrl_context;
1745
1746 if (!fusion)
1747 return;
1748
1749 if (sdev->channel >= MEGASAS_MAX_PD_CHANNELS) {
1750 device_id = ((sdev->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL)
1751 + sdev->id;
1752 local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)];
1753 ld = MR_TargetIdToLdGet(device_id, local_map_ptr);
1754 raid = MR_LdRaidGet(ld, local_map_ptr);
1755
1756 if (raid->capability.ldPiMode == MR_PROT_INFO_TYPE_CONTROLLER)
1757 blk_queue_update_dma_alignment(sdev->request_queue, 0x7);
1758 }
1759}
1760
1662static int megasas_slave_configure(struct scsi_device *sdev) 1761static int megasas_slave_configure(struct scsi_device *sdev)
1663{ 1762{
1763 u16 pd_index = 0;
1764 struct megasas_instance *instance;
1765
1766 instance = megasas_lookup_instance(sdev->host->host_no);
1767 if (instance->allow_fw_scan) {
1768 if (sdev->channel < MEGASAS_MAX_PD_CHANNELS &&
1769 sdev->type == TYPE_DISK) {
1770 pd_index = (sdev->channel * MEGASAS_MAX_DEV_PER_CHANNEL) +
1771 sdev->id;
1772 if (instance->pd_list[pd_index].driveState !=
1773 MR_PD_STATE_SYSTEM)
1774 return -ENXIO;
1775 }
1776 }
1777 megasas_set_dma_alignment(sdev);
1664 /* 1778 /*
1665 * The RAID firmware may require extended timeouts. 1779 * The RAID firmware may require extended timeouts.
1666 */ 1780 */
@@ -1683,8 +1797,8 @@ static int megasas_slave_alloc(struct scsi_device *sdev)
1683 pd_index = 1797 pd_index =
1684 (sdev->channel * MEGASAS_MAX_DEV_PER_CHANNEL) + 1798 (sdev->channel * MEGASAS_MAX_DEV_PER_CHANNEL) +
1685 sdev->id; 1799 sdev->id;
1686 if (instance->pd_list[pd_index].driveState == 1800 if ((instance->allow_fw_scan || instance->pd_list[pd_index].driveState ==
1687 MR_PD_STATE_SYSTEM) { 1801 MR_PD_STATE_SYSTEM)) {
1688 return 0; 1802 return 0;
1689 } 1803 }
1690 return -ENXIO; 1804 return -ENXIO;
@@ -1736,10 +1850,7 @@ void megaraid_sas_kill_hba(struct megasas_instance *instance)
1736 msleep(1000); 1850 msleep(1000);
1737 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || 1851 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
1738 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY) || 1852 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
1739 (instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || 1853 (instance->ctrl_context)) {
1740 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
1741 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
1742 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
1743 writel(MFI_STOP_ADP, &instance->reg_set->doorbell); 1854 writel(MFI_STOP_ADP, &instance->reg_set->doorbell);
1744 /* Flush */ 1855 /* Flush */
1745 readl(&instance->reg_set->doorbell); 1856 readl(&instance->reg_set->doorbell);
@@ -2506,10 +2617,7 @@ static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
2506 /* 2617 /*
2507 * First wait for all commands to complete 2618 * First wait for all commands to complete
2508 */ 2619 */
2509 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || 2620 if (instance->ctrl_context)
2510 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
2511 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
2512 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
2513 ret = megasas_reset_fusion(scmd->device->host, 1); 2621 ret = megasas_reset_fusion(scmd->device->host, 1);
2514 else 2622 else
2515 ret = megasas_generic_reset(scmd); 2623 ret = megasas_generic_reset(scmd);
@@ -2837,7 +2945,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
2837 struct megasas_header *hdr = &cmd->frame->hdr; 2945 struct megasas_header *hdr = &cmd->frame->hdr;
2838 unsigned long flags; 2946 unsigned long flags;
2839 struct fusion_context *fusion = instance->ctrl_context; 2947 struct fusion_context *fusion = instance->ctrl_context;
2840 u32 opcode; 2948 u32 opcode, status;
2841 2949
2842 /* flag for the retry reset */ 2950 /* flag for the retry reset */
2843 cmd->retry_for_fw_reset = 0; 2951 cmd->retry_for_fw_reset = 0;
@@ -2945,6 +3053,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
2945 && (cmd->frame->dcmd.mbox.b[1] == 1)) { 3053 && (cmd->frame->dcmd.mbox.b[1] == 1)) {
2946 fusion->fast_path_io = 0; 3054 fusion->fast_path_io = 0;
2947 spin_lock_irqsave(instance->host->host_lock, flags); 3055 spin_lock_irqsave(instance->host->host_lock, flags);
3056 instance->map_update_cmd = NULL;
2948 if (cmd->frame->hdr.cmd_status != 0) { 3057 if (cmd->frame->hdr.cmd_status != 0) {
2949 if (cmd->frame->hdr.cmd_status != 3058 if (cmd->frame->hdr.cmd_status !=
2950 MFI_STAT_NOT_FOUND) 3059 MFI_STAT_NOT_FOUND)
@@ -2982,6 +3091,27 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
2982 spin_unlock_irqrestore(&poll_aen_lock, flags); 3091 spin_unlock_irqrestore(&poll_aen_lock, flags);
2983 } 3092 }
2984 3093
3094 /* FW has an updated PD sequence */
3095 if ((opcode == MR_DCMD_SYSTEM_PD_MAP_GET_INFO) &&
3096 (cmd->frame->dcmd.mbox.b[0] == 1)) {
3097
3098 spin_lock_irqsave(instance->host->host_lock, flags);
3099 status = cmd->frame->hdr.cmd_status;
3100 instance->jbod_seq_cmd = NULL;
3101 megasas_return_cmd(instance, cmd);
3102
3103 if (status == MFI_STAT_OK) {
3104 instance->pd_seq_map_id++;
3105 /* Re-register a pd sync seq num cmd */
3106 if (megasas_sync_pd_seq_num(instance, true))
3107 instance->use_seqnum_jbod_fp = false;
3108 } else
3109 instance->use_seqnum_jbod_fp = false;
3110
3111 spin_unlock_irqrestore(instance->host->host_lock, flags);
3112 break;
3113 }
3114
2985 /* 3115 /*
2986 * See if got an event notification 3116 * See if got an event notification
2987 */ 3117 */
@@ -3348,22 +3478,14 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
3348 PCI_DEVICE_ID_LSI_SAS0073SKINNY) || 3478 PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
3349 (instance->pdev->device == 3479 (instance->pdev->device ==
3350 PCI_DEVICE_ID_LSI_SAS0071SKINNY) || 3480 PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
3351 (instance->pdev->device == 3481 (instance->ctrl_context))
3352 PCI_DEVICE_ID_LSI_FUSION) ||
3353 (instance->pdev->device ==
3354 PCI_DEVICE_ID_LSI_PLASMA) ||
3355 (instance->pdev->device ==
3356 PCI_DEVICE_ID_LSI_INVADER) ||
3357 (instance->pdev->device ==
3358 PCI_DEVICE_ID_LSI_FURY)) {
3359 writel( 3482 writel(
3360 MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG, 3483 MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG,
3361 &instance->reg_set->doorbell); 3484 &instance->reg_set->doorbell);
3362 } else { 3485 else
3363 writel( 3486 writel(
3364 MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG, 3487 MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG,
3365 &instance->reg_set->inbound_doorbell); 3488 &instance->reg_set->inbound_doorbell);
3366 }
3367 3489
3368 max_wait = MEGASAS_RESET_WAIT_TIME; 3490 max_wait = MEGASAS_RESET_WAIT_TIME;
3369 cur_state = MFI_STATE_WAIT_HANDSHAKE; 3491 cur_state = MFI_STATE_WAIT_HANDSHAKE;
@@ -3374,17 +3496,10 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
3374 PCI_DEVICE_ID_LSI_SAS0073SKINNY) || 3496 PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
3375 (instance->pdev->device == 3497 (instance->pdev->device ==
3376 PCI_DEVICE_ID_LSI_SAS0071SKINNY) || 3498 PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
3377 (instance->pdev->device == 3499 (instance->ctrl_context))
3378 PCI_DEVICE_ID_LSI_FUSION) ||
3379 (instance->pdev->device ==
3380 PCI_DEVICE_ID_LSI_PLASMA) ||
3381 (instance->pdev->device ==
3382 PCI_DEVICE_ID_LSI_INVADER) ||
3383 (instance->pdev->device ==
3384 PCI_DEVICE_ID_LSI_FURY)) {
3385 writel(MFI_INIT_HOTPLUG, 3500 writel(MFI_INIT_HOTPLUG,
3386 &instance->reg_set->doorbell); 3501 &instance->reg_set->doorbell);
3387 } else 3502 else
3388 writel(MFI_INIT_HOTPLUG, 3503 writel(MFI_INIT_HOTPLUG,
3389 &instance->reg_set->inbound_doorbell); 3504 &instance->reg_set->inbound_doorbell);
3390 3505
@@ -3401,24 +3516,11 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
3401 PCI_DEVICE_ID_LSI_SAS0073SKINNY) || 3516 PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
3402 (instance->pdev->device == 3517 (instance->pdev->device ==
3403 PCI_DEVICE_ID_LSI_SAS0071SKINNY) || 3518 PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
3404 (instance->pdev->device 3519 (instance->ctrl_context)) {
3405 == PCI_DEVICE_ID_LSI_FUSION) ||
3406 (instance->pdev->device
3407 == PCI_DEVICE_ID_LSI_PLASMA) ||
3408 (instance->pdev->device
3409 == PCI_DEVICE_ID_LSI_INVADER) ||
3410 (instance->pdev->device
3411 == PCI_DEVICE_ID_LSI_FURY)) {
3412 writel(MFI_RESET_FLAGS, 3520 writel(MFI_RESET_FLAGS,
3413 &instance->reg_set->doorbell); 3521 &instance->reg_set->doorbell);
3414 if ((instance->pdev->device == 3522
3415 PCI_DEVICE_ID_LSI_FUSION) || 3523 if (instance->ctrl_context) {
3416 (instance->pdev->device ==
3417 PCI_DEVICE_ID_LSI_PLASMA) ||
3418 (instance->pdev->device ==
3419 PCI_DEVICE_ID_LSI_INVADER) ||
3420 (instance->pdev->device ==
3421 PCI_DEVICE_ID_LSI_FURY)) {
3422 for (i = 0; i < (10 * 1000); i += 20) { 3524 for (i = 0; i < (10 * 1000); i += 20) {
3423 if (readl( 3525 if (readl(
3424 &instance-> 3526 &instance->
@@ -3639,11 +3741,7 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
3639 memset(cmd->frame, 0, total_sz); 3741 memset(cmd->frame, 0, total_sz);
3640 cmd->frame->io.context = cpu_to_le32(cmd->index); 3742 cmd->frame->io.context = cpu_to_le32(cmd->index);
3641 cmd->frame->io.pad_0 = 0; 3743 cmd->frame->io.pad_0 = 0;
3642 if ((instance->pdev->device != PCI_DEVICE_ID_LSI_FUSION) && 3744 if (!instance->ctrl_context && reset_devices)
3643 (instance->pdev->device != PCI_DEVICE_ID_LSI_PLASMA) &&
3644 (instance->pdev->device != PCI_DEVICE_ID_LSI_INVADER) &&
3645 (instance->pdev->device != PCI_DEVICE_ID_LSI_FURY) &&
3646 (reset_devices))
3647 cmd->frame->hdr.cmd = MFI_CMD_INVALID; 3745 cmd->frame->hdr.cmd = MFI_CMD_INVALID;
3648 } 3746 }
3649 3747
@@ -4136,11 +4234,21 @@ megasas_get_ctrl_info(struct megasas_instance *instance)
4136 le32_to_cpus((u32 *)&ctrl_info->adapterOperations2); 4234 le32_to_cpus((u32 *)&ctrl_info->adapterOperations2);
4137 le32_to_cpus((u32 *)&ctrl_info->adapterOperations3); 4235 le32_to_cpus((u32 *)&ctrl_info->adapterOperations3);
4138 megasas_update_ext_vd_details(instance); 4236 megasas_update_ext_vd_details(instance);
4237 instance->use_seqnum_jbod_fp =
4238 ctrl_info->adapterOperations3.useSeqNumJbodFP;
4139 instance->is_imr = (ctrl_info->memory_size ? 0 : 1); 4239 instance->is_imr = (ctrl_info->memory_size ? 0 : 1);
4140 dev_info(&instance->pdev->dev, 4240 dev_info(&instance->pdev->dev,
4141 "controller type\t: %s(%dMB)\n", 4241 "controller type\t: %s(%dMB)\n",
4142 instance->is_imr ? "iMR" : "MR", 4242 instance->is_imr ? "iMR" : "MR",
4143 le16_to_cpu(ctrl_info->memory_size)); 4243 le16_to_cpu(ctrl_info->memory_size));
4244 instance->disableOnlineCtrlReset =
4245 ctrl_info->properties.OnOffProperties.disableOnlineCtrlReset;
4246 dev_info(&instance->pdev->dev, "Online Controller Reset(OCR)\t: %s\n",
4247 instance->disableOnlineCtrlReset ? "Disabled" : "Enabled");
4248 instance->secure_jbod_support =
4249 ctrl_info->adapterOperations3.supportSecurityonJBOD;
4250 dev_info(&instance->pdev->dev, "Secure JBOD support\t: %s\n",
4251 instance->secure_jbod_support ? "Yes" : "No");
4144 } 4252 }
4145 4253
4146 pci_free_consistent(instance->pdev, sizeof(struct megasas_ctrl_info), 4254 pci_free_consistent(instance->pdev, sizeof(struct megasas_ctrl_info),
@@ -4481,6 +4589,62 @@ megasas_destroy_irqs(struct megasas_instance *instance) {
4481} 4589}
4482 4590
4483/** 4591/**
4592 * megasas_setup_jbod_map - setup jbod map for FP seq_number.
4593 * @instance: Adapter soft state
4594 * @is_probe: Driver probe check
4595 *
4596 * Return 0 on success.
4597 */
4598void
4599megasas_setup_jbod_map(struct megasas_instance *instance)
4600{
4601 int i;
4602 struct fusion_context *fusion = instance->ctrl_context;
4603 u32 pd_seq_map_sz;
4604
4605 pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
4606 (sizeof(struct MR_PD_CFG_SEQ) * (MAX_PHYSICAL_DEVICES - 1));
4607
4608 if (reset_devices || !fusion ||
4609 !instance->ctrl_info->adapterOperations3.useSeqNumJbodFP) {
4610 dev_info(&instance->pdev->dev,
4611 "Jbod map is not supported %s %d\n",
4612 __func__, __LINE__);
4613 instance->use_seqnum_jbod_fp = false;
4614 return;
4615 }
4616
4617 if (fusion->pd_seq_sync[0])
4618 goto skip_alloc;
4619
4620 for (i = 0; i < JBOD_MAPS_COUNT; i++) {
4621 fusion->pd_seq_sync[i] = dma_alloc_coherent
4622 (&instance->pdev->dev, pd_seq_map_sz,
4623 &fusion->pd_seq_phys[i], GFP_KERNEL);
4624 if (!fusion->pd_seq_sync[i]) {
4625 dev_err(&instance->pdev->dev,
4626 "Failed to allocate memory from %s %d\n",
4627 __func__, __LINE__);
4628 if (i == 1) {
4629 dma_free_coherent(&instance->pdev->dev,
4630 pd_seq_map_sz, fusion->pd_seq_sync[0],
4631 fusion->pd_seq_phys[0]);
4632 fusion->pd_seq_sync[0] = NULL;
4633 }
4634 instance->use_seqnum_jbod_fp = false;
4635 return;
4636 }
4637 }
4638
4639skip_alloc:
4640 if (!megasas_sync_pd_seq_num(instance, false) &&
4641 !megasas_sync_pd_seq_num(instance, true))
4642 instance->use_seqnum_jbod_fp = true;
4643 else
4644 instance->use_seqnum_jbod_fp = false;
4645}
4646
4647/**
4484 * megasas_init_fw - Initializes the FW 4648 * megasas_init_fw - Initializes the FW
4485 * @instance: Adapter soft state 4649 * @instance: Adapter soft state
4486 * 4650 *
@@ -4498,6 +4662,9 @@ static int megasas_init_fw(struct megasas_instance *instance)
4498 unsigned long bar_list; 4662 unsigned long bar_list;
4499 int i, loop, fw_msix_count = 0; 4663 int i, loop, fw_msix_count = 0;
4500 struct IOV_111 *iovPtr; 4664 struct IOV_111 *iovPtr;
4665 struct fusion_context *fusion;
4666
4667 fusion = instance->ctrl_context;
4501 4668
4502 /* Find first memory bar */ 4669 /* Find first memory bar */
4503 bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM); 4670 bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM);
@@ -4523,6 +4690,10 @@ static int megasas_init_fw(struct megasas_instance *instance)
4523 case PCI_DEVICE_ID_LSI_PLASMA: 4690 case PCI_DEVICE_ID_LSI_PLASMA:
4524 case PCI_DEVICE_ID_LSI_INVADER: 4691 case PCI_DEVICE_ID_LSI_INVADER:
4525 case PCI_DEVICE_ID_LSI_FURY: 4692 case PCI_DEVICE_ID_LSI_FURY:
4693 case PCI_DEVICE_ID_LSI_INTRUDER:
4694 case PCI_DEVICE_ID_LSI_INTRUDER_24:
4695 case PCI_DEVICE_ID_LSI_CUTLASS_52:
4696 case PCI_DEVICE_ID_LSI_CUTLASS_53:
4526 instance->instancet = &megasas_instance_template_fusion; 4697 instance->instancet = &megasas_instance_template_fusion;
4527 break; 4698 break;
4528 case PCI_DEVICE_ID_LSI_SAS1078R: 4699 case PCI_DEVICE_ID_LSI_SAS1078R:
@@ -4541,6 +4712,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
4541 case PCI_DEVICE_ID_DELL_PERC5: 4712 case PCI_DEVICE_ID_DELL_PERC5:
4542 default: 4713 default:
4543 instance->instancet = &megasas_instance_template_xscale; 4714 instance->instancet = &megasas_instance_template_xscale;
4715 instance->allow_fw_scan = 1;
4544 break; 4716 break;
4545 } 4717 }
4546 4718
@@ -4575,37 +4747,32 @@ static int megasas_init_fw(struct megasas_instance *instance)
4575 scratch_pad_2 = readl 4747 scratch_pad_2 = readl
4576 (&instance->reg_set->outbound_scratch_pad_2); 4748 (&instance->reg_set->outbound_scratch_pad_2);
4577 /* Check max MSI-X vectors */ 4749 /* Check max MSI-X vectors */
4578 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || 4750 if (fusion) {
4579 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA)) { 4751 if (fusion->adapter_type == THUNDERBOLT_SERIES) { /* Thunderbolt Series*/
4580 instance->msix_vectors = (scratch_pad_2 4752 instance->msix_vectors = (scratch_pad_2
4581 & MR_MAX_REPLY_QUEUES_OFFSET) + 1; 4753 & MR_MAX_REPLY_QUEUES_OFFSET) + 1;
4582 fw_msix_count = instance->msix_vectors; 4754 fw_msix_count = instance->msix_vectors;
4583 if (msix_vectors) 4755 } else { /* Invader series supports more than 8 MSI-x vectors*/
4584 instance->msix_vectors = 4756 instance->msix_vectors = ((scratch_pad_2
4585 min(msix_vectors, 4757 & MR_MAX_REPLY_QUEUES_EXT_OFFSET)
4586 instance->msix_vectors); 4758 >> MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT) + 1;
4587 } else if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) 4759 fw_msix_count = instance->msix_vectors;
4588 || (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) { 4760 /* Save 1-15 reply post index address to local memory
4589 /* Invader/Fury supports more than 8 MSI-X */ 4761 * Index 0 is already saved from reg offset
4590 instance->msix_vectors = ((scratch_pad_2 4762 * MPI2_REPLY_POST_HOST_INDEX_OFFSET
4591 & MR_MAX_REPLY_QUEUES_EXT_OFFSET) 4763 */
4592 >> MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT) + 1; 4764 for (loop = 1; loop < MR_MAX_MSIX_REG_ARRAY; loop++) {
4593 fw_msix_count = instance->msix_vectors; 4765 instance->reply_post_host_index_addr[loop] =
4594 /* Save 1-15 reply post index address to local memory 4766 (u32 __iomem *)
4595 * Index 0 is already saved from reg offset 4767 ((u8 __iomem *)instance->reg_set +
4596 * MPI2_REPLY_POST_HOST_INDEX_OFFSET 4768 MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET
4597 */ 4769 + (loop * 0x10));
4598 for (loop = 1; loop < MR_MAX_MSIX_REG_ARRAY; loop++) { 4770 }
4599 instance->reply_post_host_index_addr[loop] =
4600 (u32 __iomem *)
4601 ((u8 __iomem *)instance->reg_set +
4602 MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET
4603 + (loop * 0x10));
4604 } 4771 }
4605 if (msix_vectors) 4772 if (msix_vectors)
4606 instance->msix_vectors = min(msix_vectors, 4773 instance->msix_vectors = min(msix_vectors,
4607 instance->msix_vectors); 4774 instance->msix_vectors);
4608 } else 4775 } else /* MFI adapters */
4609 instance->msix_vectors = 1; 4776 instance->msix_vectors = 1;
4610 /* Don't bother allocating more MSI-X vectors than cpus */ 4777 /* Don't bother allocating more MSI-X vectors than cpus */
4611 instance->msix_vectors = min(instance->msix_vectors, 4778 instance->msix_vectors = min(instance->msix_vectors,
@@ -4626,6 +4793,9 @@ static int megasas_init_fw(struct megasas_instance *instance)
4626 "current msix/online cpus\t: (%d/%d)\n", 4793 "current msix/online cpus\t: (%d/%d)\n",
4627 instance->msix_vectors, (unsigned int)num_online_cpus()); 4794 instance->msix_vectors, (unsigned int)num_online_cpus());
4628 4795
4796 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet,
4797 (unsigned long)instance);
4798
4629 if (instance->msix_vectors ? 4799 if (instance->msix_vectors ?
4630 megasas_setup_irqs_msix(instance, 1) : 4800 megasas_setup_irqs_msix(instance, 1) :
4631 megasas_setup_irqs_ioapic(instance)) 4801 megasas_setup_irqs_ioapic(instance))
@@ -4646,13 +4816,13 @@ static int megasas_init_fw(struct megasas_instance *instance)
4646 if (instance->instancet->init_adapter(instance)) 4816 if (instance->instancet->init_adapter(instance))
4647 goto fail_init_adapter; 4817 goto fail_init_adapter;
4648 4818
4649 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet,
4650 (unsigned long)instance);
4651 4819
4652 instance->instancet->enable_intr(instance); 4820 instance->instancet->enable_intr(instance);
4653 4821
4654 dev_err(&instance->pdev->dev, "INIT adapter done\n"); 4822 dev_err(&instance->pdev->dev, "INIT adapter done\n");
4655 4823
4824 megasas_setup_jbod_map(instance);
4825
4656 /** for passthrough 4826 /** for passthrough
4657 * the following function will get the PD LIST. 4827 * the following function will get the PD LIST.
4658 */ 4828 */
@@ -4686,8 +4856,6 @@ static int megasas_init_fw(struct megasas_instance *instance)
4686 4856
4687 tmp_sectors = min_t(u32, max_sectors_1, max_sectors_2); 4857 tmp_sectors = min_t(u32, max_sectors_1, max_sectors_2);
4688 4858
4689 instance->disableOnlineCtrlReset =
4690 ctrl_info->properties.OnOffProperties.disableOnlineCtrlReset;
4691 instance->mpio = ctrl_info->adapterOperations2.mpio; 4859 instance->mpio = ctrl_info->adapterOperations2.mpio;
4692 instance->UnevenSpanSupport = 4860 instance->UnevenSpanSupport =
4693 ctrl_info->adapterOperations2.supportUnevenSpans; 4861 ctrl_info->adapterOperations2.supportUnevenSpans;
@@ -4700,18 +4868,22 @@ static int megasas_init_fw(struct megasas_instance *instance)
4700 4868
4701 } 4869 }
4702 if (ctrl_info->host_interface.SRIOV) { 4870 if (ctrl_info->host_interface.SRIOV) {
4703 if (!ctrl_info->adapterOperations2.activePassive) 4871 instance->requestorId = ctrl_info->iov.requestorId;
4704 instance->PlasmaFW111 = 1; 4872 if (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) {
4705 4873 if (!ctrl_info->adapterOperations2.activePassive)
4706 if (!instance->PlasmaFW111) 4874 instance->PlasmaFW111 = 1;
4707 instance->requestorId = 4875
4708 ctrl_info->iov.requestorId; 4876 dev_info(&instance->pdev->dev, "SR-IOV: firmware type: %s\n",
4709 else { 4877 instance->PlasmaFW111 ? "1.11" : "new");
4710 iovPtr = (struct IOV_111 *)((unsigned char *)ctrl_info + IOV_111_OFFSET); 4878
4711 instance->requestorId = iovPtr->requestorId; 4879 if (instance->PlasmaFW111) {
4880 iovPtr = (struct IOV_111 *)
4881 ((unsigned char *)ctrl_info + IOV_111_OFFSET);
4882 instance->requestorId = iovPtr->requestorId;
4883 }
4712 } 4884 }
4713 dev_warn(&instance->pdev->dev, "I am VF " 4885 dev_info(&instance->pdev->dev, "SRIOV: VF requestorId %d\n",
4714 "requestorId %d\n", instance->requestorId); 4886 instance->requestorId);
4715 } 4887 }
4716 4888
4717 instance->crash_dump_fw_support = 4889 instance->crash_dump_fw_support =
@@ -4732,8 +4904,6 @@ static int megasas_init_fw(struct megasas_instance *instance)
4732 instance->crash_dump_buf = NULL; 4904 instance->crash_dump_buf = NULL;
4733 } 4905 }
4734 4906
4735 instance->secure_jbod_support =
4736 ctrl_info->adapterOperations3.supportSecurityonJBOD;
4737 4907
4738 dev_info(&instance->pdev->dev, 4908 dev_info(&instance->pdev->dev,
4739 "pci id\t\t: (0x%04x)/(0x%04x)/(0x%04x)/(0x%04x)\n", 4909 "pci id\t\t: (0x%04x)/(0x%04x)/(0x%04x)/(0x%04x)\n",
@@ -4743,16 +4913,14 @@ static int megasas_init_fw(struct megasas_instance *instance)
4743 le16_to_cpu(ctrl_info->pci.sub_device_id)); 4913 le16_to_cpu(ctrl_info->pci.sub_device_id));
4744 dev_info(&instance->pdev->dev, "unevenspan support : %s\n", 4914 dev_info(&instance->pdev->dev, "unevenspan support : %s\n",
4745 instance->UnevenSpanSupport ? "yes" : "no"); 4915 instance->UnevenSpanSupport ? "yes" : "no");
4746 dev_info(&instance->pdev->dev, "disable ocr : %s\n",
4747 instance->disableOnlineCtrlReset ? "yes" : "no");
4748 dev_info(&instance->pdev->dev, "firmware crash dump : %s\n", 4916 dev_info(&instance->pdev->dev, "firmware crash dump : %s\n",
4749 instance->crash_dump_drv_support ? "yes" : "no"); 4917 instance->crash_dump_drv_support ? "yes" : "no");
4750 dev_info(&instance->pdev->dev, "secure jbod : %s\n", 4918 dev_info(&instance->pdev->dev, "jbod sync map : %s\n",
4751 instance->secure_jbod_support ? "yes" : "no"); 4919 instance->use_seqnum_jbod_fp ? "yes" : "no");
4752 4920
4753 4921
4754 instance->max_sectors_per_req = instance->max_num_sge * 4922 instance->max_sectors_per_req = instance->max_num_sge *
4755 PAGE_SIZE / 512; 4923 SGE_BUFFER_SIZE / 512;
4756 if (tmp_sectors && (instance->max_sectors_per_req > tmp_sectors)) 4924 if (tmp_sectors && (instance->max_sectors_per_req > tmp_sectors))
4757 instance->max_sectors_per_req = tmp_sectors; 4925 instance->max_sectors_per_req = tmp_sectors;
4758 4926
@@ -5049,7 +5217,6 @@ static int megasas_start_aen(struct megasas_instance *instance)
5049static int megasas_io_attach(struct megasas_instance *instance) 5217static int megasas_io_attach(struct megasas_instance *instance)
5050{ 5218{
5051 struct Scsi_Host *host = instance->host; 5219 struct Scsi_Host *host = instance->host;
5052 u32 error;
5053 5220
5054 /* 5221 /*
5055 * Export parameters required by SCSI mid-layer 5222 * Export parameters required by SCSI mid-layer
@@ -5092,20 +5259,10 @@ static int megasas_io_attach(struct megasas_instance *instance)
5092 host->max_cmd_len = 16; 5259 host->max_cmd_len = 16;
5093 5260
5094 /* Fusion only supports host reset */ 5261 /* Fusion only supports host reset */
5095 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || 5262 if (instance->ctrl_context) {
5096 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
5097 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
5098 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
5099 host->hostt->eh_device_reset_handler = NULL; 5263 host->hostt->eh_device_reset_handler = NULL;
5100 host->hostt->eh_bus_reset_handler = NULL; 5264 host->hostt->eh_bus_reset_handler = NULL;
5101 } 5265 }
5102 error = scsi_init_shared_tag_map(host, host->can_queue);
5103 if (error) {
5104 dev_err(&instance->pdev->dev,
5105 "Failed to shared tag from %s %d\n",
5106 __func__, __LINE__);
5107 return -ENODEV;
5108 }
5109 5266
5110 /* 5267 /*
5111 * Notify the mid-layer about the new controller 5268 * Notify the mid-layer about the new controller
@@ -5218,6 +5375,10 @@ static int megasas_probe_one(struct pci_dev *pdev,
5218 case PCI_DEVICE_ID_LSI_PLASMA: 5375 case PCI_DEVICE_ID_LSI_PLASMA:
5219 case PCI_DEVICE_ID_LSI_INVADER: 5376 case PCI_DEVICE_ID_LSI_INVADER:
5220 case PCI_DEVICE_ID_LSI_FURY: 5377 case PCI_DEVICE_ID_LSI_FURY:
5378 case PCI_DEVICE_ID_LSI_INTRUDER:
5379 case PCI_DEVICE_ID_LSI_INTRUDER_24:
5380 case PCI_DEVICE_ID_LSI_CUTLASS_52:
5381 case PCI_DEVICE_ID_LSI_CUTLASS_53:
5221 { 5382 {
5222 instance->ctrl_context_pages = 5383 instance->ctrl_context_pages =
5223 get_order(sizeof(struct fusion_context)); 5384 get_order(sizeof(struct fusion_context));
@@ -5231,6 +5392,11 @@ static int megasas_probe_one(struct pci_dev *pdev,
5231 fusion = instance->ctrl_context; 5392 fusion = instance->ctrl_context;
5232 memset(fusion, 0, 5393 memset(fusion, 0,
5233 ((1 << PAGE_SHIFT) << instance->ctrl_context_pages)); 5394 ((1 << PAGE_SHIFT) << instance->ctrl_context_pages));
5395 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
5396 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA))
5397 fusion->adapter_type = THUNDERBOLT_SERIES;
5398 else
5399 fusion->adapter_type = INVADER_SERIES;
5234 } 5400 }
5235 break; 5401 break;
5236 default: /* For all other supported controllers */ 5402 default: /* For all other supported controllers */
@@ -5333,10 +5499,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
5333 instance->disableOnlineCtrlReset = 1; 5499 instance->disableOnlineCtrlReset = 1;
5334 instance->UnevenSpanSupport = 0; 5500 instance->UnevenSpanSupport = 0;
5335 5501
5336 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || 5502 if (instance->ctrl_context) {
5337 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
5338 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
5339 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
5340 INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq); 5503 INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq);
5341 INIT_WORK(&instance->crash_init, megasas_fusion_crash_dump_wq); 5504 INIT_WORK(&instance->crash_init, megasas_fusion_crash_dump_wq);
5342 } else 5505 } else
@@ -5416,10 +5579,7 @@ fail_io_attach:
5416 instance->instancet->disable_intr(instance); 5579 instance->instancet->disable_intr(instance);
5417 megasas_destroy_irqs(instance); 5580 megasas_destroy_irqs(instance);
5418 5581
5419 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || 5582 if (instance->ctrl_context)
5420 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
5421 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
5422 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
5423 megasas_release_fusion(instance); 5583 megasas_release_fusion(instance);
5424 else 5584 else
5425 megasas_release_mfi(instance); 5585 megasas_release_mfi(instance);
@@ -5506,10 +5666,14 @@ static void megasas_shutdown_controller(struct megasas_instance *instance,
5506 5666
5507 if (instance->aen_cmd) 5667 if (instance->aen_cmd)
5508 megasas_issue_blocked_abort_cmd(instance, 5668 megasas_issue_blocked_abort_cmd(instance,
5509 instance->aen_cmd, 30); 5669 instance->aen_cmd, MEGASAS_BLOCKED_CMD_TIMEOUT);
5510 if (instance->map_update_cmd) 5670 if (instance->map_update_cmd)
5511 megasas_issue_blocked_abort_cmd(instance, 5671 megasas_issue_blocked_abort_cmd(instance,
5512 instance->map_update_cmd, 30); 5672 instance->map_update_cmd, MEGASAS_BLOCKED_CMD_TIMEOUT);
5673 if (instance->jbod_seq_cmd)
5674 megasas_issue_blocked_abort_cmd(instance,
5675 instance->jbod_seq_cmd, MEGASAS_BLOCKED_CMD_TIMEOUT);
5676
5513 dcmd = &cmd->frame->dcmd; 5677 dcmd = &cmd->frame->dcmd;
5514 5678
5515 memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); 5679 memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
@@ -5628,12 +5792,7 @@ megasas_resume(struct pci_dev *pdev)
5628 instance->msix_vectors)) 5792 instance->msix_vectors))
5629 goto fail_reenable_msix; 5793 goto fail_reenable_msix;
5630 5794
5631 switch (instance->pdev->device) { 5795 if (instance->ctrl_context) {
5632 case PCI_DEVICE_ID_LSI_FUSION:
5633 case PCI_DEVICE_ID_LSI_PLASMA:
5634 case PCI_DEVICE_ID_LSI_INVADER:
5635 case PCI_DEVICE_ID_LSI_FURY:
5636 {
5637 megasas_reset_reply_desc(instance); 5796 megasas_reset_reply_desc(instance);
5638 if (megasas_ioc_init_fusion(instance)) { 5797 if (megasas_ioc_init_fusion(instance)) {
5639 megasas_free_cmds(instance); 5798 megasas_free_cmds(instance);
@@ -5642,14 +5801,11 @@ megasas_resume(struct pci_dev *pdev)
5642 } 5801 }
5643 if (!megasas_get_map_info(instance)) 5802 if (!megasas_get_map_info(instance))
5644 megasas_sync_map_info(instance); 5803 megasas_sync_map_info(instance);
5645 } 5804 } else {
5646 break;
5647 default:
5648 *instance->producer = 0; 5805 *instance->producer = 0;
5649 *instance->consumer = 0; 5806 *instance->consumer = 0;
5650 if (megasas_issue_init_mfi(instance)) 5807 if (megasas_issue_init_mfi(instance))
5651 goto fail_init_mfi; 5808 goto fail_init_mfi;
5652 break;
5653 } 5809 }
5654 5810
5655 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, 5811 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet,
@@ -5674,6 +5830,7 @@ megasas_resume(struct pci_dev *pdev)
5674 } 5830 }
5675 5831
5676 instance->instancet->enable_intr(instance); 5832 instance->instancet->enable_intr(instance);
5833 megasas_setup_jbod_map(instance);
5677 instance->unload = 0; 5834 instance->unload = 0;
5678 5835
5679 /* 5836 /*
@@ -5721,6 +5878,7 @@ static void megasas_detach_one(struct pci_dev *pdev)
5721 struct Scsi_Host *host; 5878 struct Scsi_Host *host;
5722 struct megasas_instance *instance; 5879 struct megasas_instance *instance;
5723 struct fusion_context *fusion; 5880 struct fusion_context *fusion;
5881 u32 pd_seq_map_sz;
5724 5882
5725 instance = pci_get_drvdata(pdev); 5883 instance = pci_get_drvdata(pdev);
5726 instance->unload = 1; 5884 instance->unload = 1;
@@ -5769,12 +5927,11 @@ static void megasas_detach_one(struct pci_dev *pdev)
5769 if (instance->msix_vectors) 5927 if (instance->msix_vectors)
5770 pci_disable_msix(instance->pdev); 5928 pci_disable_msix(instance->pdev);
5771 5929
5772 switch (instance->pdev->device) { 5930 if (instance->ctrl_context) {
5773 case PCI_DEVICE_ID_LSI_FUSION:
5774 case PCI_DEVICE_ID_LSI_PLASMA:
5775 case PCI_DEVICE_ID_LSI_INVADER:
5776 case PCI_DEVICE_ID_LSI_FURY:
5777 megasas_release_fusion(instance); 5931 megasas_release_fusion(instance);
5932 pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
5933 (sizeof(struct MR_PD_CFG_SEQ) *
5934 (MAX_PHYSICAL_DEVICES - 1));
5778 for (i = 0; i < 2 ; i++) { 5935 for (i = 0; i < 2 ; i++) {
5779 if (fusion->ld_map[i]) 5936 if (fusion->ld_map[i])
5780 dma_free_coherent(&instance->pdev->dev, 5937 dma_free_coherent(&instance->pdev->dev,
@@ -5784,11 +5941,15 @@ static void megasas_detach_one(struct pci_dev *pdev)
5784 if (fusion->ld_drv_map[i]) 5941 if (fusion->ld_drv_map[i])
5785 free_pages((ulong)fusion->ld_drv_map[i], 5942 free_pages((ulong)fusion->ld_drv_map[i],
5786 fusion->drv_map_pages); 5943 fusion->drv_map_pages);
5944 if (fusion->pd_seq_sync)
5945 dma_free_coherent(&instance->pdev->dev,
5946 pd_seq_map_sz,
5947 fusion->pd_seq_sync[i],
5948 fusion->pd_seq_phys[i]);
5787 } 5949 }
5788 free_pages((ulong)instance->ctrl_context, 5950 free_pages((ulong)instance->ctrl_context,
5789 instance->ctrl_context_pages); 5951 instance->ctrl_context_pages);
5790 break; 5952 } else {
5791 default:
5792 megasas_release_mfi(instance); 5953 megasas_release_mfi(instance);
5793 pci_free_consistent(pdev, sizeof(u32), 5954 pci_free_consistent(pdev, sizeof(u32),
5794 instance->producer, 5955 instance->producer,
@@ -5796,7 +5957,6 @@ static void megasas_detach_one(struct pci_dev *pdev)
5796 pci_free_consistent(pdev, sizeof(u32), 5957 pci_free_consistent(pdev, sizeof(u32),
5797 instance->consumer, 5958 instance->consumer,
5798 instance->consumer_h); 5959 instance->consumer_h);
5799 break;
5800 } 5960 }
5801 5961
5802 kfree(instance->ctrl_info); 5962 kfree(instance->ctrl_info);
@@ -6316,6 +6476,9 @@ static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg)
6316 int i; 6476 int i;
6317 int error = 0; 6477 int error = 0;
6318 compat_uptr_t ptr; 6478 compat_uptr_t ptr;
6479 unsigned long local_raw_ptr;
6480 u32 local_sense_off;
6481 u32 local_sense_len;
6319 6482
6320 if (clear_user(ioc, sizeof(*ioc))) 6483 if (clear_user(ioc, sizeof(*ioc)))
6321 return -EFAULT; 6484 return -EFAULT;
@@ -6333,9 +6496,15 @@ static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg)
6333 * sense_len is not null, so prepare the 64bit value under 6496 * sense_len is not null, so prepare the 64bit value under
6334 * the same condition. 6497 * the same condition.
6335 */ 6498 */
6336 if (ioc->sense_len) { 6499 if (get_user(local_raw_ptr, ioc->frame.raw) ||
6500 get_user(local_sense_off, &ioc->sense_off) ||
6501 get_user(local_sense_len, &ioc->sense_len))
6502 return -EFAULT;
6503
6504
6505 if (local_sense_len) {
6337 void __user **sense_ioc_ptr = 6506 void __user **sense_ioc_ptr =
6338 (void __user **)(ioc->frame.raw + ioc->sense_off); 6507 (void __user **)((u8*)local_raw_ptr + local_sense_off);
6339 compat_uptr_t *sense_cioc_ptr = 6508 compat_uptr_t *sense_cioc_ptr =
6340 (compat_uptr_t *)(cioc->frame.raw + cioc->sense_off); 6509 (compat_uptr_t *)(cioc->frame.raw + cioc->sense_off);
6341 if (get_user(ptr, sense_cioc_ptr) || 6510 if (get_user(ptr, sense_cioc_ptr) ||
@@ -6504,6 +6673,7 @@ megasas_aen_polling(struct work_struct *work)
6504 instance->ev = NULL; 6673 instance->ev = NULL;
6505 host = instance->host; 6674 host = instance->host;
6506 if (instance->evt_detail) { 6675 if (instance->evt_detail) {
6676 megasas_decode_evt(instance);
6507 6677
6508 switch (le32_to_cpu(instance->evt_detail->code)) { 6678 switch (le32_to_cpu(instance->evt_detail->code)) {
6509 case MR_EVT_PD_INSERTED: 6679 case MR_EVT_PD_INSERTED:
@@ -6564,8 +6734,7 @@ megasas_aen_polling(struct work_struct *work)
6564 case MR_EVT_CFG_CLEARED: 6734 case MR_EVT_CFG_CLEARED:
6565 case MR_EVT_LD_DELETED: 6735 case MR_EVT_LD_DELETED:
6566 if (!instance->requestorId || 6736 if (!instance->requestorId ||
6567 (instance->requestorId && 6737 megasas_get_ld_vf_affiliation(instance, 0)) {
6568 megasas_get_ld_vf_affiliation(instance, 0))) {
6569 if (megasas_ld_list_query(instance, 6738 if (megasas_ld_list_query(instance,
6570 MR_LD_QUERY_TYPE_EXPOSED_TO_HOST)) 6739 MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
6571 megasas_get_ld_list(instance); 6740 megasas_get_ld_list(instance);
@@ -6596,8 +6765,7 @@ megasas_aen_polling(struct work_struct *work)
6596 break; 6765 break;
6597 case MR_EVT_LD_CREATED: 6766 case MR_EVT_LD_CREATED:
6598 if (!instance->requestorId || 6767 if (!instance->requestorId ||
6599 (instance->requestorId && 6768 megasas_get_ld_vf_affiliation(instance, 0)) {
6600 megasas_get_ld_vf_affiliation(instance, 0))) {
6601 if (megasas_ld_list_query(instance, 6769 if (megasas_ld_list_query(instance,
6602 MR_LD_QUERY_TYPE_EXPOSED_TO_HOST)) 6770 MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
6603 megasas_get_ld_list(instance); 6771 megasas_get_ld_list(instance);
@@ -6627,6 +6795,9 @@ megasas_aen_polling(struct work_struct *work)
6627 case MR_EVT_LD_STATE_CHANGE: 6795 case MR_EVT_LD_STATE_CHANGE:
6628 doscan = 1; 6796 doscan = 1;
6629 break; 6797 break;
6798 case MR_EVT_CTRL_PROP_CHANGED:
6799 megasas_get_ctrl_info(instance);
6800 break;
6630 default: 6801 default:
6631 doscan = 0; 6802 doscan = 0;
6632 break; 6803 break;
@@ -6663,8 +6834,7 @@ megasas_aen_polling(struct work_struct *work)
6663 } 6834 }
6664 6835
6665 if (!instance->requestorId || 6836 if (!instance->requestorId ||
6666 (instance->requestorId && 6837 megasas_get_ld_vf_affiliation(instance, 0)) {
6667 megasas_get_ld_vf_affiliation(instance, 0))) {
6668 if (megasas_ld_list_query(instance, 6838 if (megasas_ld_list_query(instance,
6669 MR_LD_QUERY_TYPE_EXPOSED_TO_HOST)) 6839 MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
6670 megasas_get_ld_list(instance); 6840 megasas_get_ld_list(instance);