Commit fad119b7 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen

scsi: megaraid_sas: switch to pci_alloc_irq_vectors

[mkp: fixed bad indentation]
Signed-off-by: default avatarHannes Reinecke <hare@suse.com>
Acked-by: default avatarSumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 9c58b395
...@@ -2120,7 +2120,6 @@ struct megasas_instance { ...@@ -2120,7 +2120,6 @@ struct megasas_instance {
u32 ctrl_context_pages; u32 ctrl_context_pages;
struct megasas_ctrl_info *ctrl_info; struct megasas_ctrl_info *ctrl_info;
unsigned int msix_vectors; unsigned int msix_vectors;
struct msix_entry msixentry[MEGASAS_MAX_MSIX_QUEUES];
struct megasas_irq_context irq_context[MEGASAS_MAX_MSIX_QUEUES]; struct megasas_irq_context irq_context[MEGASAS_MAX_MSIX_QUEUES];
u64 map_id; u64 map_id;
u64 pd_seq_map_id; u64 pd_seq_map_id;
......
...@@ -4837,7 +4837,7 @@ megasas_init_adapter_mfi(struct megasas_instance *instance) ...@@ -4837,7 +4837,7 @@ megasas_init_adapter_mfi(struct megasas_instance *instance)
} }
/* /*
* megasas_setup_irqs_msix - register legacy interrupts. * megasas_setup_irqs_ioapic - register legacy interrupts.
* @instance: Adapter soft state * @instance: Adapter soft state
* *
* Do not enable interrupt, only setup ISRs. * Do not enable interrupt, only setup ISRs.
...@@ -4852,8 +4852,9 @@ megasas_setup_irqs_ioapic(struct megasas_instance *instance) ...@@ -4852,8 +4852,9 @@ megasas_setup_irqs_ioapic(struct megasas_instance *instance)
pdev = instance->pdev; pdev = instance->pdev;
instance->irq_context[0].instance = instance; instance->irq_context[0].instance = instance;
instance->irq_context[0].MSIxIndex = 0; instance->irq_context[0].MSIxIndex = 0;
if (request_irq(pdev->irq, instance->instancet->service_isr, if (request_irq(pci_irq_vector(pdev, 0),
IRQF_SHARED, "megasas", &instance->irq_context[0])) { instance->instancet->service_isr, IRQF_SHARED,
"megasas", &instance->irq_context[0])) {
dev_err(&instance->pdev->dev, dev_err(&instance->pdev->dev,
"Failed to register IRQ from %s %d\n", "Failed to register IRQ from %s %d\n",
__func__, __LINE__); __func__, __LINE__);
...@@ -4874,28 +4875,23 @@ megasas_setup_irqs_ioapic(struct megasas_instance *instance) ...@@ -4874,28 +4875,23 @@ megasas_setup_irqs_ioapic(struct megasas_instance *instance)
static int static int
megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe) megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe)
{ {
int i, j, cpu; int i, j;
struct pci_dev *pdev; struct pci_dev *pdev;
pdev = instance->pdev; pdev = instance->pdev;
/* Try MSI-x */ /* Try MSI-x */
cpu = cpumask_first(cpu_online_mask);
for (i = 0; i < instance->msix_vectors; i++) { for (i = 0; i < instance->msix_vectors; i++) {
instance->irq_context[i].instance = instance; instance->irq_context[i].instance = instance;
instance->irq_context[i].MSIxIndex = i; instance->irq_context[i].MSIxIndex = i;
if (request_irq(instance->msixentry[i].vector, if (request_irq(pci_irq_vector(pdev, i),
instance->instancet->service_isr, 0, "megasas", instance->instancet->service_isr, 0, "megasas",
&instance->irq_context[i])) { &instance->irq_context[i])) {
dev_err(&instance->pdev->dev, dev_err(&instance->pdev->dev,
"Failed to register IRQ for vector %d.\n", i); "Failed to register IRQ for vector %d.\n", i);
for (j = 0; j < i; j++) { for (j = 0; j < i; j++)
if (smp_affinity_enable) free_irq(pci_irq_vector(pdev, j),
irq_set_affinity_hint( &instance->irq_context[j]);
instance->msixentry[j].vector, NULL);
free_irq(instance->msixentry[j].vector,
&instance->irq_context[j]);
}
/* Retry irq register for IO_APIC*/ /* Retry irq register for IO_APIC*/
instance->msix_vectors = 0; instance->msix_vectors = 0;
if (is_probe) if (is_probe)
...@@ -4903,14 +4899,6 @@ megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe) ...@@ -4903,14 +4899,6 @@ megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe)
else else
return -1; return -1;
} }
if (smp_affinity_enable) {
if (irq_set_affinity_hint(instance->msixentry[i].vector,
get_cpu_mask(cpu)))
dev_err(&instance->pdev->dev,
"Failed to set affinity hint"
" for cpu %d\n", cpu);
cpu = cpumask_next(cpu, cpu_online_mask);
}
} }
return 0; return 0;
} }
...@@ -4927,14 +4915,12 @@ megasas_destroy_irqs(struct megasas_instance *instance) { ...@@ -4927,14 +4915,12 @@ megasas_destroy_irqs(struct megasas_instance *instance) {
if (instance->msix_vectors) if (instance->msix_vectors)
for (i = 0; i < instance->msix_vectors; i++) { for (i = 0; i < instance->msix_vectors; i++) {
if (smp_affinity_enable) free_irq(pci_irq_vector(instance->pdev, i),
irq_set_affinity_hint(
instance->msixentry[i].vector, NULL);
free_irq(instance->msixentry[i].vector,
&instance->irq_context[i]); &instance->irq_context[i]);
} }
else else
free_irq(instance->pdev->irq, &instance->irq_context[0]); free_irq(pci_irq_vector(instance->pdev, 0),
&instance->irq_context[0]);
} }
/** /**
...@@ -5092,6 +5078,8 @@ static int megasas_init_fw(struct megasas_instance *instance) ...@@ -5092,6 +5078,8 @@ static int megasas_init_fw(struct megasas_instance *instance)
msix_enable = (instance->instancet->read_fw_status_reg(reg_set) & msix_enable = (instance->instancet->read_fw_status_reg(reg_set) &
0x4000000) >> 0x1a; 0x4000000) >> 0x1a;
if (msix_enable && !msix_disable) { if (msix_enable && !msix_disable) {
int irq_flags = PCI_IRQ_MSIX;
scratch_pad_2 = readl scratch_pad_2 = readl
(&instance->reg_set->outbound_scratch_pad_2); (&instance->reg_set->outbound_scratch_pad_2);
/* Check max MSI-X vectors */ /* Check max MSI-X vectors */
...@@ -5128,15 +5116,18 @@ static int megasas_init_fw(struct megasas_instance *instance) ...@@ -5128,15 +5116,18 @@ static int megasas_init_fw(struct megasas_instance *instance)
/* Don't bother allocating more MSI-X vectors than cpus */ /* Don't bother allocating more MSI-X vectors than cpus */
instance->msix_vectors = min(instance->msix_vectors, instance->msix_vectors = min(instance->msix_vectors,
(unsigned int)num_online_cpus()); (unsigned int)num_online_cpus());
for (i = 0; i < instance->msix_vectors; i++) if (smp_affinity_enable)
instance->msixentry[i].entry = i; irq_flags |= PCI_IRQ_AFFINITY;
i = pci_enable_msix_range(instance->pdev, instance->msixentry, i = pci_alloc_irq_vectors(instance->pdev, 1,
1, instance->msix_vectors); instance->msix_vectors, irq_flags);
if (i > 0) if (i > 0)
instance->msix_vectors = i; instance->msix_vectors = i;
else else
instance->msix_vectors = 0; instance->msix_vectors = 0;
} }
i = pci_alloc_irq_vectors(instance->pdev, 1, 1, PCI_IRQ_LEGACY);
if (i < 0)
goto fail_setup_irqs;
dev_info(&instance->pdev->dev, dev_info(&instance->pdev->dev,
"firmware supports msix\t: (%d)", fw_msix_count); "firmware supports msix\t: (%d)", fw_msix_count);
...@@ -5307,10 +5298,11 @@ static int megasas_init_fw(struct megasas_instance *instance) ...@@ -5307,10 +5298,11 @@ static int megasas_init_fw(struct megasas_instance *instance)
fail_get_pd_list: fail_get_pd_list:
instance->instancet->disable_intr(instance); instance->instancet->disable_intr(instance);
megasas_destroy_irqs(instance);
fail_init_adapter: fail_init_adapter:
megasas_destroy_irqs(instance);
fail_setup_irqs:
if (instance->msix_vectors) if (instance->msix_vectors)
pci_disable_msix(instance->pdev); pci_free_irq_vectors(instance->pdev);
instance->msix_vectors = 0; instance->msix_vectors = 0;
fail_ready_state: fail_ready_state:
kfree(instance->ctrl_info); kfree(instance->ctrl_info);
...@@ -5579,7 +5571,6 @@ static int megasas_io_attach(struct megasas_instance *instance) ...@@ -5579,7 +5571,6 @@ static int megasas_io_attach(struct megasas_instance *instance)
/* /*
* Export parameters required by SCSI mid-layer * Export parameters required by SCSI mid-layer
*/ */
host->irq = instance->pdev->irq;
host->unique_id = instance->unique_id; host->unique_id = instance->unique_id;
host->can_queue = instance->max_scsi_cmds; host->can_queue = instance->max_scsi_cmds;
host->this_id = instance->init_id; host->this_id = instance->init_id;
...@@ -5942,7 +5933,7 @@ static int megasas_probe_one(struct pci_dev *pdev, ...@@ -5942,7 +5933,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
else else
megasas_release_mfi(instance); megasas_release_mfi(instance);
if (instance->msix_vectors) if (instance->msix_vectors)
pci_disable_msix(instance->pdev); pci_free_irq_vectors(instance->pdev);
fail_init_mfi: fail_init_mfi:
fail_alloc_dma_buf: fail_alloc_dma_buf:
if (instance->evt_detail) if (instance->evt_detail)
...@@ -6100,7 +6091,7 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -6100,7 +6091,7 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state)
megasas_destroy_irqs(instance); megasas_destroy_irqs(instance);
if (instance->msix_vectors) if (instance->msix_vectors)
pci_disable_msix(instance->pdev); pci_free_irq_vectors(instance->pdev);
pci_save_state(pdev); pci_save_state(pdev);
pci_disable_device(pdev); pci_disable_device(pdev);
...@@ -6120,6 +6111,7 @@ megasas_resume(struct pci_dev *pdev) ...@@ -6120,6 +6111,7 @@ megasas_resume(struct pci_dev *pdev)
int rval; int rval;
struct Scsi_Host *host; struct Scsi_Host *host;
struct megasas_instance *instance; struct megasas_instance *instance;
int irq_flags = PCI_IRQ_LEGACY;
instance = pci_get_drvdata(pdev); instance = pci_get_drvdata(pdev);
host = instance->host; host = instance->host;
...@@ -6155,9 +6147,15 @@ megasas_resume(struct pci_dev *pdev) ...@@ -6155,9 +6147,15 @@ megasas_resume(struct pci_dev *pdev)
goto fail_ready_state; goto fail_ready_state;
/* Now re-enable MSI-X */ /* Now re-enable MSI-X */
if (instance->msix_vectors && if (instance->msix_vectors) {
pci_enable_msix_exact(instance->pdev, instance->msixentry, irq_flags = PCI_IRQ_MSIX;
instance->msix_vectors)) if (smp_affinity_enable)
irq_flags |= PCI_IRQ_AFFINITY;
}
rval = pci_alloc_irq_vectors(instance->pdev, 1,
instance->msix_vectors ?
instance->msix_vectors : 1, irq_flags);
if (rval < 0)
goto fail_reenable_msix; goto fail_reenable_msix;
if (instance->ctrl_context) { if (instance->ctrl_context) {
...@@ -6330,7 +6328,7 @@ static void megasas_detach_one(struct pci_dev *pdev) ...@@ -6330,7 +6328,7 @@ static void megasas_detach_one(struct pci_dev *pdev)
megasas_destroy_irqs(instance); megasas_destroy_irqs(instance);
if (instance->msix_vectors) if (instance->msix_vectors)
pci_disable_msix(instance->pdev); pci_free_irq_vectors(instance->pdev);
if (instance->ctrl_context) { if (instance->ctrl_context) {
megasas_release_fusion(instance); megasas_release_fusion(instance);
...@@ -6425,7 +6423,7 @@ static void megasas_shutdown(struct pci_dev *pdev) ...@@ -6425,7 +6423,7 @@ static void megasas_shutdown(struct pci_dev *pdev)
megasas_destroy_irqs(instance); megasas_destroy_irqs(instance);
if (instance->msix_vectors) if (instance->msix_vectors)
pci_disable_msix(instance->pdev); pci_free_irq_vectors(instance->pdev);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment