All of lore.kernel.org
 help / color / mirror / Atom feed
From: dmkhn@proton.me
To: xen-devel@lists.xenproject.org
Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech,
	jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com,
	roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com
Subject: [PATCH v1 8/8] xen/console: introduce console_get_focus()
Date: Tue, 18 Mar 2025 23:37:04 +0000	[thread overview]
Message-ID: <20250318233617.849903-9-dmukhin@ford.com> (raw)
In-Reply-To: <20250318233617.849903-1-dmukhin@ford.com>

Add console_get_focus() as a console public API to the retrieve current
console owner domain ID.

Make console_{get,put}_domain() private and simplify vpl011 code a bit.

Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
 xen/arch/arm/vpl011.c      | 5 +----
 xen/drivers/char/console.c | 9 +++++++--
 xen/include/xen/console.h  | 3 +--
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c
index 147958eee8..9ce6151c2a 100644
--- a/xen/arch/arm/vpl011.c
+++ b/xen/arch/arm/vpl011.c
@@ -78,12 +78,11 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data)
     unsigned long flags;
     struct vpl011 *vpl011 = &d->arch.vpl011;
     struct vpl011_xen_backend *intf = vpl011->backend.xen;
-    struct domain *input = console_get_domain();
 
     VPL011_LOCK(d, flags);
 
     intf->out[intf->out_prod++] = data;
-    if ( d == input )
+    if ( d->domain_id == console_get_focus() )
     {
         if ( intf->out_prod == 1 )
         {
@@ -123,8 +122,6 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data)
     vpl011_update_interrupt_status(d);
 
     VPL011_UNLOCK(d, flags);
-
-    console_put_domain(input);
 }
 
 /*
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 0e2349a868..906a0ae996 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -484,12 +484,12 @@ static struct domain *console_get_domain_by_id(domid_t domid)
     return NULL;
 }
 
-struct domain *console_get_domain(void)
+static struct domain *console_get_domain(void)
 {
     return console_get_domain_by_id(console_focus);
 }
 
-void console_put_domain(struct domain *d)
+static void console_put_domain(struct domain *d)
 {
     if ( d )
         rcu_unlock_domain(d);
@@ -523,6 +523,11 @@ static int console_set_focus(domid_t domid)
     return 0;
 }
 
+domid_t console_get_focus(void)
+{
+    return console_focus;
+}
+
 /*
  * Switch console focus.
  * Rotates input focus among Xen, dom0 and boot-time created domUs while
diff --git a/xen/include/xen/console.h b/xen/include/xen/console.h
index 83cbc9fbda..19da2b755c 100644
--- a/xen/include/xen/console.h
+++ b/xen/include/xen/console.h
@@ -32,8 +32,7 @@ void console_end_sync(void);
 void console_start_log_everything(void);
 void console_end_log_everything(void);
 
-struct domain *console_get_domain(void);
-void console_put_domain(struct domain *d);
+domid_t console_get_focus(void);
 
 /*
  * Steal output from the console. Returns +ve identifier, else -ve error.
-- 
2.34.1




  parent reply	other threads:[~2025-03-18 23:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18 23:36 [PATCH v1 0/8] xen/console: cleanup console input switch logic dmkhn
2025-03-18 23:36 ` [PATCH v1 1/8] xen/console: fix trailing whitespaces dmkhn
2025-03-19  9:45   ` Jan Beulich
2025-03-18 23:36 ` [PATCH v1 2/8] xen/console: introduce console input permission dmkhn
2025-03-26 13:44   ` Jan Beulich
2025-03-29  0:03     ` Denis Mukhin
2025-03-18 23:36 ` [PATCH v1 3/8] xen/domain: introduce domid_top dmkhn
2025-03-26 13:52   ` Jan Beulich
2025-03-18 23:36 ` [PATCH v1 4/8] xen/domain: introduce domid_alloc() dmkhn
2025-03-26 13:56   ` Jan Beulich
2025-03-18 23:36 ` [PATCH v1 5/8] xen/console: rename switch_serial_input() to console_switch_focus() dmkhn
2025-03-26 13:58   ` Jan Beulich
2025-03-18 23:36 ` [PATCH v1 6/8] xen/console: rename console_rx to console_focus dmkhn
2025-03-26 14:00   ` Jan Beulich
2025-03-18 23:37 ` [PATCH v1 7/8] xen/console: introduce console_set_focus() dmkhn
2025-03-19 19:53   ` Denis Mukhin
2025-03-26 14:28     ` Jan Beulich
2025-03-26 14:32   ` Jan Beulich
2025-03-18 23:37 ` dmkhn [this message]
2025-03-19 19:52 ` [PATCH v1 0/8] xen/console: cleanup console input switch logic Denis Mukhin

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=20250318233617.849903-9-dmukhin@ford.com \
    --to=dmkhn@proton.me \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=dmukhin@ford.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.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.