public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* console.c unblank_screen problem
@ 2001-03-25 16:40 Benjamin Herrenschmidt
  0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2001-03-25 16:40 UTC (permalink / raw)
  To: Linux Frame Buffer Device Development, Linux Kernel Development

There is a problem with the power management code for console.c

The current code calls do_blank_screen(0); on PM_SUSPEND, and
unblank_screen() on PM_RESUME.

The problem happens when X is the current display while putting the
machine to sleep. The do_blank_screen(0) code will do nothing as
the console is not in KD_TEXT mode.
However, unblank_screen has no such protection. That means that
on wakeup, the cursor timer & console blank timers will be re-enabled
while X is frontmost, causing the blinking cursor to be displayed on
top of X, and other possible issues.

I hacked the following pacth to work around this. It appear to work
fine, but since the console code is pretty complex, I'm not sure about
possible side effects and I'd like some comments before submiting it
to Linus:

(Don't worry about the {} I added, I just noticed them and will remove
them before submitting ;)

--- 1.2/drivers/char/console.c	Sat Feb 10 18:54:15 2001
+++ edited/drivers/char/console.c	Sun Mar 25 17:57:46 2001
@@ -2595,8 +2595,9 @@
 	int currcons = fg_console;
 	int i;
 
-	if (console_blanked)
+	if (console_blanked) {
 		return;
+	}
 
 	/* entering graphics mode? */
 	if (entering_gfx) {
@@ -2660,12 +2661,16 @@
 		printk("unblank_screen: tty %d not allocated ??\n", fg_console+1);
 		return;
 	}
+	currcons = fg_console;
+	if (vcmode != KD_TEXT) {
+		console_blanked = 0;
+		return;
+	}
 	console_timer.function = blank_screen;
 	if (blankinterval) {
 		mod_timer(&console_timer, jiffies + blankinterval);
 	}
 
-	currcons = fg_console;
 	console_blanked = 0;
 	if (console_blank_hook)
 		console_blank_hook(0);



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

* Re: console.c unblank_screen problem
@ 2001-04-04 11:09 Mikael Pettersson
  2001-04-04 12:18 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Pettersson @ 2001-04-04 11:09 UTC (permalink / raw)
  To: alan, benh, linux-fbdev-devel, linux-kernel

On Sun, 25 Mar 2001 18:40:03 +0200, Benjamin Herrenschmidt wrote:

>There is a problem with the power management code for console.c
>
>The current code calls do_blank_screen(0); on PM_SUSPEND, and
>unblank_screen() on PM_RESUME.
>
>The problem happens when X is the current display while putting the
>machine to sleep. The do_blank_screen(0) code will do nothing as
>the console is not in KD_TEXT mode.
>However, unblank_screen has no such protection. That means that
>on wakeup, the cursor timer & console blank timers will be re-enabled
>while X is frontmost, causing the blinking cursor to be displayed on
>top of X, and other possible issues.
>
>I hacked the following pacth to work around this. It appear to work
>fine, but since the console code is pretty complex, I'm not sure about
>possible side effects and I'd like some comments before submiting it
>to Linus:

Thanks for this patch. I've been using it on my Dell Latitude laptop
for the last 10 days, and it has been a significant improvement.

Before the patch: After a few days with a 2.4 kernel and RH7.0
(XFree86-4.0.1-1 and XFree86-SVGA-3.3.6-33) the latop would
misbehave at a resume event: when I opened the lid the screen would
unblank and then after less than a second the entire screen would
shift (wrap/rotate) left by about 40% of its width. Restarting X
would only fix this temporarily, as the next resume would have the
same problem. This does not occur with a 2.2 kernel or with the
Accelerated-X server I used before.

With the patch: No problem after 10 days with frequent suspend/resume
cycles. (2.4.2-ac24 + the patch)

[Alan, mind putting this in the next 2.4.3-ac? I've rediffed it
against 2.4.3-ac2.]

/Mikael


--- linux-2.4.3-ac2/drivers/char/console.c.~1~	Wed Apr  4 12:15:28 2001
+++ linux-2.4.3-ac2/drivers/char/console.c	Wed Apr  4 12:29:01 2001
@@ -2713,12 +2713,16 @@
 		printk("unblank_screen: tty %d not allocated ??\n", fg_console+1);
 		return;
 	}
+	currcons = fg_console;
+	if (vcmode != KD_TEXT) {
+		console_blanked = 0;
+		return;
+	}
 	console_timer.function = blank_screen;
 	if (blankinterval) {
 		mod_timer(&console_timer, jiffies + blankinterval);
 	}
 
-	currcons = fg_console;
 	console_blanked = 0;
 	if (console_blank_hook)
 		console_blank_hook(0);

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

* Re: console.c unblank_screen problem
  2001-04-04 11:09 console.c unblank_screen problem Mikael Pettersson
@ 2001-04-04 12:18 ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2001-04-04 12:18 UTC (permalink / raw)
  To: Mikael Pettersson, linux-kernel, linux-fbdev-devel

