linux-yocto/Documentation/driver-api
Alexis Lothoré c504c11b94 serial: mctrl_gpio: split disable_ms into sync and no_sync APIs
[ Upstream commit 1bd2aad57da95f7f2d2bb52f7ad15c0f4993a685 ]

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>
2025-06-04 14:42:07 +02:00
..
80211
acpi
backlight
cxl Documentation: cxl: remove dangling kernel-doc reference 2022-08-05 08:41:02 -07:00
dmaengine Documentation: driver-api: correct spelling 2023-02-02 11:05:16 -07:00
driver-model devres: Provide krealloc_array 2023-05-30 21:07:15 +01:00
early-userspace
firmware Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
fpga fpga: region: add owner module and take its refcount 2024-06-12 11:12:23 +02:00
gpio gpiolib: remove unused gpio_cansleep() 2023-06-13 16:49:23 +02:00
hte hte: Re-phrase tegra API document 2023-04-26 15:43:19 -07:00
i3c
iio
md Documentation: driver-api: correct spelling 2023-02-02 11:05:16 -07:00
media media updates for v6.6-rc1 2023-09-01 12:21:32 -07:00
mei Documentation: driver-api: correct spelling 2023-02-02 11:05:16 -07:00
memory-devices
mmc
mtd mtd: spi-nor: Stop exporting spi_nor_restore() 2023-04-04 09:43:50 +03:00
nfc Documentation: driver-api: correct spelling 2023-02-02 11:05:16 -07:00
nvdimm Documentation: driver-api: correct spelling 2023-02-02 11:05:16 -07:00
pci PCI/P2PDMA: Remove reference to pci_p2pdma_map_sg() 2024-01-25 15:35:47 -08:00
phy phy: Add devm_of_phy_optional_get() helper 2023-02-03 10:52:49 +05:30
pldmfw Documentation: driver-api: correct spelling 2023-02-02 11:05:16 -07:00
pm
rapidio
serial serial: mctrl_gpio: split disable_ms into sync and no_sync APIs 2025-06-04 14:42:07 +02:00
soundwire
surface_aggregator It has been a moderately calm cycle for documentation; the significant 2023-02-22 12:00:20 -08:00
thermal thermal: intel: int340x: Add DLVR support for RFIM control 2023-04-18 15:24:40 +02:00
tty tty: tty_buffer: use __tty_insert_flip_string_flags() in tty_insert_flip_char() 2023-08-22 14:58:15 +02:00
usb USB: Remove Wireless USB and UWB documentation 2023-08-09 14:17:32 +02:00
virtio docs: driver-api: virtio: commentize spec version checking 2023-02-20 19:26:57 -05:00
xilinx
aperture.rst drm: Implement DRM aperture helpers under video/ 2022-06-27 11:07:55 +02:00
auxiliary_bus.rst
basics.rst docs: time: make separate section for time and timers 2023-07-14 13:47:07 -06:00
clk.rst docs: clk: add documentation to log which clocks have been disabled 2023-04-20 17:53:38 -06:00
component.rst
connector.rst
console.rst
dcdbas.rst
devfreq.rst
device_link.rst
device-io.rst docs: move x86 documentation into Documentation/arch/ 2023-03-30 12:58:51 -06:00
dma-buf.rst dma-buf/sync_file: Surface sync-file uABI 2023-03-28 13:39:02 -07:00
edac.rst EDAC/amd64: Document heterogeneous system enumeration 2023-06-05 12:27:15 +02:00
eisa.rst Documentation: eisa: Fix typo 2022-11-15 14:52:38 -07:00
firewire.rst
frame-buffer.rst
generic-counter.rst
hsi.rst Documentation: driver-api: correct spelling 2023-02-02 11:05:16 -07:00
i2c.rst
index.rst platform/x86: wmi: Add documentation 2023-05-09 11:54:42 +02:00
infiniband.rst
infrastructure.rst docs: add more driver-model infrastructure interfaces 2023-07-14 13:18:50 -06:00
input.rst
interconnect.rst interconnect: Add debugfs test client 2023-08-22 21:04:50 +03:00
io_ordering.rst
io-mapping.rst Documentation: driver-api: correct spelling 2023-02-02 11:05:16 -07:00
ioctl.rst
ipmb.rst
ipmi.rst ipmi: docs: don't advertise deprecated sysfs entries 2024-10-04 16:29:12 +02:00
isa.rst Remove duplicate words inside documentation 2022-09-27 13:21:43 -06:00
isapnp.rst
libata.rst ata: libata: remove deprecated EH callbacks 2023-08-02 17:45:42 +09:00
mailbox.rst
men-chameleon-bus.rst
message-based.rst
misc_devices.rst
miscellaneous.rst docs/driver-api/miscellaneous: Remove kernel-doc of serial_core.c 2022-11-09 14:56:05 +01:00
mtdnand.rst
ntb.rst ntb.rst: Fix copy and paste error 2023-07-08 11:05:05 -04:00
nvmem.rst nvmem: core: introduce NVMEM layouts 2023-04-05 19:41:11 +02:00
parport-lowlevel.rst
pin-control.rst It has been a moderately calm cycle for documentation; the significant 2023-02-22 12:00:20 -08:00
pps.rst
ptp.rst docs: ptp.rst: Add information about NVIDIA Mellanox devices 2023-06-20 09:02:32 +01:00
pwm.rst pwm: Rename pwm_apply_state() to pwm_apply_might_sleep() 2024-06-12 11:12:24 +02:00
regulator.rst
reset.rst
rfkill.rst
s390-drivers.rst docs: move s390 under arch 2023-07-24 12:12:24 +02:00
scsi.rst
slimbus.rst
sm501.rst
spi.rst spi: Update reference to struct spi_controller 2022-11-01 18:30:09 +00:00
switchtec.rst
sync_file.rst
target.rst
uio-howto.rst
vfio-mediated-device.rst vfio-mdev: remove an non-existing driver from vfio-mediated-device 2023-01-23 11:26:29 -07:00
vfio-pci-device-specific-driver-acceptance.rst
vfio.rst docs: vfio: Add vfio device cdev description 2023-07-25 10:20:54 -06:00
vme.rst vme: move back to staging 2022-06-10 15:38:14 +02:00
w1.rst
wmi.rst platform/x86: wmi: Add documentation 2023-05-09 11:54:42 +02:00
xillybus.rst
zorro.rst