linux/drivers/tty
Erwan Le Ray ad76768124 serial: stm32: fix a deadlock condition with wakeup event
Deadlock issue is seen when enabling CONFIG_PROVE_LOCKING=Y, and uart
console as wakeup source. Deadlock occurs when resuming from low power
mode if system is waked up via usart console.
The deadlock is triggered 100% when also disabling console suspend prior
to go to suspend.

Simplified call stack, deadlock condition:
- stm32_console_write <-- spin_lock already held
- print_circular_bug
- pm_wakeup_dev_event <-- triggers lockdep as seen above
- stm32_receive_chars
- stm32_interrupt <-- wakeup via uart console, takes the lock

So, revisit spin_lock in stm32-usart driver:
- there is no need to hold the lock to access ICR (atomic clear of status
  flags)
- only hold the lock inside stm32_receive_chars() routine (no need to
  call pm_wakeup_dev_event with lock held)
- keep stm32_transmit_chars() routine called with lock held

Fixes: 48a6092fb4 ("serial: stm32-usart: Add STM32 USART Driver")
Signed-off-by: Erwan Le Ray <erwan.leray@foss.st.com>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://lore.kernel.org/r/20210304162308.8984-6-erwan.leray@foss.st.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-10 09:34:10 +01:00
..
hvc tty: hvc, drop unneeded forward declarations 2021-03-10 09:34:09 +01:00
ipwireless tty: make everyone's write_room return >= 0 2021-03-10 09:34:09 +01:00
serdev tty: serdev: core: Provide missing description for 'owner' 2020-11-06 10:49:27 +01:00
serial serial: stm32: fix a deadlock condition with wakeup event 2021-03-10 09:34:10 +01:00
vt vt_ioctl: Remove in_interrupt() check 2021-02-09 11:45:04 +01:00
amiserial.c tty: do not check tty_unregister_driver's return value 2021-03-10 09:34:09 +01:00
ehv_bytechan.c tty: evh_bytechan: Fix out of bounds accesses 2020-03-17 23:40:31 +11:00
goldfish.c tty: goldfish: use __raw_writel()/__raw_readl() 2020-10-28 13:44:43 +01:00
Kconfig tty: rocket, remove the driver 2021-03-10 09:34:06 +01:00
Makefile tty: rocket, remove the driver 2021-03-10 09:34:06 +01:00
mips_ejtag_fdc.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
moxa.c tty: do not check tty_unregister_driver's return value 2021-03-10 09:34:09 +01:00
moxa.h tty: fix spelling mistake 2020-06-27 16:21:20 +02:00
mxser.c tty_port: drop last traces of low_latency 2021-01-07 16:17:32 +01:00
mxser.h
n_gsm.c tty: make everyone's write_room return >= 0 2021-03-10 09:34:09 +01:00
n_hdlc.c tty: remove TTY_LDISC_MAGIC 2021-03-10 09:34:06 +01:00
n_null.c tty: remove TTY_LDISC_MAGIC 2021-03-10 09:34:06 +01:00
n_r3964.c tty: remove TTY_LDISC_MAGIC 2021-03-10 09:34:06 +01:00
n_tty.c tty: n_tty, set tty_ldisc_ops::owner 2021-03-10 09:34:06 +01:00
nozomi.c tty: nozomi, remove useless debug prints 2021-03-10 09:34:08 +01:00
pty.c drivers:tty:pty: Fix a race causing data loss on close 2021-01-07 16:30:55 +01:00
synclink_gt.c tty: synclink_gt, drop unneeded forward declarations 2021-03-10 09:34:09 +01:00
sysrq.c tty/sysrq: Extend the sysrq_key_table to cover capital letters 2020-10-02 14:56:06 +02:00
tty_audit.c tty: tty_audit: Demote non-conformant kernel-doc headers 2020-11-06 10:54:04 +01:00
tty_baudrate.c tty: tty_baudrate: Add missing description for 'tty' 2020-11-06 10:49:27 +01:00
tty_buffer.c tty: tty_buffer: Add missing description for 'limit' 2020-11-06 10:49:27 +01:00
tty_io.c tty: localise ptychar and make it const 2021-03-10 09:34:09 +01:00
tty_ioctl.c tty: cleanup tty_chars_in_buffer 2021-03-10 09:34:09 +01:00
tty_jobctrl.c Merge 5.10-rc7 into tty-next 2020-12-07 10:19:31 +01:00
tty_ldisc.c tty: tty_ldisc: Fix some kernel-doc related misdemeanours 2020-11-13 15:30:45 +01:00
tty_ldsem.c locking/lockdep: Remove unused @nested argument from lock_release() 2019-10-09 12:46:10 +02:00
tty_mutex.c
tty_port.c tty: tty_port: Demote obvious abuse of kernel-doc formatting 2020-11-06 10:49:27 +01:00
ttynull.c Revert "init/console: Use ttynull as a fallback when there is no console" 2021-01-08 11:02:18 -08:00
vcc.c tty: make everyone's write_room return >= 0 2021-03-10 09:34:09 +01:00