Skip to contentSkip to conversation

Three lpfc fixes

PATCH In review Bart Van Assche 3 participants 11 messages Nov 7, 2019 – Nov 9, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Three lpfc fixes

Hi Martin,

The three patches in this series fix recently introduced issues in the lpfc driver. Please consider these patches for inclusion in the upstream kernel.

Thanks,

Bart.

Bart Van Assche (3):
lpfc: Fix a kernel warning triggered by lpfc_get_sgl_per_hdwq()
lpfc: Fix a kernel warning triggered by lpfc_sli4_enable_intr()
lpfc: Fix lpfc_cpumask_of_node_init()

 drivers/scsi/lpfc/lpfc_init.c | 17 ++++-------------
 drivers/scsi/lpfc/lpfc_sli.c  |  4 ++--
 2 files changed, 6 insertions(+), 15 deletions(-)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/3 lpfc: Fix a kernel warning triggered by lpfc_get_sgl_per_hdwq()

Fix the following kernel bug report:

BUG: using smp_processor_id() in preemptible [00000000] code: systemd-udevd/954
Fixes d79c9e9d4b3d ("scsi: lpfc: Support dynamic unbounded SGL lists on G7 hardware.")
---
 drivers/scsi/lpfc/lpfc_sli.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_sli.c +2 -2
index fad890cea21a..613fbf4a7da9 100644
@@ -20668,7 +20668,7 @@ lpfc_get_sgl_per_hdwq(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_buf)
 		/* allocate more */
 		spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags);
 		tmp = kmalloc_node(sizeof(*tmp), GFP_ATOMIC,
-				   cpu_to_node(smp_processor_id()));
+				   cpu_to_node(raw_smp_processor_id()));
 		if (!tmp) {
 			lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
 					"8353 error kmalloc memory for HDWQ "
@@ -20811,7 +20811,7 @@ lpfc_get_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba,
 		/* allocate more */
 		spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags);
 		tmp = kmalloc_node(sizeof(*tmp), GFP_ATOMIC,
-				   cpu_to_node(smp_processor_id()));
+				   cpu_to_node(raw_smp_processor_id()));
 		if (!tmp) {
 			lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
 					"8355 error kmalloc memory for HDWQ "
Signature · 1 line
2.23.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] lpfc: Fix a kernel warning triggered by lpfc_get_sgl_per_hdwq()

Quoted 6 lines · Bart Van Assche

Fix the following kernel bug report:

BUG: using smp_processor_id() in preemptible [00000000] code: systemd-udevd/954
Fixes d79c9e9d4b3d ("scsi: lpfc: Support dynamic unbounded SGL lists on G7 hardware.")

Looks good - thanks Bart

-- james

#3 lore raw

PATCH 1/2 qla2xxx: Remove an include directive

In reply to Bart Van Assche

Since the code in qla_init.c is initiator code, remove the SCSI target core include directive.

Cc Himanshu Madhani <[email protected]>
---
 drivers/scsi/qla2xxx/qla_init.c | 1 -
 1 file changed, 1 deletion(-)
drivers/scsi/qla2xxx/qla_init.c +0 -1
index 7cb7545de962..c1004d47514c 100644
@@ -17,7 +17,6 @@
 #include <asm/prom.h>
 #endif
 
