linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Luca <kronos@kronoz.cjb.net>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>, linux-kernel@vger.kernel.org
Subject: Re: Suspend to RAM: help with whitelist wanted
Date: Sat, 28 Jan 2006 17:27:48 +0100	[thread overview]
Message-ID: <20060128162748.GA1858@elf.ucw.cz> (raw)
In-Reply-To: <20060128155800.GA3064@dreamland.darkstar.lan>

Hi!

> > > void s2ram_restore(void) {
> > >         if (needed)
> > >                 fork_and_exec(vbetool);
> > > }
> > > 
> > > machine_table could set a global flag or something. It would be
> > > possibile to us an array to carry the informations about what need to be
> > > done on restore, i.e. something like:
> > 
> > I can imagine fork_and_exec... Disadvantages are:
> > 
> > * if disk driver is toast, user does not see anything
> > 
> > * vbetool can be missing from the system, or wrong version, or
> > something like that.
> > 
> > Other solution is to just integrate vbetool into s2ram. Advantages
> > are:
> > 
> > * s2ram is nicely integrated.
> > 
> > Disadvantages are:
> > 
> > * code duplication.
> > 
> > If vbetool's primary purpose is to fix video after suspend/resume,
> > then perhaps right thing to do is to integrate it into s2ram and
> > maintain it there.
> > 
> > Matthew, what do you think?
> > 
> > Luca, would you cook quick&hacky fork-and-exec patch? I do not have
> > machine that needs vbetool...
> 
> Very quick and very hacky ;)
> 
> The following patch works on my notebook. A few notes about it:
> 
> - I must stop acpid before suspending otherwise it will get a "power
>   button pressed" event on resume and shutdown the machine; not related
>   to s2ram though.

I work around this one by pressing lid button to wake the machine up.

> - vbetool manpage says that it must be invoked from a text console;
>   since it works from X on my system I never bothered to do a chvt from
>   my suspend script.
> - I always save state before suspend since sometimes I STR from X,
>   sometimes from the console and the state file generated by vbetool is
>   different. According to Matthew Garrett this will break on some
>   setups... if state needs to the saved before X is started then I guess
>   that we need an init script that dump the state in a known place; even
>   if you integrate vbetool into s2ram it will need the state file, so if
>   the disk doesn't come back to life you're screwed...

No, I'm not... I'd just load state file into memory before even
starting suspend :-).

Thanks for the patch!
							Pavel

> --- suspend/s2ram.c	2006-01-28 13:59:41.000000000 +0100
> +++ suspend/s2ram.c	2006-01-28 14:19:37.000000000 +0100
> @@ -15,2 +15,4 @@ int test_mode;
>  
> +static int need_vbetool;
> +
>  static void machine_known(void)
> @@ -49,2 +51,9 @@ static void machine_table(void)
>  	}
> +	if (!strcmp(sys_vendor, "ASUSTEK ")) {
> +		if (!strcmp(sys_product, "L3000D")) {
> +			machine_known();
> +			need_vbetool = 1;
> +			return;
> +		}
> +	}
>  
> @@ -59,2 +68,30 @@ static void machine_table(void)
>  
> +static int vbe_state_save() {
> +	int err;
> +	
> +	err = system("vbetool vbestate save > /tmp/.vbe.state");
> +	if (err)
> +		printf("vbetool failed to save video state with error %d\n.", err);
> +
> +	return err;
> +}
> +
> +static int vbe_state_restore() {
> +	int err;
> +
> +	err = system("vbetool post");
> +	if (err) {
> +		printf("vbetool failed to POST video board with error %d.\n", err);
> +		return err;
> +	}
> +	
> +	err = system("vbetool vbestate restore < /tmp/.vbe.state");
> +	if (err)
> +		printf("vbetool failed to restore video state with error %d.\n", err);
> +
> +	remove("/tmp/.vbe.state");
> +	
> +	return err;
> +}
> +
>  /* Code that can only be run on non-frozen system. It does not matter now
> @@ -66,2 +103,5 @@ void s2ram_prepare(void)
>  	machine_table();
> +	if (need_vbetool)
> +		if (vbe_state_save())
> +			exit(1);
>  }
> @@ -81,2 +121,7 @@ void s2ram_do(void)
>  
> +void s2ram_resume(void) {
> +	if (need_vbetool)
> +		vbe_state_restore();
> +}
> +
>  int main(int argc, char *argv[])
> @@ -103,2 +148,3 @@ int main(int argc, char *argv[])
>  	s2ram_do();
> +	s2ram_resume();
>  	return 0;
> 
> 
> Luca

-- 
Thanks, Sharp!

  parent reply	other threads:[~2006-01-28 16:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-26 21:36 Suspend to RAM: help with whitelist wanted Pavel Machek
2006-01-27 17:04 ` Luca
2006-01-27 23:05   ` Pavel Machek
2006-01-28  1:05     ` Olivier Galibert
2006-01-28  8:12       ` Pavel Machek
2006-01-27 23:22   ` Pavel Machek
2006-01-28  1:31     ` Matthew Garrett
2006-01-28  8:42       ` Pavel Machek
2006-01-29  7:12         ` Matthew Garrett
2006-02-04 21:11           ` Pavel Machek
2006-01-28 15:58     ` Luca
2006-01-28 16:04       ` Jan De Luyck
2006-01-28 17:11         ` Luca
2006-01-28 16:27       ` Pavel Machek [this message]
2006-01-28 16:36       ` Pavel Machek
2006-01-29 14:42         ` Luca

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060128162748.GA1858@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=kronos@kronoz.cjb.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).