diff -uprN a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h --- a/drivers/scsi/arcmsr/arcmsr.h 2013-02-08 13:55:55.221492667 +0800 +++ b/drivers/scsi/arcmsr/arcmsr.h 2013-02-08 13:56:07.892748621 +0800 @@ -64,6 +64,7 @@ struct device_attribute; #define ARCMSR_MAX_HBB_POSTQUEUE 264 #define ARCMSR_MAX_XFER_LEN 0x26000 #define ARCMSR_CDB_SG_PAGE_LENGTH 256 +#define ARCMST_NUM_MSIX_VECTORS 4 #ifndef PCI_DEVICE_ID_ARECA_1880 #define PCI_DEVICE_ID_ARECA_1880 0x1880 #endif @@ -510,6 +511,7 @@ struct AdapterControlBlock struct pci_dev *pdev; struct Scsi_Host *host; unsigned long vir2phy_offset; + struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS]; /* Offset is used in making arc cdb physical to virtual calculations */ uint32_t outbound_int_enable; uint32_t cdb_phyaddr_hi32; @@ -546,6 +548,8 @@ struct AdapterControlBlock /* iop init */ #define ACB_F_ABORT 0x0200 #define ACB_F_FIRMWARE_TRAP 0x0400 + #define ACB_F_MSI_ENABLED 0x1000 + #define ACB_F_MSIX_ENABLED 0x2000 struct CommandControlBlock *pccb_pool[ARCMSR_MAX_FREECCB_NUM]; /* used for memory free */ struct list_head ccb_free_list; diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c --- a/drivers/scsi/arcmsr/arcmsr_hba.c 2013-02-08 13:55:55.583499141 +0800 +++ b/drivers/scsi/arcmsr/arcmsr_hba.c 2013-02-08 13:56:08.261754647 +0800 @@ -678,13 +678,24 @@ arcmsr_message_isr_bh_fn(struct work_str static int arcmsr_suspend(struct pci_dev *pdev, pm_message_t state) { + int i; uint32_t intmask_org; struct Scsi_Host *host = pci_get_drvdata(pdev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *)host->hostdata; intmask_org = arcmsr_disable_outbound_ints(acb); - free_irq(pdev->irq, acb); + if (acb->acb_flags & ACB_F_MSI_ENABLED) { + free_irq(pdev->irq, acb); + pci_disable_msi(pdev); + } else if (acb->acb_flags & ACB_F_MSIX_ENABLED) { + for (i = 0; i < ARCMST_NUM_MSIX_VECTORS; i++) { + free_irq(acb->entries[i].vector, acb); + } + pci_disable_msix(pdev); + } else { + free_irq(pdev->irq, acb); + } del_timer_sync(&acb->eternal_timer); flush_scheduled_work(); arcmsr_stop_adapter_bgrb(acb); @@ -700,10 +711,11 @@ arcmsr_message_isr_bh_fn(struct work_str static int arcmsr_resume(struct pci_dev *pdev) { - int error; + int error, i, j; struct Scsi_Host *host = pci_get_drvdata(pdev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *)host->hostdata; + struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS]; pci_set_power_state(pdev, PCI_D0); pci_enable_wake(pdev, PCI_D0, 0); pci_restore_state(pdev); @@ -722,9 +734,45 @@ arcmsr_message_isr_bh_fn(struct work_str } pci_set_master(pdev); arcmsr_iop_init(acb); - if (request_irq(pdev->irq, arcmsr_do_interrupt, - IRQF_SHARED, "arcmsr", acb)) { - goto controller_stop; + if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) { + if (!pci_enable_msix(pdev, entries, + ARCMST_NUM_MSIX_VECTORS)) { + for (i = 0; i < ARCMST_NUM_MSIX_VECTORS; + i++) { + entries[i].entry = i; + if (request_irq(entries[i].vector, + arcmsr_do_interrupt, 0, + "arcmsr", acb)) { + for (j = 0 ; j < i ; j++) + free_irq(entries[i].vector, + acb); + goto controller_stop; + } + acb->entries[i] = entries[i]; + } + acb->acb_flags |= ACB_F_MSIX_ENABLED; + } else { + printk("arcmsr%d: MSI-X" + "failed to enable\n", acb->host->host_no); + if (request_irq(pdev->irq, + arcmsr_do_interrupt, IRQF_SHARED, + "arcmsr", acb)) { + goto controller_stop; + } + } + } else if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) { + if (!pci_enable_msi(pdev)) { + acb->acb_flags |= ACB_F_MSI_ENABLED; + } + if (request_irq(pdev->irq, arcmsr_do_interrupt, + IRQF_SHARED, "arcmsr", acb)) { + goto controller_stop; + } + } else { + if (request_irq(pdev->irq, arcmsr_do_interrupt, + IRQF_SHARED, "arcmsr", acb)) { + goto controller_stop; + } } INIT_WORK(&acb->arcmsr_do_message_isr_bh, arcmsr_message_isr_bh_fn); @@ -757,8 +805,9 @@ static int arcmsr_probe(struct pci_dev * { struct Scsi_Host *host; struct AdapterControlBlock *acb; - uint8_t bus,dev_fun; - int error; + uint8_t bus, dev_fun; + struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS]; + int error, i, j; error = pci_enable_device(pdev); if (error) return -ENODEV; @@ -815,10 +864,46 @@ static int arcmsr_probe(struct pci_dev * error = scsi_add_host(host, &pdev->dev); if (error) goto RAID_controller_stop; - error = request_irq(pdev->irq, arcmsr_do_interrupt, - IRQF_SHARED, "arcmsr", acb); - if (error) - goto scsi_host_remove; + if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) { + if (!pci_enable_msix(pdev, entries, ARCMST_NUM_MSIX_VECTORS)) { + for (i = 0; i < ARCMST_NUM_MSIX_VECTORS; i++) { + entries[i].entry = i; + if (request_irq(entries[i].vector, + arcmsr_do_interrupt, 0, "arcmsr", + acb)) { + for (j = 0 ; j < i ; j++) + free_irq(entries[i].vector, + acb); + goto scsi_host_remove; + } + acb->entries[i] = entries[i]; + } + acb->acb_flags |= ACB_F_MSIX_ENABLED; + } else { + if (request_irq(pdev->irq, arcmsr_do_interrupt, + IRQF_SHARED, "arcmsr", acb)) { + printk("arcmsr%d: request_irq = %d failed!\n", + acb->host->host_no, pdev->irq); + goto scsi_host_remove; + } + } + } else if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) { + if (!pci_enable_msi(pdev)) + acb->acb_flags |= ACB_F_MSI_ENABLED; + if (request_irq(pdev->irq, arcmsr_do_interrupt, + IRQF_SHARED, "arcmsr", acb)) { + pr_warn("arcmsr%d: request_irq =%d failed!\n", + acb->host->host_no, pdev->irq); + goto scsi_host_remove; + } + } else { + if (request_irq(pdev->irq, arcmsr_do_interrupt, + IRQF_SHARED, "arcmsr", acb)) { + pr_warn("arcmsr%d: request_irq = %d failed!\n", + acb->host->host_no, pdev->irq); + goto scsi_host_remove; + } + } host->irq = pdev->irq; scsi_scan_host(host); INIT_WORK(&acb->arcmsr_do_message_isr_bh, @@ -838,6 +923,11 @@ static int arcmsr_probe(struct pci_dev * return 0; out_free_sysfs: scsi_host_remove: + if (acb->acb_flags & ACB_F_MSI_ENABLED) { + pci_disable_msi(pdev); + } else if (acb->acb_flags & ACB_F_MSIX_ENABLED) { + pci_disable_msix(pdev); + } scsi_remove_host(host); RAID_controller_stop: arcmsr_stop_adapter_bgrb(acb); @@ -1050,11 +1140,11 @@ arcmsr_report_ccb_state(struct AdapterCo default: pr_notice("arcmsr%d: scsi id = %d lun = %d" "isr get command error done, but got unknown" - "DeviceStatus = 0x%x\n" - , acb->host->host_no - , id - , lun - , ccb->arcmsr_cdb.DeviceStatus); + "DeviceStatus = 0x%x\n" + , acb->host->host_no + , id + , lun + , ccb->arcmsr_cdb.DeviceStatus); acb->devstate[id][lun] = ARECA_RAID_GONE; ccb->pcmd->result = DID_NO_CONNECT << 16; arcmsr_ccb_complete(ccb); @@ -1076,7 +1166,7 @@ struct CommandControlBlock *pCCB, bool e lun = abortcmd->device->lun; abortcmd->result |= DID_ABORT << 16; arcmsr_ccb_complete(pCCB); - pr_notice("arcmsr%d: pCCB ='0x%p' isr" + pr_notice("arcmsr%d: pCCB = '0x%p' isr" "got aborted command\n", acb->host->host_no, pCCB); } @@ -1086,12 +1176,12 @@ struct CommandControlBlock *pCCB, bool e "done acb = '0x%p'" "ccb = '0x%p' ccbacb = '0x%p' startdone = 0x%x" "ccboutstandingcount = %d\n" - , acb->host->host_no - , acb - , pCCB - , pCCB->acb - , pCCB->startdone - , atomic_read(&acb->ccboutstandingcount)); + , acb->host->host_no + , acb + , pCCB + , pCCB->acb + , pCCB->startdone + , atomic_read(&acb->ccboutstandingcount)); return; } arcmsr_report_ccb_state(acb, pCCB, error);