diff options
author | Christoph Hellwig <hch@lst.de> | 2016-12-06 08:56:50 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-12-07 18:58:58 -0500 |
commit | f5b893c947151d424a4ab55ea3a8544b81974b31 (patch) | |
tree | e4d0e3e07d589ee96a21536f8da775af1c8b2ee0 | |
parent | 26f3ba9600e5d4437bb7299d2b01003b0d93e853 (diff) |
scsi: qla4xxx: switch to pci_alloc_irq_vectors
And simplify the MSI-X logic in general - just request the two vectors
directly instead of going through an indirection table.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Nilesh Javali <nilesh.javali@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_def.h | 18 | ||||
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_glbl.h | 1 | ||||
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_isr.c | 27 | ||||
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_nx.c | 89 |
4 files changed, 37 insertions, 98 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h index a7cfc270bd08..aeebefb1e9f8 100644 --- a/drivers/scsi/qla4xxx/ql4_def.h +++ b/drivers/scsi/qla4xxx/ql4_def.h | |||
@@ -409,18 +409,9 @@ struct qla4_8xxx_legacy_intr_set { | |||
409 | 409 | ||
410 | /* MSI-X Support */ | 410 | /* MSI-X Support */ |
411 | 411 | ||
412 | #define QLA_MSIX_DEFAULT 0x00 | 412 | #define QLA_MSIX_DEFAULT 0 |
413 | #define QLA_MSIX_RSP_Q 0x01 | 413 | #define QLA_MSIX_RSP_Q 1 |
414 | |||
415 | #define QLA_MSIX_ENTRIES 2 | 414 | #define QLA_MSIX_ENTRIES 2 |
416 | #define QLA_MIDX_DEFAULT 0 | ||
417 | #define QLA_MIDX_RSP_Q 1 | ||
418 | |||
419 | struct ql4_msix_entry { | ||
420 | int have_irq; | ||
421 | uint16_t msix_vector; | ||
422 | uint16_t msix_entry; | ||
423 | }; | ||
424 | 415 | ||
425 | /* | 416 | /* |
426 | * ISP Operations | 417 | * ISP Operations |
@@ -572,9 +563,6 @@ struct scsi_qla_host { | |||
572 | #define AF_IRQ_ATTACHED 10 /* 0x00000400 */ | 563 | #define AF_IRQ_ATTACHED 10 /* 0x00000400 */ |
573 | #define AF_DISABLE_ACB_COMPLETE 11 /* 0x00000800 */ | 564 | #define AF_DISABLE_ACB_COMPLETE 11 /* 0x00000800 */ |
574 | #define AF_HA_REMOVAL 12 /* 0x00001000 */ | 565 | #define AF_HA_REMOVAL 12 /* 0x00001000 */ |
575 | #define AF_INTx_ENABLED 15 /* 0x00008000 */ | ||
576 | #define AF_MSI_ENABLED 16 /* 0x00010000 */ | ||
577 | #define AF_MSIX_ENABLED 17 /* 0x00020000 */ | ||
578 | #define AF_MBOX_COMMAND_NOPOLL 18 /* 0x00040000 */ | 566 | #define AF_MBOX_COMMAND_NOPOLL 18 /* 0x00040000 */ |
579 | #define AF_FW_RECOVERY 19 /* 0x00080000 */ | 567 | #define AF_FW_RECOVERY 19 /* 0x00080000 */ |
580 | #define AF_EEH_BUSY 20 /* 0x00100000 */ | 568 | #define AF_EEH_BUSY 20 /* 0x00100000 */ |
@@ -762,8 +750,6 @@ struct scsi_qla_host { | |||
762 | struct isp_operations *isp_ops; | 750 | struct isp_operations *isp_ops; |
763 | struct ql82xx_hw_data hw; | 751 | struct ql82xx_hw_data hw; |
764 | 752 | ||
765 | struct ql4_msix_entry msix_entries[QLA_MSIX_ENTRIES]; | ||
766 | |||
767 | uint32_t nx_dev_init_timeout; | 753 | uint32_t nx_dev_init_timeout; |
768 | uint32_t nx_reset_timeout; | 754 | uint32_t nx_reset_timeout; |
769 | void *fw_dump; | 755 | void *fw_dump; |
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h index 2559144f5475..bce96a58f14e 100644 --- a/drivers/scsi/qla4xxx/ql4_glbl.h +++ b/drivers/scsi/qla4xxx/ql4_glbl.h | |||
@@ -134,7 +134,6 @@ int qla4_8xxx_get_flash_info(struct scsi_qla_host *ha); | |||
134 | void qla4_82xx_enable_intrs(struct scsi_qla_host *ha); | 134 | void qla4_82xx_enable_intrs(struct scsi_qla_host *ha); |
135 | void qla4_82xx_disable_intrs(struct scsi_qla_host *ha); | 135 | void qla4_82xx_disable_intrs(struct scsi_qla_host *ha); |
136 | int qla4_8xxx_enable_msix(struct scsi_qla_host *ha); | 136 | int qla4_8xxx_enable_msix(struct scsi_qla_host *ha); |
137 | void qla4_8xxx_disable_msix(struct scsi_qla_host *ha); | ||
138 | irqreturn_t qla4_8xxx_msi_handler(int irq, void *dev_id); | 137 | irqreturn_t qla4_8xxx_msi_handler(int irq, void *dev_id); |
139 | irqreturn_t qla4_8xxx_default_intr_handler(int irq, void *dev_id); | 138 | irqreturn_t qla4_8xxx_default_intr_handler(int irq, void *dev_id); |
140 | irqreturn_t qla4_8xxx_msix_rsp_q(int irq, void *dev_id); | 139 | irqreturn_t qla4_8xxx_msix_rsp_q(int irq, void *dev_id); |
diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c index 4f9c0f2be89d..d2cd33d8d67f 100644 --- a/drivers/scsi/qla4xxx/ql4_isr.c +++ b/drivers/scsi/qla4xxx/ql4_isr.c | |||
@@ -1107,7 +1107,7 @@ static void qla4_82xx_spurious_interrupt(struct scsi_qla_host *ha, | |||
1107 | DEBUG2(ql4_printk(KERN_INFO, ha, "Spurious Interrupt\n")); | 1107 | DEBUG2(ql4_printk(KERN_INFO, ha, "Spurious Interrupt\n")); |
1108 | if (is_qla8022(ha)) { | 1108 | if (is_qla8022(ha)) { |
1109 | writel(0, &ha->qla4_82xx_reg->host_int); | 1109 | writel(0, &ha->qla4_82xx_reg->host_int); |
1110 | if (test_bit(AF_INTx_ENABLED, &ha->flags)) | 1110 | if (!ha->pdev->msi_enabled && !ha->pdev->msix_enabled) |
1111 | qla4_82xx_wr_32(ha, ha->nx_legacy_intr.tgt_mask_reg, | 1111 | qla4_82xx_wr_32(ha, ha->nx_legacy_intr.tgt_mask_reg, |
1112 | 0xfbff); | 1112 | 0xfbff); |
1113 | } | 1113 | } |
@@ -1564,19 +1564,18 @@ int qla4xxx_request_irqs(struct scsi_qla_host *ha) | |||
1564 | 1564 | ||
1565 | try_msi: | 1565 | try_msi: |
1566 | /* Trying MSI */ | 1566 | /* Trying MSI */ |
1567 | ret = pci_enable_msi(ha->pdev); | 1567 | ret = pci_alloc_irq_vectors(ha->pdev, 1, 1, PCI_IRQ_MSI); |
1568 | if (!ret) { | 1568 | if (ret > 0) { |
1569 | ret = request_irq(ha->pdev->irq, qla4_8xxx_msi_handler, | 1569 | ret = request_irq(ha->pdev->irq, qla4_8xxx_msi_handler, |
1570 | 0, DRIVER_NAME, ha); | 1570 | 0, DRIVER_NAME, ha); |
1571 | if (!ret) { | 1571 | if (!ret) { |
1572 | DEBUG2(ql4_printk(KERN_INFO, ha, "MSI: Enabled.\n")); | 1572 | DEBUG2(ql4_printk(KERN_INFO, ha, "MSI: Enabled.\n")); |
1573 | set_bit(AF_MSI_ENABLED, &ha->flags); | ||
1574 | goto irq_attached; | 1573 | goto irq_attached; |
1575 | } else { | 1574 | } else { |
1576 | ql4_printk(KERN_WARNING, ha, | 1575 | ql4_printk(KERN_WARNING, ha, |
1577 | "MSI: Failed to reserve interrupt %d " | 1576 | "MSI: Failed to reserve interrupt %d " |
1578 | "already in use.\n", ha->pdev->irq); | 1577 | "already in use.\n", ha->pdev->irq); |
1579 | pci_disable_msi(ha->pdev); | 1578 | pci_free_irq_vectors(ha->pdev); |
1580 | } | 1579 | } |
1581 | } | 1580 | } |
1582 | 1581 | ||
@@ -1592,7 +1591,6 @@ try_intx: | |||
1592 | IRQF_SHARED, DRIVER_NAME, ha); | 1591 | IRQF_SHARED, DRIVER_NAME, ha); |
1593 | if (!ret) { | 1592 | if (!ret) { |
1594 | DEBUG2(ql4_printk(KERN_INFO, ha, "INTx: Enabled.\n")); | 1593 | DEBUG2(ql4_printk(KERN_INFO, ha, "INTx: Enabled.\n")); |
1595 | set_bit(AF_INTx_ENABLED, &ha->flags); | ||
1596 | goto irq_attached; | 1594 | goto irq_attached; |
1597 | 1595 | ||
1598 | } else { | 1596 | } else { |
@@ -1614,14 +1612,11 @@ irq_not_attached: | |||
1614 | 1612 | ||
1615 | void qla4xxx_free_irqs(struct scsi_qla_host *ha) | 1613 | void qla4xxx_free_irqs(struct scsi_qla_host *ha) |
1616 | { | 1614 | { |
1617 | if (test_and_clear_bit(AF_IRQ_ATTACHED, &ha->flags)) { | 1615 | if (!test_and_clear_bit(AF_IRQ_ATTACHED, &ha->flags)) |
1618 | if (test_bit(AF_MSIX_ENABLED, &ha->flags)) { | 1616 | return; |
1619 | qla4_8xxx_disable_msix(ha); | 1617 | |
1620 | } else if (test_and_clear_bit(AF_MSI_ENABLED, &ha->flags)) { | 1618 | if (ha->pdev->msix_enabled) |
1621 | free_irq(ha->pdev->irq, ha); | 1619 | free_irq(pci_irq_vector(ha->pdev, 1), ha); |
1622 | pci_disable_msi(ha->pdev); | 1620 | free_irq(pci_irq_vector(ha->pdev, 0), ha); |
1623 | } else if (test_and_clear_bit(AF_INTx_ENABLED, &ha->flags)) { | 1621 | pci_free_irq_vectors(ha->pdev); |
1624 | free_irq(ha->pdev->irq, ha); | ||
1625 | } | ||
1626 | } | ||
1627 | } | 1622 | } |
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c index bccd8b674234..e91abb327745 100644 --- a/drivers/scsi/qla4xxx/ql4_nx.c +++ b/drivers/scsi/qla4xxx/ql4_nx.c | |||
@@ -3945,7 +3945,7 @@ void qla4_82xx_process_mbox_intr(struct scsi_qla_host *ha, int out_count) | |||
3945 | ha->isp_ops->interrupt_service_routine(ha, intr_status); | 3945 | ha->isp_ops->interrupt_service_routine(ha, intr_status); |
3946 | 3946 | ||
3947 | if (test_bit(AF_INTERRUPTS_ON, &ha->flags) && | 3947 | if (test_bit(AF_INTERRUPTS_ON, &ha->flags) && |
3948 | test_bit(AF_INTx_ENABLED, &ha->flags)) | 3948 | (!ha->pdev->msi_enabled && !ha->pdev->msix_enabled)) |
3949 | qla4_82xx_wr_32(ha, ha->nx_legacy_intr.tgt_mask_reg, | 3949 | qla4_82xx_wr_32(ha, ha->nx_legacy_intr.tgt_mask_reg, |
3950 | 0xfbff); | 3950 | 0xfbff); |
3951 | } | 3951 | } |
@@ -4174,78 +4174,37 @@ qla4_82xx_disable_intrs(struct scsi_qla_host *ha) | |||
4174 | spin_unlock_irq(&ha->hardware_lock); | 4174 | spin_unlock_irq(&ha->hardware_lock); |
4175 | } | 4175 | } |
4176 | 4176 | ||
4177 | struct ql4_init_msix_entry { | ||
4178 | uint16_t entry; | ||
4179 | uint16_t index; | ||
4180 | const char *name; | ||
4181 | irq_handler_t handler; | ||
4182 | }; | ||
4183 | |||
4184 | static struct ql4_init_msix_entry qla4_8xxx_msix_entries[QLA_MSIX_ENTRIES] = { | ||
4185 | { QLA_MSIX_DEFAULT, QLA_MIDX_DEFAULT, | ||
4186 | "qla4xxx (default)", | ||
4187 | (irq_handler_t)qla4_8xxx_default_intr_handler }, | ||
4188 | { QLA_MSIX_RSP_Q, QLA_MIDX_RSP_Q, | ||
4189 | "qla4xxx (rsp_q)", (irq_handler_t)qla4_8xxx_msix_rsp_q }, | ||
4190 | }; | ||
4191 | |||
4192 | void | ||
4193 | qla4_8xxx_disable_msix(struct scsi_qla_host *ha) | ||
4194 | { | ||
4195 | int i; | ||
4196 | struct ql4_msix_entry *qentry; | ||
4197 | |||
4198 | for (i = 0; i < QLA_MSIX_ENTRIES; i++) { | ||
4199 | qentry = &ha->msix_entries[qla4_8xxx_msix_entries[i].index]; | ||
4200 | if (qentry->have_irq) { | ||
4201 | free_irq(qentry->msix_vector, ha); | ||
4202 | DEBUG2(ql4_printk(KERN_INFO, ha, "%s: %s\n", | ||
4203 | __func__, qla4_8xxx_msix_entries[i].name)); | ||
4204 | } | ||
4205 | } | ||
4206 | pci_disable_msix(ha->pdev); | ||
4207 | clear_bit(AF_MSIX_ENABLED, &ha->flags); | ||
4208 | } | ||
4209 | |||
4210 | int | 4177 | int |
4211 | qla4_8xxx_enable_msix(struct scsi_qla_host *ha) | 4178 | qla4_8xxx_enable_msix(struct scsi_qla_host *ha) |
4212 | { | 4179 | { |
4213 | int i, ret; | 4180 | int ret; |
4214 | struct msix_entry entries[QLA_MSIX_ENTRIES]; | ||
4215 | struct ql4_msix_entry *qentry; | ||
4216 | |||
4217 | for (i = 0; i < QLA_MSIX_ENTRIES; i++) | ||
4218 | entries[i].entry = qla4_8xxx_msix_entries[i].entry; | ||
4219 | 4181 | ||
4220 | ret = pci_enable_msix_exact(ha->pdev, entries, ARRAY_SIZE(entries)); | 4182 | ret = pci_alloc_irq_vectors(ha->pdev, QLA_MSIX_ENTRIES, |
4221 | if (ret) { | 4183 | QLA_MSIX_ENTRIES, PCI_IRQ_MSIX); |
4184 | if (ret < 0) { | ||
4222 | ql4_printk(KERN_WARNING, ha, | 4185 | ql4_printk(KERN_WARNING, ha, |
4223 | "MSI-X: Failed to enable support -- %d/%d\n", | 4186 | "MSI-X: Failed to enable support -- %d/%d\n", |
4224 | QLA_MSIX_ENTRIES, ret); | 4187 | QLA_MSIX_ENTRIES, ret); |
4225 | goto msix_out; | 4188 | return ret; |
4226 | } | ||
4227 | set_bit(AF_MSIX_ENABLED, &ha->flags); | ||
4228 | |||
4229 | for (i = 0; i < QLA_MSIX_ENTRIES; i++) { | ||
4230 | qentry = &ha->msix_entries[qla4_8xxx_msix_entries[i].index]; | ||
4231 | qentry->msix_vector = entries[i].vector; | ||
4232 | qentry->msix_entry = entries[i].entry; | ||
4233 | qentry->have_irq = 0; | ||
4234 | ret = request_irq(qentry->msix_vector, | ||
4235 | qla4_8xxx_msix_entries[i].handler, 0, | ||
4236 | qla4_8xxx_msix_entries[i].name, ha); | ||
4237 | if (ret) { | ||
4238 | ql4_printk(KERN_WARNING, ha, | ||
4239 | "MSI-X: Unable to register handler -- %x/%d.\n", | ||
4240 | qla4_8xxx_msix_entries[i].index, ret); | ||
4241 | qla4_8xxx_disable_msix(ha); | ||
4242 | goto msix_out; | ||
4243 | } | ||
4244 | qentry->have_irq = 1; | ||
4245 | DEBUG2(ql4_printk(KERN_INFO, ha, "%s: %s\n", | ||
4246 | __func__, qla4_8xxx_msix_entries[i].name)); | ||
4247 | } | 4189 | } |
4248 | msix_out: | 4190 | |
4191 | ret = request_irq(pci_irq_vector(ha->pdev, 0), | ||
4192 | qla4_8xxx_default_intr_handler, 0, "qla4xxx (default)", | ||
4193 | ha); | ||
4194 | if (ret) | ||
4195 | goto out_free_vectors; | ||
4196 | |||
4197 | ret = request_irq(pci_irq_vector(ha->pdev, 1), | ||
4198 | qla4_8xxx_msix_rsp_q, 0, "qla4xxx (rsp_q)", ha); | ||
4199 | if (ret) | ||
4200 | goto out_free_default_irq; | ||
4201 | |||
4202 | return 0; | ||
4203 | |||
4204 | out_free_default_irq: | ||
4205 | free_irq(pci_irq_vector(ha->pdev, 0), ha); | ||
4206 | out_free_vectors: | ||
4207 | pci_free_irq_vectors(ha->pdev); | ||
4249 | return ret; | 4208 | return ret; |
4250 | } | 4209 | } |
4251 | 4210 | ||