Sergey Senozhatsky
2e76a3a166
serial: 8250: change lock order in serial8250_do_startup()
commit 205d300aea75623e1ae4aa43e0d265ab9cf195fd upstream.
We have a number of "uart.port->desc.lock vs desc.lock->uart.port"
lockdep reports coming from 8250 driver; this causes a bit of trouble
to people, so let's fix it.
The problem is reverse lock order in two different call paths:
chain #1:
serial8250_do_startup()
spin_lock_irqsave(&port->lock);
disable_irq_nosync(port->irq);
raw_spin_lock_irqsave(&desc->lock)
chain #2:
__report_bad_irq()
raw_spin_lock_irqsave(&desc->lock)
for_each_action_of_desc()
printk()
spin_lock_irqsave(&port->lock);
Fix this by changing the order of locks in serial8250_do_startup():
do disable_irq_nosync() first, which grabs desc->lock, and grab
uart->port after that, so that chain #1 and chain #2 have same lock
order.
Full lockdep splat:
======================================================
WARNING: possible circular locking dependency detected
5.4.39 #55 Not tainted
======================================================
swapper/0/0 is trying to acquire lock:
ffffffffab65b6c0 (console_owner){-...}, at: console_lock_spinning_enable+0x31/0x57
but task is already holding lock:
ffff88810a8e34c0 (&irq_desc_lock_class){-.-.}, at: __report_bad_irq+0x5b/0xba
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (&irq_desc_lock_class){-.-.}:
_raw_spin_lock_irqsave+0x61/0x8d
__irq_get_desc_lock+0x65/0x89
__disable_irq_nosync+0x3b/0x93
serial8250_do_startup+0x451/0x75c
uart_startup+0x1b4/0x2ff
uart_port_activate+0x73/0xa0
tty_port_open+0xae/0x10a
uart_open+0x1b/0x26
tty_open+0x24d/0x3a0
chrdev_open+0xd5/0x1cc
do_dentry_open+0x299/0x3c8
path_openat+0x434/0x1100
do_filp_open+0x9b/0x10a
do_sys_open+0x15f/0x3d7
kernel_init_freeable+0x157/0x1dd
kernel_init+0xe/0x105
ret_from_fork+0x27/0x50
-> #1 (&port_lock_key){-.-.}:
_raw_spin_lock_irqsave+0x61/0x8d
serial8250_console_write+0xa7/0x2a0
console_unlock+0x3b7/0x528
vprintk_emit+0x111/0x17f
printk+0x59/0x73
register_console+0x336/0x3a4
uart_add_one_port+0x51b/0x5be
serial8250_register_8250_port+0x454/0x55e
dw8250_probe+0x4dc/0x5b9
platform_drv_probe+0x67/0x8b
really_probe+0x14a/0x422
driver_probe_device+0x66/0x130
device_driver_attach+0x42/0x5b
__driver_attach+0xca/0x139
bus_for_each_dev+0x97/0xc9
bus_add_driver+0x12b/0x228
driver_register+0x64/0xed
do_one_initcall+0x20c/0x4a6
do_initcall_level+0xb5/0xc5
do_basic_setup+0x4c/0x58
kernel_init_freeable+0x13f/0x1dd
kernel_init+0xe/0x105
ret_from_fork+0x27/0x50
-> #0 (console_owner){-...}:
__lock_acquire+0x118d/0x2714
lock_acquire+0x203/0x258
console_lock_spinning_enable+0x51/0x57
console_unlock+0x25d/0x528
vprintk_emit+0x111/0x17f
printk+0x59/0x73
__report_bad_irq+0xa3/0xba
note_interrupt+0x19a/0x1d6
handle_irq_event_percpu+0x57/0x79
handle_irq_event+0x36/0x55
handle_fasteoi_irq+0xc2/0x18a
do_IRQ+0xb3/0x157
ret_from_intr+0x0/0x1d
cpuidle_enter_state+0x12f/0x1fd
cpuidle_enter+0x2e/0x3d
do_idle+0x1ce/0x2ce
cpu_startup_entry+0x1d/0x1f
start_kernel+0x406/0x46a
secondary_startup_64+0xa4/0xb0
other info that might help us debug this:
Chain exists of:
console_owner --> &port_lock_key --> &irq_desc_lock_class
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&irq_desc_lock_class);
lock(&port_lock_key);
lock(&irq_desc_lock_class);
lock(console_owner);
*** DEADLOCK ***
2 locks held by swapper/0/0:
#0: ffff88810a8e34c0 (&irq_desc_lock_class){-.-.}, at: __report_bad_irq+0x5b/0xba
#1: ffffffffab65b5c0 (console_lock){+.+.}, at: console_trylock_spinning+0x20/0x181
stack backtrace:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.4.39 #55
Hardware name: XXXXXX
Call Trace:
<IRQ>
dump_stack+0xbf/0x133
? print_circular_bug+0xd6/0xe9
check_noncircular+0x1b9/0x1c3
__lock_acquire+0x118d/0x2714
lock_acquire+0x203/0x258
? console_lock_spinning_enable+0x31/0x57
console_lock_spinning_enable+0x51/0x57
? console_lock_spinning_enable+0x31/0x57
console_unlock+0x25d/0x528
? console_trylock+0x18/0x4e
vprintk_emit+0x111/0x17f
? lock_acquire+0x203/0x258
printk+0x59/0x73
__report_bad_irq+0xa3/0xba
note_interrupt+0x19a/0x1d6
handle_irq_event_percpu+0x57/0x79
handle_irq_event+0x36/0x55
handle_fasteoi_irq+0xc2/0x18a
do_IRQ+0xb3/0x157
common_interrupt+0xf/0xf
</IRQ>
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Fixes: 768aec0b5b ("serial: 8250: fix shared interrupts issues with SMP and RT kernels")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Reported-by: Raul Rangel <rrangel@google.com>
BugLink: https://bugs.chromium.org/p/chromium/issues/detail?id=1114800
Link: https://lore.kernel.org/lkml/CAHQZ30BnfX+gxjPm1DUd5psOTqbyDh4EJE=2=VAMW_VDafctkA@mail.gmail.com/T/#u
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200817022646.1484638-1-sergey.senozhatsky@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
2020-09-03 11:27:04 +02:00 |
| .. |
|
accessibility
|
|
|
|
acpi
|
ACPICA: Do not increment operation_region reference counts for field units
|
2020-08-19 08:16:05 +02:00 |
|
amba
|
|
|
|
android
|
binder: Prevent context manager from incrementing ref 0
|
2020-08-11 15:33:35 +02:00 |
|
ata
|
ata/libata: Fix usage of page address by page_address in ata_scsi_mode_select_xlat function
|
2020-06-30 15:37:03 -04:00 |
|
atm
|
atm: fix atm_dev refcnt leaks in atmtcp_remove_persistent
|
2020-08-11 15:33:38 +02:00 |
|
auxdisplay
|
|
|
|
base
|
driver core: Avoid binding drivers to dead devices
|
2020-08-21 13:05:26 +02:00 |
|
bcma
|
|
|
|
block
|
block: loop: set discard granularity and alignment for block device backed loop
|
2020-09-03 11:27:01 +02:00 |
|
bluetooth
|
Bluetooth: hci_serdev: Only unregister device if it was registered
|
2020-08-19 08:16:16 +02:00 |
|
bus
|
bus: ti-sysc: Add missing quirk flags for usb_host_hs
|
2020-08-19 08:16:00 +02:00 |
|
cdrom
|
|
|
|
char
|
tpm: Unify the mismatching TPM space buffer sizes
|
2020-08-19 08:16:27 +02:00 |
|
clk
|
clk: bcm2835: Do not use prediv with bcm2711's PLLs
|
2020-08-21 13:05:35 +02:00 |
|
clocksource
|
arm64: arch_timer: Disable the compat vdso for cores affected by ARM64_WORKAROUND_1418040
|
2020-07-22 09:32:51 +02:00 |
|
connector
|
|
|
|
counter
|
|
|
|
cpufreq
|
cpufreq: intel_pstate: Fix EPP setting via sysfs in active mode
|
2020-09-03 11:26:53 +02:00 |
|
cpuidle
|
cpuidle: Fix three reference count leaks
|
2020-06-22 09:31:10 +02:00 |
|
crypto
|
crypto: caam - Remove broken arc4 support
|
2020-08-21 13:05:32 +02:00 |
|
dax
|
|
|
|
dca
|
|
|
|
devfreq
|
PM / devfreq: rk3399_dmc: Fix kernel oops when rockchip,pmu is absent
|
2020-09-03 11:26:50 +02:00 |
|
dio
|
|
|
|
dma
|
dmaengine: ioat setting ioat timeout as module parameter
|
2020-07-29 10:18:37 +02:00 |
|
dma-buf
|
dmabuf: use spinlock to access dmabuf->name
|
2020-07-29 10:18:29 +02:00 |
|
edac
|
EDAC/{i7core,sb,pnd2,skx}: Fix error event severity
|
2020-09-03 11:26:53 +02:00 |
|
eisa
|
|
|
|
extcon
|
extcon: adc-jack: Fix an error handling path in 'adc_jack_probe()'
|
2020-06-24 17:50:36 +02:00 |
|
firewire
|
|
|
|
firmware
|
efi: add missed destroy_workqueue when efisubsys_init fails
|
2020-08-26 10:41:07 +02:00 |
|
fpga
|
fpga: dfl: fix bug in port reset handshake
|
2020-07-29 10:18:31 +02:00 |
|
fsi
|
|
|
|
gnss
|
gnss: sirf: fix error return code in sirf_probe()
|
2020-06-22 09:31:20 +02:00 |
|
gpio
|
gpio: arizona: put pm_runtime in case of failure
|
2020-07-29 10:18:26 +02:00 |
|
gpu
|
drm/amd/display: Switch to immediate mode for updating infopackets
|
2020-09-03 11:26:58 +02:00 |
|
greybus
|
|
|
|
hid
|
HID: i2c-hid: Always sleep 60ms after I2C_HID_PWR_ON commands
|
2020-09-03 11:27:01 +02:00 |
|
hsi
|
|
|
|
hv
|
Drivers: hv: vmbus: Ignore CHANNELMSG_TL_CONNECT_RESULT(23)
|
2020-08-11 15:33:38 +02:00 |
|
hwmon
|
hwmon: (nct7904) Correct divide by 0
|
2020-09-03 11:26:54 +02:00 |
|
hwspinlock
|
|
|
|
hwtracing
|
coresight: tmc: Fix TMC mode read in tmc_read_unprepare_etb()
|
2020-08-19 08:16:14 +02:00 |
|
i2c
|
i2c: rcar: in slave mode, clear NACK earlier
|
2020-09-03 11:26:55 +02:00 |
|
i3c
|
|
|
|
ide
|
|
|
|
idle
|
|
|
|
iio
|
iio: dac: ad5592r: fix unbalanced mutex unlocks in ad5592r_read_raw()
|
2020-08-21 13:05:24 +02:00 |
|
infiniband
|
RDMA/bnxt_re: Do not add user qps to flushlist
|
2020-08-26 10:41:05 +02:00 |
|
input
|
Input: psmouse - add a newline when printing 'proto' by sysfs
|
2020-08-26 10:40:55 +02:00 |
|
interconnect
|
|
|
|
iommu
|
iommu/iova: Don't BUG on invalid PFNs
|
2020-09-03 11:26:43 +02:00 |
|
ipack
|
|
|
|
irqchip
|
genirq/affinity: Make affinity setting if activated opt-in
|
2020-08-21 13:05:20 +02:00 |
|
isdn
|
|
|
|
leds
|
leds: core: Flush scheduled work for system suspend
|
2020-08-19 08:16:11 +02:00 |
|
lightnvm
|
|
|
|
macintosh
|
macintosh/via-macii: Access autopoll_devs when inside lock
|
2020-08-19 08:16:15 +02:00 |
|
mailbox
|
mailbox: zynqmp-ipi: Fix NULL vs IS_ERR() check in zynqmp_ipi_mbox_probe()
|
2020-06-24 17:50:36 +02:00 |
|
mcb
|
|
|
|
md
|
bcache: avoid nr_stripes overflow in bcache_device_init()
|
2020-08-26 10:40:48 +02:00 |
|
media
|
media: gpio-ir-tx: improve precision of transmitted signal due to scheduling
|
2020-09-03 11:26:53 +02:00 |
|
memory
|
|
|
|
memstick
|
|
|
|
message
|
scsi: mptscsih: Fix read sense data size
|
2020-07-16 08:16:36 +02:00 |
|
mfd
|
mfd: intel-lpss: Add Intel Tiger Lake PCH-H PCI IDs
|
2020-09-03 11:26:43 +02:00 |
|
misc
|
cxl: Fix kobject memleak
|
2020-08-19 08:16:08 +02:00 |
|
mmc
|
mmc: renesas_sdhi_internal_dmac: clean up the code for dma complete
|
2020-08-21 13:05:32 +02:00 |
|
mtd
|
mtd: rawnand: fsl_upm: Remove unused mtd var
|
2020-08-21 13:05:30 +02:00 |
|
mux
|
|
|
|
net
|
net: gianfar: Add of_node_put() before goto statement
|
2020-09-03 11:27:00 +02:00 |
|
nfc
|
nfc: s3fwrn5: add missing release on skb in s3fwrn5_recv_frame
|
2020-08-05 09:59:50 +02:00 |
|
ntb
|
NTB: perf: Fix race condition when run with ntb_test
|
2020-06-24 17:50:41 +02:00 |
|
nubus
|
|
|
|
nvdimm
|
libnvdimm/security: ensure sysfs poll thread woke up and fetch updated attr
|
2020-08-21 13:05:35 +02:00 |
|
nvme
|
nvme: multipath: round-robin: fix single non-optimized path case
|
2020-09-03 11:26:55 +02:00 |
|
nvmem
|
nvmem: qfprom: remove incorrect write support
|
2020-06-10 20:24:57 +02:00 |
|
of
|
of: of_mdio: Correct loop scanning logic
|
2020-07-22 09:32:55 +02:00 |
|
opp
|
opp: Enable resources again if they were disabled earlier
|
2020-08-26 10:40:53 +02:00 |
|
oprofile
|
|
|
|
parisc
|
parisc: mask out enable and reserved bits from sba imask
|
2020-08-19 08:16:26 +02:00 |
|
parport
|
|
|
|
pci
|
PCI: qcom: Add missing reset for ipq806x
|
2020-09-03 11:26:53 +02:00 |
|
pcmcia
|
|
|
|
perf
|
drivers/perf: Prevent forced unbinding of PMU drivers
|
2020-07-29 10:18:40 +02:00 |
|
phy
|
phy: armada-38x: fix NETA lockup when repeatedly switching speeds
|
2020-08-19 08:16:14 +02:00 |
|
pinctrl
|
pinctrl: ingenic: Properly detect GPIO direction when configured for IRQ
|
2020-08-21 13:05:29 +02:00 |
|
platform
|
platform/chrome: cros_ec_ishtp: Fix a double-unlock issue
|
2020-08-21 13:05:30 +02:00 |
|
pnp
|
|
|
|
power
|
power: supply: check if calc_soc succeeded in pm860x_init_battery
|
2020-08-19 08:16:16 +02:00 |
|
powercap
|
|
|
|
pps
|
|
|
|
ps3
|
|
|
|
ptp
|
|
|
|
pwm
|
pwm: bcm-iproc: handle clk_get_rate() return
|
2020-08-21 13:05:34 +02:00 |
|
rapidio
|
|
|
|
ras
|
|
|
|
regulator
|
regulator: fix memory leak on error path of regulator_register()
|
2020-08-19 08:15:57 +02:00 |
|
remoteproc
|
remoteproc: qcom_q6v5_mss: Validate modem blob firmware size before load
|
2020-08-21 13:05:29 +02:00 |
|
reset
|
|
|
|
rpmsg
|
|
|
|
rtc
|
rtc: goldfish: Enable interrupt in set_alarm() when necessary
|
2020-08-26 10:40:54 +02:00 |
|
s390
|
s390/cio: add cond_resched() in the slow_eval_known_fn() loop
|
2020-09-03 11:26:59 +02:00 |
|
sbus
|
|
|
|
scsi
|
Revert "scsi: qla2xxx: Fix crash on qla2x00_mailbox_command"
|
2020-09-03 11:27:00 +02:00 |
|
sfi
|
|
|
|
sh
|
|
|
|
siox
|
|
|
|
slimbus
|
slimbus: core: Fix mismatch in of_node_get/put
|
2020-07-22 09:33:08 +02:00 |
|
soc
|
soc: qcom: rpmh-rsc: Set suppress_bind_attrs flag
|
2020-08-19 08:15:59 +02:00 |
|
soundwire
|
soundwire: intel: fix memory leak with devm_kasprintf
|
2020-07-22 09:33:00 +02:00 |
|
spi
|
spi: stm32: always perform registers configuration prior to transfer
|
2020-09-03 11:26:58 +02:00 |
|
spmi
|
|
|
|
ssb
|
|
|
|
staging
|
staging: rtl8192u: fix a dubious looking mask before a shift
|
2020-08-19 08:16:13 +02:00 |
|
target
|
scsi: target: Fix xcopy sess release leak
|
2020-09-03 11:26:44 +02:00 |
|
tc
|
|
|
|
tee
|
|
|
|
thermal
|
thermal: ti-soc-thermal: Fix reversed condition in ti_thermal_expose_sensor()
|
2020-08-19 08:16:14 +02:00 |
|
thunderbolt
|
|
|
|
tty
|
serial: 8250: change lock order in serial8250_do_startup()
|
2020-09-03 11:27:04 +02:00 |
|
uio
|
uio_pdrv_genirq: fix use without device tree and no interrupt
|
2020-07-22 09:33:13 +02:00 |
|
usb
|
USB: lvtest: return proper error code in probe
|
2020-09-03 11:27:02 +02:00 |
|
vfio
|
vfio/type1: Add proper error unwind for vfio_iommu_replay()
|
2020-08-26 10:41:03 +02:00 |
|
vhost
|
vhost/scsi: fix up req type endian-ness
|
2020-08-05 09:59:42 +02:00 |
|
video
|
fbcon: prevent user font height or width change from causing potential out-of-bounds access
|
2020-09-03 11:27:02 +02:00 |
|
virt
|
virt: vbox: Fix guest capabilities mask check
|
2020-07-22 09:33:11 +02:00 |
|
virtio
|
virtio_ring: Avoid loop when vq is broken in virtqueue_poll
|
2020-08-26 10:40:57 +02:00 |
|
visorbus
|
|
|
|
vlynq
|
|
|
|
vme
|
|
|
|
w1
|
w1: omap-hdq: cleanup to add missing newline for some dev_dbg
|
2020-06-22 09:31:26 +02:00 |
|
watchdog
|
watchdog: initialize device before misc_register
|
2020-08-21 13:05:36 +02:00 |
|
xen
|
xen: don't reschedule in preemption off sections
|
2020-08-26 10:41:07 +02:00 |
|
zorro
|
|
|
|
Kconfig
|
|
|
|
Makefile
|
|
|