b312fc
From bd2314e40123381058f15b3ae49616d1cccb4f44 Mon Sep 17 00:00:00 2001
b312fc
From: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
b312fc
Date: Wed, 26 Oct 2016 13:34:38 +0530
b312fc
Subject: [PATCH 07/11] scsi: mpt3sas: Increased/Additional MSIX support for
b312fc
 SAS35 devices.
b312fc
b312fc
For SAS35 devices MSIX vectors are inceased to 128 from 96. To support this
b312fc
Reply post host index register count is increased to 16. Also variable
b312fc
msix96_vector is replaced with combined_reply_queue and variable
b312fc
combined_reply_index_count is added to set different values for SAS3 and
b312fc
SAS35 devices.
b312fc
b312fc
Signed-off-by: Chaitra P B <chaitra.basappa@broadcom.com>
b312fc
Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
b312fc
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
b312fc
Reviewed-by: Hannes Reinecke <hare@suse.com>
b312fc
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
b312fc
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
b312fc
---
b312fc
 drivers/scsi/mpt3sas/mpt3sas_base.c  | 14 +++++++-------
b312fc
 drivers/scsi/mpt3sas/mpt3sas_base.h  |  8 +++++---
b312fc
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 11 +++++++++--
b312fc
 3 files changed, 21 insertions(+), 12 deletions(-)
b312fc
b312fc
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
b312fc
index ac87e12..b26fa23 100644
b312fc
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
b312fc
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
b312fc
@@ -1079,7 +1079,7 @@ _base_interrupt(int irq, void *bus_id)
b312fc
 	 * new reply host index value in ReplyPostIndex Field and msix_index
b312fc
 	 * value in MSIxIndex field.
b312fc
 	 */
b312fc
-	if (ioc->msix96_vector)
b312fc
+	if (ioc->combined_reply_queue)
b312fc
 		writel(reply_q->reply_post_host_index | ((msix_index  & 7) <<
b312fc
 			MPI2_RPHI_MSIX_INDEX_SHIFT),
b312fc
 			ioc->replyPostRegisterIndex[msix_index/8]);
b312fc
@@ -2053,7 +2053,7 @@ mpt3sas_base_unmap_resources(struct MPT3SAS_ADAPTER *ioc)
b312fc
 	_base_free_irq(ioc);
b312fc
 	_base_disable_msix(ioc);
b312fc
 
b312fc
-	if (ioc->msix96_vector) {
b312fc
+	if (ioc->combined_reply_queue) {
b312fc
 		kfree(ioc->replyPostRegisterIndex);
b312fc
 		ioc->replyPostRegisterIndex = NULL;
b312fc
 	}
b312fc
@@ -2163,7 +2163,7 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc)
b312fc
 	/* Use the Combined reply queue feature only for SAS3 C0 & higher
b312fc
 	 * revision HBAs and also only when reply queue count is greater than 8
b312fc
 	 */
b312fc
-	if (ioc->msix96_vector && ioc->reply_queue_count > 8) {
b312fc
+	if (ioc->combined_reply_queue && ioc->reply_queue_count > 8) {
b312fc
 		/* Determine the Supplemental Reply Post Host Index Registers
b312fc
 		 * Addresse. Supplemental Reply Post Host Index Registers
b312fc
 		 * starts at offset MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET and
b312fc
@@ -2171,7 +2171,7 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc)
b312fc
 		 * MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET from previous one.
b312fc
 		 */
b312fc
 		ioc->replyPostRegisterIndex = kcalloc(
b312fc
-		     MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT,
b312fc
+		     ioc->combined_reply_index_count,
b312fc
 		     sizeof(resource_size_t *), GFP_KERNEL);
b312fc
 		if (!ioc->replyPostRegisterIndex) {
b312fc
 			dfailprintk(ioc, printk(MPT3SAS_FMT
b312fc
@@ -2181,14 +2181,14 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc)
b312fc
 			goto out_fail;
b312fc
 		}
b312fc
 
b312fc
-		for (i = 0; i < MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT; i++) {
b312fc
+		for (i = 0; i < ioc->combined_reply_index_count; i++) {
b312fc
 			ioc->replyPostRegisterIndex[i] = (resource_size_t *)
b312fc
 			     ((u8 *)&ioc->chip->Doorbell +
b312fc
 			     MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET +
b312fc
 			     (i * MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET));
b312fc
 		}
b312fc
 	} else
b312fc
-		ioc->msix96_vector = 0;
b312fc
+		ioc->combined_reply_queue = 0;
b312fc
 
b312fc
 	list_for_each_entry(reply_q, &ioc->reply_queue_list, list)
b312fc
 		pr_info(MPT3SAS_FMT "%s: IRQ %d\n",
b312fc
@@ -5161,7 +5161,7 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc, int sleep_flag)
b312fc
 
b312fc
 	/* initialize reply post host index */
b312fc
 	list_for_each_entry(reply_q, &ioc->reply_queue_list, list) {
b312fc
-		if (ioc->msix96_vector)
b312fc
+		if (ioc->combined_reply_queue)
b312fc
 			writel((reply_q->msix_index & 7)<<
b312fc
 			   MPI2_RPHI_MSIX_INDEX_SHIFT,
b312fc
 			   ioc->replyPostRegisterIndex[reply_q->msix_index/8]);
b312fc
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h
b312fc
index c3a39e8..240c360 100644
b312fc
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
b312fc
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
b312fc
@@ -304,8 +304,9 @@
b312fc
  * There are twelve Supplemental Reply Post Host Index Registers
b312fc
  * and each register is at offset 0x10 bytes from the previous one.
b312fc
  */
b312fc
-#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT 12
b312fc
-#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET (0x10)
b312fc
+#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G3	12
b312fc
+#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G35	16
b312fc
+#define MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET	(0x10)
b312fc
 
b312fc
 /* OEM Identifiers */
b312fc
 #define MFG10_OEM_ID_INVALID                   (0x00000000)
b312fc
@@ -1172,7 +1173,8 @@ struct MPT3SAS_ADAPTER {
b312fc
 	u8		reply_queue_count;
b312fc
 	struct list_head reply_queue_list;
b312fc
 
b312fc
-	u8		msix96_vector;
b312fc
+	u8		combined_reply_queue;
b312fc
+	u8		combined_reply_index_count;
b312fc
 	/* reply post register index */
b312fc
 	resource_size_t	**replyPostRegisterIndex;
b312fc
 
b312fc
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
b312fc
index eaef45c..980c69d 100644
b312fc
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
b312fc
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
b312fc
@@ -8797,8 +8797,15 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
b312fc
 		}
b312fc
 		if ((ioc->hba_mpi_version_belonged == MPI25_VERSION &&
b312fc
 			pdev->revision >= SAS3_PCI_DEVICE_C0_REVISION) ||
b312fc
-			(ioc->hba_mpi_version_belonged == MPI26_VERSION))
b312fc
-			ioc->msix96_vector = 1;
b312fc
+			(ioc->hba_mpi_version_belonged == MPI26_VERSION)) {
b312fc
+			ioc->combined_reply_queue = 1;
b312fc
+			if (ioc->is_gen35_ioc)
b312fc
+				ioc->combined_reply_index_count =
b312fc
+				 MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G35;
b312fc
+			else
b312fc
+				ioc->combined_reply_index_count =
b312fc
+				 MPT3_SUP_REPLY_POST_HOST_INDEX_REG_COUNT_G3;
b312fc
+		}
b312fc
 		break;
b312fc
 	default:
b312fc
 		return -ENODEV;
b312fc
-- 
b312fc
1.8.3.1
b312fc