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

[PATCH v3 3/4] xen/drivers/char/cadence-uart: fix IRQ registration failure propagation


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>
  • Date: Wed, 22 Apr 2026 09:33:14 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pZFIzJHIEhj0/DcfLKHa9Srjz1IUu8KC+j6B9uuxT7A=; b=eCtyB872bUfTOnXKpeGynGhsiFvkrs9gzArU1jnYqXm+XLRSaxV5uLNPYFgpKK8tGHzxcWA4Ok6JIdmfWqTm77SbmJ2Ryzl7gigkiVrEW3J/ENyycKmZMaeqCWidKc33bnueY/p31WLz1ZO7iGkK2+Qy770mjY75Ru0x4msaTI4yeXAKtvYoXjinNfQRQVbLkxGDCUis9TJw2vEYbqzf8CIJhcixb4VMo3RFg2zCLSCoET3GOkZTTvF10Cyyjmq/ZLULq0Lxf3Nqow0QEj8UsbnhNxfoDRaEJ02H6y6CBpPcSII7VS5luAUXGe9XxIqtnC8/GB2hWf97O5h+hj7EzQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dnDgQtjIk5mjUzWBH84HHV1XHL1DX9kNXewpHWWG+gR38xOc9N8yembUMnQhVI2F8nNCchaxVe2pxnnwVUXV7OHwWoH9nAGCfd5gfF0fvVzy6VEjkcRap51FYMGI+PhTWaTOJ8BgIvk0Z11TOkf9VWr6uCaS9xca3dI0AvA0SWLqnkj0Q5cx0lv5vM4XDLN6TW7TcfJnHrAAenrhI+iSpU2EGYyHEfbGaYJ/eaYG2+qTvKvjwqGTFkLsKhWJjaxpTZq1qnEbEe3Qeus3Vpkt13K8+cWxQGn6ivu83JcFjEduDFeIyLmnglz7FZMkG+HC61EjguKhxBUVBWoF4Avz0Q==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>
  • Delivery-date: Wed, 22 Apr 2026 09:33:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHc0jsKDUGFeFpJykGixIc8urTLVg==
  • Thread-topic: [PATCH v3 3/4] xen/drivers/char/cadence-uart: fix IRQ registration failure propagation

In cuart_init_postirq(), two code paths could reach the
interrupt-enable write to IER without a handler being registered:

- When no valid IRQ number was provided (uart->irq <= 0), the original
  positive-condition guard (if uart->irq > 0) skipped the irqaction
  setup but still fell through to the IER write, enabling the receive
  data interrupt with no handler installed.

- When setup_irq() returned an error, only an error message was
  printed and execution continued to the IER write, arming the
  receive hardware interrupt line with no handler to service it. On
  platforms where the GIC receives this asserted line, the result is
  either repeated spurious-interrupt warnings or an unhandled
  interrupt fault.

Restructure cuart_init_postirq() to use early returns in both error
paths.

Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@xxxxxxxx>
---

Changes in v3:
- clear pending error interrupts before setup_irq call for cadence uart
- change uart->irq <= 0 to uart->irq == 0 since irq is unsigned

 xen/drivers/char/cadence-uart.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/xen/drivers/char/cadence-uart.c b/xen/drivers/char/cadence-uart.c
index b2f379833f..8961d39de1 100644
--- a/xen/drivers/char/cadence-uart.c
+++ b/xen/drivers/char/cadence-uart.c
@@ -72,19 +72,25 @@ static void __init cuart_init_postirq(struct serial_port 
*port)
     struct cuart *uart = port->uart;
     int rc;
 
-    if ( uart->irq > 0 )
-    {
-        uart->irqaction.handler = cuart_interrupt;
-        uart->irqaction.name    = "cadence-uart";
-        uart->irqaction.dev_id  = port;
-        if ( (rc = setup_irq(uart->irq, 0, &uart->irqaction)) != 0 )
-            printk("ERROR: Failed to allocate cadence-uart IRQ %d\n", 
uart->irq);
-    }
+    /* Don't unmask interrupts if no valid irq was provided */
+    if ( uart->irq == 0 )
+        return;
+
+    uart->irqaction.handler = cuart_interrupt;
+    uart->irqaction.name    = "cadence-uart";
+    uart->irqaction.dev_id  = port;
 
     /* Clear pending error interrupts */
     cuart_write(uart, R_UART_RTRIG, 1);
     cuart_write(uart, R_UART_CISR, ~0);
 
+    if ( (rc = setup_irq(uart->irq, 0, &uart->irqaction)) != 0 )
+    {
+        printk("ERROR: Failed to allocate cadence-uart IRQ %d\n", uart->irq);
+        /* Do not unmask interrupts if irq handler wasn't set */
+        return;
+    }
+
     /* Unmask interrupts */
     cuart_write(uart, R_UART_IDR, ~0);
     cuart_write(uart, R_UART_IER, UART_SR_INTR_RTRIG);
-- 
2.43.0



 


Rackspace

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