linux/drivers
Qian Cai 696ac2e3bf x86: ACPI: fix CPU hotplug deadlock
Similar to commit 0266d81e9b ("acpi/processor: Prevent cpu hotplug
deadlock") except this is for acpi_processor_ffh_cstate_probe():

"The problem is that the work is scheduled on the current CPU from the
hotplug thread associated with that CPU.

It's not required to invoke these functions via the workqueue because
the hotplug thread runs on the target CPU already.

Check whether current is a per cpu thread pinned on the target CPU and
invoke the function directly to avoid the workqueue."

 WARNING: possible circular locking dependency detected
 ------------------------------------------------------
 cpuhp/1/15 is trying to acquire lock:
 ffffc90003447a28 ((work_completion)(&wfc.work)){+.+.}-{0:0}, at: __flush_work+0x4c6/0x630

 but task is already holding lock:
 ffffffffafa1c0e8 (cpuidle_lock){+.+.}-{3:3}, at: cpuidle_pause_and_lock+0x17/0x20

 which lock already depends on the new lock.

 the existing dependency chain (in reverse order) is:

 ->  (cpu_hotplug_lock){++++}-{0:0}:
 cpus_read_lock+0x3e/0xc0
 irq_calc_affinity_vectors+0x5f/0x91
 __pci_enable_msix_range+0x10f/0x9a0
 pci_alloc_irq_vectors_affinity+0x13e/0x1f0
 pci_alloc_irq_vectors_affinity at drivers/pci/msi.c:1208
 pqi_ctrl_init+0x72f/0x1618 [smartpqi]
 pqi_pci_probe.cold.63+0x882/0x892 [smartpqi]
 local_pci_probe+0x7a/0xc0
 work_for_cpu_fn+0x2e/0x50
 process_one_work+0x57e/0xb90
 worker_thread+0x363/0x5b0
 kthread+0x1f4/0x220
 ret_from_fork+0x27/0x50

 ->  ((work_completion)(&wfc.work)){+.+.}-{0:0}:
 __lock_acquire+0x2244/0x32a0
 lock_acquire+0x1a2/0x680
 __flush_work+0x4e6/0x630
 work_on_cpu+0x114/0x160
 acpi_processor_ffh_cstate_probe+0x129/0x250
 acpi_processor_evaluate_cst+0x4c8/0x580
 acpi_processor_get_power_info+0x86/0x740
 acpi_processor_hotplug+0xc3/0x140
 acpi_soft_cpu_online+0x102/0x1d0
 cpuhp_invoke_callback+0x197/0x1120
 cpuhp_thread_fun+0x252/0x2f0
 smpboot_thread_fn+0x255/0x440
 kthread+0x1f4/0x220
 ret_from_fork+0x27/0x50

 other info that might help us debug this:

 Chain exists of:
 (work_completion)(&wfc.work) --> cpuhp_state-up --> cpuidle_lock

 Possible unsafe locking scenario:

 CPU0                    CPU1
 ----                    ----
 lock(cpuidle_lock);
                         lock(cpuhp_state-up);
                         lock(cpuidle_lock);
 lock((work_completion)(&wfc.work));

 *** DEADLOCK ***

 3 locks held by cpuhp/1/15:
 : ffffffffaf51ab10 (cpu_hotplug_lock){++++}-{0:0}, at: cpuhp_thread_fun+0x69/0x2f0
 : ffffffffaf51ad40 (cpuhp_state-up){+.+.}-{0:0}, at: cpuhp_thread_fun+0x69/0x2f0
 : ffffffffafa1c0e8 (cpuidle_lock){+.+.}-{3:3}, at: cpuidle_pause_and_lock+0x17/0x20

 Call Trace:
 dump_stack+0xa0/0xea
 print_circular_bug.cold.52+0x147/0x14c
 check_noncircular+0x295/0x2d0
 __lock_acquire+0x2244/0x32a0
 lock_acquire+0x1a2/0x680
 __flush_work+0x4e6/0x630
 work_on_cpu+0x114/0x160
 acpi_processor_ffh_cstate_probe+0x129/0x250
 acpi_processor_evaluate_cst+0x4c8/0x580
 acpi_processor_get_power_info+0x86/0x740
 acpi_processor_hotplug+0xc3/0x140
 acpi_soft_cpu_online+0x102/0x1d0
 cpuhp_invoke_callback+0x197/0x1120
 cpuhp_thread_fun+0x252/0x2f0
 smpboot_thread_fn+0x255/0x440
 kthread+0x1f4/0x220
 ret_from_fork+0x27/0x50

Signed-off-by: Qian Cai <cai@lca.pw>
Tested-by: Borislav Petkov <bp@suse.de>
[ rjw: Subject ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-04-04 16:28:24 +02:00
..
accessibility
acpi x86: ACPI: fix CPU hotplug deadlock 2020-04-04 16:28:24 +02:00
amba
android
ata ata: make "libata.force" kernel parameter optional 2020-03-26 10:28:20 -06:00
atm
auxdisplay
base Power management updates for 5.7-rc1 2020-03-30 15:05:01 -07:00
bcma
block for-5.7/drivers-2020-03-29 2020-03-30 11:43:51 -07:00
bluetooth
bus Merge tag 'omap-for-v5.6/fixes-rc6-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into arm/fixes 2020-03-25 14:27:22 +01:00
cdrom
char
clk clk: imx: Align imx sc clock parent msg structs to 4 2020-03-25 18:46:05 -07:00
clocksource clocksource/drivers/hyper-v: Make sched clock return nanoseconds correctly 2020-03-27 12:27:45 +01:00
connector
counter
cpufreq Merge branches 'pm-devfreq', 'powercap' and 'pm-docs' 2020-03-30 14:48:31 +02:00
cpuidle Merge branches 'pm-core', 'pm-sleep', 'pm-acpi' and 'pm-domains' 2020-03-30 14:46:58 +02:00
crypto
dax
dca
devfreq PM / devfreq: Fix handling dev_pm_qos_remove_request result 2020-03-25 08:35:03 +09:00
dio
dma dmaengine: ti: k3-udma-glue: Fix an error handling path in 'k3_udma_glue_cfg_rx_flow()' 2020-03-23 11:48:34 +05:30
dma-buf
edac Merge branches 'edac-mc-cleanup', 'edac-misc', 'edac-drivers' and 'edac-urgent' into edac-updates-for-5.7 2020-03-30 10:07:58 +02:00
eisa
extcon
firewire
firmware Driver core patches for 5.7-rc1 2020-03-30 13:59:52 -07:00
fpga
fsi
gnss
gpio gpiolib: acpi: Add quirk to ignore EC wakeups on HP x2 10 CHT + AXP288 model 2020-03-24 10:06:54 +01:00
gpu Power management updates for 5.7-rc1 2020-03-30 15:05:01 -07:00
greybus
hid Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid 2020-03-17 09:38:03 -07:00
hsi
hv
hwmon hwmon: (pmbus) add support for 2nd Gen Renesas digital multiphase 2020-03-22 16:42:21 -07:00
hwspinlock
hwtracing intel_th: pci: Add Elkhart Lake CPU support 2020-03-18 11:32:56 +01:00
i2c i2c: pca-platform: Use platform_irq_get_optional 2020-03-28 05:03:17 +01:00
i3c i3c: convert to use i2c_new_client_device() 2020-03-29 10:35:50 +02:00
ide
idle
iio staging: iio: adc: ad7192: Re-indent enum labels 2020-03-23 11:43:42 +01:00
infiniband RDMA/mlx5: Block delay drop to unprivileged users 2020-03-25 09:56:30 -03:00
input Driver core patches for 5.7-rc1 2020-03-30 13:59:52 -07:00
interconnect
iommu
ipack
irqchip
isdn
leds
lightnvm for-5.7/drivers-2020-03-29 2020-03-30 11:43:51 -07:00
macintosh
mailbox
mcb
md for-5.7/drivers-2020-03-29 2020-03-30 11:43:51 -07:00
media Power management updates for 5.7-rc1 2020-03-30 15:05:01 -07:00
memory
memstick
message
mfd
misc mmc: rtsx_pci: Fix support for speed-modes that relies on tuning 2020-03-18 11:55:02 +01:00
mmc Merge branch 'pm-qos' 2020-03-30 14:45:57 +02:00
most staging: most: move core files out of the staging area 2020-03-24 13:42:44 +01:00
mtd
mux
net Power management updates for 5.7-rc1 2020-03-30 15:05:01 -07:00
nfc NFC: fdp: Fix a signedness bug in fdp_nci_send_patch() 2020-03-23 21:05:13 -07:00
ntb
nubus
nvdimm block: simplify queue allocation 2020-03-27 10:23:43 -06:00
nvme for-5.7/drivers-2020-03-29 2020-03-30 11:43:51 -07:00
nvmem
of Driver core patches for 5.7-rc1 2020-03-30 13:59:52 -07:00
opp
oprofile
parisc
parport
pci
pcmcia
perf
phy phy: for 5.7 2020-03-21 12:02:20 +01:00
pinctrl Driver core patches for 5.7-rc1 2020-03-30 13:59:52 -07:00
platform platform/x86: touchscreen_dmi: Add info for the Chuwi Vi8 Plus tablet 2020-03-20 14:57:54 +01:00
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator spi/regulator: Updates for v5.7 2020-03-30 14:58:26 -07:00
remoteproc
reset
rpmsg
rtc PNP subsystem updates for 5.7-rc1 2020-03-30 15:28:12 -07:00
s390 for-5.7/block-2020-03-29 2020-03-30 11:20:13 -07:00
sbus
scsi for-5.7/block-2020-03-29 2020-03-30 11:20:13 -07:00
sfi
sh
siox
slimbus
soc soc: samsung: chipid: Fix return value on non-Exynos platforms 2020-03-25 14:27:27 +01:00
soundwire
spi Power management updates for 5.7-rc1 2020-03-30 15:05:01 -07:00
spmi
ssb
staging Staging/IIO driver patches for 5.7-rc1 2020-03-30 14:20:41 -07:00
target
tc
tee Merge tag 'tee-amdtee-fix2-for-5.6' of https://git.linaro.org/people/jens.wiklander/linux-tee into arm/fixes 2020-03-25 14:27:27 +01:00
thermal
thunderbolt Merge 5.6-rc7 into usb-next 2020-03-23 08:04:08 +01:00
tty Merge branch 'pm-qos' 2020-03-30 14:45:57 +02:00
uio
usb Power management updates for 5.7-rc1 2020-03-30 15:05:01 -07:00
vfio
vhost
video
virt
virtio
visorbus
vlynq
vme
w1
watchdog
xen
zorro
Kconfig staging: most: move core files out of the staging area 2020-03-24 13:42:44 +01:00
Makefile staging: most: move core files out of the staging area 2020-03-24 13:42:44 +01:00