* [PATCH] regulator: notify sysfs when voltage is set
@ 2012-03-15 12:04 Simon Horman
2012-03-15 12:46 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2012-03-15 12:04 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-kernel, Simon Horman
This allows libudev to be used to monitor voltage changes and thus allows
user-space code to avoid polling the sysfs entry for changes.
Signed-off-by: Simon Horman <horms@verge.net.au>
---
drivers/regulator/core.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index b97c4a2..f3905b0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1783,6 +1783,19 @@ int regulator_is_supported_voltage(struct regulator *regulator,
}
EXPORT_SYMBOL_GPL(regulator_is_supported_voltage);
+static void regulator_generate_event(struct regulator_dev *rdev)
+{
+ char buf[32], *envp[2];
+
+ sprintf(buf, "MICROVOLTS=%d", _regulator_get_voltage(rdev));
+
+ envp[0] = buf;
+ envp[1] = NULL;
+
+ kobject_uevent_env(&rdev->dev.kobj, KOBJ_CHANGE, envp);
+ sysfs_notify(&rdev->dev.kobj, NULL, "microvolts");
+}
+
static int _regulator_do_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
@@ -1862,6 +1875,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
udelay(delay);
}
+ regulator_generate_event(rdev);
+
if (ret == 0)
_notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE,
NULL);
--
1.7.6.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] regulator: notify sysfs when voltage is set
2012-03-15 12:04 [PATCH] regulator: notify sysfs when voltage is set Simon Horman
@ 2012-03-15 12:46 ` Mark Brown
2012-03-15 14:26 ` Simon Horman
0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2012-03-15 12:46 UTC (permalink / raw)
To: Simon Horman; +Cc: Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 497 bytes --]
On Thu, Mar 15, 2012 at 09:04:33PM +0900, Simon Horman wrote:
> This allows libudev to be used to monitor voltage changes and thus allows
> user-space code to avoid polling the sysfs entry for changes.
I notice that we don't generate similar events for cpufreq... what are
the performance implications from firing off udev (which isn't free)
every time we scale the CPU frequency? It feels like this might be
disruptive, especially with a governor like ondemand which responds to
system load.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] regulator: notify sysfs when voltage is set
2012-03-15 12:46 ` Mark Brown
@ 2012-03-15 14:26 ` Simon Horman
2012-03-15 14:47 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2012-03-15 14:26 UTC (permalink / raw)
To: Mark Brown; +Cc: Liam Girdwood, linux-kernel
On Thu, Mar 15, 2012 at 12:46:31PM +0000, Mark Brown wrote:
> On Thu, Mar 15, 2012 at 09:04:33PM +0900, Simon Horman wrote:
>
> > This allows libudev to be used to monitor voltage changes and thus allows
> > user-space code to avoid polling the sysfs entry for changes.
>
> I notice that we don't generate similar events for cpufreq... what are
> the performance implications from firing off udev (which isn't free)
> every time we scale the CPU frequency? It feels like this might be
> disruptive, especially with a governor like ondemand which responds to
> system load.
Hi Mark,
that is a good point and to be honest not one that I had considered. For
the use-case that I have in mind, which is basically to log voltage changes
over time, it may be acceptable to rate-limit notifications somehow. But at
that point I may be better off just polling.
Out of interest, how often can ondemand potentially change the voltage?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] regulator: notify sysfs when voltage is set
2012-03-15 14:26 ` Simon Horman
@ 2012-03-15 14:47 ` Mark Brown
2012-03-15 23:23 ` Simon Horman
0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2012-03-15 14:47 UTC (permalink / raw)
To: Simon Horman; +Cc: Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1457 bytes --]
On Thu, Mar 15, 2012 at 11:26:58PM +0900, Simon Horman wrote:
> On Thu, Mar 15, 2012 at 12:46:31PM +0000, Mark Brown wrote:
> > I notice that we don't generate similar events for cpufreq... what are
> > the performance implications from firing off udev (which isn't free)
> > every time we scale the CPU frequency? It feels like this might be
> > disruptive, especially with a governor like ondemand which responds to
> > system load.
> that is a good point and to be honest not one that I had considered. For
> the use-case that I have in mind, which is basically to log voltage changes
> over time, it may be acceptable to rate-limit notifications somehow. But at
> that point I may be better off just polling.
Hrm, if you're doing logging then we do already have tracepoints defined
for voltage changes - could you have your application work with those
instead of sysfs? One of the applications of tracepoints is flight
recorder style system monitoring.
> Out of interest, how often can ondemand potentially change the voltage?
Depends on how slow it thinks frequency changes are. I'm not so worried
about the performance impact from that point of view, I'm more worried
about what happens when we lower the clock frequency and generate a
sysfs event causing userspace to wake up and start doing stuff. It'd be
bad if ondemand (or another dynamic governor) noticed that the system
got more busy again and responded by ramping the frequency...
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] regulator: notify sysfs when voltage is set
2012-03-15 14:47 ` Mark Brown
@ 2012-03-15 23:23 ` Simon Horman
0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2012-03-15 23:23 UTC (permalink / raw)
To: Mark Brown; +Cc: Liam Girdwood, linux-kernel
On Thu, Mar 15, 2012 at 02:47:08PM +0000, Mark Brown wrote:
> On Thu, Mar 15, 2012 at 11:26:58PM +0900, Simon Horman wrote:
> > On Thu, Mar 15, 2012 at 12:46:31PM +0000, Mark Brown wrote:
>
> > > I notice that we don't generate similar events for cpufreq... what are
> > > the performance implications from firing off udev (which isn't free)
> > > every time we scale the CPU frequency? It feels like this might be
> > > disruptive, especially with a governor like ondemand which responds to
> > > system load.
>
> > that is a good point and to be honest not one that I had considered. For
> > the use-case that I have in mind, which is basically to log voltage changes
> > over time, it may be acceptable to rate-limit notifications somehow. But at
> > that point I may be better off just polling.
>
> Hrm, if you're doing logging then we do already have tracepoints defined
> for voltage changes - could you have your application work with those
> instead of sysfs? One of the applications of tracepoints is flight
> recorder style system monitoring.
Thanks, that does sound like it would work for me.
I'll look into it further.
> > Out of interest, how often can ondemand potentially change the voltage?
>
> Depends on how slow it thinks frequency changes are. I'm not so worried
> about the performance impact from that point of view, I'm more worried
> about what happens when we lower the clock frequency and generate a
> sysfs event causing userspace to wake up and start doing stuff. It'd be
> bad if ondemand (or another dynamic governor) noticed that the system
> got more busy again and responded by ramping the frequency...
Ok, understood, that could be a bit nasty.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-15 23:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-15 12:04 [PATCH] regulator: notify sysfs when voltage is set Simon Horman
2012-03-15 12:46 ` Mark Brown
2012-03-15 14:26 ` Simon Horman
2012-03-15 14:47 ` Mark Brown
2012-03-15 23:23 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox