David:

I did some testing with "echo 4 >/proc/acpi/sleep" and looked at the code 
in drivers/base/power.  What a mess!  The routines there have no real 
concept of suspending or resuming individual devices, only the entire 
system.  This business of handling separately drivers that require 
interrupts to be disabled looks ridiculous -- and it will break the 
necessary topological ordering of the device lists.

I also found a few bugs in the USB code.  The problems can be summed up 
like this: Who is responsible, the caller or the callee, for checking that 
old_state != new_state (i.e., whether the call is necessary), and who is 
responsible for setting dev->power.power_state to new_state?  The code is 
inconsistent in its answers to these questions, leading to various weird 
behaviors.

For instance, interface drivers' resume() method can be called either from
finish_port_resume() or from usb_generic_resume().  One checks whether the
interface has already been resumed and the other doesn't.  One of the
callees, hub_resume(), doesn't check.  Hence there can be multiple resumes 
of a hub.

As another example, the bus->op->hub_suspend() call in 
__usb_suspend_device() doesn't have to set power_state because the code 
following the call does so.  But the corresponding call to 
bus->op->hub_resume() in usb_resume_device() does have to set power_state.

Even the suspend_device() and resume_device() routines in 
drivers/base/power/{suspend,resume}.c are inconsistent about checking 
whether the device is already suspended/resumed.  At least they are 
consistent in relying on the callee to set power_state.

Presumably the callee is always supposed to set power_state, rather than 
the caller -- that is the majority behavior.  But who's supposed to weed 
out unnecessary calls?

Alan Stern



-------------------------------------------------------
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
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to