replace pci_enable_msi_{exact_range} with pci_alloc_irq_vectors
Subsystems (10)
Hi all,
this series switch the remaining users of pci_enable_msi_{exact_range} (accounting for ahci and nvme being done through other channels) to use the pci_alloc_irq_vectors helper instead and thus simplify the interrupt code in those drivers a lot. I decided to post it as a series to everyone involved and linux-pci so that we can get a bit of cross-review given that I have none of the involved hardware myself.
PATCH 1/6 arcmsr: use pci_alloc_irq_vectors
Switch the arcmsr driver to use pci_alloc_irq_vectors. We need to two calls to pci_alloc_irq_vectors as arcmsr only supports multiple MSI-X vectors, but not multiple MSI vectors.
Otherwise this cleans up a lot of cruft and allows to use a common request_irq loop for irq types, which happens to only iterate over a single line in the non MSI-X case.
--- drivers/scsi/arcmsr/arcmsr.h | 5 +-- drivers/scsi/arcmsr/arcmsr_hba.c | 82 ++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 54 deletions(-)
drivers/scsi/arcmsr/arcmsr.h +1 -4
@@ -629,7 +629,6 @@ 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;
@@ -671,8 +670,6 @@ 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;
@@ -725,7 +722,7 @@ struct AdapterControlBlockatomic_t rq_map_token;atomic_t ante_token_value;uint32_t maxOutstanding; -int msix_vector_count; +int vector_count; };/* HW_DEVICE_EXTENSION */ /* *******************************************************************************
drivers/scsi/arcmsr/arcmsr_hba.c +32 -50
98 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 2/6 ipr: use pci_irq_allocate_vectors
In reply to Christoph HellwigSwitch the ipr driver to use pci_alloc_irq_vectors. We need to two calls to pci_alloc_irq_vectors as ipr only supports multiple MSI-X vectors, but not multiple MSI vectors.
Otherwise this cleans up a lot of cruft and allows to use a common request_irq loop for irq types, which happens to only iterate over a single line in the non MSI-X case.
--- drivers/scsi/ipr.c | 173 ++++++++++++++++------------------------------------- drivers/scsi/ipr.h | 7 +-- 2 files changed, 52 insertions(+), 128 deletions(-)
drivers/scsi/ipr.c +51 -122
@@ -186,16 +186,16 @@ static const struct ipr_chip_cfg_t ipr_chip_cfg[] = { };static const struct ipr_chip_t ipr_chip[] = { - {PCI_VENDOR_ID_MYLEX ,PCI_DEVICE_ID_IBM_GEMSTONE ,IPR_USE_LSI ,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[0 ] }, - {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_CITRINE ,IPR_USE_LSI ,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[0 ] }, - {PCI_VENDOR_ID_ADAPTEC2 ,PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN ,IPR_USE_LSI ,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[0 ] }, - {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_OBSIDIAN ,IPR_USE_LSI ,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[0 ] }, - {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_OBSIDIAN_E ,IPR_USE_MSI ,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[0 ] }, - {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_SNIPE ,IPR_USE_LSI ,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[1 ] }, - {PCI_VENDOR_ID_ADAPTEC2 ,PCI_DEVICE_ID_ADAPTEC2_SCAMP ,IPR_USE_LSI ,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[1 ] }, - {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_CROC_FPGA_E2 ,IPR_USE_MSI ,IPR_SIS64 ,IPR_MMIO , &ipr_chip_cfg[2 ] }, - {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_CROCODILE ,IPR_USE_MSI ,IPR_SIS64 ,IPR_MMIO , &ipr_chip_cfg[2 ] }, - {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_RATTLESNAKE ,IPR_USE_MSI ,IPR_SIS64 ,IPR_MMIO , &ipr_chip_cfg[2 ] } + {PCI_VENDOR_ID_MYLEX ,PCI_DEVICE_ID_IBM_GEMSTONE , false,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[0 ] }, + {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_CITRINE , false,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[0 ] }, + {PCI_VENDOR_ID_ADAPTEC2 ,PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN , false,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[0 ] }, + {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_OBSIDIAN , false,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[0 ] }, + {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_OBSIDIAN_E , true,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[0 ] }, + {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_SNIPE , false,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[1 ] }, + {PCI_VENDOR_ID_ADAPTEC2 ,PCI_DEVICE_ID_ADAPTEC2_SCAMP , false,IPR_SIS32 ,IPR_PCI_CFG , &ipr_chip_cfg[1 ] }, + {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_CROC_FPGA_E2 , true,IPR_SIS64 ,IPR_MMIO , &ipr_chip_cfg[2 ] }, + {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_CROCODILE , true,IPR_SIS64 ,IPR_MMIO , &ipr_chip_cfg[2 ] }, + {PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_RATTLESNAKE , true,IPR_SIS64 ,IPR_MMIO , &ipr_chip_cfg[2 ] } };static int ipr_max_bus_speeds[] = {
@@ -9356,23 +9356,11 @@ static void ipr_free_mem(struct ipr_ioa_cfg *ioa_cfg)static void ipr_free_irqs (struct ipr_ioa_cfg *ioa_cfg) {struct pci_dev *pdev = ioa_cfg->pdev; +int i; -if (ioa_cfg->intr_flag ==IPR_USE_MSI || - ioa_cfg->intr_flag ==IPR_USE_MSIX ) { -int i; -for (i =0 ; i < ioa_cfg->nvectors; i++) -free_irq (ioa_cfg->vectors_info[i].vec, - &ioa_cfg->hrrq[i]); - }else -free_irq (pdev->irq, &ioa_cfg->hrrq[0 ]); - -if (ioa_cfg->intr_flag ==IPR_USE_MSI ) { -pci_disable_msi (pdev); - ioa_cfg->intr_flag &= ~IPR_USE_MSI ; - }else if (ioa_cfg->intr_flag ==IPR_USE_MSIX ) { -pci_disable_msix (pdev); - ioa_cfg->intr_flag &= ~IPR_USE_MSIX ; - } +for (i =0 ; i < ioa_cfg->nvectors; i++) +free_irq (pci_irq_vector (pdev, i), &ioa_cfg->hrrq[i]); +pci_free_irq_vectors (pdev); }/**
@@ -9799,45 +9787,6 @@ static void ipr_wait_for_pci_err_recovery(struct ipr_ioa_cfg *ioa_cfg) } } -static int ipr_enable_msix (struct ipr_ioa_cfg *ioa_cfg) -{ -struct msix_entry entries[IPR_MAX_MSIX_VECTORS ]; -int i, vectors; - -for (i =0 ; i <ARRAY_SIZE (entries); ++i) - entries[i].entry = i; - - vectors =pci_enable_msix_range (ioa_cfg->pdev, - entries,1 , ipr_number_of_msix); -if (vectors <0 ) { -ipr_wait_for_pci_err_recovery (ioa_cfg); -return vectors; - } - -for (i =0 ; i < vectors; i++) - ioa_cfg->vectors_info[i].vec = entries[i].vector; - ioa_cfg->nvectors = vectors; - -return 0 ; -} - -static int ipr_enable_msi (struct ipr_ioa_cfg *ioa_cfg) -{ -int i, vectors; - - vectors =pci_enable_msi_range (ioa_cfg->pdev,1 , ipr_number_of_msix); -if (vectors <0 ) { -ipr_wait_for_pci_err_recovery (ioa_cfg); -return vectors; - } - -for (i =0 ; i < vectors; i++) - ioa_cfg->vectors_info[i].vec = ioa_cfg->pdev->irq + i; - ioa_cfg->nvectors = vectors; - -return 0 ; -} -static void name_msi_vectors (struct ipr_ioa_cfg *ioa_cfg) {int vec_idx, n =sizeof (ioa_cfg->vectors_info[0 ].desc) -1 ;
@@ -9850,19 +9799,20 @@ static void name_msi_vectors(struct ipr_ioa_cfg *ioa_cfg) } } -static int ipr_request_other_msi_irqs (struct ipr_ioa_cfg *ioa_cfg) +static int ipr_request_other_msi_irqs (struct ipr_ioa_cfg *ioa_cfg, +struct pci_dev *pdev) {int i, rc;for (i =1 ; i < ioa_cfg->nvectors; i++) { - rc =request_irq (ioa_cfg->vectors_info[i].vec, + rc =request_irq (pci_irq_vector (pdev, i), ipr_isr_mhrrq,0 , ioa_cfg->vectors_info[i].desc, &ioa_cfg->hrrq[i]);if (rc) {while (--i >=0 ) -free_irq (ioa_cfg->vectors_info[i].vec, +free_irq (pci_irq_vector (pdev, i), &ioa_cfg->hrrq[i]);return rc; }
@@ -9900,8 +9850,7 @@ static irqreturn_t ipr_test_intr(int irq, void *devp)* ipr_test_msi - Test for Message Signaled Interrupt (MSI) support. * @pdev: PCI device struct * -* Description: The return value from pci_enable_msi_range() can not always be -* trusted. This routine sets up and initiates a test interrupt to determine +* Description: This routine sets up and initiates a test interrupt to determine * if the interrupt is received via the ipr_test_intr() service routine. * If the tests fails, the driver will fall back to LSI. *
@@ -9913,6 +9862,7 @@ static int ipr_test_msi(struct ipr_ioa_cfg *ioa_cfg, struct pci_dev *pdev)int rc;volatile u32 int_reg;unsigned long lock_flags =0 ; +int irq =pci_irq_vector (pdev,0 );ENTER ;
@@ -9924,15 +9874,12 @@ static int ipr_test_msi(struct ipr_ioa_cfg *ioa_cfg, struct pci_dev *pdev) int_reg =readl (ioa_cfg->regs.sense_interrupt_mask_reg);spin_unlock_irqrestore (ioa_cfg->host->host_lock, lock_flags); -if (ioa_cfg->intr_flag ==IPR_USE_MSIX ) - rc =request_irq (ioa_cfg->vectors_info[0 ].vec, ipr_test_intr,0 ,IPR_NAME , ioa_cfg); -else - rc =request_irq (pdev->irq, ipr_test_intr,0 ,IPR_NAME , ioa_cfg); + rc =request_irq (irq, ipr_test_intr,0 ,IPR_NAME , ioa_cfg);if (rc) { -dev_err (&pdev->dev,"Can not assign irq %d\n" , pdev->irq); +dev_err (&pdev->dev,"Can not assign irq %d\n" , irq);return rc; }else if (ipr_debug) -dev_info (&pdev->dev,"IRQ assigned: %d\n" , pdev->irq); +dev_info (&pdev->dev,"IRQ assigned: %d\n" , irq);writel (IPR_PCII_IO_DEBUG_ACKNOWLEDGE , ioa_cfg->regs.sense_interrupt_reg32); int_reg =readl (ioa_cfg->regs.sense_interrupt_reg);
@@ -9949,10 +9896,7 @@ static int ipr_test_msi(struct ipr_ioa_cfg *ioa_cfg, struct pci_dev *pdev)spin_unlock_irqrestore (ioa_cfg->host->host_lock, lock_flags); -if (ioa_cfg->intr_flag ==IPR_USE_MSIX ) -free_irq (ioa_cfg->vectors_info[0 ].vec, ioa_cfg); -else -free_irq (pdev->irq, ioa_cfg); +free_irq (irq, ioa_cfg);LEAVE ;
@@ -9976,6 +9920,7 @@ static int ipr_probe_ioa(struct pci_dev *pdev,int rc =PCIBIOS_SUCCESSFUL ;volatile u32 mask, uproc, interrupts;unsigned long lock_flags, driver_lock_flags; +unsigned int irq_flag;ENTER ;
@@ -10091,18 +10036,18 @@ static int ipr_probe_ioa(struct pci_dev *pdev, ipr_number_of_msix =IPR_MAX_MSIX_VECTORS ; } -if (ioa_cfg->ipr_chip->intr_type ==IPR_USE_MSI && -ipr_enable_msix (ioa_cfg) ==0 ) - ioa_cfg->intr_flag =IPR_USE_MSIX ; -else if (ioa_cfg->ipr_chip->intr_type ==IPR_USE_MSI && -ipr_enable_msi (ioa_cfg) ==0 ) - ioa_cfg->intr_flag =IPR_USE_MSI ; -else { - ioa_cfg->intr_flag =IPR_USE_LSI ; - ioa_cfg->clear_isr =1 ; - ioa_cfg->nvectors =1 ; -dev_info (&pdev->dev,"Cannot enable MSI.\n" ); + irq_flag =PCI_IRQ_LEGACY ; +if (ioa_cfg->ipr_chip->has_msi) + irq_flag |=PCI_IRQ_MSI |PCI_IRQ_MSIX ; + rc =pci_alloc_irq_vectors (pdev,1 , ipr_number_of_msix, irq_flag); +if (rc <0 ) { +ipr_wait_for_pci_err_recovery (ioa_cfg); + goto cleanup_nomem; } + ioa_cfg->nvectors = rc; + +if (!pdev->msi_enabled && !pdev->msix_enabled) + ioa_cfg->clear_isr =1 ;pci_set_master (pdev);
@@ -10115,33 +10060,22 @@ static int ipr_probe_ioa(struct pci_dev *pdev, } } -if (ioa_cfg->intr_flag ==IPR_USE_MSI || - ioa_cfg->intr_flag ==IPR_USE_MSIX ) { +if (pdev->msi_enabled || pdev->msix_enabled) { rc =ipr_test_msi (ioa_cfg, pdev); -if (rc == -EOPNOTSUPP ) { +switch (rc) { +case 0 : +dev_info (&pdev->dev, +"Request for %d MSI%ss succeeded." , ioa_cfg->nvectors, + pdev->msix_enabled ?"-X" :"" ); +break ; +case -EOPNOTSUPP :ipr_wait_for_pci_err_recovery (ioa_cfg); -if (ioa_cfg->intr_flag ==IPR_USE_MSI ) { - ioa_cfg->intr_flag &= ~IPR_USE_MSI ; -pci_disable_msi (pdev); - }else if (ioa_cfg->intr_flag ==IPR_USE_MSIX ) { - ioa_cfg->intr_flag &= ~IPR_USE_MSIX ; -pci_disable_msix (pdev); - } +pci_free_irq_vectors (pdev); - ioa_cfg->intr_flag =IPR_USE_LSI ; ioa_cfg->nvectors =1 ; - } -else if (rc) +break ; +default : goto out_msi_disable; -else { -if (ioa_cfg->intr_flag ==IPR_USE_MSI ) -dev_info (&pdev->dev, -"Request for %d MSIs succeeded with starting IRQ: %d\n" , - ioa_cfg->nvectors, pdev->irq); -else if (ioa_cfg->intr_flag ==IPR_USE_MSIX ) -dev_info (&pdev->dev, -"Request for %d MSIXs succeeded." , - ioa_cfg->nvectors); } }
@@ -10189,15 +10123,13 @@ static int ipr_probe_ioa(struct pci_dev *pdev,ipr_mask_and_clear_interrupts (ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER );spin_unlock_irqrestore (ioa_cfg->host->host_lock, lock_flags); -if (ioa_cfg->intr_flag ==IPR_USE_MSI - || ioa_cfg->intr_flag ==IPR_USE_MSIX ) { +if (pdev->msi_enabled || pdev->msix_enabled) {name_msi_vectors (ioa_cfg); - rc =request_irq (ioa_cfg->vectors_info[0 ].vec, ipr_isr, -0 , + rc =request_irq (pci_irq_vector (pdev,0 ), ipr_isr,0 , ioa_cfg->vectors_info[0 ].desc, &ioa_cfg->hrrq[0 ]);if (!rc) - rc =ipr_request_other_msi_irqs (ioa_cfg); + rc =ipr_request_other_msi_irqs (ioa_cfg, pdev); }else { rc = request_irq(pdev->irq, ipr_isr, IRQF_SHARED,
@@ -10239,10 +10171,7 @@ cleanup_nolog:ipr_free_mem (ioa_cfg); out_msi_disable:ipr_wait_for_pci_err_recovery (ioa_cfg); -if (ioa_cfg->intr_flag ==IPR_USE_MSI ) -pci_disable_msi (pdev); -else if (ioa_cfg->intr_flag ==IPR_USE_MSIX ) -pci_disable_msix (pdev); +pci_free_irq_vectors (pdev); cleanup_nomem:iounmap (ipr_regs); out_disable:
drivers/scsi/ipr.h +1 -6
@@ -1411,10 +1411,7 @@ struct ipr_chip_cfg_t {struct ipr_chip_t {u16 vendor;u16 device; -u16 intr_type; -#define IPR_USE_LSI 0x00 -#define IPR_USE_MSI 0x01 -#define IPR_USE_MSIX 0x02 +bool has_msi;u16 sis_type;#define IPR_SIS32 0x00#define IPR_SIS64 0x01
@@ -1589,11 +1586,9 @@ struct ipr_ioa_cfg {struct ipr_cmnd **ipr_cmnd_list;dma_addr_t *ipr_cmnd_list_dma; -u16 intr_flag;unsigned int nvectors;struct { -unsigned short vec;char desc[22 ]; } vectors_info[IPR_MAX_MSIX_VECTORS ];
Signature · 1 line
2.1.4
PATCH 3/6 skd: use pci_alloc_irq_vectors
In reply to Christoph HellwigSwitch the skd driver to use pci_alloc_irq_vectors. We need to two calls to pci_alloc_irq_vectors as skd only supports multiple MSI-X vectors, but not multiple MSI vectors.
Otherwise this cleans up a lot of cruft and allows to a lot more common code.
--- drivers/block/skd_main.c | 212 +++++++++++++++-------------------------------- 1 file changed, 66 insertions(+), 146 deletions(-)
drivers/block/skd_main.c +66 -146
@@ -270,8 +270,6 @@ struct skd_device {resource_size_t mem_phys[SKD_MAX_BARS ];u32 mem_size[SKD_MAX_BARS ]; -skd_irq_type_t irq_type; -u32 msix_count;struct skd_msix_entry *msix_entries;struct pci_dev *pdev;
@@ -3821,10 +3819,6 @@ static irqreturn_t skd_qfull_isr(int irq, void *skd_host_data)*/ struct skd_msix_entry { -int have_irq; -u32 vector; -u32 entry; -struct skd_device *rsp;char isr_name[30 ]; };
@@ -3853,56 +3847,21 @@ static struct skd_init_msix_entry msix_entries[SKD_MAX_MSIX_COUNT] = { { "(Queue Full 3)", skd_qfull_isr }, }; -static void skd_release_msix (struct skd_device *skdev) -{ -struct skd_msix_entry *qentry; -int i; - -if (skdev->msix_entries) { -for (i =0 ; i < skdev->msix_count; i++) { - qentry = &skdev->msix_entries[i]; - skdev = qentry->rsp; - -if (qentry->have_irq) -devm_free_irq (&skdev->pdev->dev, - qentry->vector, qentry->rsp); - } - -kfree (skdev->msix_entries); - } - -if (skdev->msix_count) -pci_disable_msix (skdev->pdev); - - skdev->msix_count =0 ; - skdev->msix_entries =NULL ; -} -static int skd_acquire_msix (struct skd_device *skdev) {int i, rc;struct pci_dev *pdev = skdev->pdev; -struct msix_entry *entries; -struct skd_msix_entry *qentry; - - entries =kzalloc (sizeof (struct msix_entry ) *SKD_MAX_MSIX_COUNT , -GFP_KERNEL ); -if (!entries) -return -ENOMEM ; -for (i =0 ; i <SKD_MAX_MSIX_COUNT ; i++) - entries[i].entry = i; - - rc =pci_enable_msix_exact (pdev, entries,SKD_MAX_MSIX_COUNT ); -if (rc) { + rc =pci_alloc_irq_vectors (pdev,SKD_MAX_MSIX_COUNT ,SKD_MAX_MSIX_COUNT , +PCI_IRQ_MSIX ); +if (rc <0 ) {pr_err ("(%s): failed to enable MSI-X %d\n" ,skd_name (skdev), rc); goto msix_out; } - skdev->msix_count =SKD_MAX_MSIX_COUNT ; - skdev->msix_entries =kzalloc (sizeof (struct skd_msix_entry ) * - skdev->msix_count,GFP_KERNEL ); + skdev->msix_entries =kcalloc (SKD_MAX_MSIX_COUNT , +sizeof (struct skd_msix_entry ),GFP_KERNEL );if (!skdev->msix_entries) { rc = -ENOMEM ; pr_err("(%s): msix table allocation error\n",
@@ -3910,136 +3869,98 @@ static int skd_acquire_msix(struct skd_device *skdev) goto msix_out; } -for (i =0 ; i < skdev->msix_count; i++) { - qentry = &skdev->msix_entries[i]; - qentry->vector = entries[i].vector; - qentry->entry = entries[i].entry; - qentry->rsp =NULL ; - qentry->have_irq =0 ; -pr_debug ("%s:%s:%d %s: <%s> msix (%d) vec %d, entry %x\n" , - skdev->name, __func__, __LINE__, -pci_name (pdev), skdev->name, - i, qentry->vector, qentry->entry); - } -/* Enable MSI-X vectors for the base queue */ -for (i =0 ; i < skdev->msix_count; i++) { - qentry = &skdev->msix_entries[i]; +for (i =0 ; i <SKD_MAX_MSIX_COUNT ; i++) { +struct skd_msix_entry *qentry = &skdev->msix_entries[i]; +snprintf (qentry->isr_name,sizeof (qentry->isr_name),"%s%d-msix %s" ,DRV_NAME , skdev->devno, msix_entries[i].name); - rc =devm_request_irq (&skdev->pdev->dev, qentry->vector, - msix_entries[i].handler,0 , - qentry->isr_name, skdev); + + rc =devm_request_irq (&skdev->pdev->dev, +pci_irq_vector (skdev->pdev, i), + msix_entries[i].handler,0 , + qentry->isr_name, skdev);if (rc) {pr_err ("(%s): Unable to register(%d) MSI-X " "handler %d: %s\n" ,skd_name (skdev), rc, i, qentry->isr_name); goto msix_out; - }else { - qentry->have_irq =1 ; - qentry->rsp = skdev; } } +pr_debug ("%s:%s:%d %s: <%s> msix %d irq(s) enabled\n" , skdev->name, __func__, __LINE__, -pci_name (pdev), skdev->name, skdev->msix_count); +pci_name (pdev), skdev->name,SKD_MAX_MSIX_COUNT );return 0 ; msix_out: -if (entries) -kfree (entries); -skd_release_msix (skdev); +while (--i >=0 ) +devm_free_irq (&pdev->dev,pci_irq_vector (pdev, i), skdev); +kfree (skdev->msix_entries); + skdev->msix_entries =NULL ;return rc; }static int skd_acquire_irq (struct skd_device *skdev) { +struct pci_dev *pdev = skdev->pdev; +unsigned int irq_flag =PCI_IRQ_LEGACY ;int rc; -struct pci_dev *pdev; - pdev = skdev->pdev; - skdev->msix_count =0 ; - -RETRY_IRQ_TYPE: -switch (skdev->irq_type) { -case SKD_IRQ_MSIX : +if (skd_isr_type ==SKD_IRQ_MSIX ) { rc =skd_acquire_msix (skdev);if (!rc) -pr_info ("(%s): MSI-X %d irqs enabled\n" , -skd_name (skdev), skdev->msix_count); -else { -pr_err ( -"(%s): failed to enable MSI-X, re-trying with MSI %d\n" , -skd_name (skdev), rc); - skdev->irq_type =SKD_IRQ_MSI ; - goto RETRY_IRQ_TYPE; - } -break ; -case SKD_IRQ_MSI : -snprintf (skdev->isr_name,sizeof (skdev->isr_name),"%s%d-msi" , -DRV_NAME , skdev->devno); - rc =pci_enable_msi_range (pdev,1 ,1 ); -if (rc >0 ) { - rc =devm_request_irq (&pdev->dev, pdev->irq, skd_isr,0 , - skdev->isr_name, skdev); -if (rc) { -pci_disable_msi (pdev); -pr_err ( -"(%s): failed to allocate the MSI interrupt %d\n" , -skd_name (skdev), rc); - goto RETRY_IRQ_LEGACY; - } -pr_info ("(%s): MSI irq %d enabled\n" , -skd_name (skdev), pdev->irq); - }else { -RETRY_IRQ_LEGACY: -pr_err ( -"(%s): failed to enable MSI, re-trying with LEGACY %d\n" , -skd_name (skdev), rc); - skdev->irq_type =SKD_IRQ_LEGACY ; - goto RETRY_IRQ_TYPE; - } -break ; -case SKD_IRQ_LEGACY : -snprintf (skdev->isr_name,sizeof (skdev->isr_name), -"%s%d-legacy" ,DRV_NAME , skdev->devno); - rc =devm_request_irq (&pdev->dev, pdev->irq, skd_isr, -IRQF_SHARED , skdev->isr_name, skdev); -if (!rc) -pr_info ("(%s): LEGACY irq %d enabled\n" , -skd_name (skdev), pdev->irq); -else -pr_err ("(%s): request LEGACY irq error %d\n" , -skd_name (skdev), rc); -break ; -default : -pr_info ("(%s): irq_type %d invalid, re-set to %d\n" , -skd_name (skdev), skdev->irq_type,SKD_IRQ_DEFAULT ); - skdev->irq_type =SKD_IRQ_LEGACY ; - goto RETRY_IRQ_TYPE; +return 0 ; + +pr_err ("(%s): failed to enable MSI-X, re-trying with MSI %d\n" , +skd_name (skdev), rc); } -return rc; + +snprintf (skdev->isr_name,sizeof (skdev->isr_name),"%s%d" ,DRV_NAME , + skdev->devno); + +if (skd_isr_type !=SKD_IRQ_LEGACY ) + irq_flag |=PCI_IRQ_MSI ; + rc =pci_alloc_irq_vectors (pdev,1 ,1 , irq_flag); +if (rc <0 ) { +pr_err ("(%s): failed to allocate the MSI interrupt %d\n" , +skd_name (skdev), rc); +return rc; + } + + rc =devm_request_irq (&pdev->dev, pdev->irq, skd_isr, + pdev->msi_enabled ?0 :IRQF_SHARED , + skdev->isr_name, skdev); +if (rc) { +pci_free_irq_vectors (pdev); +pr_err ("(%s): failed to allocate interrupt %d\n" , +skd_name (skdev), rc); +return rc; + } + +return 0 ; }static void skd_release_irq (struct skd_device *skdev) { -switch (skdev->irq_type) { -case SKD_IRQ_MSIX : -skd_release_msix (skdev); -break ; -case SKD_IRQ_MSI : -devm_free_irq (&skdev->pdev->dev, skdev->pdev->irq, skdev); -pci_disable_msi (skdev->pdev); -break ; -case SKD_IRQ_LEGACY : -devm_free_irq (&skdev->pdev->dev, skdev->pdev->irq, skdev); -break ; -default : -pr_err ("(%s): wrong irq type %d!" , -skd_name (skdev), skdev->irq_type); -break ; +struct pci_dev *pdev = skdev->pdev; + +if (skdev->msix_entries) { +int i; + +for (i =0 ; i <SKD_MAX_MSIX_COUNT ; i++) { +devm_free_irq (&pdev->dev,pci_irq_vector (pdev, i), + skdev); + } + +kfree (skdev->msix_entries); + skdev->msix_entries =NULL ; + }else { +devm_free_irq (&pdev->dev, pdev->irq, skdev); } + +pci_free_irq_vectors (pdev); }/*
@@ -4402,7 +4323,6 @@ static struct skd_device *skd_construct(struct pci_dev *pdev) skdev->pdev = pdev; skdev->devno = skd_next_devno++; skdev->major = blk_major; - skdev->irq_type = skd_isr_type;sprintf (skdev->name,DRV_NAME "%d" , skdev->devno); skdev->dev_max_queue_depth =0 ;
Signature · 1 line
2.1.4
PATCH 4/6 vfio_pci: use pci_irq_allocate_vectors
In reply to Christoph HellwigSimply the interrupt setup by using the new PCI layer helpers.
--- drivers/vfio/pci/vfio_pci_intrs.c | 45 +++++++++---------------------------- drivers/vfio/pci/vfio_pci_private.h | 1 - 2 files changed, 10 insertions(+), 36 deletions(-)
drivers/vfio/pci/vfio_pci_intrs.c +10 -35
@@ -250,6 +250,7 @@ static irqreturn_t vfio_msihandler(int irq, void *arg)static int vfio_msi_enable (struct vfio_pci_device *vdev,int nvec,bool msix) {struct pci_dev *pdev = vdev->pdev; +unsigned int flag = msix ?PCI_IRQ_MSIX :PCI_IRQ_MSI ;int ret;if (!is_irq_none (vdev))
@@ -259,35 +260,13 @@ static int vfio_msi_enable(struct vfio_pci_device *vdev, int nvec, bool msix)if (!vdev->ctx)return -ENOMEM ; -if (msix) { -int i; - - vdev->msix =kzalloc (nvec *sizeof (struct msix_entry ), -GFP_KERNEL ); -if (!vdev->msix) { -kfree (vdev->ctx); -return -ENOMEM ; - } - -for (i =0 ; i < nvec; i++) - vdev->msix[i].entry = i; - - ret =pci_enable_msix_range (pdev, vdev->msix,1 , nvec); -if (ret < nvec) { -if (ret >0 ) -pci_disable_msix (pdev); -kfree (vdev->msix); -kfree (vdev->ctx); -return ret; - } - }else { - ret =pci_enable_msi_range (pdev,1 , nvec); -if (ret < nvec) { -if (ret >0 ) -pci_disable_msi (pdev); -kfree (vdev->ctx); -return ret; - } +/* return the number of supported vectors if we can't get all: */ + ret =pci_alloc_irq_vectors (pdev,1 , nvec, flag); +if (ret < nvec) { +if (ret >0 ) +pci_free_irq_vectors (pdev); +kfree (vdev->ctx); +return ret; } vdev->num_ctx = nvec;
@@ -315,7 +294,7 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,if (vector <0 || vector >= vdev->num_ctx)return -EINVAL ; - irq = msix ? vdev->msix[vector].vector : pdev->irq + vector; + irq =pci_irq_vector (pdev, vector);if (vdev->ctx[vector].trigger) {free_irq (irq, vdev->ctx[vector].trigger);
@@ -408,11 +387,7 @@ static void vfio_msi_disable(struct vfio_pci_device *vdev, bool msix)vfio_msi_set_block (vdev,0 , vdev->num_ctx,NULL , msix); -if (msix) { -pci_disable_msix (vdev->pdev); -kfree (vdev->msix); - }else -pci_disable_msi (pdev); +pci_free_irq_vectors (pdev); vdev->irq_type =VFIO_PCI_NUM_IRQS ; vdev->num_ctx =0 ;
drivers/vfio/pci/vfio_pci_private.h +0 -1
@@ -72,7 +72,6 @@ struct vfio_pci_device {struct perm_bits *msi_perm;spinlock_t irqlock;struct mutex igate; -struct msix_entry *msix;struct vfio_pci_irq_ctx *ctx;int num_ctx;int irq_type;
Signature · 1 line
2.1.4
PATCH 5/6 genwqe: use pci_irq_allocate_vectors
In reply to Christoph HellwigSimply the interrupt setup by using the new PCI layer helpers.
One odd thing about this driver is that it looks like it could request multiple MSI vectors, but it will then only ever use a single one.
--- drivers/misc/genwqe/card_base.h | 1 - drivers/misc/genwqe/card_utils.c | 12 ++---------- 2 files changed, 2 insertions(+), 11 deletions(-)
drivers/misc/genwqe/card_base.h +0 -1
@@ -41,7 +41,6 @@#include "genwqe_driver.h" #define GENWQE_MSI_IRQS 4/* Just one supported, no MSIx */ -#define GENWQE_FLAG_MSI_ENABLED (1 << 0)#define GENWQE_MAX_VFS 15/* maximum 15 VFs are possible */ #define GENWQE_MAX_FUNCS 16/* 1 PF and 15 VFs */
drivers/misc/genwqe/card_utils.c +2 -10
@@ -730,13 +730,10 @@ int genwqe_read_softreset(struct genwqe_dev *cd)int genwqe_set_interrupt_capability (struct genwqe_dev *cd,int count) {int rc; -struct pci_dev *pci_dev = cd->pci_dev; - rc =pci_enable_msi_range (pci_dev,1 , count); + rc =pci_alloc_irq_vectors (cd->pci_dev,1 , count,PCI_IRQ_MSI );if (rc <0 )return rc; - - cd->flags |=GENWQE_FLAG_MSI_ENABLED ;return 0 ; }
@@ -746,12 +743,7 @@ int genwqe_set_interrupt_capability(struct genwqe_dev *cd, int count)*/ void genwqe_reset_interrupt_capability (struct genwqe_dev *cd) { -struct pci_dev *pci_dev = cd->pci_dev; - -if (cd->flags &GENWQE_FLAG_MSI_ENABLED ) { -pci_disable_msi (pci_dev); - cd->flags &= ~GENWQE_FLAG_MSI_ENABLED ; - } +pci_free_irq_vectors (cd->pci_dev); }/**
Signature · 1 line
2.1.4
PATCH 6/6 media/cobalt: use pci_irq_allocate_vectors
In reply to Christoph HellwigSimply the interrupt setup by using the new PCI layer helpers.
Despite using pci_enable_msi_range, this driver was only requesting a single MSI vector anyway.
--- drivers/media/pci/cobalt/cobalt-driver.c | 8 ++------ drivers/media/pci/cobalt/cobalt-driver.h | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-)
drivers/media/pci/cobalt/cobalt-driver.c +2 -6
@@ -307,9 +307,7 @@ static void cobalt_pci_iounmap(struct cobalt *cobalt, struct pci_dev *pci_dev)static void cobalt_free_msi (struct cobalt *cobalt,struct pci_dev *pci_dev) {free_irq (pci_dev->irq, (void *)cobalt); - -if (cobalt->msi_enabled) -pci_disable_msi (pci_dev); +pci_free_irq_vectors (pci_dev); } static int cobalt_setup_pci(struct cobalt *cobalt, struct pci_dev *pci_dev,
@@ -386,14 +384,12 @@ static int cobalt_setup_pci(struct cobalt *cobalt, struct pci_dev *pci_dev,from being generated. */ cobalt_set_interrupt (cobalt, false); -if (pci_enable_msi_range (pci_dev,1 ,1 ) <1 ) { +if (pci_alloc_irq_vectors (pci_dev,1 ,1 ,PCI_IRQ_MSI ) <1 ) {cobalt_err ("Could not enable MSI\n" ); - cobalt->msi_enabled = false; ret = -EIO ; goto err_release; }msi_config_show (cobalt, pci_dev); - cobalt->msi_enabled = true;/* Register IRQ */ if (request_irq(pci_dev->irq, cobalt_irq_handler, IRQF_SHARED,
drivers/media/pci/cobalt/cobalt-driver.h +0 -2
@@ -287,8 +287,6 @@ struct cobalt {u32 irq_none;u32 irq_full_fifo; -bool msi_enabled; -/* omnitek dma */ int dma_channels;int first_fifo_channel;
Signature · 1 line
2.1.4
Re: [PATCH 6/6] media/cobalt: use pci_irq_allocate_vectors
Hi Christoph,
Quoted 27 lines · Christoph Hellwig
Simply the interrupt setup by using the new PCI layer helpers.
Despite using
pci_enable_msi_range, this driver was only requesting a single MSI vector anyway.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/media/pci/cobalt/cobalt-driver.c | 8 ++------ drivers/media/pci/cobalt/cobalt-driver.h | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-)drivers/media/pci/cobalt/cobalt-driver.c +1
-3@@ -307,9 +307,7 @@ static void cobalt_pci_iounmap(struct cobalt *cobalt, struct pci_dev *pci_dev)static void cobalt_free_msi (struct cobalt *cobalt,struct pci_dev *pci_dev) {free_irq (pci_dev->irq, (void *)cobalt); - -if (cobalt->msi_enabled) -pci_disable_msi (pci_dev); +pci_free_irq_vectors (pci_dev); } static int cobalt_setup_pci(struct cobalt *cobalt, struct pci_dev *pci_dev,
drivers/media/pci/cobalt/cobalt-driver.c static int cobalt_setup_pci(struct cobalt *cobalt, struct pci_dev *pci_dev, · line 387
Quoted 5 lines
drivers/media/pci/cobalt/cobalt-driver.c +1
-1@@ -386,14 +384,12 @@ static int cobalt_setup_pci(struct cobalt *cobalt, struct pci_dev *pci_dev,from being generated. */ cobalt_set_interrupt (cobalt, false); -if (pci_enable_msi_range (pci_dev,1 ,1 ) <1 ) { +if (pci_alloc_irq_vectors (pci_dev,1 ,1 ,PCI_IRQ_MSI ) <1 ) {
PCI_IRQ_MSI is unknown, I assume that this will appear in 4.9?
Looks good otherwise.
Regards,
Hans
Quoted 24 lines
drivers/media/pci/cobalt/cobalt-driver.c +0
-2cobalt_err ("Could not enable MSI\n" ); - cobalt->msi_enabled = false; ret = -EIO ; goto err_release; }msi_config_show (cobalt, pci_dev); - cobalt->msi_enabled = true;/* Register IRQ */ if (request_irq(pci_dev->irq, cobalt_irq_handler, IRQF_SHARED,drivers/media/pci/cobalt/cobalt-driver.h +0
-2@@ -287,8 +287,6 @@ struct cobalt {u32 irq_none;u32 irq_full_fifo; -bool msi_enabled; -/* omnitek dma */ int dma_channels;int first_fifo_channel;
Re: [PATCH 6/6] media/cobalt: use pci_irq_allocate_vectors
Quoted 1 line · Hans Verkuil
PCI_IRQ_MSIis unknown, I assume that this will appear in 4.9?
The flag is in 4.8-rc.
Re: [PATCH 2/6] ipr: use pci_irq_allocate_vectors
In reply to Christoph HellwigQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Christoph" == Christoph Hellwig <[email protected]> writes:
Christoph> Switch the ipr driver to use pci_alloc_irq_vectors. We need Christoph> to two calls to pci_alloc_irq_vectors as ipr only supports Christoph> multiple MSI-X vectors, but not multiple MSI vectors.
Christoph> Otherwise this cleans up a lot of cruft and allows to use a Christoph> common request_irq loop for irq types, which happens to only Christoph> iterate over a single line in the non MSI-X case.
Brian, Gabriel: Please test and review. Thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 1/6] arcmsr: use pci_alloc_irq_vectors
In reply to Christoph HellwigQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Christoph" == Christoph Hellwig <[email protected]> writes:
Christoph> Switch the arcmsr driver to use pci_alloc_irq_vectors. We Christoph> need to two calls to pci_alloc_irq_vectors as arcmsr only Christoph> supports multiple MSI-X vectors, but not multiple MSI Christoph> vectors.
Christoph> Otherwise this cleans up a lot of cruft and allows to use a Christoph> common request_irq loop for irq types, which happens to only Christoph> iterate over a single line in the non MSI-X case.
Ching: Please test and review. Thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 2/6] ipr: use pci_irq_allocate_vectors
In reply to Christoph HellwigThanks Christoph. Very nice. As I was reviewing the patch, I noticed the additional PCI_IRQ_AFFINITY flag, which is currently not being set in this patch. Is the intention to set that globally by default, or should I follow up with a one liner to add that to the ipr driver in the next patch set I send out?
Thanks,
Brian
Signature · 3 lines
Brian King Power Linux I/O IBM Linux Technology Center
Re: [PATCH 2/6] ipr: use pci_irq_allocate_vectors
Quoted 5 lines · Brian King
Thanks Christoph. Very nice. As I was reviewing the patch, I noticed the additional
PCI_IRQ_AFFINITYflag, which is currently not being set in this patch. Is the intention to set that globally by default, or should I follow up with a one liner to add that to the ipr driver in the next patch set I send out?
Hi Brian,
PCI_IRQ_AFFINITY seems useful for ipr, especially if you also increase the number of vectors above the current default 2. And yes, please make it a separate patch.
Re: [PATCH 5/6] genwqe: use pci_irq_allocate_vectors
In reply to Christoph HellwigQuoted 1 line · Christoph Hellwig
Simply the interrupt setup by using the new PCI layer helpers.
Good clean up. Tested and:
Quoted 2 lines
One odd thing about this driver is that it looks like it could request multiple MSI vectors, but it will then only ever use a single one.
I'll take a look at this.
Signature · 1 line
Gabriel Krisman Bertazi
Re: [PATCH 5/6] genwqe: use pci_irq_allocate_vectors
Quoted 7 lines · Gabriel Krisman Bertazi
Quoted 1 line · Christoph Hellwig
Simply the interrupt setup by using the new PCI layer helpers.
Good clean up. Tested and:
Which tree should this go in through?
Re: [PATCH 4/6] vfio_pci: use pci_irq_allocate_vectors
In reply to Christoph HellwigQuoted 3 lines · Christoph Hellwig
Simply the interrupt setup by using the new PCI layer helpers.
Signed-off-by Christoph Hellwig <[email protected]>
Any chance to get a review for this one? Vfio seems to be actively maintained, so the silence seems odd. I'm still hoping to get rid of the pci_enable_msi_range interface for 4.9.
Re: [PATCH 3/6] skd: use pci_alloc_irq_vectors
In reply to Christoph HellwigQuoted 7 lines · Christoph Hellwig
Switch the skd driver to use
pci_alloc_irq_vectors. We need to two calls topci_alloc_irq_vectorsas skd only supports multiple MSI-X vectors, but not multiple MSI vectors.Otherwise this cleans up a lot of cruft and allows to a lot more common code.
Signed-off-by Christoph Hellwig <[email protected]>
Jens, is this something you could pick up for 4.9? I'd like to get get rid of all users of pci_enable_msi_range in this merge window.
Re: [PATCH 5/6] genwqe: use pci_irq_allocate_vectors
In reply to Christoph HellwigQuoted 10 lines · Christoph Hellwig
Quoted 7 lines · Gabriel Krisman Bertazi
Quoted 1 line · Christoph Hellwig
Simply the interrupt setup by using the new PCI layer helpers.
Good clean up. Tested and:
Which tree should this go in through?
I'd say Greg's char-misc tree.
I'm stepping up to assist with the genwqe_card driver just now, since we (ibm) missed some of the last patches that went in. I'll add myself to maintainers file.
Signature · 1 line
Gabriel Krisman Bertazi
Re: [PATCH 5/6] genwqe: use pci_irq_allocate_vectors
Quoted 3 lines · Gabriel Krisman Bertazi
I'm stepping up to assist with the
genwqe_carddriver just now, since we (ibm) missed some of the last patches that went in. I'll add myself to maintainers file.
Can your forward it to Greg together with whatever other changes are pending for the driver?
Re: [PATCH 5/6] genwqe: use pci_irq_allocate_vectors
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Gabriel Krisman Bertazi
I'm stepping up to assist with the
genwqe_carddriver just now, since we (ibm) missed some of the last patches that went in. I'll add myself to maintainers file.Can your forward it to Greg together with whatever other changes are pending for the driver?
sure, will do.
Signature · 1 line
Gabriel Krisman Bertazi
Re: [PATCH 4/6] vfio_pci: use pci_irq_allocate_vectors
In reply to Christoph HellwigQuoted 7 lines · On Sun, 11 Sep 2016 15:31:26 +0200 Christoph Hellwig <[email protected]> wrote:
Simply the interrupt setup by using the new PCI layer helpers.
Signed-off-by Christoph Hellwig <[email protected]>--- drivers/vfio/pci/vfio_pci_intrs.c | 45 +++++++++---------------------------- drivers/vfio/pci/vfio_pci_private.h | 1 - 2 files changed, 10 insertions(+), 36 deletions(-)
Sorry for the delay, slipped by me. Overall a really nice cleanup. One tiny nit, the commit log mis-names the function as pci_irq_allocate_vectors instead of pci_alloc_irq_vectors. With that,
Let me know if you're wanting me to pull this through my tree, I'm assuming not. Thanks,
Alex
Quoted 89 lines
drivers/vfio/pci/vfio_pci_intrs.c +10
-35@@ -250,6 +250,7 @@ static irqreturn_t vfio_msihandler(int irq, void *arg)static int vfio_msi_enable (struct vfio_pci_device *vdev,int nvec,bool msix) {struct pci_dev *pdev = vdev->pdev; +unsigned int flag = msix ?PCI_IRQ_MSIX :PCI_IRQ_MSI ;int ret;if (!is_irq_none (vdev))@@ -259,35 +260,13 @@ static int vfio_msi_enable(struct vfio_pci_device *vdev, int nvec, bool msix)if (!vdev->ctx)return -ENOMEM ; -if (msix) { -int i; - - vdev->msix =kzalloc (nvec *sizeof (struct msix_entry ), -GFP_KERNEL ); -if (!vdev->msix) { -kfree (vdev->ctx); -return -ENOMEM ; - } - -for (i =0 ; i < nvec; i++) - vdev->msix[i].entry = i; - - ret =pci_enable_msix_range (pdev, vdev->msix,1 , nvec); -if (ret < nvec) { -if (ret >0 ) -pci_disable_msix (pdev); -kfree (vdev->msix); -kfree (vdev->ctx); -return ret; - } - }else { - ret =pci_enable_msi_range (pdev,1 , nvec); -if (ret < nvec) { -if (ret >0 ) -pci_disable_msi (pdev); -kfree (vdev->ctx); -return ret; - } +/* return the number of supported vectors if we can't get all: */ + ret =pci_alloc_irq_vectors (pdev,1 , nvec, flag); +if (ret < nvec) { +if (ret >0 ) +pci_free_irq_vectors (pdev); +kfree (vdev->ctx); +return ret; } vdev->num_ctx = nvec;@@ -315,7 +294,7 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,if (vector <0 || vector >= vdev->num_ctx)return -EINVAL ; - irq = msix ? vdev->msix[vector].vector : pdev->irq + vector; + irq =pci_irq_vector (pdev, vector);if (vdev->ctx[vector].trigger) {free_irq (irq, vdev->ctx[vector].trigger);@@ -408,11 +387,7 @@ static void vfio_msi_disable(struct vfio_pci_device *vdev, bool msix)vfio_msi_set_block (vdev,0 , vdev->num_ctx,NULL , msix); -if (msix) { -pci_disable_msix (vdev->pdev); -kfree (vdev->msix); - }else -pci_disable_msi (pdev); +pci_free_irq_vectors (pdev); vdev->irq_type =VFIO_PCI_NUM_IRQS ; vdev->num_ctx =0 ;drivers/vfio/pci/vfio_pci_private.h +0
-1@@ -72,7 +72,6 @@ struct vfio_pci_device {struct perm_bits *msi_perm;spinlock_t irqlock;struct mutex igate; -struct msix_entry *msix;struct vfio_pci_irq_ctx *ctx;int num_ctx;int irq_type;
Re: [PATCH 4/6] vfio_pci: use pci_irq_allocate_vectors
Quoted 8 lines · Alex Williamson
Sorry for the delay, slipped by me. Overall a really nice cleanup. One tiny nit, the commit log mis-names the function as
pci_irq_allocate_vectorsinstead ofpci_alloc_irq_vectors. With that,Acked-by Alex Williamson <[email protected]>Let me know if you're wanting me to pull this through my tree, I'm assuming not. Thanks,
Please pull in through your tree. If you can also just fix up that type that'd be even better.
Thanks a lot!
Re: [PATCH 4/6] vfio_pci: use pci_irq_allocate_vectors
Quoted 5 lines · On Thu, 29 Sep 2016 21:24:04 +0200 Christoph Hellwig <[email protected]> wrote:
Quoted 4 lines · Alex Williamson
Sorry for the delay, slipped by me. Overall a really nice cleanup. One tiny nit, the commit log mis-names the function as
pci_irq_allocate_vectorsinstead ofpci_alloc_irq_vectors. With that,
Quoted 7 lines
Quoted 4 lines
Acked-by Alex Williamson <[email protected]>Let me know if you're wanting me to pull this through my tree, I'm assuming not. Thanks,
Please pull in through your tree. If you can also just fix up that type that'd be even better.
Will do. Thanks,
Alex
Martin K. Petersen
AppliedRe: [PATCH 1/6] arcmsr: use pci_alloc_irq_vectors
In reply to Christoph HellwigQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Christoph" == Christoph Hellwig <[email protected]> writes:
Christoph> Switch the arcmsr driver to use pci_alloc_irq_vectors. We Christoph> need to two calls to pci_alloc_irq_vectors as arcmsr only Christoph> supports multiple MSI-X vectors, but not multiple MSI Christoph> vectors.
Christoph> Otherwise this cleans up a lot of cruft and allows to use a Christoph> common request_irq loop for irq types, which happens to only Christoph> iterate over a single line in the non MSI-X case.
Applied to 4.10/scsi-queue.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedRe: [PATCH 2/6] ipr: use pci_irq_allocate_vectors
In reply to Christoph HellwigQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Christoph" == Christoph Hellwig <[email protected]> writes:
Christoph> Switch the ipr driver to use pci_alloc_irq_vectors. We need Christoph> to two calls to pci_alloc_irq_vectors as ipr only supports Christoph> multiple MSI-X vectors, but not multiple MSI vectors.
Christoph> Otherwise this cleans up a lot of cruft and allows to use a Christoph> common request_irq loop for irq types, which happens to only Christoph> iterate over a single line in the non MSI-X case.
Applied to 4.10/scsi-queue.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 6/6] media/cobalt: use pci_irq_allocate_vectors
In reply to Hans VerkuilHi Hans,
just checked the current Linux tree and cobalt still uses the old pci_enable_msi_range call. Did you queue this patch up for 4.10?
Re: [PATCH 6/6] media/cobalt: use pci_irq_allocate_vectors
Quoted 9 lines · Christoph Hellwig
Hi Hans,
just checked the current Linux tree and cobalt still uses the old
pci_enable_msi_rangecall. Did you queue this patch up for 4.10? --
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Completely forgot this. Is it OK to queue it for 4.11? Or is it blocking other follow-up work you want to do for 4.10?
Regards,
Hans
Re: [PATCH 6/6] media/cobalt: use pci_irq_allocate_vectors
Quoted 2 lines · Hans Verkuil
Completely forgot this. Is it OK to queue it for 4.11? Or is it blocking other follow-up work you want to do for 4.10?
My plan was to see if Bjorn would take the patch to do the trivial removal of pci_enable_msix_exact and pci_enable_msix_range even as a late 4.10 patch given it's so harmless, but either way there is follow work pending ASAP so getting it in for 4.10 would be very helpful.
Re: [PATCH 6/6] media/cobalt: use pci_irq_allocate_vectors
Quoted 9 lines · Christoph Hellwig
Quoted 2 lines · Hans Verkuil
Completely forgot this. Is it OK to queue it for 4.11? Or is it blocking other follow-up work you want to do for 4.10?
My plan was to see if Bjorn would take the patch to do the trivial removal of
pci_enable_msix_exactandpci_enable_msix_rangeeven as a late 4.10 patch given it's so harmless, but either way there is follow work pending ASAP so getting it in for 4.10 would be very helpful.
OK, then I'll make a pull request for 4.10 tomorrow.
Regards,
Hans