diff mbox series

[Xen-devel,16/25,v6] xen/arm: vpl011: Add a new handle_console_ring function in xenconsole

Message ID 1500296815-10243-17-git-send-email-bhupinder.thakur@linaro.org
State Superseded
Headers show
Series SBSA UART emulation support in Xen | expand

Commit Message

Bhupinder Thakur July 17, 2017, 1:06 p.m. UTC
This patch introduces a new handle_console_ring function. This function
reads the data from the ring buffer on receiving an event.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
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 | 41 ++++++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 13 deletions(-)

Comments

Wei Liu July 18, 2017, 1:12 p.m. UTC | #1
On Mon, Jul 17, 2017 at 06:36:46PM +0530, Bhupinder Thakur wrote:
> This patch introduces a new handle_console_ring function. This function
> reads the data from the ring buffer on receiving an event.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> ---
> 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 | 41 ++++++++++++++++++++++++++++-------------
>  1 file changed, 28 insertions(+), 13 deletions(-)
> 
> diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
> index c272fe6..775fb04 100644
> --- a/tools/console/daemon/io.c
> +++ b/tools/console/daemon/io.c
> @@ -935,17 +935,24 @@ 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)
> +	{

Coding style.

> +		dolog(LOG_ERR, 

Trailing space.

> +		      "Event received for invalid port %d, Expected port is %d\n",
> +		      port, con->local_port);
> +		return;
> +	}
> +
>  	con->event_count++;
>  
>  	buffer_append(con);
> @@ -954,6 +961,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;

It is worth noting in the commit message that you move the setting to -1
here but there shouldn't be any change in behaviour.
Stefano Stabellini July 18, 2017, 7:51 p.m. UTC | #2
On Mon, 17 Jul 2017, Bhupinder Thakur wrote:
> This patch introduces a new handle_console_ring function. This function
> reads the data from the ring buffer on receiving an event.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> 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 | 41 ++++++++++++++++++++++++++++-------------
>  1 file changed, 28 insertions(+), 13 deletions(-)
> 
> diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
> index c272fe6..775fb04 100644
> --- a/tools/console/daemon/io.c
> +++ b/tools/console/daemon/io.c
> @@ -935,17 +935,24 @@ 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);
> @@ -954,6 +961,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;
> @@ -1238,15 +1260,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 &
> @@ -1263,7 +1278,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
>
diff mbox series

Patch

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index c272fe6..775fb04 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -935,17 +935,24 @@  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);
@@ -954,6 +961,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;
@@ -1238,15 +1260,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 &
@@ -1263,7 +1278,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);