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

[xen staging] xen/drivers/char: fix SCIF IRQ registration failure propagation



commit d4873af5348386f8dee4a7bfa102b5443e1078dc
Author:     Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>
AuthorDate: Thu Apr 23 16:11:41 2026 +0000
Commit:     Michal Orzel <michal.orzel@xxxxxxx>
CommitDate: Mon Apr 27 08:52:38 2026 +0200

    xen/drivers/char: fix SCIF IRQ registration failure propagation
    
    In scif_uart_init_postirq(), when setup_irq() returns an error the
    failure was only logged via dprintk() and execution continued,
    unconditionally writing TIE|RIE|REIE into the Serial Control Register
    (SCSCR). This armed all three hardware interrupt lines (TX FIFO empty,
    RX data ready, receive error) with no handler registered to service
    them. On platforms where the GIC receives these asserted lines, the
    result is either repeated spurious-interrupt warnings or an unhandled
    interrupt fault.
    
    The fix adds an early return inside the error branch. The
    interrupt-enable write to SCSCR is skipped entirely when no handler is
    registered.
    
    SCIF TX continues to operate correctly after this change. The Xen
    serial framework never calls serial_async_transmit() for SCIF, so
    port->txbuf is always NULL. This causes __serial_putc() to take the
    synchronous finite-capacity path, which polls the SCFSR_TDFE hardware
    flag directly and does not depend on the interrupt mechanism. RX
    wouldn't work if irq wasn't registered.
    
    As a secondary clean-up, the hardware error-flag clearing sequence is
    moved to before the setup_irq() call so that error bits accumulated
    since init_preirq() are cleared unconditionally, regardless of whether
    IRQ registration succeeds.
    
    Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@xxxxxxxx>
    Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 xen/drivers/char/scif-uart.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c
index 888821a3b8..350d5f14b9 100644
--- a/xen/drivers/char/scif-uart.c
+++ b/xen/drivers/char/scif-uart.c
@@ -187,16 +187,20 @@ static void __init scif_uart_init_postirq(struct 
serial_port *port)
     uart->irqaction.name    = "scif_uart";
     uart->irqaction.dev_id  = port;
 
-    if ( (rc = setup_irq(uart->irq, 0, &uart->irqaction)) != 0 )
-        dprintk(XENLOG_ERR, "Failed to allocated scif_uart IRQ %d\n",
-                uart->irq);
-
     /* Clear all errors */
     if ( scif_readw(uart, params->status_reg) & params->error_mask )
         scif_writew(uart, params->status_reg, ~params->error_mask);
     if ( scif_readw(uart, params->overrun_reg) & params->overrun_mask )
         scif_writew(uart, params->overrun_reg, ~params->overrun_mask);
 
+    if ( (rc = setup_irq(uart->irq, 0, &uart->irqaction)) != 0 )
+    {
+        dprintk(XENLOG_ERR, "Failed to allocated scif_uart IRQ %u\n",
+                uart->irq);
+        /* Do not unmask interrupts if irq handler wasn't set */
+        return;
+    }
+
     /* Enable TX/RX and Error Interrupts  */
     scif_writew(uart, SCIF_SCSCR, scif_readw(uart, SCIF_SCSCR) |
                 params->irq_flags);
--
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®.