All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] console+serial: don't open-code IRQ-safe locking primitives
@ 2026-06-29 14:04 Jan Beulich
  2026-06-29 14:44 ` Andrew Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2026-06-29 14:04 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
	Michal Orzel, Roger Pau Monné

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -1010,8 +1010,7 @@ vprintk_common(const char *fmt, va_list
     unsigned long flags;
 
     /* console_lock can be acquired recursively from __printk_ratelimit(). */
-    local_irq_save(flags);
-    rspin_lock(&console_lock);
+    flags = rspin_lock_irqsave(&console_lock);
     state = &this_cpu(state);
 
     (void)vsnprintf(buf, sizeof(buf), fmt, args);
@@ -1047,8 +1046,7 @@ vprintk_common(const char *fmt, va_list
         state->continued = 1;
     }
 
-    rspin_unlock(&console_lock);
-    local_irq_restore(flags);
+    rspin_unlock_irqrestore(&console_lock, flags);
 }
 
 void vprintk(const char *fmt, va_list args)
--- a/xen/drivers/char/serial.c
+++ b/xen/drivers/char/serial.c
@@ -76,17 +76,15 @@ void serial_tx_interrupt(struct serial_p
     int i, n;
     unsigned long flags;
 
-    local_irq_save(flags);
-
     /*
      * Avoid spinning for a long time: if there is a long-term lock holder
      * then we know that they'll be stuffing bytes into the transmitter which
      * will therefore not be empty for long.
      */
-    while ( !spin_trylock(&port->tx_lock) )
+    while ( !spin_trylock_irqsave(&port->tx_lock, flags) )
     {
         if ( port->driver->tx_ready(port) <= 0 )
-            goto out;
+            return;
         cpu_relax();
     }
 
@@ -94,7 +92,6 @@ void serial_tx_interrupt(struct serial_p
     {
         /* Disable TX. nothing to send */
         serial_stop_tx(port);
-        spin_unlock(&port->tx_lock);
         goto out;
     }
     else
@@ -112,10 +109,8 @@ void serial_tx_interrupt(struct serial_p
     if ( i && port->driver->flush )
         port->driver->flush(port);
 
-    spin_unlock(&port->tx_lock);
-
  out:
-    local_irq_restore(flags);
+    spin_unlock_irqrestore(&port->tx_lock, flags);
 }
 
 static void __serial_putc(struct serial_port *port, char c)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] console+serial: don't open-code IRQ-safe locking primitives
  2026-06-29 14:04 [PATCH] console+serial: don't open-code IRQ-safe locking primitives Jan Beulich
@ 2026-06-29 14:44 ` Andrew Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2026-06-29 14:44 UTC (permalink / raw)
  To: Jan Beulich, xen-devel@lists.xenproject.org
  Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
	Michal Orzel, Roger Pau Monné

On 29/06/2026 3:04 pm, Jan Beulich wrote:
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-29 14:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 14:04 [PATCH] console+serial: don't open-code IRQ-safe locking primitives Jan Beulich
2026-06-29 14:44 ` Andrew Cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.