linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty/hvc/hvc_console: Fix wakeup of HVC thread on hvc_kick()
@ 2014-05-23  9:41 Benjamin Herrenschmidt
  2014-05-28  0:01 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2014-05-23  9:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, Linux Kernel list, linuxppc-dev list

Some backends call hvc_kick() to wakeup the HVC thread from its
slumber upon incoming characters. This however doesn't work
properly because it uses msleep_interruptible() which is mostly
immune to wake_up_process(). It will basically go back to sleep
until the timeout is expired (only signals can really wake it).

Replace it with a simple shedule_timeout_interruptible() instead,
which may wakeup earlier every now and then but we really don't
care in this case.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/tty/hvc/hvc_console.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 94f9e3a..1094265 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -760,10 +760,17 @@ static int khvcd(void *unused)
 			if (poll_mask == 0)
 				schedule();
 			else {
+				unsigned long j_timeout;
+
 				if (timeout < MAX_TIMEOUT)
 					timeout += (timeout >> 6) + 1;
 
-				msleep_interruptible(timeout);
+				/*
+				 * We don't use msleep_interruptible otherwise
+				 * "kick" will fail to wake us up
+				 */
+				j_timeout = msecs_to_jiffies(timeout) + 1;
+				schedule_timeout_interruptible(j_timeout);
 			}
 		}
 		__set_current_state(TASK_RUNNING);



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

* Re: [PATCH] tty/hvc/hvc_console: Fix wakeup of HVC thread on hvc_kick()
  2014-05-23  9:41 [PATCH] tty/hvc/hvc_console: Fix wakeup of HVC thread on hvc_kick() Benjamin Herrenschmidt
@ 2014-05-28  0:01 ` Benjamin Herrenschmidt
  2014-05-28 20:32   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2014-05-28  0:01 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, Linux Kernel list, linuxppc-dev list

On Fri, 2014-05-23 at 19:41 +1000, Benjamin Herrenschmidt wrote:
> Some backends call hvc_kick() to wakeup the HVC thread from its
> slumber upon incoming characters. This however doesn't work
> properly because it uses msleep_interruptible() which is mostly
> immune to wake_up_process(). It will basically go back to sleep
> until the timeout is expired (only signals can really wake it).
>
> Replace it with a simple shedule_timeout_interruptible() instead,
> which may wakeup earlier every now and then but we really don't
> care in this case.

Nobody commented ? :-)

Greg, do you want to take this in the tty tree or can I stick it in
powerpc ?

Cheers,
Ben 

> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>  drivers/tty/hvc/hvc_console.c |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
> index 94f9e3a..1094265 100644
> --- a/drivers/tty/hvc/hvc_console.c
> +++ b/drivers/tty/hvc/hvc_console.c
> @@ -760,10 +760,17 @@ static int khvcd(void *unused)
>  			if (poll_mask == 0)
>  				schedule();
>  			else {
> +				unsigned long j_timeout;
> +
>  				if (timeout < MAX_TIMEOUT)
>  					timeout += (timeout >> 6) + 1;
>  
> -				msleep_interruptible(timeout);
> +				/*
> +				 * We don't use msleep_interruptible otherwise
> +				 * "kick" will fail to wake us up
> +				 */
> +				j_timeout = msecs_to_jiffies(timeout) + 1;
> +				schedule_timeout_interruptible(j_timeout);
>  			}
>  		}
>  		__set_current_state(TASK_RUNNING);
> 



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

* Re: [PATCH] tty/hvc/hvc_console: Fix wakeup of HVC thread on hvc_kick()
  2014-05-28  0:01 ` Benjamin Herrenschmidt
@ 2014-05-28 20:32   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2014-05-28 20:32 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Jiri Slaby, Linux Kernel list, linuxppc-dev list

On Wed, May 28, 2014 at 10:01:30AM +1000, Benjamin Herrenschmidt wrote:
> On Fri, 2014-05-23 at 19:41 +1000, Benjamin Herrenschmidt wrote:
> > Some backends call hvc_kick() to wakeup the HVC thread from its
> > slumber upon incoming characters. This however doesn't work
> > properly because it uses msleep_interruptible() which is mostly
> > immune to wake_up_process(). It will basically go back to sleep
> > until the timeout is expired (only signals can really wake it).
> >
> > Replace it with a simple shedule_timeout_interruptible() instead,
> > which may wakeup earlier every now and then but we really don't
> > care in this case.
> 
> Nobody commented ? :-)
> 
> Greg, do you want to take this in the tty tree or can I stick it in
> powerpc ?

I'll take it, thanks.

greg k-h

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

end of thread, other threads:[~2014-05-28 20:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-23  9:41 [PATCH] tty/hvc/hvc_console: Fix wakeup of HVC thread on hvc_kick() Benjamin Herrenschmidt
2014-05-28  0:01 ` Benjamin Herrenschmidt
2014-05-28 20:32   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).