[Xen-devel,13/27,v8] xen/arm: vpl011: Add a new maybe_add_console_evtchn_fd function in xenconsole

Message ID 1503910570-24427-14-git-send-email-bhupinder.thakur@linaro.org
State Superseded
Headers show
Series
  • SBSA UART emulation support in Xen
Related show

Commit Message

Bhupinder Thakur Aug. 28, 2017, 8:55 a.m.
This patch introduces a new maybe_add_console_evtchn_fd function. This
function adds the console event channel FD to list of polled FDs.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.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 v6:
- Renamed add_console_evtchn_fd to maybe_add_console_evtchn_fd since it 
  adds the FD to the poll list conditionally.

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

 tools/console/daemon/io.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

Patch

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 0009bbe..3483252 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -1047,6 +1047,26 @@  static void reset_fds(void)
 		memset(fds, 0, sizeof(struct pollfd) * current_array_size);
 }
 
+static void maybe_add_console_evtchn_fd(struct console *con, void *data)
+{
+	long long next_timeout = *((long long *)data);
+
+	if (con->event_count >= RATE_LIMIT_ALLOWANCE) {
+		/* Determine if we're going to be the next time slice to expire */
+		if (!next_timeout ||
+		    con->next_period < next_timeout)
+			next_timeout = con->next_period;
+	} else if (con->xce_handle != NULL) {
+		if (buffer_available(con)) {
+			int evtchn_fd = xenevtchn_fd(con->xce_handle);
+			con->xce_pollfd_idx = set_fds(evtchn_fd,
+						      POLLIN|POLLPRI);
+		}
+	}
+
+	*((long long *)data) = next_timeout;
+}
+
 void handle_io(void)
 {
 	int ret;
@@ -1124,18 +1144,7 @@  void handle_io(void)
 		for (d = dom_head; d; d = d->next) {
 			struct console *con = &d->console;
 
-			if (con->event_count >= RATE_LIMIT_ALLOWANCE) {
-				/* Determine if we're going to be the next time slice to expire */
-				if (!next_timeout ||
-				    con->next_period < next_timeout)
-					next_timeout = con->next_period;
-			} else if (con->xce_handle != NULL) {
-			        if (buffer_available(con)) {
-					int evtchn_fd = xenevtchn_fd(con->xce_handle);
-					con->xce_pollfd_idx = set_fds(evtchn_fd,
-								    POLLIN|POLLPRI);
-				}
-			}
+			maybe_add_console_evtchn_fd(con, (void *)&next_timeout);
 
 			if (con->master_fd != -1) {
 				short events = 0;