arcmsr: Adding code to support MSI-X interrupt
PATCH 2/16 arcmsr: Adding code to support MSI-X interrupt
From: Ching<[email protected]>
Adding code for supporting MSI-X interrupt.
---
drivers/scsi/arcmsr/arcmsr.h +4 -0
@@ -64,6 +64,7 @@ struct device_attribute;#define ARCMSR_MAX_HBB_POSTQUEUE 264#define ARCMSR_MAX_XFER_LEN 0x26000/* 152K */ #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
@@ -508,6 +509,7 @@ struct AdapterControlBlockstruct 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;
@@ -544,6 +546,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 0x2000struct CommandControlBlock * pccb_pool[ARCMSR_MAX_FREECCB_NUM ];/* used for memory free */ struct list_head ccb_free_list;
drivers/scsi/arcmsr/arcmsr_hba.c +93 -12
164 lines not on this page · raw message
Quoted 11 lines · ching
drivers/scsi/arcmsr/arcmsr_hba.c +11
-0+static int +arcmsr_request_irq (struct pci_dev *pdev,struct AdapterControlBlock *acb) +{ +int i, j, r; +struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS ]; + +if (!pci_find_capability (pdev,PCI_CAP_ID_MSIX )) + goto msi_int; +for (i =0 ; i <ARCMST_NUM_MSIX_VECTORS ; i++) + entries[i].entry = i; + r =pci_enable_msix (pdev, entries,ARCMST_NUM_MSIX_VECTORS );
drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_message_isr_bh_fn(str · line 626
Quoted 10 lines
drivers/scsi/arcmsr/arcmsr_hba.c +10
-0+if (r <0 ) + goto msi_int; +if (r ==0 ) { +for (i =0 ; i <ARCMST_NUM_MSIX_VECTORS ; i++) { +if (request_irq (entries[i].vector, + arcmsr_do_interrupt,0 ,"arcmsr" , acb)) { +pr_warn ("arcmsr%d: request_irq =%d failed!\n" , + acb->host->host_no, pdev->irq); +for (j =0 ; j < i ; j++) +free_irq (entries[i].vector, acb);
This is a bug here. Sorry for not noticing the first time I reviewed this patch. It should be "j" instead of "i" in free_irq(entries[i].vector, acb);.
Quoted 8 lines
drivers/scsi/arcmsr/arcmsr_hba.c +8
-0+pci_disable_msix (pdev); + goto msi_int; + } + acb->entries[i] = entries[i]; + } + acb->acb_flags |=ACB_F_MSIX_ENABLED ; +pr_info ("arcmsr%d: msi-x enabled\n" , acb->host->host_no); +return ARC_SUCCESS ;
drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_message_isr_bh_fn(str · line 644
Quoted 10 lines
drivers/scsi/arcmsr/arcmsr_hba.c +10
-0+ }else { +if (pci_enable_msix (pdev, entries, r)) + goto msi_int; +for (i =0 ; i < r; i++) { +if (request_irq (entries[i].vector, + arcmsr_do_interrupt,0 ,"arcmsr" , acb)) { +pr_warn ("arcmsr%d: request_irq =%d failed!\n" , + acb->host->host_no, pdev->irq); +for (j =0 ; j < i ; j++) +free_irq (entries[i].vector, acb);
The same thing here.
But otherwise so far as style goes this function is a lot better in this version. Thanks. Also the patchset is split up nicely into patches which do one thing per patch so that's nice as well.
regards,
dan carpenter
Hi Dan,
Thanks for correcting this bug.
Regards,
Ching
2014-05-05 18:28 GMT+08:00 Dan Carpenter <[email protected]>:
Quoted 55 lines · ching
Quoted 11 lines
drivers/scsi/arcmsr/arcmsr_hba.c +11
-0+static int +arcmsr_request_irq (struct pci_dev *pdev,struct AdapterControlBlock *acb) +{ +int i, j, r; +struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS ]; + +if (!pci_find_capability (pdev,PCI_CAP_ID_MSIX )) + goto msi_int; +for (i =0 ; i <ARCMST_NUM_MSIX_VECTORS ; i++) + entries[i].entry = i; + r =pci_enable_msix (pdev, entries,ARCMST_NUM_MSIX_VECTORS );drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_message_isr_bh_fn(str · line 626
Quoted 10 lines
drivers/scsi/arcmsr/arcmsr_hba.c +10
-0+if (r <0 ) + goto msi_int; +if (r ==0 ) { +for (i =0 ; i <ARCMST_NUM_MSIX_VECTORS ; i++) { +if (request_irq (entries[i].vector, + arcmsr_do_interrupt,0 ,"arcmsr" , acb)) { +pr_warn ("arcmsr%d: request_irq =%d failed!\n" , + acb->host->host_no, pdev->irq); +for (j =0 ; j < i ; j++) +free_irq (entries[i].vector, acb);This is a bug here. Sorry for not noticing the first time I reviewed this patch. It should be "j" instead of "i" in
free_irq(entries[i].vector, acb);.Quoted 8 lines
drivers/scsi/arcmsr/arcmsr_hba.c +8
-0+pci_disable_msix (pdev); + goto msi_int; + } + acb->entries[i] = entries[i]; + } + acb->acb_flags |=ACB_F_MSIX_ENABLED ; +pr_info ("arcmsr%d: msi-x enabled\n" , acb->host->host_no); +return ARC_SUCCESS ;drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_message_isr_bh_fn(str · line 644
Quoted 10 lines
drivers/scsi/arcmsr/arcmsr_hba.c +10
-0+ }else { +if (pci_enable_msix (pdev, entries, r)) + goto msi_int; +for (i =0 ; i < r; i++) { +if (request_irq (entries[i].vector, + arcmsr_do_interrupt,0 ,"arcmsr" , acb)) { +pr_warn ("arcmsr%d: request_irq =%d failed!\n" , + acb->host->host_no, pdev->irq); +for (j =0 ; j < i ; j++) +free_irq (entries[i].vector, acb);The same thing here.
But otherwise so far as style goes this function is a lot better in this version. Thanks. Also the patchset is split up nicely into patches which do one thing per patch so that's nice as well.
regards,
dan carpenter