linux/drivers/infiniband/hw/hfi1
Kaike Wan 28b70cd923 IB/hfi1: Do not destroy hfi1_wq when the device is shut down
The workqueue hfi1_wq is destroyed in function shutdown_device(), which is
called by either shutdown_one() or remove_one(). The function
shutdown_one() is called when the kernel is rebooted while remove_one() is
called when the hfi1 driver is unloaded. When the kernel is rebooted,
hfi1_wq is destroyed while all qps are still active, leading to a kernel
crash:

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000102
  IP: [<ffffffff94cb7b02>] __queue_work+0x32/0x3e0
  PGD 0
  Oops: 0000 [#1] SMP
  Modules linked in: dm_round_robin nvme_rdma(OE) nvme_fabrics(OE) nvme_core(OE) ib_isert iscsi_target_mod target_core_mod ib_ucm mlx4_ib iTCO_wdt iTCO_vendor_support mxm_wmi sb_edac intel_powerclamp coretemp intel_rapl iosf_mbi kvm rpcrdma sunrpc irqbypass crc32_pclmul ghash_clmulni_intel rdma_ucm aesni_intel ib_uverbs lrw gf128mul opa_vnic glue_helper ablk_helper ib_iser cryptd ib_umad rdma_cm iw_cm ses enclosure libiscsi scsi_transport_sas pcspkr joydev ib_ipoib(OE) scsi_transport_iscsi ib_cm sg ipmi_ssif mei_me lpc_ich i2c_i801 mei ioatdma ipmi_si dm_multipath ipmi_devintf ipmi_msghandler wmi acpi_pad acpi_power_meter hangcheck_timer ip_tables ext4 mbcache jbd2 mlx4_en sd_mod crc_t10dif crct10dif_generic mgag200 drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm hfi1(OE)
  crct10dif_pclmul crct10dif_common crc32c_intel drm ahci mlx4_core libahci rdmavt(OE) igb megaraid_sas ib_core libata drm_panel_orientation_quirks ptp pps_core devlink dca i2c_algo_bit dm_mirror dm_region_hash dm_log dm_mod
  CPU: 19 PID: 0 Comm: swapper/19 Kdump: loaded Tainted: G OE ------------ 3.10.0-957.el7.x86_64 #1
  Hardware name: Phegda X2226A/S2600CW, BIOS SE5C610.86B.01.01.0024.021320181901 02/13/2018
  task: ffff8a799ba0d140 ti: ffff8a799bad8000 task.ti: ffff8a799bad8000
  RIP: 0010:[<ffffffff94cb7b02>] [<ffffffff94cb7b02>] __queue_work+0x32/0x3e0
  RSP: 0018:ffff8a90dde43d80 EFLAGS: 00010046
  RAX: 0000000000000082 RBX: 0000000000000086 RCX: 0000000000000000
  RDX: ffff8a90b924fcb8 RSI: 0000000000000000 RDI: 000000000000001b
  RBP: ffff8a90dde43db8 R08: ffff8a799ba0d6d8 R09: ffff8a90dde53900
  R10: 0000000000000002 R11: ffff8a90dde43de8 R12: ffff8a90b924fcb8
  R13: 000000000000001b R14: 0000000000000000 R15: ffff8a90d2890000
  FS: 0000000000000000(0000) GS:ffff8a90dde40000(0000) knlGS:0000000000000000
  CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 0000000000000102 CR3: 0000001a70410000 CR4: 00000000001607e0
  Call Trace:
  [<ffffffff94cb8105>] queue_work_on+0x45/0x50
  [<ffffffffc03f781e>] _hfi1_schedule_send+0x6e/0xc0 [hfi1]
  [<ffffffffc03f78a2>] hfi1_schedule_send+0x32/0x70 [hfi1]
  [<ffffffffc02cf2d9>] rvt_rc_timeout+0xe9/0x130 [rdmavt]
  [<ffffffff94ce563a>] ? trigger_load_balance+0x6a/0x280
  [<ffffffffc02cf1f0>] ? rvt_free_qpn+0x40/0x40 [rdmavt]
  [<ffffffff94ca7f58>] call_timer_fn+0x38/0x110
  [<ffffffffc02cf1f0>] ? rvt_free_qpn+0x40/0x40 [rdmavt]
  [<ffffffff94caa3bd>] run_timer_softirq+0x24d/0x300
  [<ffffffff94ca0f05>] __do_softirq+0xf5/0x280
  [<ffffffff9537832c>] call_softirq+0x1c/0x30
  [<ffffffff94c2e675>] do_softirq+0x65/0xa0
  [<ffffffff94ca1285>] irq_exit+0x105/0x110
  [<ffffffff953796c8>] smp_apic_timer_interrupt+0x48/0x60
  [<ffffffff95375df2>] apic_timer_interrupt+0x162/0x170
  <EOI>
  [<ffffffff951adfb7>] ? cpuidle_enter_state+0x57/0xd0
  [<ffffffff951ae10e>] cpuidle_idle_call+0xde/0x230
  [<ffffffff94c366de>] arch_cpu_idle+0xe/0xc0
  [<ffffffff94cfc3ba>] cpu_startup_entry+0x14a/0x1e0
  [<ffffffff94c57db7>] start_secondary+0x1f7/0x270
  [<ffffffff94c000d5>] start_cpu+0x5/0x14

The solution is to destroy the workqueue only when the hfi1 driver is
unloaded, not when the device is shut down. In addition, when the device
is shut down, no more work should be scheduled on the workqueues and the
workqueues are flushed.

Fixes: 8d3e71136a ("IB/{hfi1, qib}: Add handling of kernel restart")
Link: https://lore.kernel.org/r/20200623204047.107638.77646.stgit@awfm-01.aw.intel.com
Cc: <stable@vger.kernel.org>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
2020-07-02 13:54:50 -03:00
..
affinity.c IB/hfi1: Add interrupt handler functions for accelerated ipoib 2020-05-21 11:23:56 -03:00
affinity.h IB/hfi1: Add interrupt handler functions for accelerated ipoib 2020-05-21 11:23:56 -03:00
aspm.c IB/hfi1: Reduce excessive aspm inlines 2019-06-28 22:34:26 -03:00
aspm.h IB/hfi1: Reduce excessive aspm inlines 2019-06-28 22:34:26 -03:00
chip_registers.h IB/hfi1: Add RcvShortLengthErrCnt to hfi1stats 2020-01-10 10:57:17 -04:00
chip.c IB/hfi1: Fix spelling mistake "enought" -> "enough" 2020-05-29 15:27:51 -03:00
chip.h IB/hfi1: Add interrupt handler functions for accelerated ipoib 2020-05-21 11:23:56 -03:00
common.h IB/hfi1: Enable the transmit side of the datagram ipoib netdev 2020-05-21 11:23:58 -03:00
debugfs.c IB/hfi1: Fix module use count flaw due to leftover module put calls 2020-06-24 15:54:08 -03:00
debugfs.h infiniband: hfi1: drop crazy DEBUGFS_SEQ_FILE_CREATE() macro 2019-01-24 09:22:29 -07:00
device.c
device.h
driver.c IB/hfi1: Add packet histogram trace event 2020-05-21 11:23:57 -03:00
efivar.c infiniband: hfi1: Use EFI GetVariable only when available 2020-02-23 21:59:42 +01:00
efivar.h
eprom.c
eprom.h
exp_rcv.c IB/hfi1: Remove WARN_ON when freeing expected receive groups 2019-04-03 15:27:30 -03:00
exp_rcv.h
fault.c IB/hfi1: Use scnprintf() for avoiding potential buffer overflow 2020-03-26 15:06:14 -03:00
fault.h
file_ops.c IB/hfi1: Remove module parameter for KDETH qpns 2020-05-21 11:23:54 -03:00
firmware.c
hfi.h IB/hfi1: Activate the dummy netdev 2020-05-21 11:23:56 -03:00
init.c IB/hfi1: Do not destroy hfi1_wq when the device is shut down 2020-07-02 13:54:50 -03:00
intr.c
iowait.c IB/hfi1: Don't cancel unused work item 2020-01-03 16:41:51 -04:00
iowait.h RDMA/hfi1: Fix trivial mis-spelling of 'descriptor' 2020-06-15 15:56:54 -03:00
ipoib_main.c IB/hfi1: Add rx functions for dummy netdev 2020-05-21 11:23:56 -03:00
ipoib_rx.c IB/hfi1: Activate the dummy netdev 2020-05-21 11:23:56 -03:00
ipoib_tx.c IB/hfi1: Add atomic triggered sleep/wakeup 2020-06-24 16:13:38 -03:00
ipoib.h IB/hfi1: Add atomic triggered sleep/wakeup 2020-06-24 16:13:38 -03:00
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
mad.c RDMA: Replace zero-length array with flexible-array member 2020-02-20 13:33:51 -04:00
mad.h RDMA: Replace zero-length array with flexible-array member 2020-02-20 13:33:51 -04:00
Makefile IB/hfi1: Add functions to receive accelerated ipoib packets 2020-05-21 11:23:56 -03:00
mmu_rb.c mmap locking API: convert mmap_sem comments 2020-06-09 09:39:14 -07:00
mmu_rb.h
msix.c IB/hfi1: Activate the dummy netdev 2020-05-21 11:23:56 -03:00
msix.h IB/hfi1: Activate the dummy netdev 2020-05-21 11:23:56 -03:00
netdev_rx.c IB/hfi1: Restore kfree in dummy_netdev cleanup 2020-06-24 15:54:08 -03:00
netdev.h IB/hfi1: Activate the dummy netdev 2020-05-21 11:23:56 -03:00
opa_compat.h
opfn.c IB/hfi1: Add TID RDMA retry timer 2019-02-05 18:07:43 -05:00
opfn.h IB/hfi1: Make opfn.h self sufficient 2019-04-24 11:31:49 -03:00
pcie.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
pio_copy.c
pio.c Linux 5.2-rc6 2019-06-28 21:18:23 -03:00
pio.h RDMA: Replace zero-length array with flexible-array member 2020-02-20 13:33:51 -04:00
platform.c IB/hfi1: remove redundant assignment to variable ret 2019-11-25 10:31:47 -04:00
platform.h
qp.c IB/hfi1: Do not destroy hfi1_wq when the device is shut down 2020-07-02 13:54:50 -03:00
qp.h IB/hfi1: Add the dual leg code 2019-02-05 18:07:44 -05:00
qsfp.c
qsfp.h
rc.c IB/hfi1: use true,false for bool variable 2020-01-03 19:13:59 -04:00
rc.h IB/hfi1: Delay the release of destination mr for TID RDMA WRITE DATA 2019-04-03 15:27:30 -03:00
ruc.c IB/{rdmavt, hfi1): Miscellaneous comment fixes 2019-04-24 11:31:48 -03:00
sdma_txreq.h IB/hfi1: Prioritize the sending of ACK packets 2019-02-05 18:07:44 -05:00
sdma.c RDMA: Replace zero-length array with flexible-array member 2020-02-20 13:33:51 -04:00
sdma.h RDMA: Replace zero-length array with flexible-array member 2020-02-20 13:33:51 -04:00
sysfs.c IB/hfi1: Call kobject_put() when kobject_init_and_add() fails 2020-03-27 13:13:36 -03:00
tid_rdma.c IB/hfi1: Do not destroy hfi1_wq when the device is shut down 2020-07-02 13:54:50 -03:00
tid_rdma.h IB/hfi1: Calculate flow weight based on QP MTU for TID RDMA 2019-11-06 13:15:36 -04:00
trace_ctxts.h IB/hfi1: Add packet histogram trace event 2020-05-21 11:23:57 -03:00
trace_dbg.h IB/hfi1: Fix two format strings 2019-03-28 11:03:49 -03:00
trace_ibhdrs.h IB/hfi1: Add missing INVALIDATE opcodes for trace 2019-06-28 22:34:26 -03:00
trace_iowait.h IB/hfi1: Add static trace for iowait 2018-09-30 19:21:12 -06:00
trace_misc.h
trace_mmu.h
trace_rc.h IB/hfi1: Add static trace for TID RDMA READ protocol 2019-02-05 17:53:56 -05:00
trace_rx.h IB/hfi1: Add fast and slow handlers for receive context 2020-01-10 10:57:16 -04:00
trace_tid.h ftrace: Rework event_create_dir() 2019-11-27 07:44:25 +01:00
trace_tx.h ftrace: Rework event_create_dir() 2019-11-27 07:44:25 +01:00
trace.c IB/hfi1: Add packet histogram trace event 2020-05-21 11:23:57 -03:00
trace.h IB/hfi1: Add static trace for OPFN 2019-01-31 11:37:40 -05:00
uc.c IB/{hfi1, qib, rdmavt}: Put qp in error state when cq is full 2019-06-28 22:34:26 -03:00
ud.c IB/{rdmavt, hfi1, qib}: Add helpers to hide SWQE WR details 2019-06-28 22:34:26 -03:00
user_exp_rcv.c hfi1: get rid of pointless access_ok() 2020-05-29 11:06:32 -04:00
user_exp_rcv.h RDMA: Replace zero-length array with flexible-array member 2020-02-20 13:33:51 -04:00
user_pages.c mm, tree-wide: rename put_user_page*() to unpin_user_page*() 2020-01-31 10:30:38 -08:00
user_sdma.c IB/hfi1: Fix another case where pq is left on waitlist 2020-05-12 11:47:48 -03:00
user_sdma.h IB/hfi1: Remove unused define 2019-07-22 16:10:48 -03:00
verbs_txreq.c IB/hfi1: Silence txreq allocation warnings 2019-06-17 21:15:40 -04:00
verbs_txreq.h RDMA/hfi1: Fix trivial mis-spelling of 'descriptor' 2020-06-15 15:56:54 -03:00
verbs.c RDMA: Remove 'max_map_per_fmr' 2020-06-02 20:32:54 -03:00
verbs.h treewide: Use sizeof_field() macro 2019-12-09 10:36:44 -08:00
vnic_main.c IB/hfi1: Fix hfi1_netdev_rx_init() error handling 2020-06-02 20:32:54 -03:00
vnic_sdma.c net: Use skb_frag_off accessors 2019-07-30 14:21:32 -07:00
vnic.h IB/hfi1: Activate the dummy netdev 2020-05-21 11:23:56 -03:00