public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* suspend/resume support for driver requires an external firmware
@ 2004-09-23  7:17 Zhu, Yi
       [not found] ` <Pine.LNX.4.44.0409231514270.8729-100000-7yGjFsf0sy5rdx17CPfAsdBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Zhu, Yi @ 2004-09-23  7:17 UTC (permalink / raw)
  To: Patrick Mochel, Pavel Machek,
	acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: ipw2100-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f


Hi,

I make the ipw2100 driver (http://ipw2100.sf.net) support suspend/resume
with below patch.
http://cache.gmane.org//gmane/linux/drivers/ipw2100/devel/2129-001.bin

Current state is the patch makes ipw2100 suspend/resume work in the expense
of addtional ~200k kernel runtime memory. So I'd rather look on it as a
workaround instead of a finial solution.

The problem is ipw2100 requires an external on-disk firmware support. When
the device is put to D3 state, firmware needs to be unloaded. And the
firmware should be loaded again after the device is put to D0 state. But
currently there is no suspend/resume order(dependency) for the online
devices list in the kernel (dpm_active). So the ide disk might still be in
the suspend state when ipw2100->resume is called. This causes a deadlock.


I propose 2 choices to fix the problem.

Choice 1. In 2.5 kernel, there used to be a ->save_state method in the
device PM interface. From the "not yet updated" document
(Documentation/power/pci.txt), this function can be used as "a notification
that it(the device) may be entering a sleep state in the near future". If we
take back this interface, the problem can be solved. That is, the driver
loads firmware into memory in ->save_state and frees the memory in ->resume.
The deadlock is resolved without any runtime memory wasted.

3 patches are attached for this idea.
device-save_state.patch adds back the interface ->save_state for the devices
	and implements pci bus save_state method.
swsusp-save_state.patch makes swsusp walks all devices ->save_state method
	before calling ->suspend method.
ipw2100-save_state.patch implements ipw2100 ->save_state method. 
They are proved working.


Choice 2. Add a notifier call chain for swsusp before prepare_suspend. Each
driver requires the notification(i.e. ipw2100) registers its own callback.
For people who think device PM ->save_state is an overkill since 99% devices
don't require firmwares (really today, who knows the future?), this can be
considered as another (better) solution.


Choice 3? or I missed something here?


Your comments are highly appreciated!


-- 
-----------------------------------------------------------------
Opinions expressed are those of the author and do not represent
Intel Corp.

Zhu Yi (Chuyee)

GnuPG v1.0.6 (GNU/Linux)
http://cn.geocities.com/chewie_chuyee/gpg.txt or
$ gpg --keyserver wwwkeys.pgp.net --recv-keys 71C34820
1024D/71C34820 C939 2B0B FBCE 1D51 109A  55E5 8650 DB90 71C3 4820



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: suspend/resume support for driver requires an external firmware
@ 2004-09-23 14:00 Dmitry Torokhov
       [not found] ` <20040923140018.25346.qmail-ockkSbn3fCqA/QwVtaZbd3CJp6faPEW9@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2004-09-23 14:00 UTC (permalink / raw)
  To: Zhu, Yi, Patrick Mochel, Pavel Machek,
	acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hi,

Apologies for breaking threading...

Zhu, Yi wrote:
> Hi,
> 
> I make the ipw2100 driver (http://ipw2100.sf.net) support suspend/resume
> with below patch.
> http://cache.gmane.org//gmane/linux/drivers/ipw2100/devel/2129-001.bin
> 
> Current state is the patch makes ipw2100 suspend/resume work in the
> expense
> of addtional ~200k kernel runtime memory. So I'd rather look on it as a
> workaround instead of a finial solution.
> 
> The problem is ipw2100 requires an external on-disk firmware support. When
> the device is put to D3 state, firmware needs to be unloaded. And the
> firmware should be loaded again after the device is put to D0 state. But
> currently there is no suspend/resume order(dependency) for the online
> devices list in the kernel (dpm_active). So the ide disk might still be in
> the suspend state when ipw2100->resume is called. This causes a deadlock.
> 
> 
> I propose 2 choices to fix the problem.
> 
> Choice 1. In 2.5 kernel, there used to be a ->save_state method in the
> device PM interface. From the "not yet updated" document
> 
> Choice 2. Add a notifier call chain for swsusp before prepare_suspend.
> Each
> driver requires the notification(i.e. ipw2100) registers its own callback.
> For people who think device PM ->save_state is an overkill since 99%
> devices
> don't require firmwares (really today, who knows the future?), this can be
> considered as another (better) solution.
> 
> 
> Choice 3? or I missed something here?
> 

What about splitting resume in 2 parts - the ->resume method
would just schedule_work() real resume for the card out of
line where it can safely wait for drive to be available without
blocking other devices from resuming. This way you do not need
to pre-load firmware on suspend.

-- 
Dmitry



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php

^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: suspend/resume support for driver requires an external firmware
@ 2004-09-24  0:02 Zhu, Yi
  0 siblings, 0 replies; 8+ messages in thread
From: Zhu, Yi @ 2004-09-24  0:02 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Patrick Mochel, acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	ipw2100-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Pavel Machek wrote:
> Are you sure you'll be able to allocate 200KB of memory at runtime?
> Well, you probably can using vmalloc or such.

If malloc fails in ->save_state, the system cannot go to suspend.
The same as ->suspend fails.

> Yes, this looks like reasonable way to go. I guess I'd
> survive notifier chain, too, because saving state can be done
> at any order for todays devices, but this looks better with
> the driver model.

Thanks for your feedback.

-yi


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php

^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: suspend/resume support for driver requires an external firmware
@ 2004-09-24  0:05 Zhu, Yi
  0 siblings, 0 replies; 8+ messages in thread
From: Zhu, Yi @ 2004-09-24  0:05 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Patrick Mochel, acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	ipw2100-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Pavel Machek wrote:
> Hi!
> 
> Docs is needed for the patch. What happens if you save_state
> and then suspend fails for whatever reason?
> 								Pavel

Yes, good point. ->resume is supposed to roll back whatever
->save_state and ->suspend did both in a success and a failure
case.

Thanks,
-yi


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php

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

end of thread, other threads:[~2004-09-24  0:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-23  7:17 suspend/resume support for driver requires an external firmware Zhu, Yi
     [not found] ` <Pine.LNX.4.44.0409231514270.8729-100000-7yGjFsf0sy5rdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2004-09-23  7:46   ` Zhu, Yi
     [not found]     ` <Pine.LNX.4.44.0409231522530.8729-400000-7yGjFsf0sy5rdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2004-09-23 12:07       ` Pavel Machek
2004-09-23 12:06   ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2004-09-23 14:00 Dmitry Torokhov
     [not found] ` <20040923140018.25346.qmail-ockkSbn3fCqA/QwVtaZbd3CJp6faPEW9@public.gmane.org>
2004-09-23 16:42   ` Pavel Machek
2004-09-24  0:02 Zhu, Yi
2004-09-24  0:05 Zhu, Yi

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