public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] pm: fix runtime powermanagement's /sys interface
@ 2005-12-27 21:34 Pavel Machek
  2005-12-27 21:55 ` [linux-pm] " Dmitry Torokhov
  0 siblings, 1 reply; 64+ messages in thread
From: Pavel Machek @ 2005-12-27 21:34 UTC (permalink / raw)
  To: Andrew Morton, kernel list, Linux-pm mailing list

/sys/devices/..../power interface is currently very broken. It takes
integer from user, and passes it to drivers as pm_message_t.event
... without even checking it. This changes the interface to pass
strings, and introduces checks.

Signed-off-by: Pavel Machek <pavel@suse.cz>

diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -27,22 +27,25 @@
 
 static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf)
 {
-	return sprintf(buf, "%u\n", dev->power.power_state.event);
+	if (dev->power.power_state.event)
+		return sprintf(buf, "suspend\n");
+	else
+		return sprintf(buf, "on\n");
 }
 
 static ssize_t state_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t n)
 {
 	pm_message_t state;
-	char * rest;
-	int error = 0;
+	int error = -EINVAL;
 
-	state.event = simple_strtoul(buf, &rest, 10);
-	if (*rest)
-		return -EINVAL;
-	if (state.event)
-		error = dpm_runtime_suspend(dev, state);
-	else
+	state.event = PM_EVENT_SUSPEND;
+	if ((n == 2) && !strncmp(buf, "on", 2)) {
 		dpm_runtime_resume(dev);
+		error = 0;
+	}
+	if ((n == 7) && !strncmp(buf, "suspend", 7))
+		error = dpm_runtime_suspend(dev, state);
+
 	return error ? error : n;
 }
 

-- 
Thanks, Sharp!

^ permalink raw reply	[flat|nested] 64+ messages in thread
* Re: [linux-pm] [patch] pm: fix runtime powermanagement's /sys interface
@ 2006-01-05 15:16 Scott E. Preece
  2006-01-05 16:41 ` Alan Stern
  2006-01-05 21:48 ` Patrick Mochel
  0 siblings, 2 replies; 64+ messages in thread
From: Scott E. Preece @ 2006-01-05 15:16 UTC (permalink / raw)
  To: pavel; +Cc: stern, akpm, linux-pm, linux-kernel


My inclination would be to have the sysfs interface know generic terms,
with the implementation mapping them to device-specific terms. It ought
to be possible to build portable tools that don't have to know about
device-specific states and have the device interfaces (in sysfs) do the
necessary translation.

However, I also think there is value in having the sysfs interface
recognize the device-specific values as well, so that device-specific
tools can also be written (offering the option of taking advantage of
special capabilities of a particular device).

scott

| On St 04-01-06 17:06:09, Alan Stern wrote:
| > On Wed, 4 Jan 2006, Pavel Machek wrote:
| > 
| > > > As I mentioned in the thread (currently happening, BTW) on the linux-pm
| > > > list, what you want to do is accept a string that reflects an actual state
| > > > that the device supports. For PCI devices that support low-power states,
| > > > this would be "D1", "D2", "D3", etc. For USB devices, which only support
| > > > an "on" and "suspended" state, the values that this patch parses would
| > > > actually work.
| > > 
| > > We want _common_ values, anyway. So, we do not want "D0", "D1", "D2",
| > > "D3hot" in PCI cases. We probably want "on", "D1", "D2", "suspend",
| > > and I'm not sure about those "D1" and "D2" parts. Userspace should not
| > > have to know about details, it will mostly use "on"/"suspend" anyway.
| > 
| > It would be good to make the details available so that they are there when
| > needed.  For instance, we might export "D0", "on", "D1", "D2", "D3", and
| > "suspend", treating "on" as a synonym for "D0" and "suspend" as a synonym
| > for "D3".
| 
| Why to make it this complex?
| 
| I do not think there's any confusion possible. "on" always corresponds
| to "D0", and "suspend" is "D3". Anyone who knows what "D2" means,
| should know that, too...
| 							Pavel
| -- 
| Thanks, Sharp!
| 
| --===============85566774732936779==
| ----------
| _______________________________________________
| linux-pm mailing list
| linux-pm@lists.osdl.org
| https://lists.osdl.org/mailman/listinfo/linux-pm
| 
| --===============85566774732936779==--

-- 
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



^ permalink raw reply	[flat|nested] 64+ messages in thread
* RE: [linux-pm] [patch] pm: fix runtime powermanagement's /sys interface
@ 2006-01-05 22:13 Preece Scott-PREECE
  0 siblings, 0 replies; 64+ messages in thread
From: Preece Scott-PREECE @ 2006-01-05 22:13 UTC (permalink / raw)
  To: Patrick Mochel; +Cc: pavel, akpm, linux-pm, linux-kernel

User space has no particular reason to know which state of a particular
device corresponds to the logical state "on" or "off" or whatever other
states might be needed. Once you've defined the set of standard, generic
states, then the device driver writer can figure out which device state
matches the requirements for a given generic state.

While I wouldn't hate putting this in a system-level configuration file,
I really think it's device-specific stuff that should be built-in.

scott

-----Original Message-----
From: Patrick Mochel [mailto:mochel@digitalimplant.org] 
Sent: Thursday, January 05, 2006 3:48 PM
To: Preece Scott-PREECE
Cc: pavel@suse.cz; ; ; 
Subject: Re: [linux-pm] [patch] pm: fix runtime powermanagement's /sys
interface


On Thu, 5 Jan 2006, Scott E. Preece wrote:

> --===============26103097005026354==
>
>
> My inclination would be to have the sysfs interface know generic 
> terms, with the implementation mapping them to device-specific terms. 
> It ought to be possible to build portable tools that don't have to 
> know about device-specific states and have the device interfaces (in 
> sysfs) do the necessary translation.

Userspace should do the translation. You should give the user the
ability to specify simple, meaningful states, like "on" and "off". But,
it should be the tools itself that are mapping those requests to valid
input for the sysfs files.

Why force the translation into the kernel, and provide more
opportunities for error in parsing the sysfs files? Do it in userspace,
and you can afford much more flexibility and portability.

Thanks,


	Patrick


^ permalink raw reply	[flat|nested] 64+ messages in thread
* RE: [linux-pm] [patch] pm: fix runtime powermanagement's /sys interface
@ 2006-01-05 22:21 Preece Scott-PREECE
  2006-01-05 22:45 ` Pavel Machek
  2006-01-06  0:02 ` Patrick Mochel
  0 siblings, 2 replies; 64+ messages in thread
From: Preece Scott-PREECE @ 2006-01-05 22:21 UTC (permalink / raw)
  To: Pavel Machek, Alan Stern; +Cc: akpm, linux-pm, linux-kernel

We do have multiple system-level low-power modes. I believe today they
differ in turning whole devices on or off, but there are some of those
devices that could be put in reduced-function/lowered-speed modes if we
were ready to use a finer-grained distinction.

This is, of course, in an embedded framework rather than a desktop
framework - we suspend and wakeup automatically, not via user
intervention. Answering a question asked in another piece of mail, we
have roughly a dozen different devices that cause the system to wakeup -
keypad press, touchscreen touch, flip open/close, etc.

And, PCI is totally alien to us...

scott  

-----Original Message-----
From: Pavel Machek [mailto:pavel@ucw.cz] 

Bring example hardware that needs more than two states, implement driver
support for that, and then we can talk about adding more than two states
into core code.

								Pavel


And from another mail:

Out of curiosity, are there really cases where there is > 1 wakeup
device?

--
Thanks, Sharp!

^ permalink raw reply	[flat|nested] 64+ messages in thread
* RE: [linux-pm] [patch] pm: fix runtime powermanagement's /sys interface
@ 2006-01-05 22:55 Preece Scott-PREECE
  2006-01-05 23:05 ` Pavel Machek
  0 siblings, 1 reply; 64+ messages in thread
From: Preece Scott-PREECE @ 2006-01-05 22:55 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Alan Stern, akpm, linux-pm, linux-kernel

I shouldn't oversimplify the power management in a cell phone. When I said we turned whole devices on/off, I was referring only to what the system-level PM (which uses suspend/resume) does. There's a fair amount of subsystem-specific power management outside the Linux suspend/resume framework. Some of it might be handled in the framework, if the framework were more capable.

scott

-----Original Message-----
From: Pavel Machek [mailto:pavel@ucw.cz] 
Sent: Thursday, January 05, 2006 4:46 PM
To: Preece Scott-PREECE
Cc: Alan Stern; akpm@osdl.org; linux-pm@lists.osdl.org; linux-kernel@vger.kernel.org
Subject: Re: [linux-pm] [patch] pm: fix runtime powermanagement's /sys interface

On Čt 05-01-06 17:21:38, Preece Scott-PREECE wrote:
> We do have multiple system-level low-power modes. I believe today they 
> differ in turning whole devices on or off, but there are some of those 
> devices that could be put in reduced-function/lowered-speed modes if 
> we were ready to use a finer-grained distinction.

I think we were talking multiple off modes for _single device_. It is good to know that even cellphones can get away with whole devices on/off today.
								Pavel

--
Thanks, Sharp!

^ permalink raw reply	[flat|nested] 64+ messages in thread
* Re: [linux-pm] [patch] pm: fix runtime powermanagement's /sys interface
@ 2006-01-06  0:31 Scott E. Preece
  0 siblings, 0 replies; 64+ messages in thread
From: Scott E. Preece @ 2006-01-06  0:31 UTC (permalink / raw)
  To: mochel; +Cc: scott.preece, pavel, stern, akpm, linux-pm, linux-kernel


OK - sorry, my misparsing of what you asked. I agree that wakeup would
always be caused by some single device, not by multiple devices.

scott

| From mochel@digitalimplant.org Thu Jan  5 18:04:42 2006
| Date: Thu, 5 Jan 2006 16:02:29 -0800 (PST)
| From: Patrick Mochel<mochel@digitalimplant.org>
| cc: Pavel Machek<pavel@ucw.cz>, Alan Stern<stern@rowland.harvard.edu>,
| 
| 
| On Thu, 5 Jan 2006, Preece Scott-PREECE wrote:
| 
| > This is, of course, in an embedded framework rather than a desktop
| > framework - we suspend and wakeup automatically, not via user
| > intervention. Answering a question asked in another piece of mail, we
| > have roughly a dozen different devices that cause the system to wakeup -
| > keypad press, touchscreen touch, flip open/close, etc.
| 
| Hmm, it would be nice if that comment was in reply to the email in which
| it came. At least if it was in the same thread..
| 
| Many systems have > 1 _possible_ wakeup devices (keyboard, touchscreen,
| lid, etc). You implied that when a system wakes up, there could be > 1
| device that actually woke the system up, which is in direct conflict with
| what I've always assumed - that when a system wakes up, it is caused by a
| single device (and if there were multiple events, like a key press *and* a
| mouse movement, it's doesn't really matter)..
| 
| Thanks,
| 
| 
| 	Patrick
| 
| 

-- 
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



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

end of thread, other threads:[~2006-01-13 19:55 UTC | newest]

Thread overview: 64+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-27 21:34 [patch] pm: fix runtime powermanagement's /sys interface Pavel Machek
2005-12-27 21:55 ` [linux-pm] " Dmitry Torokhov
2005-12-27 22:05   ` Pavel Machek
2005-12-28  4:22     ` Patrick Mochel
2006-01-04 21:34       ` Pavel Machek
2006-01-04 22:06         ` Alan Stern
2006-01-04 22:16           ` Pavel Machek
2006-01-05 21:43           ` Patrick Mochel
2006-01-05 22:06             ` Alan Stern
2006-01-05 22:28               ` Pavel Machek
2006-01-05 21:42         ` Patrick Mochel
2006-01-05 21:55           ` Pavel Machek
2006-01-05 22:13             ` Dominik Brodowski
2006-01-05 22:23               ` Pavel Machek
2006-01-05 22:27                 ` Dominik Brodowski
2006-01-05 22:59                   ` Pavel Machek
2006-01-05 23:08                   ` Pavel Machek
2006-01-05 23:46                     ` Dominik Brodowski
2006-01-05 23:58                       ` Pavel Machek
2006-01-06  0:04                         ` Patrick Mochel
2006-01-06  0:12                           ` Pavel Machek
2006-01-06  1:37                             ` Patrick Mochel
2006-01-06  8:59                               ` Pavel Machek
2006-01-07  5:47                                 ` Adam Belay
2006-01-06  9:00                               ` Pavel Machek
2006-01-06 15:00                               ` Dominik Brodowski
2006-01-07  5:58                                 ` Adam Belay
2006-01-06 15:42                               ` Alan Stern
2006-01-07  0:08                                 ` Pavel Machek
2006-01-07  3:19                                   ` Alan Stern
2006-01-07  7:58                                   ` Adam Belay
2006-01-07 10:20                                     ` Pavel Machek
2006-01-07 13:06                                       ` Adam Belay
2006-01-06  4:17                                         ` Pavel Machek
2006-01-07  7:41                                 ` Adam Belay
2006-01-07 15:24                                   ` Alan Stern
2006-01-06  0:38                   ` Greg KH
2006-01-06 15:03                     ` Dominik Brodowski
2006-01-06 16:25                       ` Kay Sievers
2006-01-09 20:10                         ` Dominik Brodowski
2006-01-05 22:15             ` Patrick Mochel
2006-01-05 22:44               ` Pavel Machek
2006-01-05 23:54                 ` Patrick Mochel
2006-01-06  0:07                   ` Pavel Machek
2006-01-06 14:34             ` Tom Marshall
2006-01-06 16:20               ` Pavel Machek
2006-01-07  8:36         ` Adam Belay
2006-01-07 10:25           ` Pavel Machek
2006-01-07 12:45             ` Adam Belay
2006-01-06  4:24               ` Pavel Machek
2006-01-13 20:00                 ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2006-01-05 15:16 Scott E. Preece
2006-01-05 16:41 ` Alan Stern
2006-01-05 21:14   ` Pavel Machek
2006-01-05 21:37     ` Alan Stern
2006-01-05 21:44       ` Pavel Machek
2006-01-05 21:48 ` Patrick Mochel
2006-01-05 22:13 Preece Scott-PREECE
2006-01-05 22:21 Preece Scott-PREECE
2006-01-05 22:45 ` Pavel Machek
2006-01-06  0:02 ` Patrick Mochel
2006-01-05 22:55 Preece Scott-PREECE
2006-01-05 23:05 ` Pavel Machek
2006-01-06  0:31 Scott E. Preece

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