-#include <target/target_core_base.h>
 #include "qla_target.h"
 
 /*
Signature · 1 line
2.23.0
#4 lore raw

PATCH 2/3 lpfc: Fix a kernel warning triggered by lpfc_sli4_enable_intr()

In reply to Bart Van Assche

Fix the following lockdep warning:

============================================
WARNING: possible recursive locking detected
5.4.0-rc6-dbg+ #2 Not tainted
--------------------------------------------
systemd-udevd/130 is trying to acquire lock:
ffffffff826b05d0 (cpu_hotplug_lock.rw_sem){++++}, at: irq_calc_affinity_vectors+0x63/0x90

but task is already holding lock:

ffffffff826b05d0 (cpu_hotplug_lock.rw_sem){++++}, at: lpfc_sli4_enable_intr+0x422/0xd50 [lpfc]

other info that might help us debug this:

 Possible unsafe locking scenario:
       CPU0
       ----
  lock(cpu_hotplug_lock.rw_sem);
  lock(cpu_hotplug_lock.rw_sem);

*** DEADLOCK ***
May be due to missing lock nesting notation
2 locks held by systemd-udevd/130:
#0: ffff8880d53fe210 (&dev->mutex){....}, at: __device_driver_lock+0x4a/0x70
#1: ffffffff826b05d0 (cpu_hotplug_lock.rw_sem){++++}, at: lpfc_sli4_enable_intr+0x422/0xd50 [lpfc]

stack backtrace:
CPU: 1 PID: 130 Comm: systemd-udevd Not tainted 5.4.0-rc6-dbg+ #2
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Call Trace:
 dump_stack+0xa5/0xe6
 __lock_acquire.cold+0xf7/0x23a
 lock_acquire+0x106/0x240
 cpus_read_lock+0x41/0xe0
 irq_calc_affinity_vectors+0x63/0x90
 __pci_enable_msix_range+0x10a/0x950
 pci_alloc_irq_vectors_affinity+0x144/0x210
 lpfc_sli4_enable_intr+0x4b2/0xd50 [lpfc]
 lpfc_pci_probe_one+0x1411/0x22b0 [lpfc]
 local_pci_probe+0x7c/0xc0
 pci_device_probe+0x25d/0x390
 really_probe+0x170/0x510
 driver_probe_device+0x127/0x190
 device_driver_attach+0x98/0xa0
 __driver_attach+0xb6/0x1a0
 bus_for_each_dev+0x100/0x150
 driver_attach+0x31/0x40
 bus_add_driver+0x246/0x300
 driver_register+0xe0/0x170
 __pci_register_driver+0xde/0xf0
 lpfc_init+0x134/0x1000 [lpfc]
 do_one_initcall+0xda/0x47e
 do_init_module+0x10a/0x3b0
 load_module+0x4318/0x47c0
 __do_sys_finit_module+0x134/0x1d0
 __x64_sys_finit_module+0x47/0x50
 do_syscall_64+0x6f/0x2e0
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
Fixes dcaa21367938 ("scsi: lpfc: Change default IRQ model on AMD architectures")
---
 drivers/scsi/lpfc/lpfc_init.c | 2 --
 1 file changed, 2 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +0 -2
index 28e6a763f106..37e57fd9ba5d 100644
@@ -11580,9 +11580,7 @@ lpfc_sli4_enable_intr(struct lpfc_hba *phba, uint32_t cfg_mode)
 		retval = 0;
 		if (!retval) {
 			/* Now, try to enable MSI-X interrupt mode */
-			get_online_cpus();
 			retval = lpfc_sli4_enable_msix(phba);
-			put_online_cpus();
 			if (!retval) {
 				/* Indicate initialization to MSI-X mode */
 				phba->intr_type = MSIX;
Signature · 1 line
2.23.0
Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] lpfc: Fix a kernel warning triggered by lpfc_sli4_enable_intr()

Quoted 60 lines · Bart Van Assche

Fix the following lockdep warning:

============================================
WARNING: possible recursive locking detected
5.4.0-rc6-dbg+ #2 Not tainted
--------------------------------------------
systemd-udevd/130 is trying to acquire lock:
ffffffff826b05d0 (cpu_hotplug_lock.rw_sem){++++}, at: irq_calc_affinity_vectors+0x63/0x90

but task is already holding lock:

ffffffff826b05d0 (cpu_hotplug_lock.rw_sem){++++}, at: lpfc_sli4_enable_intr+0x422/0xd50 [lpfc]

other info that might help us debug this:

  Possible unsafe locking scenario:
        CPU0
        ----
   lock(cpu_hotplug_lock.rw_sem);
   lock(cpu_hotplug_lock.rw_sem);

*** DEADLOCK ***
May be due to missing lock nesting notation
2 locks held by systemd-udevd/130:
#0: ffff8880d53fe210 (&dev->mutex){....}, at: __device_driver_lock+0x4a/0x70
#1: ffffffff826b05d0 (cpu_hotplug_lock.rw_sem){++++}, at: lpfc_sli4_enable_intr+0x422/0xd50 [lpfc]

stack backtrace:
CPU: 1 PID: 130 Comm: systemd-udevd Not tainted 5.4.0-rc6-dbg+ #2
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Call Trace:
  dump_stack+0xa5/0xe6
  __lock_acquire.cold+0xf7/0x23a
  lock_acquire+0x106/0x240
  cpus_read_lock+0x41/0xe0
  irq_calc_affinity_vectors+0x63/0x90
  __pci_enable_msix_range+0x10a/0x950
  pci_alloc_irq_vectors_affinity+0x144/0x210
  lpfc_sli4_enable_intr+0x4b2/0xd50 [lpfc]
  lpfc_pci_probe_one+0x1411/0x22b0 [lpfc]
  local_pci_probe+0x7c/0xc0
  pci_device_probe+0x25d/0x390
  really_probe+0x170/0x510
  driver_probe_device+0x127/0x190
  device_driver_attach+0x98/0xa0
  __driver_attach+0xb6/0x1a0
  bus_for_each_dev+0x100/0x150
  driver_attach+0x31/0x40
  bus_add_driver+0x246/0x300
  driver_register+0xe0/0x170
  __pci_register_driver+0xde/0xf0
  lpfc_init+0x134/0x1000 [lpfc]
  do_one_initcall+0xda/0x47e
  do_init_module+0x10a/0x3b0
  load_module+0x4318/0x47c0
  __do_sys_finit_module+0x134/0x1d0
  __x64_sys_finit_module+0x47/0x50
  do_syscall_64+0x6f/0x2e0
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
Quoted 2 lines
Fixes dcaa21367938 ("scsi: lpfc: Change default IRQ model on AMD architectures")

Looks good. Thank You Bart.

-- jsmart

#6 lore raw

PATCH 2/2 qla2xxx: Fix a dma_pool_free() call

In reply to Bart Van Assche

This patch fixes the following kernel warning:

DMA-API: qla2xxx 0000:00:0a.0: device driver frees DMA memory with different size [device address=0x00000000c7b60000] [map size=4088 bytes] [unmap size=512 bytes]

WARNING: CPU: 3 PID: 1122 at kernel/dma/debug.c:1021 check_unmap+0x4d0/0xbd0
CPU: 3 PID: 1122 Comm: rmmod Tainted: G           O      5.4.0-rc1-dbg+ #1
RIP: 0010:check_unmap+0x4d0/0xbd0
Call Trace:
 debug_dma_free_coherent+0x123/0x173
 dma_free_attrs+0x76/0xe0
 qla2x00_mem_free+0x329/0xc40 [qla2xxx_scst]
 qla2x00_free_device+0x170/0x1c0 [qla2xxx_scst]
 qla2x00_remove_one+0x4f0/0x6d0 [qla2xxx_scst]
 pci_device_remove+0xd5/0x1f0
 device_release_driver_internal+0x159/0x280
 driver_detach+0x8b/0xf2
 bus_remove_driver+0x9a/0x15a
 driver_unregister+0x51/0x70
 pci_unregister_driver+0x2d/0x130
 qla2x00_module_exit+0x1c/0xbc [qla2xxx_scst]
 __x64_sys_delete_module+0x22a/0x300
 do_syscall_64+0x6f/0x2e0
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
Cc Michael Hernandez <[email protected]>
Cc Himanshu Madhani <[email protected]>
Fixes 3f006ac342c0 ("scsi: qla2xxx: Secure flash update support for ISP28XX") # v5.2-rc1~130^2~270.
---
 drivers/scsi/qla2xxx/qla_os.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_os.c +2 -1
index 16f9b6ed574a..05fba5c2c926 100644
@@ -4676,7 +4676,8 @@ qla2x00_mem_free(struct qla_hw_data *ha)
 	ha->sfp_data = NULL;
 
 	if (ha->flt)
