Skip to contentSkip to conversation

tty/hvc/hvc_console: Fix wakeup of HVC thread on hvc_kick()

PATCH In review Benjamin Herrenschmidt 2 participants 3 messages May 23, 2014 – May 28, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty/hvc/hvc_console: Fix wakeup of HVC thread on hvc_kick()

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.

---
 drivers/tty/hvc/hvc_console.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/tty/hvc/hvc_console.c +8 -1
index 94f9e3a..1094265 100644
@@ -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);
#1 lore raw
Quoted 9 lines · Benjamin Herrenschmidt

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

Quoted 29 lines
---
 drivers/tty/hvc/hvc_console.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/tty/hvc/hvc_console.c +8 -1
index 94f9e3a..1094265 100644
@@ -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);
#2 lore raw
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 6 lines · Benjamin Herrenschmidt

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).

Quoted 8 lines
Quoted 3 lines

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