linux/Documentation
Alexis Lothoré 1bd2aad57d serial: mctrl_gpio: split disable_ms into sync and no_sync APIs
The following splat has been observed on a SAMA5D27 platform using
atmel_serial:

BUG: sleeping function called from invalid context at kernel/irq/manage.c:738
in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 27, name: kworker/u5:0
preempt_count: 1, expected: 0
INFO: lockdep is turned off.
irq event stamp: 0
hardirqs last  enabled at (0): [<00000000>] 0x0
hardirqs last disabled at (0): [<c01588f0>] copy_process+0x1c4c/0x7bec
softirqs last  enabled at (0): [<c0158944>] copy_process+0x1ca0/0x7bec
softirqs last disabled at (0): [<00000000>] 0x0
CPU: 0 UID: 0 PID: 27 Comm: kworker/u5:0 Not tainted 6.13.0-rc7+ #74
Hardware name: Atmel SAMA5
Workqueue: hci0 hci_power_on [bluetooth]
Call trace:
  unwind_backtrace from show_stack+0x18/0x1c
  show_stack from dump_stack_lvl+0x44/0x70
  dump_stack_lvl from __might_resched+0x38c/0x598
  __might_resched from disable_irq+0x1c/0x48
  disable_irq from mctrl_gpio_disable_ms+0x74/0xc0
  mctrl_gpio_disable_ms from atmel_disable_ms.part.0+0x80/0x1f4
  atmel_disable_ms.part.0 from atmel_set_termios+0x764/0x11e8
  atmel_set_termios from uart_change_line_settings+0x15c/0x994
  uart_change_line_settings from uart_set_termios+0x2b0/0x668
  uart_set_termios from tty_set_termios+0x600/0x8ec
  tty_set_termios from ttyport_set_flow_control+0x188/0x1e0
  ttyport_set_flow_control from wilc_setup+0xd0/0x524 [hci_wilc]
  wilc_setup [hci_wilc] from hci_dev_open_sync+0x330/0x203c [bluetooth]
  hci_dev_open_sync [bluetooth] from hci_dev_do_open+0x40/0xb0 [bluetooth]
  hci_dev_do_open [bluetooth] from hci_power_on+0x12c/0x664 [bluetooth]
  hci_power_on [bluetooth] from process_one_work+0x998/0x1a38
  process_one_work from worker_thread+0x6e0/0xfb4
  worker_thread from kthread+0x3d4/0x484
  kthread from ret_from_fork+0x14/0x28

This warning is emitted when trying to toggle, at the highest level,
some flow control (with serdev_device_set_flow_control) in a device
driver. At the lowest level, the atmel_serial driver is using
serial_mctrl_gpio lib to enable/disable the corresponding IRQs
accordingly.  The warning emitted by CONFIG_DEBUG_ATOMIC_SLEEP is due to
disable_irq (called in mctrl_gpio_disable_ms) being possibly called in
some atomic context (some tty drivers perform modem lines configuration
in regions protected by port lock).

Split mctrl_gpio_disable_ms into two differents APIs, a non-blocking one
and a blocking one. Replace mctrl_gpio_disable_ms calls with the
relevant version depending on whether the call is protected by some port
lock.