-		dma_free_coherent(&ha->pdev->dev, SFP_DEV_SIZE,
+		dma_free_coherent(&ha->pdev->dev,
+		    sizeof(struct qla_flt_header) + FLT_REGIONS_SIZE,
 		    ha->flt, ha->flt_dma);
 	ha->flt = NULL;
 	ha->flt_dma = 0;
Signature · 1 line
2.23.0
#7 lore raw

PATCH 3/3 lpfc: Fix lpfc_cpumask_of_node_init()

In reply to Bart Van Assche

Fix the following kernel warning:

cpumask_of_node(-1): (unsigned)node >= nr_node_ids(1)

Fixes dcaa21367938 ("scsi: lpfc: Change default IRQ model on AMD architectures")
---
 drivers/scsi/lpfc/lpfc_init.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +4 -11
index 37e57fd9ba5d..f2051e2f5f56 100644
@@ -6005,21 +6005,14 @@ static void
 lpfc_cpumask_of_node_init(struct lpfc_hba *phba)
 {
 	unsigned int cpu, numa_node;
-	struct cpumask *numa_mask = NULL;
+	struct cpumask *numa_mask = &phba->sli4_hba.numa_mask;
 
-#ifdef CONFIG_NUMA
-	numa_node = phba->pcidev->dev.numa_node;
-#else
-	numa_node = NUMA_NO_NODE;
-#endif
-	numa_mask = &phba->sli4_hba.numa_mask;
+	numa_node = dev_to_node(&phba->pcidev->dev);
+	if (numa_node == NUMA_NO_NODE)
+		return;
 
 	cpumask_clear(numa_mask);
 
-	/* Check if we're a NUMA architecture */
-	if (!cpumask_of_node(numa_node))
-		return;
-
 	for_each_possible_cpu(cpu)
 		if (cpu_to_node(cpu) == numa_node)
 			cpumask_set_cpu(cpu, numa_mask);
Signature · 1 line
2.23.0
#8 lore raw

Re: [PATCH 3/3] lpfc: Fix lpfc_cpumask_of_node_init()

Quoted 22 lines · Bart Van Assche

Fix the following kernel warning:

cpumask_of_node(-1): (unsigned)node >= nr_node_ids(1)

Fixes dcaa21367938 ("scsi: lpfc: Change default IRQ model on AMD architectures")
---
  drivers/scsi/lpfc/lpfc_init.c | 15 ++++-----------
  1 file changed, 4 insertions(+), 11 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +1 -2
index 37e57fd9ba5d..f2051e2f5f56 100644
@@ -6005,21 +6005,14 @@ static void
  lpfc_cpumask_of_node_init(struct lpfc_hba *phba)
  {
  	unsigned int cpu, numa_node;
-	struct cpumask *numa_mask = NULL;
+	struct cpumask *numa_mask = &phba->sli4_hba.numa_mask;
 
-#ifdef CONFIG_NUMA

drivers/scsi/lpfc/lpfc_init.c static void · line 6014

Quoted 10 lines
drivers/scsi/lpfc/lpfc_init.c +3 -5
-	numa_node = phba->pcidev->dev.numa_node;
-#else
-	numa_node = NUMA_NO_NODE;
-#endif
-	numa_mask = &phba->sli4_hba.numa_mask;
+	numa_node = dev_to_node(&phba->pcidev->dev);
+	if (numa_node == NUMA_NO_NODE)
+		return;
 
  	cpumask_clear(numa_mask);

This patch is good - except that the cpumask_clear needs to be done before the return if not numa.

I'll repost with the mod

-- james

Quoted 9 lines
drivers/scsi/lpfc/lpfc_init.c +0 -4
-	/* Check if we're a NUMA architecture */
-	if (!cpumask_of_node(numa_node))
-		return;
-
  	for_each_possible_cpu(cpu)
  		if (cpu_to_node(cpu) == numa_node)
  			cpumask_set_cpu(cpu, numa_mask);
 
#9 lore raw

Re: [PATCH 3/3] lpfc: Fix lpfc_cpumask_of_node_init()

Quoted 1 line · James Smart

I'll repost with the mod

Thanks!

Bart.

#10 lore raw
In reply to Bart Van Assche

Bart,

Quoted 3 lines

The three patches in this series fix recently introduced issues in the lpfc driver. Please consider these patches for inclusion in the upstream kernel.

Applied #1 + #2 to 5.5/scsi-queue. Thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering