public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC 3/3] Runtime PM support for named power states
@ 2005-09-30 20:31 Alan Stern
  2005-10-03 18:18 ` David Brownell
  0 siblings, 1 reply; 14+ messages in thread
From: Alan Stern @ 2005-09-30 20:31 UTC (permalink / raw)
  To: Linux-pm mailing list

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2225 bytes --]

This patch adds support for named power states to the USB device drivers.  
It's fairly simple and well-contained because USB devices have only two 
states: on and suspended.  Even so, the confusion over which field in 
dev->power.power_state should represent the true state remains.

Alan Stern

P.S.:  I forgot the mention this in the original cover message.  This 
entire series of patches is meant to go on top of 2.6.14-rc2-git6 plus

http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/gregkh-all-2.6.14-rc2-git6.patch



Index: usb-2.6/drivers/usb/core/usb.c
===================================================================
--- usb-2.6.orig/drivers/usb/core/usb.c
+++ usb-2.6/drivers/usb/core/usb.c
@@ -58,6 +58,8 @@ static int nousb;	/* Disable USB when bu
 
 static DECLARE_RWSEM(usb_all_devices_rwsem);
 
+const char *(usb_states[3]) = { pm_name_ON, pm_name_SUSPEND, NULL };
+
 
 static int generic_probe (struct device *dev)
 {
@@ -739,6 +741,7 @@ usb_alloc_dev(struct usb_device *parent,
 	dev->dev.driver_data = &usb_generic_driver_data;
 	dev->dev.driver = &usb_generic_driver;
 	dev->dev.release = usb_release_dev;
+	dev->dev.power.states = usb_states;
 	dev->state = USB_STATE_ATTACHED;
 
 	INIT_LIST_HEAD(&dev->ep0.urb_list);
Index: usb-2.6/drivers/usb/core/usb.h
===================================================================
--- usb-2.6.orig/drivers/usb/core/usb.h
+++ usb-2.6/drivers/usb/core/usb.h
@@ -29,6 +29,7 @@ extern void usb_major_cleanup(void);
 extern int usb_host_init(void);
 extern void usb_host_cleanup(void);
 
+extern const char *(usb_states[]);
 extern int usb_suspend_device(struct usb_device *dev);
 extern int usb_resume_device(struct usb_device *dev);
 
Index: usb-2.6/drivers/usb/core/message.c
===================================================================
--- usb-2.6.orig/drivers/usb/core/message.c
+++ usb-2.6/drivers/usb/core/message.c
@@ -1393,6 +1393,7 @@ free_interfaces:
 			intf->dev.dma_mask = dev->dev.dma_mask;
 			intf->dev.release = release_interface;
 			device_initialize (&intf->dev);
+			intf->dev.power.states = usb_states;
 			mark_quiesced(intf);
 			sprintf (&intf->dev.bus_id[0], "%d-%s:%d.%d",
 				 dev->bus->busnum, dev->devpath,


[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [RFC 3/3] Runtime PM support for named power states
@ 2005-10-05 20:45 Scott E. Preece
  2005-10-05 21:24 ` Alan Stern
  0 siblings, 1 reply; 14+ messages in thread
From: Scott E. Preece @ 2005-10-05 20:45 UTC (permalink / raw)
  To: stern; +Cc: david-b, linux-pm

[-- Attachment #1: Type: text/plain, Size: 3214 bytes --]



| From: "Alan Stern" <stern@rowland.harvard.edu>
| 
| IMO we could avoid the need for power_state by removing the guarantee
| about never calling ->suspend when a device is already in a low-power
| state.  The system sleep code could issue an optimistic ->suspend call,
| and if that fails then do ->resume followed by ->suspend.
---

That assumes it's "safe" to call suspend regardless of device power
state - that in the worst case, the device will just return failure.
That seems reasonable, but it's a constraint driver writers would want
to know about.

---
|
| People have already pretty much agreed that ->resume needs to take a 
| pm_message_t argument, and that will mean changing a lot of drivers.  We
| ought to settle on a decision about the rest of this too, so we won't
| have to go through and change them all yet again.
---

Yes, it seems reasonable to tell the device what state the system is
trying to get to, so it can determine what state it needs to be in to
support that.

---
| 
| (BTW, a theoretical advantage of passing a pm_message_t to ->resume is
| that a driver could use the _same_ subroutine as a combined
| suspend/resume
| method.  :-))
---

It would be nice to encourage code cohesion by NOT encouraging
multipurpose interfaces...

---
| 
| The PM core shouldn't worry too much about redundant calls.  Drivers can
| easily filter them out, and the core won't have enough information to
| detect them in general.
| 
| As I see it, we can use the new .name field to distinguish between the 
| different kinds of system state change calls.  The PM core could export 
| strings like (for FREEZE):
| 
| 	APM-standby, APM-suspend, snapshot, kexec;
| 
| or (for SUSPEND):
| 
| 	RAM, S3, S4, S5, shutdown;
| 
| or (for RESUME):
| 
| 	snapshot, RAM, kexec.
| 
| Something like this will provide drivers the means for telling which
| target state to use, thus addressing one of your biggest complaints
| about
| the current system.
| 
| Of course, this means that drivers will need code to map these 
| higher-level names to the appropriate target state, although that code 
| wouldn't need to be very sophisticated.  It would have to be smart
| enough 
| to recognize that when .event is PM_EVENT_RUNTIME, the name indicates
| the 
| requested power state directly.
---

It would be nicer if the system didn't need to know anything about the
internal state of the devices, but could just tell the device what
system state it wants to go to and let the device map that to whatever
internal state or sequence of sub-states the device needs. This would be
helped if the set of system states were either (a) a limited set of
well-known states or (b) described as a set of state-constraints that
describe what facilities are available to devices in a given state
(e.g., "Bus XYZ shut down") and what demands the system might expect
the device to provide while in that state (e.g., "provide wakeup
signal"). Or, maybe that's what you were describing and I just misread
it.

scott

-- 
scott preece
motorola mobile devices, il67, 1800 s. oak st., champaign, il  61820  
e-mail:	preece@motorola.com	fax:	+1-217-384-8550
phone:	+1-217-384-8589	cell: +1-217-433-6114	pager: 2174336114@vtext.com



[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

end of thread, other threads:[~2005-10-09 20:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-30 20:31 [RFC 3/3] Runtime PM support for named power states Alan Stern
2005-10-03 18:18 ` David Brownell
2005-10-03 19:46   ` Alan Stern
2005-10-05  1:31     ` David Brownell
2005-10-05 20:08       ` Alan Stern
2005-10-05 20:48         ` Adam Belay
2005-10-05 21:16           ` Alan Stern
2005-10-05 23:34         ` David Brownell
2005-10-06 17:16           ` Alan Stern
2005-10-08 17:00         ` Pavel Machek
2005-10-09 15:08           ` Alan Stern
2005-10-09 20:15             ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2005-10-05 20:45 Scott E. Preece
2005-10-05 21:24 ` Alan Stern

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