All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>
Subject: [PATCH v4 1/8] serial: fake IRQ-regs context in poll handlers
Date: Tue, 20 Feb 2024 09:52:48 +0100	[thread overview]
Message-ID: <a3644326-7514-40f9-939c-2b6294dc5a8b@suse.com> (raw)
In-Reply-To: <e5f62a45-5b68-404d-908e-909f84f87b44@suse.com>

In preparation of dropping the register parameters from
serial_[rt]x_interrupt() and in turn from IRQ handler functions,
register state needs making available another way for the few key
handlers which need it. Fake IRQ-like state.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
The use of guest_cpu_user_regs() in dbc_uart_poll() is inconsistent with
other console poll functions we have, and it's unclear whether that's
actually generally correct. It is only for this reason that it doesn't
need changing here.

Andrew suggested to move set_irq_regs() to BUGFRAME_run_fn handling;
it's not clear to me whether that would be (a) correct from an abstract
pov (that's exception, not interrupt context after all) and (b) really
beneficial.
---
v4: Drop xhci-dbc.c change as unnecessary with dump_registers() falling
    back to using guest_cpu_user_regs() as of patch 2, i.e. ahead of
    serial_rx_interrupt() having its 2nd parameter dropped.
v2: New.

--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -1253,6 +1253,7 @@ static void cf_check _ehci_dbgp_poll(str
     unsigned long flags;
     unsigned int timeout = MICROSECS(DBGP_CHECK_INTERVAL);
     bool empty = false;
+    struct cpu_user_regs *old_regs;
 
     if ( !dbgp->ehci_debug )
         return;
@@ -1268,12 +1269,17 @@ static void cf_check _ehci_dbgp_poll(str
         spin_unlock_irqrestore(&port->tx_lock, flags);
     }
 
+    /* Mimic interrupt context. */
+    old_regs = set_irq_regs(regs);
+
     if ( dbgp->in.chunk )
         serial_rx_interrupt(port, regs);
 
     if ( empty )
         serial_tx_interrupt(port, regs);
 
+    set_irq_regs(old_regs);
+
     if ( spin_trylock_irqsave(&port->tx_lock, flags) )
     {
         if ( dbgp->state == dbgp_idle && !dbgp->in.chunk &&
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -211,10 +211,14 @@ static void cf_check __ns16550_poll(stru
 {
     struct serial_port *port = this_cpu(poll_port);
     struct ns16550 *uart = port->uart;
+    struct cpu_user_regs *old_regs;
 
     if ( uart->intr_works )
         return; /* Interrupts work - no more polling */
 
+    /* Mimic interrupt context. */
+    old_regs = set_irq_regs(regs);
+
     while ( ns_read_reg(uart, UART_LSR) & UART_LSR_DR )
     {
         if ( ns16550_ioport_invalid(uart) )
@@ -227,6 +231,7 @@ static void cf_check __ns16550_poll(stru
         serial_tx_interrupt(port, regs);
 
 out:
+    set_irq_regs(old_regs);
     set_timer(&uart->timer, NOW() + MILLISECS(uart->timeout_ms));
 }
 



  reply	other threads:[~2024-02-20  8:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20  8:51 [PATCH v4 0/8] limit passing around of cpu_user_regs Jan Beulich
2024-02-20  8:52 ` Jan Beulich [this message]
2024-02-21 23:01   ` [PATCH v4 1/8] serial: fake IRQ-regs context in poll handlers Julien Grall
2024-02-20  8:53 ` [PATCH v4 2/8] keyhandler: drop regs parameter from handle_keyregs() Jan Beulich
2024-02-20  8:53 ` [PATCH v4 3/8] serial: drop serial_rx_fn's regs parameter Jan Beulich
2024-02-20  8:53 ` [PATCH v4 4/8] PV-shim: drop pv_console_rx()'s " Jan Beulich
2024-02-20  8:55 ` [PATCH v4 5/8] serial: drop serial_[rt]x_interrupt()'s " Jan Beulich
2024-02-21 23:02   ` Julien Grall
2024-02-20  8:55 ` [PATCH v4 6/8] IRQ: drop regs parameter from handler functions Jan Beulich
2024-02-20  8:56 ` [PATCH v4 7/8] x86/APIC: drop regs parameter from direct vector " Jan Beulich
2024-02-20  8:57 ` [PATCH v4 8/8] consolidate do_bug_frame() / bug_fn_t Jan Beulich
2024-02-20  8:58 ` [PATCH v4 0/8] limit passing around of cpu_user_regs Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a3644326-7514-40f9-939c-2b6294dc5a8b@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.