From c749a72feb60c7bfe519ebc42eab5b154e37d820 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 5 Apr 2019 01:03:04 +0000 Subject: [PATCH 1/8] scst/include/backport.h: Add a mempool_destroy() backport This patch makes it safe to call mempool_destroy(NULL) for kernel versions before v4.3. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8150 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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) && \ From 3c9d681a5fdd58343eb4b55ee6c9ca44ac3af326 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 5 Apr 2019 01:03:28 +0000 Subject: [PATCH 2/8] qla2x00t-32gbit, target: Move variable declarations into a header file git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8151 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t-32gbit/qla2x00-target/qla_tgt.c | 4 ---- qla2x00t-32gbit/qla2x00-target/scst_qla2xxx.c | 1 - qla2x00t-32gbit/qla_target.h | 3 +++ 3 files changed, 3 insertions(+), 5 deletions(-) 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_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. From 0fe36f31ace2c308488454212eb7b2308bd0cf50 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 5 Apr 2019 01:03:47 +0000 Subject: [PATCH 3/8] qla2x00t-32gbit: Remove pci_irq_vector() backport git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8152 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t-32gbit/qla_isr.c | 53 +++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/qla2x00t-32gbit/qla_isr.c b/qla2x00t-32gbit/qla_isr.c index a2381156a..701355954 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) { @@ -3583,8 +3599,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; @@ -3772,6 +3793,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 +3813,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) From 2b09d01896a7ea120adfaeca7141a08ffa2681da Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 5 Apr 2019 01:04:14 +0000 Subject: [PATCH 4/8] qla2x00t-32gbit: Only free 'entries' after its last use git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8153 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t-32gbit/qla_isr.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/qla2x00t-32gbit/qla_isr.c b/qla2x00t-32gbit/qla_isr.c index 701355954..ad0d46b49 100644 --- a/qla2x00t-32gbit/qla_isr.c +++ b/qla2x00t-32gbit/qla_isr.c @@ -3550,10 +3550,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, " @@ -3680,6 +3676,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; } From 304ab2ac64e88eea38b7b6ca75ba3aed25af774a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 5 Apr 2019 01:04:38 +0000 Subject: [PATCH 5/8] qla2x00t-32gbit: Fix qla24xx_enable_msix() for kernel versions before v3.14 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8154 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t-32gbit/qla_isr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qla2x00t-32gbit/qla_isr.c b/qla2x00t-32gbit/qla_isr.c index ad0d46b49..43036ae6b 100644 --- a/qla2x00t-32gbit/qla_isr.c +++ b/qla2x00t-32gbit/qla_isr.c @@ -3532,6 +3532,8 @@ msix_failed: 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, From e55a145f3b563f87590c745f5dcb9c6b1d05216e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 5 Apr 2019 01:05:20 +0000 Subject: [PATCH 6/8] qla2x00t-32gbit: Add -Wno-stringop-truncation to the compiler options git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8155 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t-32gbit/Makefile_in-tree | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 8258e882d0f5b369642b9525eeabafe05ba7fcfd Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 5 Apr 2019 01:05:54 +0000 Subject: [PATCH 7/8] qla2x00t-32gbit: Remove a superfluous assignment from the pre-v3.14 code git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8156 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t-32gbit/qla_isr.c | 1 - 1 file changed, 1 deletion(-) diff --git a/qla2x00t-32gbit/qla_isr.c b/qla2x00t-32gbit/qla_isr.c index 43036ae6b..3130530c9 100644 --- a/qla2x00t-32gbit/qla_isr.c +++ b/qla2x00t-32gbit/qla_isr.c @@ -3531,7 +3531,6 @@ msix_failed: ha->msix_count, ret); goto msix_out; } - ha->max_rsp_queues = ha->msix_count - 1; } else { ret = ha->msix_count; } From 8a10f5c744e4cdddffeb145e2eabf82ff58760f5 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 5 Apr 2019 01:06:34 +0000 Subject: [PATCH 8/8] qla2x00t-32gbit: Calculate min_vecs correctly for kernel versions < v4.8 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8157 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t-32gbit/qla_isr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qla2x00t-32gbit/qla_isr.c b/qla2x00t-32gbit/qla_isr.c index 3130530c9..7099ede9d 100644 --- a/qla2x00t-32gbit/qla_isr.c +++ b/qla2x00t-32gbit/qla_isr.c @@ -3494,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++; @@ -3511,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) {