Re: [PATCH 24/24] serial: stm32: don't report a wakeup to a closed tty

From: Jiri Slaby

Date: Fri Oct 30 2026 - 03:07:17 EST


On 29. 10. 26, 12:56, Ilpo Järvinen wrote:
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -872,8 +872,15 @@ static irqreturn_t stm32_usart_interrupt(int irq,
void *ptr)
writel_relaxed(USART_ICR_WUCF,
port->membase + ofs->icr);
stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_WUFIE);
- if (irqd_is_wakeup_set(irq_get_irq_data(port->irq)))
- pm_wakeup_event(tport->tty->dev, 0);
+ if (irqd_is_wakeup_set(irq_get_irq_data(port->irq))) {
+ struct tty_struct *tty = tty_port_tty_get(tport);
+
+ /* A console stays set up after the last close */
+ if (tty) {
+ pm_wakeup_event(tty->dev, 0);
+ tty_kref_put(tty);
+ }
+ }

Could we like add a helper into serial core to do this tty wakeup dance?
It is duplicated in quite many of these patches.

Likely. Or use scoped_guard(tty_port_tty) at minimum.

Also the irqd_is_wakeup_set(irq_get_irq_data(xx)) part seemed duplicated
so it's not just about the reference dance what is duplicated in this
fragment.

Sure, I was not disputing that.

--
js
suse labs