liuyingdong / rpms / kernel

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