b312fc
From 13ac44ddfb8f0cfc407bb91713384e9961f6e762 Mon Sep 17 00:00:00 2001
b312fc
From: Sasikumar Chandrasekaran <sasikumar.pc@broadcom.com>
b312fc
Date: Tue, 10 Jan 2017 18:20:44 -0500
b312fc
Subject: [PATCH 02/11] scsi: megaraid_sas: 128 MSIX Support
b312fc
b312fc
SAS3.5 Generic Megaraid based Controllers will have the support for 128 MSI-X vectors,
b312fc
resulting in the need to support 128 reply queues
b312fc
b312fc
Signed-off-by: Sasikumar Chandrasekaran <sasikumar.pc@broadcom.com>
b312fc
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
b312fc
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
b312fc
---
b312fc
 drivers/scsi/megaraid/megaraid_sas.h        |  1 +
b312fc
 drivers/scsi/megaraid/megaraid_sas_base.c   | 24 +++++++++++++++++-------
b312fc
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  4 ++--
b312fc
 3 files changed, 20 insertions(+), 9 deletions(-)
b312fc
b312fc
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
b312fc
index e5ac6b1..ccef47b 100644
b312fc
--- a/drivers/scsi/megaraid/megaraid_sas.h
b312fc
+++ b/drivers/scsi/megaraid/megaraid_sas.h
b312fc
@@ -2149,6 +2149,7 @@ struct megasas_instance {
b312fc
 	bool dev_handle;
b312fc
 	bool fw_sync_cache_support;
b312fc
 	bool is_ventura;
b312fc
+	bool msix_combined;
b312fc
 };
b312fc
 struct MR_LD_VF_MAP {
b312fc
 	u32 size;
b312fc
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
b312fc
index a73e6f6..c78d7ee 100644
b312fc
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
b312fc
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
b312fc
@@ -5119,13 +5119,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
b312fc
 			goto fail_ready_state;
b312fc
 	}
b312fc
 
b312fc
-	/*
b312fc
-	 * MSI-X host index 0 is common for all adapter.
b312fc
-	 * It is used for all MPT based Adapters.
b312fc
-	 */
b312fc
-	instance->reply_post_host_index_addr[0] =
b312fc
-		(u32 __iomem *)((u8 __iomem *)instance->reg_set +
b312fc
-		MPI2_REPLY_POST_HOST_INDEX_OFFSET);
b312fc
+
b312fc
 
b312fc
 	/* Check if MSI-X is supported while in ready state */
b312fc
 	msix_enable = (instance->instancet->read_fw_status_reg(reg_set) &
b312fc
@@ -5143,6 +5137,9 @@ static int megasas_init_fw(struct megasas_instance *instance)
b312fc
 				instance->msix_vectors = ((scratch_pad_2
b312fc
 					& MR_MAX_REPLY_QUEUES_EXT_OFFSET)
b312fc
 					>> MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT) + 1;
b312fc
+				if (instance->msix_vectors > 16)
b312fc
+					instance->msix_combined = true;
b312fc
+
b312fc
 				if (rdpq_enable)
b312fc
 					instance->is_rdpq = (scratch_pad_2 & MR_RDPQ_MODE_OFFSET) ?
b312fc
 								1 : 0;
b312fc
@@ -5176,6 +5173,19 @@ static int megasas_init_fw(struct megasas_instance *instance)
b312fc
 		else
b312fc
 			instance->msix_vectors = 0;
b312fc
 	}
b312fc
+	/*
b312fc
+	 * MSI-X host index 0 is common for all adapter.
b312fc
+	 * It is used for all MPT based Adapters.
b312fc
+	 */
b312fc
+	if (instance->msix_combined) {
b312fc
+		instance->reply_post_host_index_addr[0] =
b312fc
+				(u32 *)((u8 *)instance->reg_set +
b312fc
+				MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET);
b312fc
+	} else {
b312fc
+		instance->reply_post_host_index_addr[0] =
b312fc
+			(u32 *)((u8 *)instance->reg_set +
b312fc
+			MPI2_REPLY_POST_HOST_INDEX_OFFSET);
b312fc
+	}
b312fc
 
b312fc
 	dev_info(&instance->pdev->dev,
b312fc
 		"firmware supports msix\t: (%d)", fw_msix_count);
b312fc
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
b312fc
index 5ad8a07..c64b85a 100644
b312fc
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
b312fc
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
b312fc
@@ -2391,7 +2391,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
b312fc
 		 * pending to be completed
b312fc
 		 */
b312fc
 		if (threshold_reply_count >= THRESHOLD_REPLY_COUNT) {
b312fc
-			if (fusion->adapter_type == INVADER_SERIES)
b312fc
+			if (instance->msix_combined)
b312fc
 				writel(((MSIxIndex & 0x7) << 24) |
b312fc
 					fusion->last_reply_idx[MSIxIndex],
b312fc
 					instance->reply_post_host_index_addr[MSIxIndex/8]);
b312fc
@@ -2407,7 +2407,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
b312fc
 		return IRQ_NONE;
b312fc
 
b312fc
 	wmb();
b312fc
-	if (fusion->adapter_type == INVADER_SERIES)
b312fc
+	if (instance->msix_combined)
b312fc
 		writel(((MSIxIndex & 0x7) << 24) |
b312fc
 			fusion->last_reply_idx[MSIxIndex],
b312fc
 			instance->reply_post_host_index_addr[MSIxIndex/8]);
b312fc
-- 
b312fc
1.8.3.1
b312fc