diff --git a/qla2x00t-32gbit/Makefile_in-tree b/qla2x00t-32gbit/Makefile_in-tree index f86fa5a0b..2e7619677 100644 --- a/qla2x00t-32gbit/Makefile_in-tree +++ b/qla2x00t-32gbit/Makefile_in-tree @@ -7,4 +7,4 @@ obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx.o obj-$(CONFIG_TCM_QLA2XXX) += tcm_qla2xxx.o ccflags-y += -I$(src)/../../../include/scst/ -ccflags-y += $(call cc-option,-Wno-format-truncation) +ccflags-y += $(call cc-option,-Wno-stringop-truncation) diff --git a/qla2x00t-32gbit/qla2x00-target/qla_tgt.c b/qla2x00t-32gbit/qla2x00-target/qla_tgt.c index a6b010830..0dd5b619b 100644 --- a/qla2x00t-32gbit/qla2x00-target/qla_tgt.c +++ b/qla2x00t-32gbit/qla2x00-target/qla_tgt.c @@ -45,10 +45,6 @@ #include "qla_def.h" #include "scst_qla2xxx.h" -extern struct mutex qla_tgt_mutex; -extern struct list_head qla_tgt_glist; - - size_t qlt_add_vtarget(u64 port_name, u64 node_name, u64 parent_host) { struct Scsi_Host *shost = NULL; diff --git a/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c b/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c index 964d3673c..76233876e 100644 --- a/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c +++ b/qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c @@ -1528,7 +1528,6 @@ static int sqa_init_scst_tgt(struct scsi_qla_host *vha) return res; } -extern struct list_head qla_tgt_glist; static void sqa_get_target_list(void) { struct qla_tgt *tgt; diff --git a/qla2x00t-32gbit/qla_isr.c b/qla2x00t-32gbit/qla_isr.c index a2381156a..7099ede9d 100644 --- a/qla2x00t-32gbit/qla_isr.c +++ b/qla2x00t-32gbit/qla_isr.c @@ -3423,21 +3423,15 @@ qla2xxx_msix_rsp_q(int irq, void *dev_id) /* */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) && \ - (!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 7) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) || \ + (defined(RHEL_MAJOR) && RHEL_MAJOR -0 >= 7) /* * See also commit aff171641d18 ("PCI: Provide sensible IRQ vector alloc/free * routines") # v4.8. */ -/** - * pci_irq_vector - return Linux IRQ number of a device vector - * @dev: PCI device to operate on - * @nr: device-relative interrupt vector index (0-based). - */ -static inline int pci_irq_vector(struct pci_dev *dev, unsigned int nr) -{ - return dev->irq + nr; -} +#define HAVE_PCI_IRQ_VECTOR 1 +#else +#define HAVE_PCI_IRQ_VECTOR 0 #endif struct qla_init_msix_entry { @@ -3457,6 +3451,28 @@ static const struct qla_init_msix_entry qla82xx_msix_entries[] = { { "qla2xxx (rsp_q)", qla82xx_msix_rsp_q }, }; +#if !HAVE_PCI_IRQ_VECTOR +static void +qla24xx_disable_msix(struct qla_hw_data *ha) +{ + int i; + struct qla_msix_entry *qentry; + scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); + + for (i = 0; i < ha->msix_count; i++) { + qentry = &ha->msix_entries[i]; + if (qentry->have_irq) + free_irq(qentry->vector, qentry->handle); + } + pci_disable_msix(ha->pdev); + kfree(ha->msix_entries); + ha->msix_entries = NULL; + ha->flags.msix_enabled = 0; + ql_dbg(ql_dbg_init, vha, 0x0042, + "Disabled the MSI.\n"); +} +#endif + static int qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) { @@ -3478,7 +3494,9 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) for (i = 0; i < ha->msix_count; i++) entries[i].entry = i; -#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0) if (QLA_TGT_MODE_ENABLED() && (ql2xenablemsix != 0) && IS_ATIO_MSIX_CAPABLE(ha)) { min_vecs++; @@ -3495,6 +3513,8 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) } #endif + WARN_ON_ONCE(min_vecs > ha->msix_count); + #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) && !defined(RHEL_MAJOR) ret = pci_enable_msix(ha->pdev, entries, ha->msix_count); if (ret) { @@ -3515,7 +3535,8 @@ msix_failed: ha->msix_count, ret); goto msix_out; } - ha->max_rsp_queues = ha->msix_count - 1; + } else { + ret = ha->msix_count; } #elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) ret = pci_enable_msix_range(ha->pdev, @@ -3534,10 +3555,6 @@ msix_failed: &desc); #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) - kfree(entries); -#endif - if (ret < 0) { ql_log(ql_log_fatal, vha, 0x00c7, "MSI-X: Failed to enable support, " @@ -3583,8 +3600,13 @@ msix_failed: for (i = 0; i < ha->msix_count; i++) { qentry = &ha->msix_entries[i]; +#if HAVE_PCI_IRQ_VECTOR qentry->vector = pci_irq_vector(ha->pdev, i); qentry->entry = i; +#else + qentry->vector = entries[i].vector; + qentry->entry = entries[i].entry; +#endif qentry->have_irq = 0; qentry->in_use = 0; qentry->handle = NULL; @@ -3659,6 +3681,9 @@ msix_register_fail: ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues); msix_out: +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) + kfree(entries); +#endif return ret; } @@ -3772,6 +3797,7 @@ qla2x00_free_irqs(scsi_qla_host_t *vha) goto free_irqs; rsp = ha->rsp_q_map[0]; +#if HAVE_PCI_IRQ_VECTOR if (ha->flags.msix_enabled) { struct qla_msix_entry *qentry; int i; @@ -3791,6 +3817,15 @@ qla2x00_free_irqs(scsi_qla_host_t *vha) } else { free_irq(pci_irq_vector(ha->pdev, 0), rsp); } +#else + if (ha->flags.msix_enabled) + qla24xx_disable_msix(ha); + else if (ha->flags.msi_enabled) { + free_irq(ha->pdev->irq, rsp); + pci_disable_msi(ha->pdev); + } else + free_irq(ha->pdev->irq, rsp); +#endif free_irqs: #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) diff --git a/qla2x00t-32gbit/qla_target.h b/qla2x00t-32gbit/qla_target.h index 874e4b24f..55d056e03 100644 --- a/qla2x00t-32gbit/qla_target.h +++ b/qla2x00t-32gbit/qla_target.h @@ -1043,6 +1043,9 @@ struct qla_tgt_prm { extern struct qla_tgt_data qla_target; +extern struct mutex qla_tgt_mutex; +extern struct list_head qla_tgt_glist; + /* * Function prototypes for qla_target.c logic used by qla2xxx LLD code. diff --git a/scst/include/backport.h b/scst/include/backport.h index 6e9b92cd9..6b2273ced 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -815,6 +815,21 @@ static inline long get_user_pages_backport(unsigned long start, #define get_user_pages get_user_pages_backport #endif +/* */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) +/* + * See also commit 4e3ca3e033d1 ("mm/mempool: allow NULL `pool' pointer in + * mempool_destroy()") # v4.3. + */ +static inline void mempool_destroy_backport(mempool_t *pool) +{ + if (pool) + mempool_destroy(pool); +} + +#define mempool_destroy mempool_destroy_backport +#endif + /* */ #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) && \