Message ID | 1500296815-10243-16-git-send-email-bhupinder.thakur@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | SBSA UART emulation support in Xen | expand |
On Mon, Jul 17, 2017 at 06:36:45PM +0530, Bhupinder Thakur wrote: > This patch introduces a new console_evtchn_unmask function. This function > unmasks the console event channel if it is masked for some timeout > period. > > 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 | 44 +++++++++++++++++++++++++++----------------- > 1 file changed, 27 insertions(+), 17 deletions(-) > > diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c > index 6321d78..c272fe6 100644 > --- a/tools/console/daemon/io.c > +++ b/tools/console/daemon/io.c > @@ -117,6 +117,11 @@ struct domain { > > static struct domain *dom_head; > > +static inline bool console_enabled(struct console *con) > +{ > + return con->local_port != -1; > +} > + > static int write_all(int fd, const char* buf, size_t len) > { > while (len) { > @@ -909,6 +914,27 @@ static void handle_tty_write(struct console *con) > } > } > > +static void console_evtchn_unmask(struct console *con, void *data) No need to use void*. > +{ > + long long now = (long long)data; > + > + if (!console_enabled(con)) > + return; > + > + /* CS 16257:955ee4fa1345 introduces a 5ms fuzz > + * for select(), it is not clear poll() has > + * similar behavior (returning a couple of ms > + * sooner than requested) as well. Just leave > + * the fuzz here. Remove it with a separate > + * patch if necessary */ > + if ((now+5) > con->next_period) { > + con->next_period = now + RATE_LIMIT_PERIOD; > + if (con->event_count >= RATE_LIMIT_ALLOWANCE) > + (void)xenevtchn_unmask(con->xce_handle, con->local_port); > + con->event_count = 0; > + } > +} > + > static void handle_ring_read(struct domain *dom) > { > xenevtchn_port_or_error_t port; > @@ -1144,23 +1170,7 @@ void handle_io(void) > for (d = dom_head; d; d = d->next) { > struct console *con = &d->console; > > - /* CS 16257:955ee4fa1345 introduces a 5ms fuzz > - * for select(), it is not clear poll() has > - * similar behavior (returning a couple of ms > - * sooner than requested) as well. Just leave > - * the fuzz here. Remove it with a separate > - * patch if necessary */ > - if ((now+5) > con->next_period) { > - con->next_period = now + RATE_LIMIT_PERIOD; > - if (con->event_count >= RATE_LIMIT_ALLOWANCE) { > - (void)xenevtchn_unmask(con->xce_handle, con->local_port); > - } > - con->event_count = 0; > - } > - } > - > - for (d = dom_head; d; d = d->next) { > - struct console *con = &d->console; > + console_evtchn_unmask(con, (void *)now); > You need to keep the two loops, or you need to state why you merge them into one in the commit message. > add_console_evtchn_fd(con, (void *)&next_timeout); > > -- > 2.7.4 >
diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 6321d78..c272fe6 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -117,6 +117,11 @@ struct domain { static struct domain *dom_head; +static inline bool console_enabled(struct console *con) +{ + return con->local_port != -1; +} + static int write_all(int fd, const char* buf, size_t len) { while (len) { @@ -909,6 +914,27 @@ static void handle_tty_write(struct console *con) } } +static void console_evtchn_unmask(struct console *con, void *data) +{ + long long now = (long long)data; + + if (!console_enabled(con)) + return; + + /* CS 16257:955ee4fa1345 introduces a 5ms fuzz + * for select(), it is not clear poll() has + * similar behavior (returning a couple of ms + * sooner than requested) as well. Just leave + * the fuzz here. Remove it with a separate + * patch if necessary */ + if ((now+5) > con->next_period) { + con->next_period = now + RATE_LIMIT_PERIOD; + if (con->event_count >= RATE_LIMIT_ALLOWANCE) + (void)xenevtchn_unmask(con->xce_handle, con->local_port); + con->event_count = 0; + } +} + static void handle_ring_read(struct domain *dom) { xenevtchn_port_or_error_t port; @@ -1144,23 +1170,7 @@ void handle_io(void) for (d = dom_head; d; d = d->next) { struct console *con = &d->console; - /* CS 16257:955ee4fa1345 introduces a 5ms fuzz - * for select(), it is not clear poll() has - * similar behavior (returning a couple of ms - * sooner than requested) as well. Just leave - * the fuzz here. Remove it with a separate - * patch if necessary */ - if ((now+5) > con->next_period) { - con->next_period = now + RATE_LIMIT_PERIOD; - if (con->event_count >= RATE_LIMIT_ALLOWANCE) { - (void)xenevtchn_unmask(con->xce_handle, con->local_port); - } - con->event_count = 0; - } - } - - for (d = dom_head; d; d = d->next) { - struct console *con = &d->console; + console_evtchn_unmask(con, (void *)now); add_console_evtchn_fd(con, (void *)&next_timeout);
This patch introduces a new console_evtchn_unmask function. This function unmasks the console event channel if it is masked for some timeout period. 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 | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-)