>
>Thanks for this patch. I've been using it on my Dell Latitude laptop
>for the last 10 days, and it has been a significant improvement.
>
>Before the patch: After a few days with a 2.4 kernel and RH7.0
>(XFree86-4.0.1-1 and XFree86-SVGA-3.3.6-33) the latop would
>misbehave at a resume event: when I opened the lid the screen would
>unblank and then after less than a second the entire screen would
>shift (wrap/rotate) left by about 40% of its width. Restarting X
>would only fix this temporarily, as the next resume would have the
>same problem. This does not occur with a 2.2 kernel or with the
>Accelerated-X server I used before.
>
>With the patch: No problem after 10 days with frequent suspend/resume
>cycles. (2.4.2-ac24 + the patch)
>
>[Alan, mind putting this in the next 2.4.3-ac? I've rediffed it
>against 2.4.3-ac2.]

Glad to get some feedback !

I'm still getting other problems related to console.c power management
however. On the PowerBook, occasionally, if suspend is triggered from
a text console, the machine may hang during the sleep process. I don't
quite understand that code in console.c anyway since it seems to trigger
a timer to later call the VESA blank. That timer thing doesn't makes much
sense to me, especially since when the timer fire (if it ever fires),
the machine will probably be sleeping. 

The problem with it on powerbooks is that we do suspend the graphic chip
from fbdev layer (later on).
So if after this timer expires, the console code tries to access the chip
in any way, bad things will happen (it will die).

I'm working on workaround at the fbdev level, but I'm curious to know
if that PM code in console.c is useful at all in it's current form,
especially since it plays those tricks with timers which don't seem like
a good idea when the machine is going to sleep.

Ben.




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

* Re: console.c unblank_screen problem
@ 2001-04-06 15:46 Mikael Pettersson
  0 siblings, 0 replies; 4+ messages in thread
From: Mikael Pettersson @ 2001-04-06 15:46 UTC (permalink / raw)
  To: alan, benh, linux-fbdev-devel, linux-kernel, mikpe

On Wed, 4 Apr 2001 13:09:11 +0200 (MET DST), Mikael Petterson wrote:

> On Sun, 25 Mar 2001 18:40:03 +0200, Benjamin Herrenschmidt wrote:
> 
> >There is a problem with the power management code for console.c
> >
> >The current code calls do_blank_screen(0); on PM_SUSPEND, and
> >unblank_screen() on PM_RESUME.
> >
> >The problem happens when X is the current display while putting the
> >machine to sleep. The do_blank_screen(0) code will do nothing as
> >the console is not in KD_TEXT mode.
> >However, unblank_screen has no such protection. That means that
> >on wakeup, the cursor timer & console blank timers will be re-enabled
> >while X is frontmost, causing the blinking cursor to be displayed on
> >top of X, and other possible issues.
> >
> >I hacked the following pacth to work around this. It appear to work
> >fine, but since the console code is pretty complex, I'm not sure about
> >possible side effects and I'd like some comments before submiting it
> >to Linus:
>...
> Before the patch: After a few days with a 2.4 kernel and RH7.0
> (XFree86-4.0.1-1 and XFree86-SVGA-3.3.6-33) the latop would
> misbehave at a resume event: when I opened the lid the screen would
> unblank and then after less than a second the entire screen would
> shift (wrap/rotate) left by about 40% of its width.
>...
> With the patch: No problem after 10 days with frequent suspend/resume
> cycles. (2.4.2-ac24 + the patch)

Correction: While the patch eliminated the X screen wrap problem at resume,
it caused a new problem: now when I exit X the console is left in a blanked
state. This seems to happen if at least one suspend/resume cycle has
occurred before X is terminated.

After some experimentation I came up with the patch below (vs. 2.4.3-ac3)
which _so_far_ behaves ok on my laptop. If the resume-while-in-X problems
resurface or not I won't know until after several more days of testing,
but at least the console is unblanked correctly again.

Does _anyone_ understand this code and its interactions with X? I'm lost...

/Mikael

--- linux-2.4.3-ac3/drivers/char/console.c.~1~	Thu Apr  5 15:57:36 2001
+++ linux-2.4.3-ac3/drivers/char/console.c	Thu Apr  5 18:52:43 2001
@@ -2713,23 +2713,23 @@
 		printk("unblank_screen: tty %d not allocated ??\n", fg_console+1);
 		return;
 	}
-	currcons = fg_console;
-	if (vcmode != KD_TEXT) {
-		console_blanked = 0;
-		return;
-	}
 	console_timer.function = blank_screen;
 	if (blankinterval) {
 		mod_timer(&console_timer, jiffies + blankinterval);
 	}
-
+	currcons = fg_console;
 	console_blanked = 0;
 	if (console_blank_hook)
 		console_blank_hook(0);
 	set_palette(currcons);
-	if (sw->con_blank(vc_cons[currcons].d, 0))
+	if (sw->con_blank(vc_cons[currcons].d, 0)) {
+		if (vcmode != KD_TEXT)
+			return;
 		/* Low-level driver cannot restore -> do it ourselves */
 		update_screen(fg_console);
+	}
+	if (vcmode != KD_TEXT)
+		return;
 	set_cursor(fg_console);
 }
 

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

end of thread, other threads:[~2001-04-06 15:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-04 11:09 console.c unblank_screen problem Mikael Pettersson
2001-04-04 12:18 ` Benjamin Herrenschmidt
  -- strict thread matches above, loose matches on Subject: below --
2001-04-06 15:46 Mikael Pettersson
2001-03-25 16:40 Benjamin Herrenschmidt

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