All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bhupinder Thakur <bhupinder.thakur@linaro.org>
To: xen-devel@lists.xenproject.org
Cc: Wei Liu <wei.liu2@citrix.com>,
	Julien Grall <julien.grall@arm.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [PATCH 16/27 v8] xen/arm: vpl011: Add a new handle_console_ring function in xenconsole
Date: Mon, 28 Aug 2017 14:25:59 +0530	[thread overview]
Message-ID: <1503910570-24427-17-git-send-email-bhupinder.thakur@linaro.org> (raw)
In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org>

This patch introduces a new handle_console_ring function. This function
reads the data from the ring buffer on receiving an event.

The initialization of event channel poll fd to -1 is moved inside the
handle_console_ring function as they are related. There should be no
change in the behavior as there is no functional change.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

Changes since v5:
- Split this change in a separate patch.

 tools/console/daemon/io.c | 40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 2dcaee6..c361b42 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -934,17 +934,23 @@ static void console_evtchn_unmask(struct console *con, void *data)
 	}
 }
 
-static void handle_ring_read(struct domain *dom)
+static void handle_ring_read(struct console *con)
 {
 	xenevtchn_port_or_error_t port;
-	struct console *con = &dom->console;
 
-	if (dom->is_dead)
+	if (con->d->is_dead)
 		return;
 
 	if ((port = xenevtchn_pending(con->xce_handle)) == -1)
 		return;
 
+	if (port != con->local_port) {
+		dolog(LOG_ERR,
+		      "Event received for invalid port %d, Expected port is %d\n",
+		      port, con->local_port);
+		return;
+	}
+
 	con->event_count++;
 
 	buffer_append(con);
@@ -953,6 +959,21 @@ static void handle_ring_read(struct domain *dom)
 		(void)xenevtchn_unmask(con->xce_handle, port);
 }
 
+static void handle_console_ring(struct console *con)
+{
+	if (con->event_count < RATE_LIMIT_ALLOWANCE) {
+		if (con->xce_handle != NULL &&
+		    con->xce_pollfd_idx != -1 &&
+		    !(fds[con->xce_pollfd_idx].revents &
+		      ~(POLLIN|POLLOUT|POLLPRI)) &&
+		    (fds[con->xce_pollfd_idx].revents &
+		     POLLIN))
+			handle_ring_read(con);
+	}
+
+	con->xce_pollfd_idx = -1;
+}
+
 static void handle_xs(void)
 {
 	char **vec;
@@ -1236,15 +1257,8 @@ void handle_io(void)
 			struct console *con = &d->console;
 
 			n = d->next;
-			if (con->event_count < RATE_LIMIT_ALLOWANCE) {
-				if (con->xce_handle != NULL &&
-				    con->xce_pollfd_idx != -1 &&
-				    !(fds[con->xce_pollfd_idx].revents &
-				      ~(POLLIN|POLLOUT|POLLPRI)) &&
-				      (fds[con->xce_pollfd_idx].revents &
-				       POLLIN))
-				    handle_ring_read(d);
-			}
+
+			handle_console_ring(con);
 
 			if (con->master_fd != -1 && con->master_pollfd_idx != -1) {
 				if (fds[con->master_pollfd_idx].revents &
@@ -1261,7 +1275,7 @@ void handle_io(void)
 				}
 			}
 
-			con->xce_pollfd_idx = con->master_pollfd_idx = -1;
+			con->master_pollfd_idx = -1;
 
 			if (d->last_seen != enum_pass)
 				shutdown_domain(d);
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-08-28  8:57 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28  8:55 [PATCH 00/27 v8] SBSA UART emulation support in Xen Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 01/27 v8] xen/arm: vpl011: Define common ring buffer helper functions in console.h Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 02/27 v8] xen/arm: vpl011: Add SBSA UART emulation in Xen Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 03/27 v8] xen/arm: vpl011: Allocate a new GFN in the toolstack for vuart Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 04/27 v8] xen/arm: vpl011: Add support for vuart in libxl Bhupinder Thakur
2017-09-07 10:54   ` Andre Przywara
2017-08-28  8:55 ` [PATCH 05/27 v8] xen/arm: vpl011: Rearrange xen header includes in alphabetical order in domctl.c Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 06/27 v8] xen/arm: vpl011: Add a new domctl API to initialize vpl011 Bhupinder Thakur
2017-08-28  9:09   ` Jan Beulich
2017-09-14  6:46     ` Bhupinder Thakur
2017-08-28 16:39   ` Wei Liu
2017-08-28 16:52   ` Wei Liu
2017-08-28  8:55 ` [PATCH 07/27 v8] xen/arm: vpl011: Add a new vuart node in the xenstore Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 08/27 v8] xen/arm: vpl011: Modify xenconsole to define and use a new console structure Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 09/27 v8] xen/arm: vpl011: Rename the console structure field conspath to xspath Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 10/27 v8] xen/arm: vpl011: Modify xenconsole functions to take console structure as input Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 11/27 v8] xen/arm: vpl011: Add a new console_init function in xenconsole Bhupinder Thakur
2017-08-28 16:40   ` Wei Liu
2017-08-28  8:55 ` [PATCH 12/27 v8] xen/arm: vpl011: Add a new buffer_available " Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 13/27 v8] xen/arm: vpl011: Add a new maybe_add_console_evtchn_fd " Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 14/27 v8] xen/arm: vpl011: Add a new maybe_add_console_tty_fd " Bhupinder Thakur
2017-08-28  8:55 ` [PATCH 15/27 v8] xen/arm: vpl011: Add a new console_evtchn_unmask " Bhupinder Thakur
2017-08-28  8:55 ` Bhupinder Thakur [this message]
2017-08-28  8:56 ` [PATCH 17/27 v8] xen/arm: vpl011: Add a new handle_console_tty " Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 18/27 v8] xen/arm: vpl011: Add a new console_cleanup " Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 19/27 v8] xen/arm: vpl011: Add a new console_open_log " Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 20/27 v8] xen/arm: vpl011: Add a new console_close_evtchn " Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 21/27 v8] xen/arm: vpl011: Add support for multiple consoles " Bhupinder Thakur
2017-08-28 16:50   ` Wei Liu
2017-08-28  8:56 ` [PATCH 22/27 v8] xen/arm: vpl011: Add support for vuart console " Bhupinder Thakur
2017-08-28  9:11   ` Jan Beulich
2017-09-04 16:28     ` Bhupinder Thakur
2017-09-05  5:29       ` Jan Beulich
2017-09-05  9:31       ` Wei Liu
2017-09-06 17:29         ` Bhupinder Thakur
2017-09-07  9:08           ` Wei Liu
2017-09-12  7:25             ` Bhupinder Thakur
2017-09-12  8:54               ` Wei Liu
2017-08-28  8:56 ` [PATCH 23/27 v8] xen/arm: vpl011: Add a new vuart console type to xenconsole client Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 24/27 v8] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 25/27 v8] xen/arm: vpl011: Update documentation for vuart console support Bhupinder Thakur
2017-08-28  8:56 ` [PATCH 26/27 v8] xen/arm: vpl011: Correct the logic for asserting/de-asserting SBSA UART TX interrupt Bhupinder Thakur
2017-09-07 14:37   ` Andre Przywara
2017-09-11 16:39     ` Bhupinder Thakur
2017-09-12 14:35     ` Julien Grall
2017-09-12 14:58   ` Julien Grall
2017-08-28  8:56 ` [PATCH 27/27 v8] xen/arm: vpl011: Fix the slow early console SBSA UART output Bhupinder Thakur

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=1503910570-24427-17-git-send-email-bhupinder.thakur@linaro.org \
    --to=bhupinder.thakur@linaro.org \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=wei.liu2@citrix.com \
    --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.