Suggested-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Acked-by: Richard Genoud <richard.genoud@bootlin.com>
Link: https://lore.kernel.org/r/20250217-atomic_sleep_mctrl_serial_gpio-v3-1-59324b313eef@bootlin.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-02-19 15:08:36 +01:00
..
ABI First batch of fixes for 6.14. Nothing really stands out, 2025-01-30 12:24:20 -08:00
accel
accounting Mainly individually changelogged singleton patches. The patch series in 2025-01-26 17:50:53 -08:00
admin-guide KVM/arm64 updates for 6.14 2025-01-28 09:01:36 -08:00
arch arm64/gcs: Fix documentation for HWCAP 2025-02-04 12:26:26 +00:00
block Documentation: ublk: Drop Stefan Hajnoczi's message footnote 2025-01-28 15:02:17 -07:00
bpf
cdrom
core-api Mainly individually changelogged singleton patches. The patch series in 2025-01-26 17:50:53 -08:00
cpu-freq
crypto
dev-tools Documentation: move dev-tools debugging files to process/debugging/ 2024-12-17 13:46:53 -07:00
devicetree Merge 6.14-rc3 into tty-next 2025-02-17 07:25:34 +01:00
doc-guide
driver-api serial: mctrl_gpio: split disable_ms into sync and no_sync APIs 2025-02-19 15:08:36 +01:00
fault-injection
fb
features
filesystems bcachefs docs: SubmittingPatches.rst 2025-02-06 22:35:11 -05:00
firmware_class
firmware-guide
fpga
gpu drm: xlnx: zynqmp_dpsub: Fix kernel doc 2025-01-16 12:45:16 +01:00
hid HID: THC: Add documentation 2025-01-09 10:14:14 +01:00
hwmon hwmon updates for v6.14-rc1 2025-01-22 10:16:48 -08:00
i2c
iio iio: light: Add support for TI OPT4060 color sensor 2024-12-28 14:28:13 +00:00
images
infiniband
input
isdn
kbuild Kbuild updates for v6.14 2025-01-31 12:07:07 -08:00
kernel-hacking
leds Documentation:leds: Add leds-st1202.rst 2025-01-09 10:30:23 +00:00
litmus-tests
livepatch
locking
maintainer
mhi
misc-devices
mm The various patchsets are summarized below. Plus of course many 2025-01-26 18:36:23 -08:00
netlabel
netlink net: ethtool: tsconfig: Fix netlink type of hwtstamp flags 2025-02-06 16:35:21 -08:00
networking Documentation/networking: fix basic node example document ISO 15765-2 2025-02-08 11:28:11 +01:00
nvdimm
nvme Documentation: Document the NVMe PCI endpoint target driver 2025-01-10 19:30:49 -08:00
PCI pci-v6.14-changes 2025-01-25 16:03:40 -08:00
pcmcia
peci
power Two fixes for footnote-related warnings that appeared with Sphinx 8.x. 2025-01-30 10:57:19 -08:00
process Kbuild updates for v6.14 2025-01-31 12:07:07 -08:00
RCU
rust Rust changes for v6.13 2024-11-26 14:00:26 -08:00
scheduler sched_ext: Changes for v6.14 2025-01-23 18:49:43 -08:00
scsi scsi: documentation: Corrections for struct updates 2025-01-10 15:15:30 -05:00
security cred: remove unused get_new_cred() 2024-12-02 11:25:14 +01:00
sound Merge branch 'for-linus' into for-next 2025-01-20 09:25:33 +01:00
sphinx
sphinx-static
spi
staging
sunrpc/xdr nfsd: rename NFS4_SHARE_WANT_* constants to OPEN4_SHARE_ACCESS_WANT_* 2025-01-21 15:30:01 -05:00
target
tee
timers
tools
trace tracing updates for v6.14: 2025-01-23 17:51:16 -08:00
translations mailmap, MAINTAINERS, docs: update Carlos's email address 2025-02-01 03:53:27 -08:00
usb USB: usbip: Update USB/IP OP_REP_IMPORT documentation. 2024-12-27 13:07:22 +01:00
userspace-api Driver core and debugfs updates 2025-01-28 12:25:12 -08:00
virt KVM: s390: fake memslot for ucontrol VMs 2025-01-31 12:03:52 +01:00
w1
watchdog
wmi docs: platform/x86: wmi: mention tool for invoking WMI methods 2025-01-09 13:38:39 +02:00
.gitignore
atomic_bitops.txt
atomic_t.txt
Changes
CodingStyle
conf.py
docutils.conf
index.rst
Kconfig
Makefile tools: ynl: move python code to separate sub-directory 2025-01-09 12:53:27 -08:00
memory-barriers.txt
SubmittingPatches
subsystem-apis.rst Documentation: Document the NVMe PCI endpoint target driver 2025-01-10 19:30:49 -08:00