scsi: pmcraid: switch to pci_alloc_irq_vectors
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
984dc46c57
commit
eab5c1503b
@ -4587,16 +4587,14 @@ static void pmcraid_tasklet_function(unsigned long instance)
|
|||||||
static
|
static
|
||||||
void pmcraid_unregister_interrupt_handler(struct pmcraid_instance *pinstance)
|
void pmcraid_unregister_interrupt_handler(struct pmcraid_instance *pinstance)
|
||||||
{
|
{
|
||||||
|
struct pci_dev *pdev = pinstance->pdev;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < pinstance->num_hrrq; i++)
|
for (i = 0; i < pinstance->num_hrrq; i++)
|
||||||
free_irq(pinstance->hrrq_vector[i].vector,
|
free_irq(pci_irq_vector(pdev, i), &pinstance->hrrq_vector[i]);
|
||||||
&(pinstance->hrrq_vector[i]));
|
|
||||||
|
|
||||||
if (pinstance->interrupt_mode) {
|
pinstance->interrupt_mode = 0;
|
||||||
pci_disable_msix(pinstance->pdev);
|
pci_free_irq_vectors(pdev);
|
||||||
pinstance->interrupt_mode = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -4609,60 +4607,52 @@ void pmcraid_unregister_interrupt_handler(struct pmcraid_instance *pinstance)
|
|||||||
static int
|
static int
|
||||||
pmcraid_register_interrupt_handler(struct pmcraid_instance *pinstance)
|
pmcraid_register_interrupt_handler(struct pmcraid_instance *pinstance)
|
||||||
{
|
{
|
||||||
int rc;
|
|
||||||
struct pci_dev *pdev = pinstance->pdev;
|
struct pci_dev *pdev = pinstance->pdev;
|
||||||
|
unsigned int irq_flag = PCI_IRQ_LEGACY, flag;
|
||||||
|
int num_hrrq, rc, i;
|
||||||
|
irq_handler_t isr;
|
||||||
|
|
||||||
if ((pmcraid_enable_msix) &&
|
if (pmcraid_enable_msix)
|
||||||
(pci_find_capability(pdev, PCI_CAP_ID_MSIX))) {
|
irq_flag |= PCI_IRQ_MSIX;
|
||||||
int num_hrrq = PMCRAID_NUM_MSIX_VECTORS;
|
|
||||||
struct msix_entry entries[PMCRAID_NUM_MSIX_VECTORS];
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < PMCRAID_NUM_MSIX_VECTORS; i++)
|
|
||||||
entries[i].entry = i;
|
|
||||||
|
|
||||||
num_hrrq = pci_enable_msix_range(pdev, entries, 1, num_hrrq);
|
num_hrrq = pci_alloc_irq_vectors(pdev, 1, PMCRAID_NUM_MSIX_VECTORS,
|
||||||
if (num_hrrq < 0)
|
irq_flag);
|
||||||
goto pmcraid_isr_legacy;
|
if (num_hrrq < 0)
|
||||||
|
return num_hrrq;
|
||||||
|
|
||||||
for (i = 0; i < num_hrrq; i++) {
|
if (pdev->msix_enabled) {
|
||||||
pinstance->hrrq_vector[i].hrrq_id = i;
|
flag = 0;
|
||||||
pinstance->hrrq_vector[i].drv_inst = pinstance;
|
isr = pmcraid_isr_msix;
|
||||||
pinstance->hrrq_vector[i].vector = entries[i].vector;
|
} else {
|
||||||
rc = request_irq(pinstance->hrrq_vector[i].vector,
|
flag = IRQF_SHARED;
|
||||||
pmcraid_isr_msix, 0,
|
isr = pmcraid_isr;
|
||||||
PMCRAID_DRIVER_NAME,
|
}
|
||||||
&(pinstance->hrrq_vector[i]));
|
|
||||||
|
|
||||||
if (rc) {
|
for (i = 0; i < num_hrrq; i++) {
|
||||||
int j;
|
struct pmcraid_isr_param *vec = &pinstance->hrrq_vector[i];
|
||||||
for (j = 0; j < i; j++)
|
|
||||||
free_irq(entries[j].vector,
|
|
||||||
&(pinstance->hrrq_vector[j]));
|
|
||||||
pci_disable_msix(pdev);
|
|
||||||
goto pmcraid_isr_legacy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pinstance->num_hrrq = num_hrrq;
|
vec->hrrq_id = i;
|
||||||
|
vec->drv_inst = pinstance;
|
||||||
|
rc = request_irq(pci_irq_vector(pdev, i), isr, flag,
|
||||||
|
PMCRAID_DRIVER_NAME, vec);
|
||||||
|
if (rc)
|
||||||
|
goto out_unwind;
|
||||||
|
}
|
||||||
|
|
||||||
|
pinstance->num_hrrq = num_hrrq;
|
||||||
|
if (pdev->msix_enabled) {
|
||||||
pinstance->interrupt_mode = 1;
|
pinstance->interrupt_mode = 1;
|
||||||
iowrite32(DOORBELL_INTR_MODE_MSIX,
|
iowrite32(DOORBELL_INTR_MODE_MSIX,
|
||||||
pinstance->int_regs.host_ioa_interrupt_reg);
|
pinstance->int_regs.host_ioa_interrupt_reg);
|
||||||
ioread32(pinstance->int_regs.host_ioa_interrupt_reg);
|
ioread32(pinstance->int_regs.host_ioa_interrupt_reg);
|
||||||
goto pmcraid_isr_out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pmcraid_isr_legacy:
|
return 0;
|
||||||
/* If MSI-X registration failed fallback to legacy mode, where
|
|
||||||
* only one hrrq entry will be used
|
|
||||||
*/
|
|
||||||
pinstance->hrrq_vector[0].hrrq_id = 0;
|
|
||||||
pinstance->hrrq_vector[0].drv_inst = pinstance;
|
|
||||||
pinstance->hrrq_vector[0].vector = pdev->irq;
|
|
||||||
pinstance->num_hrrq = 1;
|
|
||||||
|
|
||||||
rc = request_irq(pdev->irq, pmcraid_isr, IRQF_SHARED,
|
out_unwind:
|
||||||
PMCRAID_DRIVER_NAME, &pinstance->hrrq_vector[0]);
|
while (--i > 0)
|
||||||
pmcraid_isr_out:
|
free_irq(pci_irq_vector(pdev, i), &pinstance->hrrq_vector[i]);
|
||||||
|
pci_free_irq_vectors(pdev);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,7 +628,6 @@ struct pmcraid_interrupts {
|
|||||||
/* ISR parameters LLD allocates (one for each MSI-X if enabled) vectors */
|
/* ISR parameters LLD allocates (one for each MSI-X if enabled) vectors */
|
||||||
struct pmcraid_isr_param {
|
struct pmcraid_isr_param {
|
||||||
struct pmcraid_instance *drv_inst;
|
struct pmcraid_instance *drv_inst;
|
||||||
u16 vector; /* allocated msi-x vector */
|
|
||||||
u8 hrrq_id; /* hrrq entry index */
|
u8 hrrq_id; /* hrrq entry index */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user