]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[SCSI] megaraid_sas: Performance boost fixes
authorSumit.Saxena@lsi.com <Sumit.Saxena@lsi.com>
Sat, 1 Mar 2014 23:58:11 +0000 (05:28 +0530)
committerJames Bottomley <JBottomley@Parallels.com>
Sat, 15 Mar 2014 17:19:20 +0000 (10:19 -0700)
Host lock is added back around queuecommand. Host lock removal can create race
conditon between ISR path(when RAID map update interrupt is raised) and IO
build path of driver, since IO build path is making use of RAID map, and in
case of RAID map update interrupt, old RAID map copy is memset to zero, which
some IOs may be referencing in build IO path.  Changes done for performance
boost- 1) Added code to set SMP IRQ affinity per CPU.  2) Pass MSI-x index,
while issuing sysPD IO.

Signed-off-by: Kashyap Desai <kashyap.desai@lsi.com>
Signed-off-by: Sumit Saxena <sumit.saxena@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/megaraid/megaraid_sas_fusion.c

index db58bbe4f95214bc6dd8dcf290f555c45f55cec8..c6203e677ab36fc675b4e699b00c3e7999e828c0 100644 (file)
@@ -4249,7 +4249,7 @@ fail_set_dma_mask:
 static int megasas_probe_one(struct pci_dev *pdev,
                             const struct pci_device_id *id)
 {
-       int rval, pos, i, j;
+       int rval, pos, i, j, cpu;
        struct Scsi_Host *host;
        struct megasas_instance *instance;
        u16 control = 0;
@@ -4422,7 +4422,8 @@ retry_irq_register:
         * Register IRQ
         */
        if (instance->msix_vectors) {
-               for (i = 0 ; i < instance->msix_vectors; i++) {
+               cpu = cpumask_first(cpu_online_mask);
+               for (i = 0; i < instance->msix_vectors; i++) {
                        instance->irq_context[i].instance = instance;
                        instance->irq_context[i].MSIxIndex = i;
                        if (request_irq(instance->msixentry[i].vector,
@@ -4431,14 +4432,22 @@ retry_irq_register:
                                        &instance->irq_context[i])) {
                                printk(KERN_DEBUG "megasas: Failed to "
                                       "register IRQ for vector %d.\n", i);
-                               for (j = 0 ; j < i ; j++)
+                               for (j = 0; j < i; j++) {
+                                       irq_set_affinity_hint(
+                                               instance->msixentry[j].vector, NULL);
                                        free_irq(
                                                instance->msixentry[j].vector,
                                                &instance->irq_context[j]);
+                               }
                                /* Retry irq register for IO_APIC */
                                instance->msix_vectors = 0;
                                goto retry_irq_register;
                        }
+                       if (irq_set_affinity_hint(instance->msixentry[i].vector,
+                               get_cpu_mask(cpu)))
+                               dev_err(&instance->pdev->dev, "Error setting"
+                                       "affinity hint for cpu %d\n", cpu);
+                       cpu = cpumask_next(cpu, cpu_online_mask);
                }
        } else {
                instance->irq_context[0].instance = instance;
@@ -4492,9 +4501,12 @@ retry_irq_register:
 
        instance->instancet->disable_intr(instance);
        if (instance->msix_vectors)
-               for (i = 0 ; i < instance->msix_vectors; i++)
+               for (i = 0; i < instance->msix_vectors; i++) {
+                       irq_set_affinity_hint(
+                               instance->msixentry[i].vector, NULL);
                        free_irq(instance->msixentry[i].vector,
                                 &instance->irq_context[i]);
+               }
        else
                free_irq(instance->pdev->irq, &instance->irq_context[0]);
 fail_irq:
@@ -4648,9 +4660,12 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state)
        instance->instancet->disable_intr(instance);
 
        if (instance->msix_vectors)
-               for (i = 0 ; i < instance->msix_vectors; i++)
+               for (i = 0; i < instance->msix_vectors; i++) {
+                       irq_set_affinity_hint(
+                               instance->msixentry[i].vector, NULL);
                        free_irq(instance->msixentry[i].vector,
                                 &instance->irq_context[i]);
+               }
        else
                free_irq(instance->pdev->irq, &instance->irq_context[0]);
        if (instance->msix_vectors)
@@ -4671,7 +4686,7 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state)
 static int
 megasas_resume(struct pci_dev *pdev)
 {
-       int rval, i, j;
+       int rval, i, j, cpu;
        struct Scsi_Host *host;
        struct megasas_instance *instance;
 
@@ -4743,6 +4758,7 @@ megasas_resume(struct pci_dev *pdev)
         * Register IRQ
         */
        if (instance->msix_vectors) {
+               cpu = cpumask_first(cpu_online_mask);
                for (i = 0 ; i < instance->msix_vectors; i++) {
                        instance->irq_context[i].instance = instance;
                        instance->irq_context[i].MSIxIndex = i;
@@ -4752,12 +4768,21 @@ megasas_resume(struct pci_dev *pdev)
                                        &instance->irq_context[i])) {
                                printk(KERN_DEBUG "megasas: Failed to "
                                       "register IRQ for vector %d.\n", i);
-                               for (j = 0 ; j < i ; j++)
+                               for (j = 0; j < i; j++) {
+                                       irq_set_affinity_hint(
+                                               instance->msixentry[j].vector, NULL);
                                        free_irq(
                                                instance->msixentry[j].vector,
                                                &instance->irq_context[j]);
+                               }
                                goto fail_irq;
                        }
+
+                       if (irq_set_affinity_hint(instance->msixentry[i].vector,
+                               get_cpu_mask(cpu)))
+                               dev_err(&instance->pdev->dev, "Error setting"
+                                       "affinity hint for cpu %d\n", cpu);
+                       cpu = cpumask_next(cpu, cpu_online_mask);
                }
        } else {
                instance->irq_context[0].instance = instance;
@@ -4856,9 +4881,12 @@ static void megasas_detach_one(struct pci_dev *pdev)
        instance->instancet->disable_intr(instance);
 
        if (instance->msix_vectors)
-               for (i = 0 ; i < instance->msix_vectors; i++)
+               for (i = 0; i < instance->msix_vectors; i++) {
+                       irq_set_affinity_hint(
+                               instance->msixentry[i].vector, NULL);
                        free_irq(instance->msixentry[i].vector,
                                 &instance->irq_context[i]);
+               }
        else
                free_irq(instance->pdev->irq, &instance->irq_context[0]);
        if (instance->msix_vectors)
@@ -4913,9 +4941,12 @@ static void megasas_shutdown(struct pci_dev *pdev)
        megasas_shutdown_controller(instance, MR_DCMD_CTRL_SHUTDOWN);
        instance->instancet->disable_intr(instance);
        if (instance->msix_vectors)
-               for (i = 0 ; i < instance->msix_vectors; i++)
+               for (i = 0; i < instance->msix_vectors; i++) {
+                       irq_set_affinity_hint(
+                               instance->msixentry[i].vector, NULL);
                        free_irq(instance->msixentry[i].vector,
                                 &instance->irq_context[i]);
+               }
        else
                free_irq(instance->pdev->irq, &instance->irq_context[0]);
        if (instance->msix_vectors)
index ba323175bc64cd2bf0be6b6a343c081520c425eb..9c4b342b048ce38ee98613259b061846494d78dd 100644 (file)
@@ -1614,6 +1614,8 @@ megasas_build_dcdb_fusion(struct megasas_instance *instance,
                         MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
                cmd->request_desc->SCSIIO.DevHandle =
                        local_map_ptr->raidMap.devHndlInfo[device_id].curDevHdl;
+               cmd->request_desc->SCSIIO.MSIxIndex =
+                       instance->msix_vectors ? smp_processor_id() % instance->msix_vectors : 0;
                /*
                 * If the command is for the tape device, set the
                 * FP timeout to the os layer timeout value.