[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] console+serial: don't open-code IRQ-safe locking primitives



commit 55ba831b14ea6f501c85974e0155169518b881ce
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Jul 1 14:13:59 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Jul 1 14:13:59 2026 +0200

    console+serial: don't open-code IRQ-safe locking primitives
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/drivers/char/console.c |  6 ++----
 xen/drivers/char/serial.c  | 11 +++--------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index bcd6d26149..dbda7f2596 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -1010,8 +1010,7 @@ vprintk_common(const char *fmt, va_list args, const char 
*prefix)
     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 args, const char 
*prefix)
         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)
diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
index adb312d796..bbbe758788 100644
--- a/xen/drivers/char/serial.c
+++ b/xen/drivers/char/serial.c
@@ -76,17 +76,15 @@ void serial_tx_interrupt(struct serial_port *port)
     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_port *port)
     {
         /* 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_port *port)
     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)
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.