summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2026-10-13serial: max310x: don't transmit while an RS485 reconfigure is pendingTapio Reijonen
TIOCSRS485 applies its register changes asynchronously: rs485_config() stores the new configuration and schedules rs_work, which programs HDPIXDELAY, MODE1.TRNSCVCTRL and the RTS path. A write() issued right after the ioctl therefore transmits against the old, half-switched state. On a single core the ordering is even deterministic: start_tx() picks the stale path first, then rs_work reprograms the chip, then tx_work pumps the data - with the transceiver already released. A TIOCSRS485 switching from the hardware to the software RTS path followed immediately by a write puts the whole transfer on the wire with the transceiver disabled: nothing reaches the bus and no error is reported anywhere. The inverse direction is as old as the asynchronous reconfigure itself: enabling RS485 and writing immediately shifts the first bytes out before rs_work has enabled the chip's auto-RTS. Defer instead: rs485_config() marks the reconfigure pending under port->lock, start_tx() leaves the data in the kfifo while the mark is set, and rs_work restarts the transmission itself once the new configuration is fully applied. The rs485-disable path's direct tx_work kick is replaced by the same mechanism, which also orders that flush after the reconfigure instead of before it. The restart kick also checks port->x_char: uart_send_xchar() reaches start_tx() too, and a lone x_char deferred by the pending gate leaves the kfifo empty, so the kick would otherwise skip it and nothing else would ever send it - an idle chip FIFO raises no TXEMPTY interrupt. And start_tx() re-checks the pending mark after the hrtimer_try_to_cancel(-1) path retakes the dropped lock, mirroring the tx_teardown re-check there: a TIOCSRS485 posted inside that window would otherwise let the transmission proceed on the stale path. rs_work takes port->lock for that restart through uart_port_lock_irqsave(): start_tx() may drop and retake the lock through the uart_port API on its hrtimer_try_to_cancel(-1) path, and a raw spinlock guard around the call would unbalance the nbcon console handling underneath. The restart also rewinds a send state adopted for the deferred write itself: set_rts_ctl_params() cannot tell data the pending gate deferred apart from an in-flight transfer's refill by the xmit buffer alone, and a deferred write pumped in the adopted send phase would skip the configured before-send delay. With the chip FIFO empty the adopted state can only be the deferred write: rewind it and let the restart run the full envelope. The chip-FIFO check for that rewind is deliberately lock-free, so a TX-empty refill can land between the read and the lock and the rewind can hit a live envelope. The consequence is bounded: the rewind runs under port->lock in a state the RTS worker reads as asserted, so the envelope pauses one before-send delay with the transceiver held - the same pause the unconditional rewind produced before patch 8's guard. Fixes: 5bdb48b501e8 ("serial: max310x: Fix RS485 handling") Assisted-by: Claude:claude-fable-5 Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com> Link: https://patch.msgid.link/20261008-max310x-rs485-sw-delay-v8-9-6ba881f81e1f@vaisala.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: max310x: drive RTS in software when hardware delays are too shortTapio Reijonen
The chip's auto-RTS path can express at most 15 bit-times of RTS setup and hold delay - a fraction of a millisecond at typical baud rates - while the uapi expresses the delays in milliseconds up to the UART core's RS485_MAX_RTS_DELAY. Requests beyond the field were rejected with -ERANGE, which makes the core silently wipe port->rs485 and disable RS485; a device tree asking for a 20 ms setup delay ends up with no RS485 at all and an unusable bus. Add a software-driven RTS path that takes over whenever the hardware cannot represent the requested timing, and clamp the delays to RS485_MAX_RTS_DELAY instead of rejecting them. max310x_set_rts_ctl_params() picks the path: software if either delay exceeds what 15 bit-times encode at the current baud rate, or if the requested RTS polarity combination cannot be produced by the auto-RTS engine; hardware otherwise, as before. On the software path the RTS envelope is driven by a single hrtimer, re-used for the before- and after-send phases (tracked in tx_state), plus a single rts_work that toggles RTS. start_tx() begins the envelope; rts_work asserts RTS and only then arms the before-send timer, so data is never shifted before RTS is on the wire. The timer expiry kicks tx_work; once the chip FIFO drains, the same timer is re-armed for one character (the byte still in the shift register) plus the after-send delay, after which rts_work releases RTS. One timer and one work keep the phases mutually exclusive and the RTS toggles ordered. A start_tx() landing while the envelope is already in its send phase only pumps the new data: rewinding it to the before-send phase would insert a spurious setup delay mid-stream. Teardown is interlocked: shutdown() and an RS485-disabling TIOCSRS485 set tx_teardown under port->lock before cancelling the timer and works, and start_tx() checks it on entry and again after the hrtimer_try_to_cancel(-1) path retakes the dropped lock - otherwise a write racing the teardown could re-arm the timer or queue rts_work against a port being shut down, leaving the transceiver driving the bus after close. The rs485-disable path additionally kicks tx_work afterwards, since a racing write may have queued data with no envelope left to pump it, and shutdown() now also cancels tx_work, which was previously cancelled only in remove(). The interlock also fences the adoption path below, so a reconfigure racing a teardown cannot re-enable the cancelled timer, and an RS485 disable flushes a queued rts_work before the pin is settled: one already past its tx_state read would re-assert RTS after the settle. set_rts_ctl_params() publishes sw_rts_during_tx with a single store and settles the RTS idle level only while tx_state is off, because serial_core calls set_termios() without port->lock and rs485_config() schedules a reconfigure on every TIOCSRS485 - either could otherwise release the transceiver mid-envelope. The settle also re-checks tx_state after its write and requeues rts_work if an envelope started meanwhile: the state read and the register write are not atomic, and rts_work re-derives the level from tx_state, so this converges without locking. shutdown() gates first - the interlock is set and the interrupts are masked before any wait, so nothing can start a new envelope or requeue tx_work behind the cancels - then honours a running after-send hold, bounded by the after-send delay plus two character times (the transmitter is already stopped by this point), and cancels the timer and works unconditionally: a TIOCSRS485 can clear sw_rts_during_tx while an envelope is still in flight, and neither may outlive the port. A hold that did not complete within the bound is settled by the final release below regardless. break_ctl() on the software path applies the configured RTS polarity itself. A reconfigure can also move the port off the hardware path while the chip's auto-RTS still owns a transmission in flight - a termios change or TIOCSRS485 pushing a delay above what the hardware can time at the new rate. Such transfers are invisible to tx_state, so the idle settle would release RTS and the MODE1 write would disable auto-RTS mid-transfer, shifting the rest of the data out with the transceiver released and no error reported anywhere. Adopt the transfer instead when the chip TX FIFO or the xmit buffer is not empty: enter MAX310X_TX_SEND and drive RTS manually before auto-RTS is disabled, so the pin is never released across the handover, and the normal drain path arms the after-send hold - or the adoption arms it directly if the FIFO drained while this raced the TX-empty worker. A transfer whose last character has already left the FIFO for the transmit shift register is still invisible and keeps the old behavior: at most one character of early release. The reverse move strands state instead: a reconfigure onto the hardware path mid-envelope left tx_state set, because nothing reset it in that direction and the TX-empty hold arming only ran while the software path was selected. A later reconfigure back off the hardware path then trusted the stale tx_state, skipped both the adoption and the idle settle, and disabled auto-RTS with the RTS register released - the rest of the transfer in flight shifted out with the transceiver off, again with no error reported (hit twice in 79 in-flight reconfigures under a multi-process stress test). The TX-empty unwind now runs regardless of the selected path - it is a no-op outside an envelope - and the reconfigure asserts RTS for any transfer it believes exists, stale or live, before auto-RTS is disabled. The hold is armed only once no transmittable data remains, so that assert cannot cut a burst short when it lands in a FIFO refill window; output that is stopped still releases through the hold. rts_work also derives the level from tx_break: a break can begin while the previous envelope's after-send hold is still armed - TIOCSBRK waits for the output to drain, which lands the break exactly there - and the expiring hold would otherwise release the transceiver mid-break. With break ownership in the derivation the hold expiry becomes an idempotent re-assert, and break-off restores the idle state as it already does. shutdown() gives its final RTS release one bit time, and at least 100 us, to reach the pin before powering the port down. The power-off stops the UART channel clock, and the RTS output stage is clocked by it: a release written immediately before the clock stops reaches the register but never moves the pin, which stays asserted until the next startup restarts the clock - a close racing the after-send hold expiry left the transceiver driving the bus, with the register reading released and the pin high. The measured propagation is about one tick of the 16x oversampling clock - below 50 us at 1200 baud - so one bit time keeps a 16x margin and scales with the clock the output stage runs on; the floor covers rates where a bit is shorter than the measured bound. Handing the pin to the chip's auto-RTS engine instead was tried and rejected on the wire: the pin level is RTSINVERT xor the selected source, so for an active-low RTS every single-register step of that handover drives the pin to the asserted level, and the same clock stop can freeze it there. Fixes: 55367c620aed ("serial: max310x: Add support for RS-485 mode") Assisted-by: Claude:claude-fable-5 Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com> Link: https://patch.msgid.link/20261008-max310x-rs485-sw-delay-v8-8-6ba881f81e1f@vaisala.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: max310x: schedule tx_work directly from the IRQ handlerTapio Reijonen
The TXEMPTY interrupt asks for a FIFO refill, and start_tx() does nothing beyond scheduling tx_work, so going through it makes no functional difference. It does conflate two distinct events, though: start_tx() is the serial core starting a new transmission, while TXEMPTY can only fire for a transmission that is already running - the bit latches on the FIFO's non-empty to empty transition, and the IRQ handler's read of IRQSTS consumes the latch, so a stale TXEMPTY cannot exist on an idle port (if the bit were level-triggered, the handler's read-until-clear loop would never terminate). Schedule tx_work directly, keeping the interrupt path a pure FIFO refill. This is preparation for a following patch that adds software-timed RS485 RTS control, where start_tx() also starts the RTS envelope and a refill must not restart it. No functional change. Assisted-by: Claude:claude-fable-5 Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com> Link: https://patch.msgid.link/20261008-max310x-rs485-sw-delay-v8-7-6ba881f81e1f@vaisala.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: max310x: support active-low RTS on the hardware pathTapio Reijonen
The chip's auto-RTS engine asserts the RTS_ pin high while data is shifting out, so a transceiver with an active-low driver-enable could not use the hardware RS485 path at all: SER_RS485_RTS_AFTER_SEND is not in the supported flags and the core normalizes it away with "invalid RTS setting, using RTS_ON_SEND instead". The output stage is invertible: program IRDA.RTSINVERT when the requested polarity is active-low and advertise SER_RS485_RTS_AFTER_SEND in rs485_supported. A break already drives break_state onto the RTS bit unadjusted, which remains correct because RTSINVERT inverts the output stage itself, not the register value. Assisted-by: Claude:claude-fable-5 Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com> Link: https://patch.msgid.link/20261008-max310x-rs485-sw-delay-v8-6-6ba881f81e1f@vaisala.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: max310x: don't power down the port mid-transmission on closeTapio Reijonen
max310x_shutdown() powers the port down regardless of what the transmitter is doing. The power-off stops the UART clock mid-character, truncating the final frame, and on the auto-RTS path it freezes the RTS output at its current level: a close() with data still queued leaves the RS485 transceiver asserted until the next open, which also emits the interrupted character corrupted. Waiting for the data to drain is no better: the tty layer's wait-until-sent is bounded by closing_wait, configurable to none, and a hangup arrives with no wait at all, so draining a full FIFO blocks close() in uninterruptible sleep for seconds at low baud rates - and forever when CTS flow control blocks the FIFO. Instead, set MODE1 TxDisabl: the character in flight completes and the transmitter ceases with TX_ at idle. Give that character one character time (the chip has no transmitter-idle status), then reset the FIFOs so the auto-RTS engine sees the transmitter empty and releases RTS within the configured after-send hold; wait that hold plus one bit time before powering off. Abandoned data was explicitly not waited for, and startup() resets the FIFOs and TxDisabl on open anyway. Measured on a MAX14830: a truncating close() at 50 baud takes 0.23 s, RTS releases one character plus the hold after the last stop bit on both polarities, and the reopen corruption is gone. Fixes: f65444187a66 ("serial: New serial driver MAX310X") Assisted-by: Claude:claude-fable-5 Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com> Link: https://patch.msgid.link/20261008-max310x-rs485-sw-delay-v8-5-6ba881f81e1f@vaisala.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: max310x: fix RS485 delays being programmed as bit-timesTapio Reijonen
The HDPIXDELAY register counts the RTS setup and hold delays in bit-times, four bits per direction, but the driver has been writing the struct serial_rs485 delay_rts_before_send/delay_rts_after_send values into it unconverted - and the uapi expresses those in milliseconds. A requested 9 ms setup delay is programmed as 9 bit-times, which at 9600 baud is 0.94 ms, roughly a tenth of what userspace asked for; the error grows with the baud rate. Cache the baud rate in set_termios() and convert the delays to bit-times at the current rate, rounding up so the delay on the wire is never shorter than requested, and capping at the 15 bit-times the 4-bit field can hold. The conversion lives in max310x_set_rts_ctl_params(); set_termios() now calls it as well, since the conversion depends on the baud rate. The delays a 4-bit bit-time field can represent still fall well short of the milliseconds the uapi can express; requests beyond 15 bit-times are capped, and the -ERANGE rejection of values above 15 ms remains in place for now. Fixes: 55367c620aed ("serial: max310x: Add support for RS-485 mode") Assisted-by: Claude:claude-fable-5 Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com> Link: https://patch.msgid.link/20261008-max310x-rs485-sw-delay-v8-4-6ba881f81e1f@vaisala.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: max310x: centralize the RS485 transceiver programmingTapio Reijonen
The HDPIXDELAY RTS delays and the MODE1 auto-transceiver enable are programmed in three places - the rs485-config worker, startup() and break_ctl()'s break-off restore - each with its own copy of the register sequence. Move the sequence into a helper, max310x_set_rts_ctl_params(), together with the tx_break guard that keeps the MODE1 write away from a break in progress; the break-off restore reapplies the current configuration through the same helper. No functional change intended. The copies differed only in that startup() clamped the delays to the 4-bit field while the worker wrote them unclamped; the helper clamps, and the difference is unreachable while rs485_config() still rejects delays above 15 ms with -ERANGE. Break-off additionally rewrites HDPIXDELAY with the values it already holds, a no-op on the wire. Assisted-by: Claude:claude-fable-5 Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com> Link: https://patch.msgid.link/20261008-max310x-rs485-sw-delay-v8-3-6ba881f81e1f@vaisala.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: max310x: fix breaks not reaching the wire in RS485 modeTapio Reijonen
The chip's auto-RTS (MODE1.TRNSCVCTRL) asserts the RS485 transceiver only while FIFO data is shifting out, and a break is not FIFO data: on an RS485 port a requested break sets the TX break bit but the transceiver is never enabled, so the break never reaches the wire. Break-led protocols cannot work at all. Disable auto-RTS for the break duration and drive RTS manually via the LCR RTS bit, then restore auto-RTS when the break ends. Track the break in tx_break and leave MODE1 alone in the rs485-config worker while it is set - a TIOCSRS485 arriving mid-break would otherwise re-enable auto-RTS on top of the manual RTS and release the transceiver before the break ends; break_ctl() restores auto-RTS from the then-current configuration when the break completes. The worker runs under port->mutex - break_ctl() and set_termios() already do - so the tx_break test and the MODE1 write cannot straddle a break starting or ending, and startup() clears tx_break alongside the latched TXBREAK bit, since a port can be closed with a break still asserted. Only the break assertion is gated on RS485 being enabled; the restore at break end runs unconditionally and derives MODE1 from the current configuration. Returning early for a port whose RS485 was disabled mid-break - that reconfigure is deferred like any other - would leak the manually driven RTS and leave the transceiver holding the bus indefinitely after the break ends. On a non-RS485 port the restore is a no-op: nothing else writes the LCR RTS bit. Fixes: 55367c620aed ("serial: max310x: Add support for RS-485 mode") Assisted-by: Claude:claude-fable-5 Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com> Link: https://patch.msgid.link/20261008-max310x-rs485-sw-delay-v8-2-6ba881f81e1f@vaisala.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: max310x: don't clobber the TX break bit in set_termiosTapio Reijonen
A TX break asserted with TIOCSBRK ends early, with no error reported, as soon as any termios change lands on the port: a break is a state that must hold until TIOCCBRK, but max310x_set_termios() overwrites the whole LCR register, and LCR also carries the TX break bit that break_ctl() drives. No concurrency is required - a baud or parity change from the same process ends the break just as well, and break-led protocols lose their break with nothing in the logs. Update only the LCR bits that are derived from termios and leave the TX break and RTS pin control bits untouched. Since nothing clears a break when a port is closed with the break still asserted - the tty core sends no break-off on release, and the unconditional write here was the accidental recovery - clear TXBREAK in startup(), the same way 8250 does. Fixes: f65444187a66 ("serial: New serial driver MAX310X") Assisted-by: Claude:claude-fable-5 Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com> Link: https://patch.msgid.link/20261008-max310x-rs485-sw-delay-v8-1-6ba881f81e1f@vaisala.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13tty: serial: move sdio_uart from mmc/core to tty/serialShawn Lin
sdio_uart is an SDIO function driver, not part of the MMC/SDIO core. Keeping it in drivers/mmc/core/ is misplaced: it registers to the SDIO bus (sdio_register_driver) and only uses the public SDIO API from include/linux/mmc/, with no dependency on any mmc core internals. Other SDIO function drivers live under their respective functional subsystem, e.g. the SDIO WiFi drivers are under drivers/net/wireless/. sdio_uart should likewise be placed under its functional subsystem, tty, just like the PCIe and I2C/SPI transport drivers (men_z135_uart, sc16is7xx, max310x) that live under drivers/tty/serial/. Historically almost all changes to this driver were tty API changes (e.g. tty_operations adjustments, alloc_tty_driver removal), yet scripts/get_maintainer.pl never listed the TTY maintainers while the file lived under drivers/mmc/core/. Moving it under drivers/tty/serial/ makes get_maintainer.pl report the proper TTY/serial maintainers and reviewers, which benefits future maintenance of this driver. No functional change. The CONFIG_SDIO_UART symbol is intentionally kept unchanged to avoid breaking existing configs; the dependency is updated to 'TTY && MMC' accordingly. Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> Link: https://patch.msgid.link/1791626517-18161-1-git-send-email-shawn.lin@rock-chips.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: sc16is7xx: declare MCR and IER as volatile registersHugo Villeneuve
MCR register has the same address as XON1 register. IER register has the same address as DLH register. Which register is accessed depends on bits configuration in some other registers. To prevent potential access errors, declare MCR and IER as volatile registers. Fixes: dfeae619d781 ("serial: sc16is7xx") Cc: stable@kernel.org Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Link: https://patch.msgid.link/20261006192540.234402-1-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13Merge branch 'tcp-fix-a-few-divide-by-zero-in-congestion-control-modules'Paolo Abeni
Jiayuan Chen says: ==================== tcp: fix a few divide-by-zero in congestion control modules Patch 1 and 2 were reported by VEGA <vega@nebusec.ai>. Patch 3 was found while reviewing the other TCP congestion control modules for the same kind of divide-by-zero on module parameters. Target net-next since it is not a big problem. v2: https://lore.kernel.org/netdev/20261001112948.322463-1-jiayuan.chen@linux.dev/ v1: https://lore.kernel.org/netdev/20260930100937.206377-1-jiayuan.chen@linux.dev/ ==================== Link: https://patch.msgid.link/20261008092641.140777-1-jiayuan.chen@linux.dev Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-10-13tcp_cubic: fix divide by zero and endless loop on bad module paramsJiayuan Chen
beta_scale and cube_factor are computed once at module init, and beta == 1024 or bic_scale == 0 is a divide by zero right there. Other out of range values give garbage: negative beta can make beta_scale 0, and bic_scale * 10 can overflow. Reject them. Read beta once, as it can be written through sysfs before the init function runs. A small beta also gives a small beta_scale, and (cwnd * beta_scale) >> 3 truncates to 0 for a tiny cwnd, so the TCP friendliness loop never ends. Rather than testing delta on every ACK, make sure beta_scale is at least 8 at init, so delta is >= 1 within the cwnd < 1 million packets limit this code is designed for. This slows the TCP friendly estimate for beta < 512, a backoff harder than Reno's 0.5, which is not a setting anyone should use. Fixes: df3271f3361b ("[TCP] BIC: CUBIC window growth (2.0)") Suggested-by: Eric Dumazet <edumazet@kernel.org> Reviewed-by: Eric Dumazet <edumazet@kernel.org> Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev> Link: https://patch.msgid.link/20261008092641.140777-4-jiayuan.chen@linux.dev Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-10-13tcp_hybla: fix divide by zero on rtt0 == 0Jiayuan Chen
rtt0 is the reference RTT in ms, so 0 makes no sense, and hybla_recalc_param() divides by it right from hybla_init(). Reject values below 1 when the parameter is written. Also cap it at U32_MAX / USEC_PER_MSEC, since rtt0 * USEC_PER_MSEC can wrap to 0 on 32-bit. An rtt0 above that (about 71 minutes) makes no sense anyway. Fixes: 835b3f0c0d7e ("[TCP]: Add TCP Hybla congestion control module.") Fixes: 740b0f1841f6 ("tcp: switch rtt estimations to usec resolution") Reported-by: VEGA <vega@nebusec.ai> Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev> Reviewed-by: Eric Dumazet <edumazet@kernel.org> Link: https://patch.msgid.link/20261008092641.140777-3-jiayuan.chen@linux.dev Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-10-13tcp_bic: fix divide by zero on max_increment == 0Jiayuan Chen
max_increment is how many packets cwnd can grow per RTT, so 0 makes no sense, and bictcp_update() divides by it. Reject values below 1 when the parameter is written. Fixes: 83803034f423 ("[TCP]: Add TCP BIC congestion control module.") Reported-by: VEGA <vega@nebusec.ai> Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev> Reviewed-by: Eric Dumazet <edumazet@kernel.org> Link: https://patch.msgid.link/20261008092641.140777-2-jiayuan.chen@linux.dev Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-10-13serial: hvc: use modern IRQ acquisition APIRosen Penev
Use platform_get_irq_optional() to be able to handle potential -EPROBE_DEFER and other errors. Move it earlier to avoid having to call kfree() on the global array. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://patch.msgid.link/20261003213148.137206-1-rosenp@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: core: shut down initialized port on removalIgor Putko
When a serial port configured as a console is opened and subsequently closed, tty_port_shutdown() skips invoking port->ops->shutdown() because port->console is true. As a result, tty_port_initialized() remains true and the port's interrupt handler stays registered in the irq subsystem. If the underlying device is later unbound or removed (e.g. via sysfs driver unbind or device hot-unplug), serial_core_remove_one_port() unregisters the console, frees uport->name via kfree(), and tears down the port without shutting it down or freeing its IRQ. Consequently, the irqaction descriptor remains registered in genirq with action->name pointing to freed memory. This triggers a use-after-free read whenever genirq accesses action->name, such as when reading /proc/interrupts: BUG: KASAN: slab-use-after-free in string+0x476/0x570 Call Trace: string+0x476/0x570 vsnprintf+0x422/0x1300 seq_printf+0x... show_interrupts+... Fix this by acquiring port->mutex in serial_core_remove_one_port() after console unregistration, clearing port->console under the mutex to prevent data races with concurrent tty_port_shutdown(), and invoking uart_shutdown(NULL, state) if the port remains initialized. This ensures that port->ops->shutdown() is called and the IRQ is freed before kfree(uport->name). Reported-by: syzbot+843bf2f48f4d12e6682e@syzkaller.appspotmail.com Cc: stable <stable@kernel.org> Closes: https://syzkaller.appspot.com/bug?extid=843bf2f48f4d12e6682e Fixes: 761ed4a94582 ("tty: serial_core: convert uart_close to use tty_port_close") Fixes: f7048b15900f ("tty: serial_core: Add name field to uart_port struct") Signed-off-by: Igor Putko <igorpetindev@gmail.com> Link: https://patch.msgid.link/20261003163337.45577-1-igorpetindev@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13tty: serial: pch_uart: use dmaengine_submit() instead of ->tx_submit()Frank Li
Replace direct dma_async_tx_descriptor->tx_submit() calls with the proper dmaengine_submit() API wrapper. Assisted-by: LLM Signed-off-by: Frank Li <Frank.Li@nxp.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20261002200927.236033-1-Frank.Li@oss.nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: sc16is7xx: fix data corruption due to unexpected xon/xoffMartin Fuzzey
The hardware supports automatically sending XON/OFF based on the FIFO status and that is already implemented by the driver. However that capability was not announced with the UPF_SOFT_FLOW bit. When the port is opened with the default of XON enabled the driver configures that in the hardware. If userspace does not want XON/OFF (which is normally the case) it will use TCSETS to disactivate it. However the serial core optimises this to only notify the driver if someting imporant has changed, and for XON/XOFF thit is only if the driver declares UPF_SOFT_FLOW. So we end up with unwanted XON/XOFF in the data stream. The problem only occurs if nothing else needed to be set by termios, ie if the user space requested values are the same as the default values, except for XON/XOFF. Since the default speed is 9600 this means that the problem only occurs when requesting 9600, otherwise the call to the driver will be made to change the speed, and that will also clear the XON/XOFF. As 9600 is quite rare these days that probably explains why this hasn't already been seen. It also only occurs on the first port open after boot since the subsequent opens will use the "logical state" set by TCSETS but not communicated to the driver the first time. Signed-off-by: Martin Fuzzey <martin.fuzzey@flowbird.group> Fixes: dfeae619d781 ("serial: sc16is7xx") Cc: stable@kernel.org Link: https://patch.msgid.link/20261001100534.1225894-1-martin.fuzzey@flowbird.group Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: 8250_bcm2835aux: Add support for RTS/CTS auto flow controlJan Čermák
The bcm2835aux mini UART can automatically de-assert RTS based on the RX FIFO fill level and gate the transmitter on CTS, but the driver never made use of it. Wire it up: - Enable AUTORTS/AUTOCTS (with the RTS4 threshold and inverted, i.e. conventional active-low, polarity) whenever CRTSCTS is set on ports declaring the "uart-has-rtscts" property, advertised via UPF_HARD_FLOW. - Gate the AUTORTS function on TIOCM_RTS in set_mctrl() so that clearing RTS (port close, TIOCMBIC, B0) actually de-asserts the pin while auto flow control is active. - Implement throttle()/unthrottle() by disabling the RX interrupts and letting the FIFO fill up, making the hardware de-assert RTS - the same approach as in 8250_omap. Re-sync this state on termios and rs485 changes, as those paths may re-enable the RX interrupts (or leave them disabled) behind the throttle's back. - Never enable auto flow control together with rs485, which uses RTS as the transceiver direction control. As the software CTS fallback of the serial core cannot work without a modem status interrupt, strip CRTSCTS whenever it cannot be handled in hardware. Keep it when a CTS GPIO is present, as the serial core's mctrl_gpio handling then delivers the interrupt and the software fallback keeps working. - Restore RXEN when rs485 is disabled, as the emulation may be torn down without the rs485_stop_tx() callback ever being called, which would leave the receiver disabled. Assisted-by: Claude:claude-fable-5 Signed-off-by: Jan Čermák <sairon@sairon.cz> Link: https://patch.msgid.link/20261001090432.1045270-1-sairon@sairon.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13serial: qcom-geni: power the console back up on system resumeDavid Heidelberg
The console holds a runtime PM reference on its port, which keeps the port powered while the tty is closed. On system suspend pm_runtime_force_suspend() powers the port down regardless, but a single reference makes pm_runtime_need_not_resume() report the port as not in use, so it is marked runtime suspended instead of being flagged for pm_runtime_force_resume(). On system resume the port therefore stays powered down while uart_resume_port() goes on to program the termios settings and re-enable the console. If the tty has been opened before, uart_resume_port() ends up in startup(), whose runtime PM reference powers the port up again, and only the register writes made before that are lost. If the tty has never been opened (no getty on the port, /dev/console backed by another console), nothing powers the port back up and the console stays dead after the first suspend. Resume the port explicitly before uart_resume_port() when the console was force suspended. Assisted-by: LLM Fixes: aee1f94dab13 ("serial: qcom-geni: remove .pm callback, use runtime PM in startup/shutdown") Signed-off-by: David Heidelberg <david@ixit.cz> Link: https://patch.msgid.link/20260918-qcom-geni-pm-v1-1-cb587e215607@ixit.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-10-13arm64: clear_page[s] using memsetLinus Walleij
There is no need to try to second-guess the compiler when clearing memory. Just call memset() like everyone else. Since memset() already has an architecture-local MOPS optimization, we do not need to do anything else to preserve the MOPS optimization. While at it, implement the shorthand for directly calling the new prototype clear_pages() for larger page chunks. No performance regressions can be seen, the fastpath benchmarks differences are in the noise. Usama Anjum tested next-20260821 with one warm-up and three repeats in four sessions, for a total of 12 measured runs. The commands were: perf bench mem memset -k 1GB -f default -s 16GB perf bench mem mmap -p 1GB -f demand -s 32GB -l 5 perf bench mem mmap -p 4KB -f demand -s 32GB -l 5 The results were: aws-m7g.metal: Benchmark Base bytes/sec Change with patch memset 1GB 63932542232.12 1.92% mmap 1GB 63272579168.03 -0.57% mmap 4KB 49692830849.48 -1.11% cesw-aarch64-ampereone-1s-a192-32x: Benchmark Base bytes/sec Change with patch memset 1GB 33895562998.71 0.25% mmap 1GB 34338454210.17 1.16% mmap 4KB 25687107580.90 -0.85% Assisted-by: LLM Suggested-by: Will Deacon <will@kernel.org> Tested-by: Usama Anjum <usama.anjum@arm.com> Link: https://lore.kernel.org/linux-arm-kernel/20260303-aarch64-clear-pages-v1-1-ad0c3ee9a555@kernel.org/ Link: https://lore.kernel.org/linux-arm-kernel/67ab6c51-4511-46ab-931b-a4323551147a@arm.com/ Signed-off-by: Linus Walleij <linusw@kernel.org> Reviewed-by: Leonardo Bras <leo.bras@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2026-10-13Merge tag 'ath-next-20261012' of ↵Johannes Berg
git://git.kernel.org/pub/scm/linux/kernel/git/ath/ath Jeff Johnson says: ================== ath.git patches for v7.4 (PR #3) Nothing special here, just a bunch of assorted cleanups and bug fixes spread across the ath family of Wi-Fi drivers. ================== Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mwifiex: validate GET_HW_SPEC TLV lengths before parsingJeff Chen
Validate TLV lengths before accessing TLV payloads in mwifiex_ret_get_hw_spec(). Signed-off-by: Jeff Chen <jeff.chen_1@nxp.com> Link: https://patch.msgid.link/20261012123624.3147417-3-jeff.chen_1@oss.nxp.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mwifiex: append hotfix number to firmware version stringJeff Chen
mwifiex_ret_get_hw_spec() parses and logs the FW_HOTFIX_VER_ID TLV, but the hotfix value is not stored in the adapter structure. As a result, the hotfix number never appears in the firmware version string returned by mwifiex_drv_get_driver_version(). Store the hotfix version from FW_HOTFIX_VER_ID and append it to the firmware version string. Assisted-by: LLM sparse Fixes: 7715d79553de ("wifi: mwifiex: Support firmware hotfix version in GET_HW_SPEC responses") Signed-off-by: Jeff Chen <jeff.chen_1@nxp.com> Link: https://patch.msgid.link/20261012123624.3147417-2-jeff.chen_1@oss.nxp.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: b43: fix use-after-free in b43_bcma_remove()Andreas Wendleder
b43_one_core_detach() frees the struct b43_wldev it is given the bus device of. b43_bcma_remove() then reads wldev->dev again to free the bus device, which is a read of freed memory. b43_ssb_remove() does not have the problem: it takes a copy of wldev->dev at the start. Do the same here. Fixes: 96838d61102a ("b43: Fix memory leaks in b43_bus_dev_ssb_init and b43_bus_dev_bcma_init") Cc: stable@vger.kernel.org Signed-off-by: Andreas Wendleder <gonsolo@gmail.com> Link: https://patch.msgid.link/20261013000124.48605-1-gonsolo@gmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mac80211: reserve MME tailroom for protected beaconsChien Wong
Beacon protection appends an MME to beacons, but the skb allocation does not reserve tailroom for it. If the available tailroom is too small, the crypto path drops the beacon. Two factors often mask this: the 256-byte TIM reservation is rarely fully used, and dev_alloc_skb() may round up the allocation, leaving extra tailroom. Neither guarantees enough room for the MME. Reserve enough room for the largest MME. Fixes: 0a3a84360b37 ("mac80211: Beacon protection using the new BIGTK (AP)") Signed-off-by: Chien Wong <m@xv97.com> Link: https://patch.msgid.link/20261012140738.70178-3-m@xv97.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mac80211: fix encryption tailroomChien Wong
BIP-CMAC-256 and BIP-GMAC append a 26-byte MME but mac80211 currently reserves only 18 bytes of encryption tailroom. Generating 26-byte MME may happen to work because the actual skb tailroom can exceed the requested amount. For example, dev_alloc_skb() rounds the allocation to kmalloc size buckets or alignment boundaries, and the extra space may cover the 8-byte shortfall. Reserve enough tailroom for the 26-byte MME. Fixes: 56c52da2d554 ("mac80111: Add BIP-CMAC-256 cipher") Signed-off-by: Chien Wong <m@xv97.com> Link: https://patch.msgid.link/20261012140738.70178-2-m@xv97.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mac80211: fix interface registration error path orderJohannes Berg
If we fail to register the inet/inet6 address notifiers, wiphy_unregister() is called before removing interface, but the default interface already exists at this point. This could also lead to a deadlock as wiphy_unregister() then waits for the interface to go away. Change the order to remove the interfaces first. Assisted-by: LLM Link: https://patch.msgid.link/20261011113308.c2cb32bf3160.Ib46993671ae3030950360ea378a507cef2bd4117@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mac80211: don't hold RTNL for rate control algoJohannes Berg
Back when we supported algorithm switching at runtime, this was needed for the open_count check. Now we don't have that any more, so the check and RTNL section can go away. Link: https://patch.msgid.link/20261011113308.0c5d35e2afea.I81141b28351e7c1ca23770616364346c33d7e08e@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: cfg80211: check wiphy name in wiphy_register()Johannes Berg
We currently check names already in wiphy_new_nm(), but that could technically race when two are registered at the same time. Currently that only happens with hwsim, which probably can't race, but it's confusing. Do the check later, with cfg80211_mutex held, so it'll always be precise. Assisted-by: LLM Link: https://patch.msgid.link/20261011113308.20e9fccb29da.I3a32d7fcfba5fd7b4ee378aa182d87e46f98c6e6@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mac80211_hwsim: get wiphy_name() after registrationJohannes Berg
The wiphy name registration is (or at least looks, since hwsim is the only user and doesn't have parallel ops) currently racy. In preparation for fixing that, grab wiphy_name() after the new radio is registered, since registration might change it. Link: https://patch.msgid.link/20261011113308.13b74d285682.I738d8363368771b442c3d9c683fef2c7e6c39da1@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: cfg80211: protect wiphy names with cfg80211_mutexJohannes Berg
The RTNL is only used for wiphy names to serialize checking for name collisions and setting the name, across all wiphys. Since the wiphy list can be walked under the cfg80211_mutex, use that instead. In nl80211_set_wiphy() this requires taking it before the wiphy mutex, and then the RTNL is no longer needed there at all if the netdev is looked up under RCU. Since the netns of the wiphy and its netdevs is now also stable under the cfg80211_mutex, only the netdev unregistering needs to be handled, by looking up the wdev again under the wiphy mutex. Assisted-by: LLM Link: https://patch.msgid.link/20261011113308.6cedefb201f4.I03ffe79f337b61ea8f91b91532d3dfb9497e0438@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: nl80211: avoid RTNL for wiphy/interface netlink dumpsJohannes Berg
The wiphy/interface netlink dumps only need the RTNL for the list and, possibly, filtering by netdev. This can be easily replaced now, do that. Link: https://patch.msgid.link/20261011113308.d2b68635eeec.I42540f72c38c1bbb6edd2396d6dcc6199f1bc8c0@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: cfg80211: switch wiphy netns under cfg80211_mutexJohannes Berg
Hold the cfg80211_mutex across the whole netns switch, so we can walk the wiphy list without worrying about a wiphy switching away to a different namespace underneath. This will allow removing RTNL from netlink dumps. Link: https://patch.msgid.link/20261011113308.89f391aea519.I7529b9055f522cfeb8a26ae3a85c1b71a98e8192@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: nl80211: don't hold RTNL for SET_SAR_SPECSJohannes Berg
There's no need for the RTNL for setting SAR specs, it seems to have just been added while I was removing the RTNL from most places. Just drop it. Link: https://patch.msgid.link/20261011113308.5a374e7bc350.I638c842c1639a8aa5d8207f784110b4a583aa7db@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: cfg80211: drop RTNL from disconnect_workJohannes Berg
The RTNL here is only needed for walking the wiphy list, which can be done under cfg80211_mutex instead, we just need to not take it in regulatory_hint_disconnect(), of which this is the only caller. Link: https://patch.msgid.link/20261011113308.3c7e002d1893.I31f6d1b43bb252b23b42c9b0375f557d90110dc6@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: nl80211: avoid RTNL in nl80211_get_reg_do()Johannes Berg
We don't need the RTNL here now, all the work can happen under RCU. Drop the RTNL and do it all under RCU instead. Link: https://patch.msgid.link/20261011113308.ef489f51e801.Iabc6383753a9e49ade17801c76fd5a91f7397475@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: nl80211: fix BSS reference leakJohannes Berg
In case nl80211_process_links() returns an error during a multi-link reconfiguration request, BSS entries might leak (if it already has one but fails on a further link). Fix it by jumping to the out label that handles this. Link: https://patch.msgid.link/20261010143543.184032-2-johannes@sipsolutions.net Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mac80211: implement unlocked STA statisticsJohannes Berg
Implement the new cfg80211 unlocked STA statistics. If the driver has an operation, then we need to always do the locked again, so return -EAGAIN unconditionally if it has a locked but not atomic operation, but drivers can implement the new atomic methods to provide needed data atomically (and can also return -EAGAIN). This should, given a driver without any ops or adding the atomic ops, reduce wiphy mutex contention. Link: https://patch.msgid.link/20261009201417.706683ff9d81.Ieb92e4c6599a198a116fa6a4f7944219c6d32932@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mac80211: refactor station statisticsJohannes Berg
Refactor the code a bit to pass around link-STA pointers instead of looking them up again and again. This will simplify the next changes, since otherwise all of these lookups would have to be converted to RCU-safe ones. It also simplifies the code generally. Link: https://patch.msgid.link/20261009201417.32dfeaa3c44d.I7ea45bf80dd493311670f8fdd018b5c4b770a4be@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: cfg80211: support unlocked station get/dumpJohannes Berg
Qualcomm reported that there can be a lot of lock contention on the wiphy mutex due to background processes dumping the station statistics. In many drivers (e.g. all mac80211 drivers without their own station statistics) it doesn't need to be locked, the data is never guaranteed to be fully consistent anyway given it's collected by concurrent TX/RX. Support unlocked get/dump station methods so that drivers can reduce lock contention by implementing these methods. As in the other cases, it's allowed to return -EAGAIN if a locked call is needed. Link: https://patch.msgid.link/20261009201417.e1d8a7d5f513.I9f6c2aff55861332c15069b9189bbf1e653648d5@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: nl80211: transmit control port frames without wiphy mutexJohannes Berg
Only mac80211 currently implements tx_control_port, and it no longer needs the wiphy mutex, so don't take it here. Link: https://patch.msgid.link/20261009201417.d89a3bc2b1ec.I30d12968a0d4ab7a4ac8d0995a9ab7583b0ce2ef@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mac80211: don't require wiphy mutex for control port TXJohannes Berg
The wiphy mutex was only required for the cookie counter, but that's been in cfg80211 for a while. The rest is just datapath, so can work under RCU, just need to be careful to handle interface type changes. Link: https://patch.msgid.link/20261009201417.dffb8da303aa.Ica8bba30018704a7c776f2ef08e6f2571cd8f8c4@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: nl80211: probe peers without wiphy mutexJohannes Berg
None of the drivers implementing probe_peer (mac80211, wil6210, nxpwifi) need the wiphy mutex for it, so we can just not take it. Document that as well. Link: https://patch.msgid.link/20261009201417.75233ff945c8.I2f462bfffa96feb8dcc4386bc35ebc25d877a92f@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mac80211: don't require wiphy mutex for probe_peerJohannes Berg
The comment about wiphy mutex is stale since the cookie cleanup, and everything else can be under RCU, we just have to drop the warning in case it races AP stop. Link: https://patch.msgid.link/20261009201417.4501c07ff31e.Ic87a72afcaea6b9a8c92f7f063bf33a2744a7992@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mac80211: implement mgmt_tx_unlocked()Johannes Berg
Implement the mgmt_tx_unlocked() method and accept frames that are transmitted on the operating channel with it, as they don't need further handling and can go out directly. For off-channel etc. just return -EAGAIN to fall back to the locked version. Link: https://patch.msgid.link/20261009201417.6491f3bdeb4e.Ib10158e2729f89719b551dadb8384e89b9dce688@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: mac80211: refactor mgmt frames TXJohannes Berg
Refactor ieee80211_mgmt_tx() into on-channel and frame building helper functions so we can later implement the new mgmt_tx_unlocked() method. Link: https://patch.msgid.link/20261009201417.a84e223f4998.I4848c3eeb2aaf327712233f0bdb38bb48bdbbba6@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: cfg80211: make cookie counter atomicJohannes Berg
The cookie counter is currently protected by the wiphy mutex, but in order to be able to transmit management frames without holding that, we need to assign cookies atomically. Link: https://patch.msgid.link/20261009201417.ec1dbc786a60.I83ec404d833100a798181234c797c558400c7145@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2026-10-13wifi: nl80211: allow mgmt frame TX without wiphy mutexJohannes Berg
Management frame transmissions need the wiphy mutex, but the normal transmit path doesn't, so most cases shouldn't need it here either. Due to checks, limit it to AP/GO for now. To support it, drivers must implement the new method mgmt_tx_unlocked(), and return -EAGAIN from that for requests that cannot be done without the wiphy mutex (e.g. off-channel in mac80211), then the operation will be retried with the wiphy mutex held. Link: https://patch.msgid.link/20261009201417.d376c87d429b.I4acfe051ab48ea9b012aa3bb26a62ab412a6eb9b@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>