[RFC 1/1] tty: vt.c: Fix TIOCL_BLANKSCREEN VT console blanking if blankinterval == 0

From: Yifeng Li
Date: Mon Feb 25 2019 - 11:44:13 EST


In vt.c, "blank_state" will be initialized to "blank_normal_wait" in
con_init() if AND ONLY IF ("blankinterval" > 0). If "blankinterval" is 0,
"blank_state" will be "blank_off" (== 0), and a call to do_blank_screen()
will always abort. Even if a forced blanking is required from the user by
calling TIOCL_BLANKSCREEN, the console won't be blanked.

In this commit, we introduce a 4th "blank_state" - "blank_normal_notimer",
it indicates the console can be blanked, but not automatically by a timer.
Then, we made a change to "con_init()" - if (blankinterval == 0),
"blank_state" will be set to "blank_normal_notimer" (we have similar
changes to "do_unblank_screen()" and "poke_blanked_console()"). Finally,
we change do_blank_screen() - now it will return if "blank_state" is
neither "blank_normal_wait" nor "blank_normal_notimer", thus allowing
the console to be blanked even if there's no timed autoblanking.

Signed-off-by: Yifeng Li <tomli@xxxxxxxx>
---
drivers/tty/vt/vt.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 41ec8e5010f3..ec84bc2868e1 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -238,6 +238,7 @@ enum {
blank_off = 0,
blank_normal_wait,
blank_vesa_wait,
+ blank_normal_notimer, /* no auto blanking, only manual blanking */
};

/*
@@ -3334,6 +3335,8 @@ static int __init con_init(void)
if (blankinterval) {
blank_state = blank_normal_wait;
mod_timer(&console_timer, jiffies + (blankinterval * HZ));
+ } else {
+ blank_state = blank_normal_notimer;
}

for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
@@ -4168,7 +4171,8 @@ void do_blank_screen(int entering_gfx)
return;
}

- if (blank_state != blank_normal_wait)
+ if (blank_state != blank_normal_wait &&
+ blank_state != blank_normal_notimer)
return;
blank_state = blank_off;

@@ -4232,6 +4236,8 @@ void do_unblank_screen(int leaving_gfx)
if (blankinterval) {
mod_timer(&console_timer, jiffies + (blankinterval * HZ));
blank_state = blank_normal_wait;
+ } else {
+ blank_state = blank_normal_notimer;
}

console_blanked = 0;
@@ -4293,7 +4299,8 @@ void poke_blanked_console(void)
else if (blankinterval) {
mod_timer(&console_timer, jiffies + (blankinterval * HZ));
blank_state = blank_normal_wait;
- }
+ } else if (!blankinterval)
+ blank_state = blank_normal_notimer;
}

/*
--
2.20.1