aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/megaraid
diff options
context:
space:
mode:
authorsumit.saxena@avagotech.com <sumit.saxena@avagotech.com>2015-10-15 04:09:34 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2015-10-29 03:14:54 -0400
commit5a8cb85b569b2349493aadb81a747e077766907d (patch)
tree66c5fa080436eb3ba61c4e64ae8dfda947224444 /drivers/scsi/megaraid
parent0d5b47a724bab0ebaaa933d6ff5e584957aaa188 (diff)
megaraid_sas: Remove PCI id checks
Remove PCI id based checks and use instance->ctrl_context to decide whether controller is MFI-based or a Fusion adapter. Additionally, Fusion adapters are divided into two categories: Thunderbolt and Invader. Signed-off-by: Sumit Saxena <sumit.saxena@avagotech.com> Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/megaraid')
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_base.c152
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_fp.c24
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_fusion.c40
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_fusion.h6
4 files changed, 76 insertions, 146 deletions
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 00a360b8f29b..7e0bf26ff2ad 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1797,10 +1797,7 @@ void megaraid_sas_kill_hba(struct megasas_instance *instance)
1797 msleep(1000); 1797 msleep(1000);
1798 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || 1798 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
1799 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY) || 1799 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
1800 (instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || 1800 (instance->ctrl_context)) {
1801 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
1802 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
1803 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
1804 writel(MFI_STOP_ADP, &instance->reg_set->doorbell); 1801 writel(MFI_STOP_ADP, &instance->reg_set->doorbell);
1805 /* Flush */ 1802 /* Flush */
1806 readl(&instance->reg_set->doorbell); 1803 readl(&instance->reg_set->doorbell);
@@ -2567,10 +2564,7 @@ static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
2567 /* 2564 /*
2568 * First wait for all commands to complete 2565 * First wait for all commands to complete
2569 */ 2566 */
2570 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || 2567 if (instance->ctrl_context)
2571 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
2572 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
2573 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
2574 ret = megasas_reset_fusion(scmd->device->host, 1); 2568 ret = megasas_reset_fusion(scmd->device->host, 1);
2575 else 2569 else
2576 ret = megasas_generic_reset(scmd); 2570 ret = megasas_generic_reset(scmd);
@@ -3431,22 +3425,14 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
3431 PCI_DEVICE_ID_LSI_SAS0073SKINNY) || 3425 PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
3432 (instance->pdev->device == 3426 (instance->pdev->device ==
3433 PCI_DEVICE_ID_LSI_SAS0071SKINNY) || 3427 PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
3434 (instance->pdev->device == 3428 (instance->ctrl_context))
3435 PCI_DEVICE_ID_LSI_FUSION) ||
3436 (instance->pdev->device ==
3437 PCI_DEVICE_ID_LSI_PLASMA) ||
3438 (instance->pdev->device ==
3439 PCI_DEVICE_ID_LSI_INVADER) ||
3440 (instance->pdev->device ==
3441 PCI_DEVICE_ID_LSI_FURY)) {
3442 writel( 3429 writel(
3443 MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG, 3430 MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG,
3444 &instance->reg_set->doorbell); 3431 &instance->reg_set->doorbell);
3445 } else { 3432 else
3446 writel( 3433 writel(
3447 MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG, 3434 MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG,
3448 &instance->reg_set->inbound_doorbell); 3435 &instance->reg_set->inbound_doorbell);
3449 }
3450 3436
3451 max_wait = MEGASAS_RESET_WAIT_TIME; 3437 max_wait = MEGASAS_RESET_WAIT_TIME;
3452 cur_state = MFI_STATE_WAIT_HANDSHAKE; 3438 cur_state = MFI_STATE_WAIT_HANDSHAKE;
@@ -3457,17 +3443,10 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
3457 PCI_DEVICE_ID_LSI_SAS0073SKINNY) || 3443 PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
3458 (instance->pdev->device == 3444 (instance->pdev->device ==
3459 PCI_DEVICE_ID_LSI_SAS0071SKINNY) || 3445 PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
3460 (instance->pdev->device == 3446 (instance->ctrl_context))
3461 PCI_DEVICE_ID_LSI_FUSION) ||
3462 (instance->pdev->device ==
3463 PCI_DEVICE_ID_LSI_PLASMA) ||
3464 (instance->pdev->device ==
3465 PCI_DEVICE_ID_LSI_INVADER) ||
3466 (instance->pdev->device ==
3467 PCI_DEVICE_ID_LSI_FURY)) {
3468 writel(MFI_INIT_HOTPLUG, 3447 writel(MFI_INIT_HOTPLUG,
3469 &instance->reg_set->doorbell); 3448 &instance->reg_set->doorbell);
3470 } else 3449 else
3471 writel(MFI_INIT_HOTPLUG, 3450 writel(MFI_INIT_HOTPLUG,
3472 &instance->reg_set->inbound_doorbell); 3451 &instance->reg_set->inbound_doorbell);
3473 3452
@@ -3484,24 +3463,11 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
3484 PCI_DEVICE_ID_LSI_SAS0073SKINNY) || 3463 PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
3485 (instance->pdev->device == 3464 (instance->pdev->device ==
3486 PCI_DEVICE_ID_LSI_SAS0071SKINNY) || 3465 PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
3487 (instance->pdev->device 3466 (instance->ctrl_context)) {
3488 == PCI_DEVICE_ID_LSI_FUSION) ||
3489 (instance->pdev->device
3490 == PCI_DEVICE_ID_LSI_PLASMA) ||
3491 (instance->pdev->device
3492 == PCI_DEVICE_ID_LSI_INVADER) ||
3493 (instance->pdev->device
3494 == PCI_DEVICE_ID_LSI_FURY)) {
3495 writel(MFI_RESET_FLAGS, 3467 writel(MFI_RESET_FLAGS,
3496 &instance->reg_set->doorbell); 3468 &instance->reg_set->doorbell);
3497 if ((instance->pdev->device == 3469
3498 PCI_DEVICE_ID_LSI_FUSION) || 3470 if (instance->ctrl_context) {
3499 (instance->pdev->device ==
3500 PCI_DEVICE_ID_LSI_PLASMA) ||
3501 (instance->pdev->device ==
3502 PCI_DEVICE_ID_LSI_INVADER) ||
3503 (instance->pdev->device ==
3504 PCI_DEVICE_ID_LSI_FURY)) {
3505 for (i = 0; i < (10 * 1000); i += 20) { 3471 for (i = 0; i < (10 * 1000); i += 20) {
3506 if (readl( 3472 if (readl(
3507 &instance-> 3473 &instance->
@@ -3722,11 +3688,7 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
3722 memset(cmd->frame, 0, total_sz); 3688 memset(cmd->frame, 0, total_sz);
3723 cmd->frame->io.context = cpu_to_le32(cmd->index); 3689 cmd->frame->io.context = cpu_to_le32(cmd->index);
3724 cmd->frame->io.pad_0 = 0; 3690 cmd->frame->io.pad_0 = 0;
3725 if ((instance->pdev->device != PCI_DEVICE_ID_LSI_FUSION) && 3691 if (!instance->ctrl_context && reset_devices)
3726 (instance->pdev->device != PCI_DEVICE_ID_LSI_PLASMA) &&
3727 (instance->pdev->device != PCI_DEVICE_ID_LSI_INVADER) &&
3728 (instance->pdev->device != PCI_DEVICE_ID_LSI_FURY) &&
3729 (reset_devices))
3730 cmd->frame->hdr.cmd = MFI_CMD_INVALID; 3692 cmd->frame->hdr.cmd = MFI_CMD_INVALID;
3731 } 3693 }
3732 3694
@@ -4639,6 +4601,9 @@ static int megasas_init_fw(struct megasas_instance *instance)
4639 unsigned long bar_list; 4601 unsigned long bar_list;
4640 int i, loop, fw_msix_count = 0; 4602 int i, loop, fw_msix_count = 0;
4641 struct IOV_111 *iovPtr; 4603 struct IOV_111 *iovPtr;
4604 struct fusion_context *fusion;
4605
4606 fusion = instance->ctrl_context;
4642 4607
4643 /* Find first memory bar */ 4608 /* Find first memory bar */
4644 bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM); 4609 bar_list = pci_select_bars(instance->pdev, IORESOURCE_MEM);
@@ -4716,37 +4681,32 @@ static int megasas_init_fw(struct megasas_instance *instance)
4716 scratch_pad_2 = readl 4681 scratch_pad_2 = readl
4717 (&instance->reg_set->outbound_scratch_pad_2); 4682 (&instance->reg_set->outbound_scratch_pad_2);
4718 /* Check max MSI-X vectors */ 4683 /* Check max MSI-X vectors */
4719 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || 4684 if (fusion) {
4720 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA)) { 4685 if (fusion->adapter_type == THUNDERBOLT_SERIES) { /* Thunderbolt Series*/
4721 instance->msix_vectors = (scratch_pad_2 4686 instance->msix_vectors = (scratch_pad_2
4722 & MR_MAX_REPLY_QUEUES_OFFSET) + 1; 4687 & MR_MAX_REPLY_QUEUES_OFFSET) + 1;
4723 fw_msix_count = instance->msix_vectors; 4688 fw_msix_count = instance->msix_vectors;
4724 if (msix_vectors) 4689 } else { /* Invader series supports more than 8 MSI-x vectors*/
4725 instance->msix_vectors = 4690 instance->msix_vectors = ((scratch_pad_2
4726 min(msix_vectors, 4691 & MR_MAX_REPLY_QUEUES_EXT_OFFSET)
4727 instance->msix_vectors); 4692 >> MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT) + 1;
4728 } else if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) 4693 fw_msix_count = instance->msix_vectors;
4729 || (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) { 4694 /* Save 1-15 reply post index address to local memory
4730 /* Invader/Fury supports more than 8 MSI-X */ 4695 * Index 0 is already saved from reg offset
4731 instance->msix_vectors = ((scratch_pad_2 4696 * MPI2_REPLY_POST_HOST_INDEX_OFFSET
4732 & MR_MAX_REPLY_QUEUES_EXT_OFFSET) 4697 */
4733 >> MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT) + 1; 4698 for (loop = 1; loop < MR_MAX_MSIX_REG_ARRAY; loop++) {
4734 fw_msix_count = instance->msix_vectors; 4699 instance->reply_post_host_index_addr[loop] =
4735 /* Save 1-15 reply post index address to local memory 4700 (u32 __iomem *)
4736 * Index 0 is already saved from reg offset 4701 ((u8 __iomem *)instance->reg_set +
4737 * MPI2_REPLY_POST_HOST_INDEX_OFFSET 4702 MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET
4738 */ 4703 + (loop * 0x10));
4739 for (loop = 1; loop < MR_MAX_MSIX_REG_ARRAY; loop++) { 4704 }
4740 instance->reply_post_host_index_addr[loop] =
4741 (u32 __iomem *)
4742 ((u8 __iomem *)instance->reg_set +
4743 MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET
4744 + (loop * 0x10));
4745 } 4705 }
4746 if (msix_vectors) 4706 if (msix_vectors)
4747 instance->msix_vectors = min(msix_vectors, 4707 instance->msix_vectors = min(msix_vectors,
4748 instance->msix_vectors); 4708 instance->msix_vectors);
4749 } else 4709 } else /* MFI adapters */
4750 instance->msix_vectors = 1; 4710 instance->msix_vectors = 1;
4751 /* Don't bother allocating more MSI-X vectors than cpus */ 4711 /* Don't bother allocating more MSI-X vectors than cpus */
4752 instance->msix_vectors = min(instance->msix_vectors, 4712 instance->msix_vectors = min(instance->msix_vectors,
@@ -5241,10 +5201,7 @@ static int megasas_io_attach(struct megasas_instance *instance)
5241 host->max_cmd_len = 16; 5201 host->max_cmd_len = 16;
5242 5202
5243 /* Fusion only supports host reset */ 5203 /* Fusion only supports host reset */
5244 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || 5204 if (instance->ctrl_context) {
5245 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
5246 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
5247 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
5248 host->hostt->eh_device_reset_handler = NULL; 5205 host->hostt->eh_device_reset_handler = NULL;
5249 host->hostt->eh_bus_reset_handler = NULL; 5206 host->hostt->eh_bus_reset_handler = NULL;
5250 } 5207 }
@@ -5380,6 +5337,11 @@ static int megasas_probe_one(struct pci_dev *pdev,
5380 fusion = instance->ctrl_context; 5337 fusion = instance->ctrl_context;
5381 memset(fusion, 0, 5338 memset(fusion, 0,
5382 ((1 << PAGE_SHIFT) << instance->ctrl_context_pages)); 5339 ((1 << PAGE_SHIFT) << instance->ctrl_context_pages));
5340 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
5341 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA))
5342 fusion->adapter_type = THUNDERBOLT_SERIES;
5343 else
5344 fusion->adapter_type = INVADER_SERIES;
5383 } 5345 }
5384 break; 5346 break;
5385 default: /* For all other supported controllers */ 5347 default: /* For all other supported controllers */
@@ -5482,10 +5444,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
5482 instance->disableOnlineCtrlReset = 1; 5444 instance->disableOnlineCtrlReset = 1;
5483 instance->UnevenSpanSupport = 0; 5445 instance->UnevenSpanSupport = 0;
5484 5446
5485 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || 5447 if (instance->ctrl_context) {
5486 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
5487 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
5488 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
5489 INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq); 5448 INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq);
5490 INIT_WORK(&instance->crash_init, megasas_fusion_crash_dump_wq); 5449 INIT_WORK(&instance->crash_init, megasas_fusion_crash_dump_wq);
5491 } else 5450 } else
@@ -5565,10 +5524,7 @@ fail_io_attach:
5565 instance->instancet->disable_intr(instance); 5524 instance->instancet->disable_intr(instance);
5566 megasas_destroy_irqs(instance); 5525 megasas_destroy_irqs(instance);
5567 5526
5568 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) || 5527 if (instance->ctrl_context)
5569 (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA) ||
5570 (instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) ||
5571 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
5572 megasas_release_fusion(instance); 5528 megasas_release_fusion(instance);
5573 else 5529 else
5574 megasas_release_mfi(instance); 5530 megasas_release_mfi(instance);
@@ -5781,12 +5737,7 @@ megasas_resume(struct pci_dev *pdev)
5781 instance->msix_vectors)) 5737 instance->msix_vectors))
5782 goto fail_reenable_msix; 5738 goto fail_reenable_msix;
5783 5739
5784 switch (instance->pdev->device) { 5740 if (instance->ctrl_context) {
5785 case PCI_DEVICE_ID_LSI_FUSION:
5786 case PCI_DEVICE_ID_LSI_PLASMA:
5787 case PCI_DEVICE_ID_LSI_INVADER:
5788 case PCI_DEVICE_ID_LSI_FURY:
5789 {
5790 megasas_reset_reply_desc(instance); 5741 megasas_reset_reply_desc(instance);
5791 if (megasas_ioc_init_fusion(instance)) { 5742 if (megasas_ioc_init_fusion(instance)) {
5792 megasas_free_cmds(instance); 5743 megasas_free_cmds(instance);
@@ -5795,14 +5746,11 @@ megasas_resume(struct pci_dev *pdev)
5795 } 5746 }
5796 if (!megasas_get_map_info(instance)) 5747 if (!megasas_get_map_info(instance))
5797 megasas_sync_map_info(instance); 5748 megasas_sync_map_info(instance);
5798 } 5749 } else {
5799 break;
5800 default:
5801 *instance->producer = 0; 5750 *instance->producer = 0;
5802 *instance->consumer = 0; 5751 *instance->consumer = 0;
5803 if (megasas_issue_init_mfi(instance)) 5752 if (megasas_issue_init_mfi(instance))
5804 goto fail_init_mfi; 5753 goto fail_init_mfi;
5805 break;
5806 } 5754 }
5807 5755
5808 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet, 5756 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet,
@@ -5924,11 +5872,7 @@ static void megasas_detach_one(struct pci_dev *pdev)
5924 if (instance->msix_vectors) 5872 if (instance->msix_vectors)
5925 pci_disable_msix(instance->pdev); 5873 pci_disable_msix(instance->pdev);
5926 5874
5927 switch (instance->pdev->device) { 5875 if (instance->ctrl_context) {
5928 case PCI_DEVICE_ID_LSI_FUSION:
5929 case PCI_DEVICE_ID_LSI_PLASMA:
5930 case PCI_DEVICE_ID_LSI_INVADER:
5931 case PCI_DEVICE_ID_LSI_FURY:
5932 megasas_release_fusion(instance); 5876 megasas_release_fusion(instance);
5933 pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) + 5877 pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
5934 (sizeof(struct MR_PD_CFG_SEQ) * 5878 (sizeof(struct MR_PD_CFG_SEQ) *
@@ -5950,8 +5894,7 @@ static void megasas_detach_one(struct pci_dev *pdev)
5950 } 5894 }
5951 free_pages((ulong)instance->ctrl_context, 5895 free_pages((ulong)instance->ctrl_context,
5952 instance->ctrl_context_pages); 5896 instance->ctrl_context_pages);
5953 break; 5897 } else {
5954 default:
5955 megasas_release_mfi(instance); 5898 megasas_release_mfi(instance);
5956 pci_free_consistent(pdev, sizeof(u32), 5899 pci_free_consistent(pdev, sizeof(u32),
5957 instance->producer, 5900 instance->producer,
@@ -5959,7 +5902,6 @@ static void megasas_detach_one(struct pci_dev *pdev)
5959 pci_free_consistent(pdev, sizeof(u32), 5902 pci_free_consistent(pdev, sizeof(u32),
5960 instance->consumer, 5903 instance->consumer,
5961 instance->consumer_h); 5904 instance->consumer_h);
5962 break;
5963 } 5905 }
5964 5906
5965 kfree(instance->ctrl_info); 5907 kfree(instance->ctrl_info);
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
index be57b18675a4..ce5b832557ef 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -741,14 +741,12 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld,
741 u8 physArm, span; 741 u8 physArm, span;
742 u64 row; 742 u64 row;
743 u8 retval = TRUE; 743 u8 retval = TRUE;
744 u8 do_invader = 0;
745 u64 *pdBlock = &io_info->pdBlock; 744 u64 *pdBlock = &io_info->pdBlock;
746 __le16 *pDevHandle = &io_info->devHandle; 745 __le16 *pDevHandle = &io_info->devHandle;
747 u32 logArm, rowMod, armQ, arm; 746 u32 logArm, rowMod, armQ, arm;
747 struct fusion_context *fusion;
748 748
749 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER || 749 fusion = instance->ctrl_context;
750 instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
751 do_invader = 1;
752 750
753 /*Get row and span from io_info for Uneven Span IO.*/ 751 /*Get row and span from io_info for Uneven Span IO.*/
754 row = io_info->start_row; 752 row = io_info->start_row;
@@ -779,7 +777,8 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld,
779 else { 777 else {
780 *pDevHandle = cpu_to_le16(MR_PD_INVALID); 778 *pDevHandle = cpu_to_le16(MR_PD_INVALID);
781 if ((raid->level >= 5) && 779 if ((raid->level >= 5) &&
782 (!do_invader || (do_invader && 780 ((fusion->adapter_type == THUNDERBOLT_SERIES) ||
781 ((fusion->adapter_type == INVADER_SERIES) &&
783 (raid->regTypeReqOnRead != REGION_TYPE_UNUSED)))) 782 (raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
784 pRAID_Context->regLockFlags = REGION_TYPE_EXCLUSIVE; 783 pRAID_Context->regLockFlags = REGION_TYPE_EXCLUSIVE;
785 else if (raid->level == 1) { 784 else if (raid->level == 1) {
@@ -823,13 +822,12 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow,
823 u8 physArm, span; 822 u8 physArm, span;
824 u64 row; 823 u64 row;
825 u8 retval = TRUE; 824 u8 retval = TRUE;
826 u8 do_invader = 0;
827 u64 *pdBlock = &io_info->pdBlock; 825 u64 *pdBlock = &io_info->pdBlock;
828 __le16 *pDevHandle = &io_info->devHandle; 826 __le16 *pDevHandle = &io_info->devHandle;
827 struct fusion_context *fusion;
828
829 fusion = instance->ctrl_context;
829 830
830 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER ||
831 instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
832 do_invader = 1;
833 831
834 row = mega_div64_32(stripRow, raid->rowDataSize); 832 row = mega_div64_32(stripRow, raid->rowDataSize);
835 833
@@ -875,7 +873,8 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow,
875 /* set dev handle as invalid. */ 873 /* set dev handle as invalid. */
876 *pDevHandle = cpu_to_le16(MR_PD_INVALID); 874 *pDevHandle = cpu_to_le16(MR_PD_INVALID);
877 if ((raid->level >= 5) && 875 if ((raid->level >= 5) &&
878 (!do_invader || (do_invader && 876 ((fusion->adapter_type == THUNDERBOLT_SERIES) ||
877 ((fusion->adapter_type == INVADER_SERIES) &&
879 (raid->regTypeReqOnRead != REGION_TYPE_UNUSED)))) 878 (raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
880 pRAID_Context->regLockFlags = REGION_TYPE_EXCLUSIVE; 879 pRAID_Context->regLockFlags = REGION_TYPE_EXCLUSIVE;
881 else if (raid->level == 1) { 880 else if (raid->level == 1) {
@@ -909,6 +908,7 @@ MR_BuildRaidContext(struct megasas_instance *instance,
909 struct RAID_CONTEXT *pRAID_Context, 908 struct RAID_CONTEXT *pRAID_Context,
910 struct MR_DRV_RAID_MAP_ALL *map, u8 **raidLUN) 909 struct MR_DRV_RAID_MAP_ALL *map, u8 **raidLUN)
911{ 910{
911 struct fusion_context *fusion;
912 struct MR_LD_RAID *raid; 912 struct MR_LD_RAID *raid;
913 u32 ld, stripSize, stripe_mask; 913 u32 ld, stripSize, stripe_mask;
914 u64 endLba, endStrip, endRow, start_row, start_strip; 914 u64 endLba, endStrip, endRow, start_row, start_strip;
@@ -929,6 +929,7 @@ MR_BuildRaidContext(struct megasas_instance *instance,
929 isRead = io_info->isRead; 929 isRead = io_info->isRead;
930 io_info->IoforUnevenSpan = 0; 930 io_info->IoforUnevenSpan = 0;
931 io_info->start_span = SPAN_INVALID; 931 io_info->start_span = SPAN_INVALID;
932 fusion = instance->ctrl_context;
932 933
933 ld = MR_TargetIdToLdGet(ldTgtId, map); 934 ld = MR_TargetIdToLdGet(ldTgtId, map);
934 raid = MR_LdRaidGet(ld, map); 935 raid = MR_LdRaidGet(ld, map);
@@ -1092,8 +1093,7 @@ MR_BuildRaidContext(struct megasas_instance *instance,
1092 cpu_to_le16(raid->fpIoTimeoutForLd ? 1093 cpu_to_le16(raid->fpIoTimeoutForLd ?
1093 raid->fpIoTimeoutForLd : 1094 raid->fpIoTimeoutForLd :
1094 map->raidMap.fpPdIoTimeoutSec); 1095 map->raidMap.fpPdIoTimeoutSec);
1095 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || 1096 if (fusion->adapter_type == INVADER_SERIES)
1096 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
1097 pRAID_Context->regLockFlags = (isRead) ? 1097 pRAID_Context->regLockFlags = (isRead) ?
1098 raid->regTypeReqOnRead : raid->regTypeReqOnWrite; 1098 raid->regTypeReqOnRead : raid->regTypeReqOnWrite;
1099 else 1099 else
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index b1314964f1d0..bed7fb1ba2a6 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -653,8 +653,7 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
653 drv_ops = (MFI_CAPABILITIES *) &(init_frame->driver_operations); 653 drv_ops = (MFI_CAPABILITIES *) &(init_frame->driver_operations);
654 654
655 /* driver support Extended MSIX */ 655 /* driver support Extended MSIX */
656 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || 656 if (fusion->adapter_type == INVADER_SERIES)
657 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
658 drv_ops->mfi_capabilities.support_additional_msix = 1; 657 drv_ops->mfi_capabilities.support_additional_msix = 1;
659 /* driver supports HA / Remote LUN over Fast Path interface */ 658 /* driver supports HA / Remote LUN over Fast Path interface */
660 drv_ops->mfi_capabilities.support_fp_remote_lun = 1; 659 drv_ops->mfi_capabilities.support_fp_remote_lun = 1;
@@ -1288,8 +1287,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
1288 1287
1289 fusion = instance->ctrl_context; 1288 fusion = instance->ctrl_context;
1290 1289
1291 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || 1290 if (fusion->adapter_type == INVADER_SERIES) {
1292 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
1293 struct MPI25_IEEE_SGE_CHAIN64 *sgl_ptr_end = sgl_ptr; 1291 struct MPI25_IEEE_SGE_CHAIN64 *sgl_ptr_end = sgl_ptr;
1294 sgl_ptr_end += fusion->max_sge_in_main_msg - 1; 1292 sgl_ptr_end += fusion->max_sge_in_main_msg - 1;
1295 sgl_ptr_end->Flags = 0; 1293 sgl_ptr_end->Flags = 0;
@@ -1306,11 +1304,9 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
1306 sgl_ptr->Length = cpu_to_le32(sg_dma_len(os_sgl)); 1304 sgl_ptr->Length = cpu_to_le32(sg_dma_len(os_sgl));
1307 sgl_ptr->Address = cpu_to_le64(sg_dma_address(os_sgl)); 1305 sgl_ptr->Address = cpu_to_le64(sg_dma_address(os_sgl));
1308 sgl_ptr->Flags = 0; 1306 sgl_ptr->Flags = 0;
1309 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || 1307 if (fusion->adapter_type == INVADER_SERIES)
1310 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
1311 if (i == sge_count - 1) 1308 if (i == sge_count - 1)
1312 sgl_ptr->Flags = IEEE_SGE_FLAGS_END_OF_LIST; 1309 sgl_ptr->Flags = IEEE_SGE_FLAGS_END_OF_LIST;
1313 }
1314 sgl_ptr++; 1310 sgl_ptr++;
1315 1311
1316 sg_processed = i + 1; 1312 sg_processed = i + 1;
@@ -1319,10 +1315,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
1319 (sge_count > fusion->max_sge_in_main_msg)) { 1315 (sge_count > fusion->max_sge_in_main_msg)) {
1320 1316
1321 struct MPI25_IEEE_SGE_CHAIN64 *sg_chain; 1317 struct MPI25_IEEE_SGE_CHAIN64 *sg_chain;
1322 if ((instance->pdev->device == 1318 if (fusion->adapter_type == INVADER_SERIES) {
1323 PCI_DEVICE_ID_LSI_INVADER) ||
1324 (instance->pdev->device ==
1325 PCI_DEVICE_ID_LSI_FURY)) {
1326 if ((le16_to_cpu(cmd->io_request->IoFlags) & 1319 if ((le16_to_cpu(cmd->io_request->IoFlags) &
1327 MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH) != 1320 MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH) !=
1328 MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH) 1321 MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH)
@@ -1338,10 +1331,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
1338 sg_chain = sgl_ptr; 1331 sg_chain = sgl_ptr;
1339 /* Prepare chain element */ 1332 /* Prepare chain element */
1340 sg_chain->NextChainOffset = 0; 1333 sg_chain->NextChainOffset = 0;
1341 if ((instance->pdev->device == 1334 if (fusion->adapter_type == INVADER_SERIES)
1342 PCI_DEVICE_ID_LSI_INVADER) ||
1343 (instance->pdev->device ==
1344 PCI_DEVICE_ID_LSI_FURY))
1345 sg_chain->Flags = IEEE_SGE_FLAGS_CHAIN_ELEMENT; 1335 sg_chain->Flags = IEEE_SGE_FLAGS_CHAIN_ELEMENT;
1346 else 1336 else
1347 sg_chain->Flags = 1337 sg_chain->Flags =
@@ -1658,8 +1648,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
1658 cmd->request_desc->SCSIIO.RequestFlags = 1648 cmd->request_desc->SCSIIO.RequestFlags =
1659 (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY 1649 (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY
1660 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); 1650 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
1661 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || 1651 if (fusion->adapter_type == INVADER_SERIES) {
1662 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
1663 if (io_request->RaidContext.regLockFlags == 1652 if (io_request->RaidContext.regLockFlags ==
1664 REGION_TYPE_UNUSED) 1653 REGION_TYPE_UNUSED)
1665 cmd->request_desc->SCSIIO.RequestFlags = 1654 cmd->request_desc->SCSIIO.RequestFlags =
@@ -1700,8 +1689,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
1700 cmd->request_desc->SCSIIO.RequestFlags = 1689 cmd->request_desc->SCSIIO.RequestFlags =
1701 (MEGASAS_REQ_DESCRIPT_FLAGS_LD_IO 1690 (MEGASAS_REQ_DESCRIPT_FLAGS_LD_IO
1702 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); 1691 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
1703 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || 1692 if (fusion->adapter_type == INVADER_SERIES) {
1704 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
1705 if (io_request->RaidContext.regLockFlags == 1693 if (io_request->RaidContext.regLockFlags ==
1706 REGION_TYPE_UNUSED) 1694 REGION_TYPE_UNUSED)
1707 cmd->request_desc->SCSIIO.RequestFlags = 1695 cmd->request_desc->SCSIIO.RequestFlags =
@@ -1890,8 +1878,7 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
1890 pRAID_Context->timeoutValue = 1878 pRAID_Context->timeoutValue =
1891 cpu_to_le16((os_timeout_value > timeout_limit) ? 1879 cpu_to_le16((os_timeout_value > timeout_limit) ?
1892 timeout_limit : os_timeout_value); 1880 timeout_limit : os_timeout_value);
1893 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || 1881 if (fusion->adapter_type == INVADER_SERIES) {
1894 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
1895 pRAID_Context->Type = MPI2_TYPE_CUDA; 1882 pRAID_Context->Type = MPI2_TYPE_CUDA;
1896 pRAID_Context->nseg = 0x1; 1883 pRAID_Context->nseg = 0x1;
1897 io_request->IoFlags |= 1884 io_request->IoFlags |=
@@ -2209,10 +2196,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
2209 * pending to be completed 2196 * pending to be completed
2210 */ 2197 */
2211 if (threshold_reply_count >= THRESHOLD_REPLY_COUNT) { 2198 if (threshold_reply_count >= THRESHOLD_REPLY_COUNT) {
2212 if ((instance->pdev->device == 2199 if (fusion->adapter_type == INVADER_SERIES)
2213 PCI_DEVICE_ID_LSI_INVADER) ||
2214 (instance->pdev->device ==
2215 PCI_DEVICE_ID_LSI_FURY))
2216 writel(((MSIxIndex & 0x7) << 24) | 2200 writel(((MSIxIndex & 0x7) << 24) |
2217 fusion->last_reply_idx[MSIxIndex], 2201 fusion->last_reply_idx[MSIxIndex],
2218 instance->reply_post_host_index_addr[MSIxIndex/8]); 2202 instance->reply_post_host_index_addr[MSIxIndex/8]);
@@ -2228,8 +2212,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
2228 return IRQ_NONE; 2212 return IRQ_NONE;
2229 2213
2230 wmb(); 2214 wmb();
2231 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || 2215 if (fusion->adapter_type == INVADER_SERIES)
2232 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY))
2233 writel(((MSIxIndex & 0x7) << 24) | 2216 writel(((MSIxIndex & 0x7) << 24) |
2234 fusion->last_reply_idx[MSIxIndex], 2217 fusion->last_reply_idx[MSIxIndex],
2235 instance->reply_post_host_index_addr[MSIxIndex/8]); 2218 instance->reply_post_host_index_addr[MSIxIndex/8]);
@@ -2352,8 +2335,7 @@ build_mpt_mfi_pass_thru(struct megasas_instance *instance,
2352 2335
2353 io_req = cmd->io_request; 2336 io_req = cmd->io_request;
2354 2337
2355 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_INVADER) || 2338 if (fusion->adapter_type == INVADER_SERIES) {
2356 (instance->pdev->device == PCI_DEVICE_ID_LSI_FURY)) {
2357 struct MPI25_IEEE_SGE_CHAIN64 *sgl_ptr_end = 2339 struct MPI25_IEEE_SGE_CHAIN64 *sgl_ptr_end =
2358 (struct MPI25_IEEE_SGE_CHAIN64 *)&io_req->SGL; 2340 (struct MPI25_IEEE_SGE_CHAIN64 *)&io_req->SGL;
2359 sgl_ptr_end += fusion->max_sge_in_main_msg - 1; 2341 sgl_ptr_end += fusion->max_sge_in_main_msg - 1;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h
index 7d89c1c950bd..473005c99b44 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
@@ -96,6 +96,11 @@ enum MR_RAID_FLAGS_IO_SUB_TYPE {
96#define THRESHOLD_REPLY_COUNT 50 96#define THRESHOLD_REPLY_COUNT 50
97#define JBOD_MAPS_COUNT 2 97#define JBOD_MAPS_COUNT 2
98 98
99enum MR_FUSION_ADAPTER_TYPE {
100 THUNDERBOLT_SERIES = 0,
101 INVADER_SERIES = 1,
102};
103
99/* 104/*
100 * Raid Context structure which describes MegaRAID specific IO Parameters 105 * Raid Context structure which describes MegaRAID specific IO Parameters
101 * This resides at offset 0x60 where the SGL normally starts in MPT IO Frames 106 * This resides at offset 0x60 where the SGL normally starts in MPT IO Frames
@@ -857,6 +862,7 @@ struct fusion_context {
857 u8 fast_path_io; 862 u8 fast_path_io;
858 struct LD_LOAD_BALANCE_INFO load_balance_info[MAX_LOGICAL_DRIVES_EXT]; 863 struct LD_LOAD_BALANCE_INFO load_balance_info[MAX_LOGICAL_DRIVES_EXT];
859 LD_SPAN_INFO log_to_span[MAX_LOGICAL_DRIVES_EXT]; 864 LD_SPAN_INFO log_to_span[MAX_LOGICAL_DRIVES_EXT];
865 u8 adapter_type;
860}; 866};
861 867
862union desc_value { 868union desc_value {