public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty/metag_da: Add console_poll module parameter
@ 2014-09-12 22:15 James Hogan
  2014-09-15 19:14 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: James Hogan @ 2014-09-12 22:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-kernel, linux-metag, James Hogan, Guenter Roeck

Currently the metag_da console channel is write only, it doesn't get
polled for incoming data. This is for performance & latency reasons as
polling blocks the processor for a significant amount of time waiting
for the JTAG probe to respond to the request and restart the thread.
This means that the console channel cannot be used for a login prompt,
so ttyDA2 is usually used instead.

In a virtual environment with a virtual DA such as QEMU however the
polling is much cheaper as the request can be handled immediately. It is
useful to be able to enable polling in such an environment in order to
get both the kernel log and a usable login prompt on the same DA
channel.

Add a console_poll module parameter which allows polling to be enabled
for the console channel. It defaults to off as that is the current
behaviour for good reason on real hardware.

It can be enabled by appending metag_da.console_poll to the kernel
command line.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Guenter Roeck <linux@roeck-us.net>
---
 drivers/tty/metag_da.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/metag_da.c b/drivers/tty/metag_da.c
index 7332e2c..3774600 100644
--- a/drivers/tty/metag_da.c
+++ b/drivers/tty/metag_da.c
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/kthread.h>
+#include <linux/moduleparam.h>
 #include <linux/mutex.h>
 #include <linux/sched.h>
 #include <linux/serial.h>
@@ -70,6 +71,15 @@ static struct tty_driver *channel_driver;
 static struct timer_list put_timer;
 static struct task_struct *dashtty_thread;
 
+/*
+ * The console_poll parameter determines whether the console channel should be
+ * polled for input.
+ * By default the console channel isn't polled at all, in order to avoid the
+ * overhead, but that means it isn't possible to have a login on /dev/console.
+ */
+static bool console_poll;
+module_param(console_poll, bool, S_IRUGO);
+
 #define RX_BUF_SIZE 1024
 
 enum {
@@ -353,7 +363,7 @@ static int dashtty_port_activate(struct tty_port *port, struct tty_struct *tty)
 	 * possible to have a login on /dev/console.
 	 *
 	 */
-	if (dport != &dashtty_ports[CONSOLE_CHANNEL])
+	if (console_poll || dport != &dashtty_ports[CONSOLE_CHANNEL])
 		if (atomic_inc_return(&num_channels_need_poll) == 1)
 			add_poll_timer(&poll_timer);
 
@@ -372,7 +382,7 @@ static void dashtty_port_shutdown(struct tty_port *port)
 	unsigned int count;
 
 	/* stop reading */
-	if (dport != &dashtty_ports[CONSOLE_CHANNEL])
+	if (console_poll || dport != &dashtty_ports[CONSOLE_CHANNEL])
 		if (atomic_dec_and_test(&num_channels_need_poll))
 			del_timer_sync(&poll_timer);
 
-- 
1.8.5.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tty/metag_da: Add console_poll module parameter
  2014-09-12 22:15 [PATCH] tty/metag_da: Add console_poll module parameter James Hogan
@ 2014-09-15 19:14 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2014-09-15 19:14 UTC (permalink / raw)
  To: James Hogan; +Cc: Greg Kroah-Hartman, Jiri Slaby, linux-kernel, linux-metag

On Fri, Sep 12, 2014 at 11:15:22PM +0100, James Hogan wrote:
> Currently the metag_da console channel is write only, it doesn't get
> polled for incoming data. This is for performance & latency reasons as
> polling blocks the processor for a significant amount of time waiting
> for the JTAG probe to respond to the request and restart the thread.
> This means that the console channel cannot be used for a login prompt,
> so ttyDA2 is usually used instead.
> 
> In a virtual environment with a virtual DA such as QEMU however the
> polling is much cheaper as the request can be handled immediately. It is
> useful to be able to enable polling in such an environment in order to
> get both the kernel log and a usable login prompt on the same DA
> channel.
> 
> Add a console_poll module parameter which allows polling to be enabled
> for the console channel. It defaults to off as that is the current
> behaviour for good reason on real hardware.
> 
> It can be enabled by appending metag_da.console_poll to the kernel
> command line.
> 
> Signed-off-by: James Hogan <james.hogan@imgtec.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jiri Slaby <jslaby@suse.cz>
> Cc: Guenter Roeck <linux@roeck-us.net>

Tested-by: Guenter Roeck <linux@roeck-us.net>

Thanks a lot!

Guenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-15 19:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-12 22:15 [PATCH] tty/metag_da: Add console_poll module parameter James Hogan
2014-09-15 19:14 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox