* [PATCH] thermal: lock the thermal zone when switching governors
@ 2014-11-25 16:00 Javi Merino
2014-12-03 19:11 ` Javi Merino
0 siblings, 1 reply; 3+ messages in thread
From: Javi Merino @ 2014-11-25 16:00 UTC (permalink / raw)
To: linux-pm; +Cc: Javi Merino, Zhang Rui, Eduardo Valentin
Currently, userspace can request a governor change while the governor
itself is running. Grab the thermal zone lock when changing the
governor to prevent this race.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Javi Merino <javi.merino@arm.com>
---
drivers/thermal/thermal_core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 43b90709585f..c1901961f8c0 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -757,6 +757,7 @@ policy_store(struct device *dev, struct device_attribute *attr,
snprintf(name, sizeof(name), "%s", buf);
mutex_lock(&thermal_governor_lock);
+ mutex_lock(&tz->lock);
gov = __find_governor(strim(name));
if (!gov)
@@ -766,6 +767,7 @@ policy_store(struct device *dev, struct device_attribute *attr,
ret = count;
exit:
+ mutex_unlock(&tz->lock);
mutex_unlock(&thermal_governor_lock);
return ret;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal: lock the thermal zone when switching governors
2014-11-25 16:00 [PATCH] thermal: lock the thermal zone when switching governors Javi Merino
@ 2014-12-03 19:11 ` Javi Merino
2014-12-08 14:31 ` Eduardo Valentin
0 siblings, 1 reply; 3+ messages in thread
From: Javi Merino @ 2014-12-03 19:11 UTC (permalink / raw)
To: linux-pm; +Cc: Zhang Rui, Eduardo Valentin
Ping
On Tue, Nov 25, 2014 at 04:00:33PM +0000, Javi Merino wrote:
> Currently, userspace can request a governor change while the governor
> itself is running. Grab the thermal zone lock when changing the
> governor to prevent this race.
>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: Eduardo Valentin <edubezval@gmail.com>
> Signed-off-by: Javi Merino <javi.merino@arm.com>
> ---
> drivers/thermal/thermal_core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index 43b90709585f..c1901961f8c0 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -757,6 +757,7 @@ policy_store(struct device *dev, struct device_attribute *attr,
> snprintf(name, sizeof(name), "%s", buf);
>
> mutex_lock(&thermal_governor_lock);
> + mutex_lock(&tz->lock);
>
> gov = __find_governor(strim(name));
> if (!gov)
> @@ -766,6 +767,7 @@ policy_store(struct device *dev, struct device_attribute *attr,
> ret = count;
>
> exit:
> + mutex_unlock(&tz->lock);
> mutex_unlock(&thermal_governor_lock);
> return ret;
> }
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal: lock the thermal zone when switching governors
2014-12-03 19:11 ` Javi Merino
@ 2014-12-08 14:31 ` Eduardo Valentin
0 siblings, 0 replies; 3+ messages in thread
From: Eduardo Valentin @ 2014-12-08 14:31 UTC (permalink / raw)
To: Javi Merino; +Cc: linux-pm, Zhang Rui
Hello,
On Wed, Dec 03, 2014 at 07:11:09PM +0000, Javi Merino wrote:
> Ping
>
> On Tue, Nov 25, 2014 at 04:00:33PM +0000, Javi Merino wrote:
> > Currently, userspace can request a governor change while the governor
> > itself is running. Grab the thermal zone lock when changing the
> > governor to prevent this race.
> >
> > Cc: Zhang Rui <rui.zhang@intel.com>
> > Cc: Eduardo Valentin <edubezval@gmail.com>
> > Signed-off-by: Javi Merino <javi.merino@arm.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
But I believe Rui has already merged this one. Just for the record
anyways.
> > ---
> > drivers/thermal/thermal_core.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> > index 43b90709585f..c1901961f8c0 100644
> > --- a/drivers/thermal/thermal_core.c
> > +++ b/drivers/thermal/thermal_core.c
> > @@ -757,6 +757,7 @@ policy_store(struct device *dev, struct device_attribute *attr,
> > snprintf(name, sizeof(name), "%s", buf);
> >
> > mutex_lock(&thermal_governor_lock);
> > + mutex_lock(&tz->lock);
> >
> > gov = __find_governor(strim(name));
> > if (!gov)
> > @@ -766,6 +767,7 @@ policy_store(struct device *dev, struct device_attribute *attr,
> > ret = count;
> >
> > exit:
> > + mutex_unlock(&tz->lock);
> > mutex_unlock(&thermal_governor_lock);
> > return ret;
> > }
> > --
> > 1.9.1
> >
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-08 14:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-25 16:00 [PATCH] thermal: lock the thermal zone when switching governors Javi Merino
2014-12-03 19:11 ` Javi Merino
2014-12-08 14:31 ` Eduardo Valentin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.