<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/thermal/gov_power_allocator.c, branch v6.6.131</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.6.131</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.6.131'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2024-02-01T00:19:10+00:00</updated>
<entry>
<title>thermal: gov_power_allocator: avoid inability to reset a cdev</title>
<updated>2024-02-01T00:19:10+00:00</updated>
<author>
<name>Di Shen</name>
<email>di.shen@unisoc.com</email>
</author>
<published>2024-01-10T11:55:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d10ff0b3eaf6cec35f6928f1cca7a56b1a089b07'/>
<id>urn:sha1:d10ff0b3eaf6cec35f6928f1cca7a56b1a089b07</id>
<content type='text'>
[ Upstream commit e95fa7404716f6e25021e66067271a4ad8eb1486 ]

Commit 0952177f2a1f ("thermal/core/power_allocator: Update once
cooling devices when temp is low") adds an update flag to avoid
triggering a thermal event when there is no need, and the thermal
cdev is updated once when the temperature is low.

But when the trips are writable, and switch_on_temp is set to be a
higher value, the cooling device state may not be reset to 0,
because last_temperature is smaller than switch_on_temp.

For example:
First:
switch_on_temp=70 control_temp=85;
Then userspace change the trip_temp:
switch_on_temp=45 control_temp=55 cur_temp=54

Then userspace reset the trip_temp:
switch_on_temp=70 control_temp=85 cur_temp=57 last_temp=54

At this time, the cooling device state should be reset to 0.
However, because cur_temp(57) &lt; switch_on_temp(70)
last_temp(54) &lt; switch_on_temp(70)  ----&gt;  update = false,
update is false, the cooling device state can not be reset.

Using the observation that tz-&gt;passive can also be regarded as the
temperature status, set the update flag to the tz-&gt;passive value.

When the temperature drops below switch_on for the first time, the
states of cooling devices can be reset once, and tz-&gt;passive is updated
to 0. In the next round, because tz-&gt;passive is 0, cdev-&gt;state will not
be updated.

By using the tz-&gt;passive value as the "update" flag, the issue above
can be solved, and the cooling devices can be updated only once when the
temperature is low.

Fixes: 0952177f2a1f ("thermal/core/power_allocator: Update once cooling devices when temp is low")
Cc: 5.13+ &lt;stable@vger.kernel.org&gt; # 5.13+
Suggested-by: Wei Wang &lt;wvw@google.com&gt;
Signed-off-by: Di Shen &lt;di.shen@unisoc.com&gt;
Reviewed-by: Lukasz Luba &lt;lukasz.luba@arm.com&gt;
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>thermal: core: Store trip pointer in struct thermal_instance</title>
<updated>2024-02-01T00:19:10+00:00</updated>
<author>
<name>Rafael J. Wysocki</name>
<email>rafael.j.wysocki@intel.com</email>
</author>
<published>2023-09-21T17:52:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=77451ef587aa8aeb562e4163fd014bde940cca99'/>
<id>urn:sha1:77451ef587aa8aeb562e4163fd014bde940cca99</id>
<content type='text'>
[ Upstream commit 2c7b4bfadef08cc0995c24a7b9eb120fe897165f ]

Replace the integer trip number stored in struct thermal_instance with
a pointer to the relevant trip and adjust the code using the structure
in question accordingly.

The main reason for making this change is to allow the trip point to
cooling device binding code more straightforward, as illustrated by
subsequent modifications of the ACPI thermal driver, but it also helps
to clarify the overall design and allows the governor code overhead to
be reduced (through subsequent modifications).

The only case in which it adds complexity is trip_point_show() that
needs to walk the trips[] table to find the index of the given trip
point, but this is not a critical path and the interface that
trip_point_show() belongs to is problematic anyway (for instance, it
doesn't cover the case when the same cooling devices is associated
with multiple trip points).

This is a preliminary change and the affected code will be refined by
a series of subsequent modifications of thermal governors, the core and
the ACPI thermal driver.

The general functionality is not expected to be affected by this change.

Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Reviewed-by: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
Stable-dep-of: e95fa7404716 ("thermal: gov_power_allocator: avoid inability to reset a cdev")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>thermal/core: Relocate the traces definition in thermal directory</title>
<updated>2023-04-01T18:51:45+00:00</updated>
<author>
<name>Daniel Lezcano</name>
<email>daniel.lezcano@linaro.org</email>
</author>
<published>2023-03-07T13:37:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=32a7a02117de01199ce15ec121ac7af417c340eb'/>
<id>urn:sha1:32a7a02117de01199ce15ec121ac7af417c340eb</id>
<content type='text'>
The traces are exported but only local to the thermal core code. On
the other side, the traces take the thermal zone device structure as
argument, thus they have to rely on the exported thermal.h header
file. As we want to move the structure to the private thermal core
header, first we have to relocate those traces to the same place as
many drivers do.

Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Suggested-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Signed-off-by: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
Reviewed-by: Steven Rostedt (Google) &lt;rostedt@goodmis.org&gt;
Link: https://lore.kernel.org/r/20230307133735.90772-2-daniel.lezcano@linaro.org
</content>
</entry>
<entry>
<title>thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions</title>
<updated>2023-01-06T13:14:47+00:00</updated>
<author>
<name>Daniel Lezcano</name>
<email>daniel.lezcano@linaro.org</email>
</author>
<published>2022-10-03T09:25:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7f725a23f2b7bb338a3d41ce7bf96d6c99bdb0b7'/>
<id>urn:sha1:7f725a23f2b7bb338a3d41ce7bf96d6c99bdb0b7</id>
<content type='text'>
The governors are using the ops-&gt;get_trip_* functions, Replace these
calls with thermal_zone_get_trip().

Signed-off-by: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
Reviewed-by: Zhang Rui &lt;rui.zhang@intel.com&gt;
Reviewed-by: Lukasz Luba &lt;lukasz.luba@arm.com&gt; # IPA
Acked-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Link: https://lore.kernel.org/r/20221003092602.1323944-5-daniel.lezcano@linaro.org
</content>
</entry>
<entry>
<title>thermal/core/power allocator: Remove a useless include</title>
<updated>2022-12-14T14:25:40+00:00</updated>
<author>
<name>Christophe JAILLET</name>
<email>christophe.jaillet@wanadoo.fr</email>
</author>
<published>2022-11-26T10:42:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=de04f680b0ab71d2b9085903fe608a15541f66cb'/>
<id>urn:sha1:de04f680b0ab71d2b9085903fe608a15541f66cb</id>
<content type='text'>
This file does not use rcu, so there is no point in including
&lt;linux/rculist.h&gt;.

Remove it.

Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Reviewed-by: Lukasz Luba &lt;lukasz.luba@arm.com&gt;
Link: https://lore.kernel.org/r/9adeec47cb5a8193016272d5c8bf936235c1711d.1669459337.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Daniel Lezcano &lt;daniel.lezcano@kernel.org&gt;
</content>
</entry>
<entry>
<title>thermal/core: Move the thermal zone lock out of the governors</title>
<updated>2022-08-17T12:09:39+00:00</updated>
<author>
<name>Daniel Lezcano</name>
<email>daniel.lezcano@linaro.org</email>
</author>
<published>2022-08-05T15:38:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=670a5e356cb6dfc61b87b599eba483af6a3a99ad'/>
<id>urn:sha1:670a5e356cb6dfc61b87b599eba483af6a3a99ad</id>
<content type='text'>
All the governors throttling ops are taking/releasing the lock at the
beginning and the end of the function.

We can move the mutex to the throttling call site instead.

Signed-off-by: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
Link: https://lore.kernel.org/r/20220805153834.2510142-4-daniel.lezcano@linaro.org
</content>
</entry>
<entry>
<title>thermal/governors: Group the thermal zone lock inside the throttle function</title>
<updated>2022-08-17T12:09:39+00:00</updated>
<author>
<name>Daniel Lezcano</name>
<email>daniel.lezcano@linaro.org</email>
</author>
<published>2022-08-05T15:38:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=63561fe36b094729d3d4d274bafaa030b39e89f6'/>
<id>urn:sha1:63561fe36b094729d3d4d274bafaa030b39e89f6</id>
<content type='text'>
The thermal zone lock is taken in the different places in the
throttling path.

At the first glance it does not hurt to move them at the beginning and
the end of the 'throttle' function. That will allow a consolidation of
the lock in the next following changes.

Signed-off-by: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
Link: https://lore.kernel.org/r/20220805153834.2510142-3-daniel.lezcano@linaro.org
</content>
</entry>
<entry>
<title>thermal/core: Rename 'trips' to 'num_trips'</title>
<updated>2022-07-28T15:29:56+00:00</updated>
<author>
<name>Daniel Lezcano</name>
<email>daniel.lezcano@linexp.org</email>
</author>
<published>2022-07-22T20:00:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e5bfcd30f88fdb0ce830229e7ccdeddcb7a59b04'/>
<id>urn:sha1:e5bfcd30f88fdb0ce830229e7ccdeddcb7a59b04</id>
<content type='text'>
In order to use thermal trips defined in the thermal structure, rename
the 'trips' field to 'num_trips' to have the 'trips' field containing the
thermal trip points.

Cc: Alexandre Bailon &lt;abailon@baylibre.com&gt;
Cc: Kevin Hilman &lt;khilman@baylibre.com&gt;
Signed-off-by: Daniel Lezcano &lt;daniel.lezcano@linexp.org&gt;
Link: https://lore.kernel.org/r/20220722200007.1839356-8-daniel.lezcano@linexp.org
Signed-off-by: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
</content>
</entry>
<entry>
<title>thermal/core/power allocator: Use the lockless __thermal_cdev_update() function</title>
<updated>2021-04-22T21:51:32+00:00</updated>
<author>
<name>Lukasz Luba</name>
<email>lukasz.luba@arm.com</email>
</author>
<published>2021-04-22T15:36:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ab39c8853737158604e154ad3b03639e74082bd6'/>
<id>urn:sha1:ab39c8853737158604e154ad3b03639e74082bd6</id>
<content type='text'>
Use the new helper function and avoid unnecessery second lock/unlock,
which was present in old approach with thermal_cdev_update().

Signed-off-by: Lukasz Luba &lt;lukasz.luba@arm.com&gt;
Signed-off-by: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
Link: https://lore.kernel.org/r/20210422153624.6074-4-lukasz.luba@arm.com
</content>
</entry>
<entry>
<title>thermal/core/power_allocator: Update once cooling devices when temp is low</title>
<updated>2021-04-22T21:51:14+00:00</updated>
<author>
<name>Lukasz Luba</name>
<email>lukasz.luba@arm.com</email>
</author>
<published>2021-04-22T11:43:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=0952177f2a1f63ba87a1940fac21768f402c0b94'/>
<id>urn:sha1:0952177f2a1f63ba87a1940fac21768f402c0b94</id>
<content type='text'>
The cooling device state change generates an event, also when there is no
need, because temperature is low and device is not throttled. Avoid to
unnecessary update the cooling device which means also not sending event.
The cooling device state has not changed because the temperature is still
below the first activation trip point value, so we can do this.
Add a tracking mechanism to make sure it updates cooling devices only
once - when the temperature dropps below first trip point.

Reported-by: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
Signed-off-by: Lukasz Luba &lt;lukasz.luba@arm.com&gt;
Signed-off-by: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
Link: https://lore.kernel.org/r/20210422114308.29684-4-lukasz.luba@arm.com
</content>
</entry>
</feed>
