linux/Documentation
Alexis Lothoré e6a46719a2 serial: mctrl_gpio: split disable_ms into sync and no_sync APIs
[ Upstream commit 1bd2aad57d ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-05-29 11:02:45 +02:00
..
ABI x86/its: Enable Indirect Target Selection mitigation 2025-05-18 08:24:59 +02:00
accel accel/qaic: Add AIC080 support 2024-12-14 20:03:46 +01:00
accounting docs: psi: use correct config name 2023-07-31 09:54:17 -06:00
admin-guide x86/bugs: Make spectre user default depend on MITIGATION_SPECTRE_V2 2025-05-29 11:02:33 +02:00
arch arm64/boot: Enable EL2 requirements for FEAT_PMUv3p9 2025-04-25 10:48:04 +02:00
block docs: block: Fix grammar and spelling mistakes in bfq-iosched.rst 2024-09-05 14:38:10 -06:00
bpf bpf: Add namespace to BPF internal symbols 2025-05-02 07:59:04 +02:00
cdrom scsi: sr: Fix unintentional arithmetic wraparound 2024-05-15 10:05:24 -04:00
core-api module: Convert default symbol namespace to string literal 2025-02-08 09:57:05 +01:00
cpu-freq Docs/subsystem-apis: Remove '[The ]Linux' prefixes from titles of listed documents 2023-01-24 15:27:08 -07:00
crypto docs: crypto: async-tx-api: fix broken code example 2024-06-12 15:41:09 -06:00
dev-tools The core clk framework is left largely untouched this time around except for 2024-09-23 15:01:48 -07:00
devicetree dt-bindings: soc: fsl: fsl,ls1028a-reset: Fix maintainer entry 2025-04-25 10:47:42 +02:00
doc-guide doc-guide: add help documentation checktransupdate.rst 2024-07-30 07:56:22 -06:00
driver-api serial: mctrl_gpio: split disable_ms into sync and no_sync APIs 2025-05-29 11:02:45 +02:00
fault-injection Fix typo "allocateed" to allocated 2024-08-26 15:37:25 -06:00
fb fbdev/intelfb: Remove driver 2024-01-12 12:38:37 +01:00
features x86: remove PG_uncached 2024-09-03 21:15:46 -07:00
filesystems fs_parser: update mount_api doc to match function signature 2024-12-05 14:02:29 +01:00
firmware-guide Documentation: firmware-guide: ACPI: Fix namespace typo 2024-04-26 18:58:13 +02:00
firmware_class firmware: revamp firmware documentation 2017-01-11 09:42:59 +01:00
fpga Documentation: use capitalization for chapters and acronyms 2023-05-16 12:49:31 -06:00
gpu drm: Add panel backlight quirks 2025-02-17 10:04:45 +01:00
hid Documentation: hid: intel-ish-hid: Add vendor custom firmware loading 2024-08-19 21:12:27 +02:00
hwmon hwmon: (dell-smm) Increment the number of fans 2025-05-29 11:02:22 +02:00
i2c i2c: i801: Add support for Intel Panther Lake 2024-12-14 20:03:55 +01:00
iio docs: iio: ad7380: fix supply for ad7380-4 2024-10-24 18:30:47 +01:00
images docs: add SVG version of the Linux logo 2022-06-01 09:32:45 -06:00
infiniband RDMA/core: Remove FMR device ops 2020-06-02 20:32:54 -03:00
input input: docs: properly format ToC headings 2023-11-17 13:05:26 -07:00
isdn Documentation: isdn: correct spelling 2023-02-10 16:28:13 -08:00
kbuild kbuild: doc: replace "gcc" in external module description 2024-09-24 03:07:21 +09:00
kernel-hacking Documentation: Add document for false sharing 2023-04-10 16:46:11 -06:00
leds - Limited LED current based on thermal conditions in the QCOM flash LED driver. 2024-09-23 14:20:11 -07:00
litmus-tests Documentation/litmus-tests: Make cmpxchg() tests safe for klitmus 2024-05-06 14:29:21 -07:00
livepatch Documentation: livepatch: Correct release locks antonym 2024-09-04 13:42:27 +02:00
locking kcsan, seqlock: Support seqcount_latch_t 2024-12-05 14:01:22 +01:00
maintainer docs: maintainer: discourage taking conversations off-list 2024-07-16 11:08:26 -06:00
mhi docs: Add documentation for MHI bus 2020-03-19 07:41:04 +01:00
misc-devices misc: mrvl-cn10k-dpi: add Octeon CN10K DPI administrative driver 2024-07-10 14:58:29 +02:00
mm Docs/damon/maintainer-profile: update deprecated awslabs GitHub URLs 2024-10-17 00:28:09 -07:00
netlabel docs: add some directories to the main documentation index 2019-07-15 11:03:03 -03:00
netlink netlink: specs: tc: all actions are indexed arrays 2025-05-22 14:29:42 +02:00
networking strparser: Add read_sock callback 2025-02-27 04:30:19 -08:00
nvdimm nvdimm: fixes to maintainter-entry-profile 2020-05-25 10:19:19 -06:00
nvme Remove duplicate "and" in 'Linux NVMe docs. 2024-09-10 15:44:20 -06:00
PCI Documentation: PCI: fix typo in pci.rst 2024-09-10 15:30:42 -06:00
pcmcia Documentation: use capitalization for chapters and acronyms 2023-05-16 12:49:31 -06:00
peci Docs/subsystem-apis: Remove '[The ]Linux' prefixes from titles of listed documents 2023-01-24 15:27:08 -07:00
power Documentation: PM: Clarify pm_runtime_resume_and_get() return value 2024-12-19 18:13:15 +01:00
process soc: fixes for 6.12 2024-10-17 09:43:36 -07:00
RCU doc: rcu: update printed dynticks counter bits 2024-12-05 14:01:19 +01:00
rust rust: remove leftover mentions of the alloc crate 2025-03-22 12:54:23 -07:00
scheduler sched_ext: Documentation: Update instructions for running example schedulers 2024-10-08 08:49:18 -10:00
scsi scsi: documentation: Clean up scsi_mid_low_api.rst 2024-04-08 22:10:05 -04:00
security landlock: Fix grammar issues in documentation 2024-10-21 20:36:26 +02:00
sound Docs/sound: Add documentation for userspace-driven ALSA timers 2024-08-18 09:55:54 +02:00
sphinx docs: kerneldoc-preamble.sty: Suppress extra spaces in CJK literal blocks 2024-09-05 14:16:41 -06:00
sphinx-static docs: translations: add translations links when they exist 2023-12-19 14:34:59 -07:00
spi spi: Enable controllers to extend the SPI protocol with MOSI idle configuration 2024-07-29 01:19:51 +01:00
staging xz: remove XZ_EXTERN and extern from functions 2024-09-01 20:43:27 -07:00
target scsi: target: docs: Remove tcm_mod_builder.py 2023-06-28 22:01:32 -04:00
tee Documentation: tee: Add TS-TEE driver 2024-04-03 14:03:09 +02:00
timers treewide: Fix wrong singular form of jiffies in comments 2024-09-08 20:47:40 +02:00
tools Documentation/tools/rv: fix document header 2024-07-03 16:36:21 -06:00
trace tracing/Documentation: Start a document on how to debug with tracing 2024-08-26 13:54:08 -04:00
translations module: Convert default symbol namespace to string literal 2025-02-08 09:57:05 +01:00
usb usb: gadget: f_uac1: Change volume name and remove alt names 2024-08-13 18:11:35 +02:00
userspace-api Landlock fix for v6.12-rc7 2024-11-12 13:01:09 -08:00
virt KVM: x86: Clean up documentation for KVM_X86_QUIRK_SLOT_ZAP_ALL 2024-10-20 07:31:05 -04:00
w1 w1: add UART w1 bus driver 2024-02-15 15:02:33 +01:00
watchdog [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
wmi platform/x86: msi-wmi-platform: Workaround a ACPI firmware bug 2025-04-25 10:48:04 +02:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
atomic_bitops.txt wait_on_bit: add an acquire memory barrier 2022-08-26 09:30:25 -07:00
atomic_t.txt Documentation/atomic_t: Emphasize that failed atomic operations give no ordering 2024-05-06 14:29:04 -07:00
Changes docs: add back 'Documentation/Changes' file (as symlink) 2016-12-14 16:30:12 -08:00
CodingStyle doc: re-add CodingStyle and SubmittingPatches 2016-10-24 08:12:35 -02:00
conf.py compiler_types: add Endianness-dependent __counted_by_{le,be} 2024-03-28 18:50:47 -07:00
docutils.conf doc-rst: Add missing newline at end of file 2019-06-20 14:16:56 -06:00
dontdiff Kbuild updates for v6.12 2024-09-24 13:02:06 -07:00
index.rst doc: fix spelling about ReStructured Text 2024-04-02 10:07:51 -06:00
Kconfig Documentation: Avoid duplicate Kconfig inclusion 2023-01-19 13:56:34 -07:00
Makefile Kbuild updates for v6.10 2024-05-18 12:39:20 -07:00
memory-barriers.txt docs/memory-barriers.txt: Remove left-over references to "CACHE COHERENCY" 2024-09-13 23:56:44 -07:00
SubmittingPatches doc: re-add CodingStyle and SubmittingPatches 2016-10-24 08:12:35 -02:00
subsystem-apis.rst docs: Fix subsystem APIs page so ungrouped entries have their own header 2024-01-30 14:02:32 -07:00