[PATCH v1 1/2] drivers/ehci-dbgp: remove use of run_in_exception_handle()

dmkhn@proton.me posted 2 patches 3 months ago
[PATCH v1 1/2] drivers/ehci-dbgp: remove use of run_in_exception_handle()
Posted by dmkhn@proton.me 3 months ago
From: Denis Mukhin <dmukhin@ford.com> 

Polling is relevant for early boot only where facilities requiring
run_in_exception_handler() are not used (e.g. 'd' keyhandler).

Rework ehci_dbgp_poll() by droppping use of run_in_exception_handler().

The ground work for run_in_exception_handler() removal was done under XSA-453:
https://xenbits.xen.org/xsa/advisory-453.html

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
 xen/drivers/char/ehci-dbgp.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index a5c79f56fcf4..ab70e53195eb 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -1245,17 +1245,13 @@ static int cf_check ehci_dbgp_getc(struct serial_port *port, char *pc)
     return 1;
 }
 
-/* Safe: ehci_dbgp_poll() runs as timer handler, so not reentrant. */
-static struct serial_port *poll_port;
-
-static void cf_check _ehci_dbgp_poll(const struct cpu_user_regs *regs)
+static void cf_check ehci_dbgp_poll(void *data)
 {
-    struct serial_port *port = poll_port;
+    struct serial_port *port = data;
     struct ehci_dbgp *dbgp = port->uart;
     unsigned long flags;
     unsigned int timeout = MICROSECS(DBGP_CHECK_INTERVAL);
     bool empty = false;
-    const struct cpu_user_regs *old_regs;
 
     if ( !dbgp->ehci_debug )
         return;
@@ -1271,17 +1267,12 @@ static void cf_check _ehci_dbgp_poll(const struct cpu_user_regs *regs)
         spin_unlock_irqrestore(&port->tx_lock, flags);
     }
 
-    /* Mimic interrupt context. */
-    old_regs = set_irq_regs(regs);
-
     if ( dbgp->in.chunk )
         serial_rx_interrupt(port);
 
     if ( empty )
         serial_tx_interrupt(port);
 
-    set_irq_regs(old_regs);
-
     if ( spin_trylock_irqsave(&port->tx_lock, flags) )
     {
         if ( dbgp->state == dbgp_idle && !dbgp->in.chunk &&
@@ -1298,12 +1289,6 @@ static void cf_check _ehci_dbgp_poll(const struct cpu_user_regs *regs)
     set_timer(&dbgp->timer, NOW() + timeout);
 }
 
-static void cf_check ehci_dbgp_poll(void *data)
-{
-    poll_port = data;
-    run_in_exception_handler(_ehci_dbgp_poll);
-}
-
 static bool ehci_dbgp_setup_preirq(struct ehci_dbgp *dbgp)
 {
     if ( !ehci_dbgp_setup(dbgp) )
-- 
2.34.1
Re: [PATCH v1 1/2] drivers/ehci-dbgp: remove use of run_in_exception_handle()
Posted by Jan Beulich 3 months ago
On 28.07.2025 22:23, dmkhn@proton.me wrote:
> From: Denis Mukhin <dmukhin@ford.com> 
> 
> Polling is relevant for early boot only where facilities requiring
> run_in_exception_handler() are not used (e.g. 'd' keyhandler).

I fear I don't understand this statement: How is polling relevant for
early boot only? If the IRQ isn't found to work, we continue using
polling perhaps for the entire lifetime of a system. For ns16550 I
know I've seen such systems (especially before MSI support was added).
Note that there even is a way to suppress use of an IRQ via command
line option (setting the IRQ field of the option to 0). That implies
that polling is going to be used forever. For EHCI there isn't even
an IRQ to use.

Jan