<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/drivers/thermal/power_allocator.c, branch linux-6.9.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.9.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.9.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2020-05-22T16:48:54Z</updated>
<entry>
<title>thermal/governors: Prefix all source files with gov_</title>
<updated>2020-05-22T16:48:54Z</updated>
<author>
<name>Amit Kucheria</name>
<email>amit.kucheria@linaro.org</email>
</author>
<published>2020-05-11T12:25:01Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=0015d9a2a72745308ef9728a746ff7b1e82138bc'/>
<id>urn:sha1:0015d9a2a72745308ef9728a746ff7b1e82138bc</id>
<content type='text'>
Bang-bang governor source file is prefixed with gov_. Do the same for
other governors for consistency so they're easy to find in the sources.

Signed-off-by: Amit Kucheria &lt;amit.kucheria@linaro.org&gt;
Signed-off-by: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
Link: https://lore.kernel.org/r/b9a85d3204712f14e320504948c12712dc0b291b.1589199124.git.amit.kucheria@linaro.org
</content>
</entry>
<entry>
<title>thermal/drivers/core: Use governor table to initialize</title>
<updated>2019-06-27T13:22:14Z</updated>
<author>
<name>Daniel Lezcano</name>
<email>daniel.lezcano@linaro.org</email>
</author>
<published>2019-06-12T20:13:25Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=57c5b2ec905933da84fe77b2b54619567ac21297'/>
<id>urn:sha1:57c5b2ec905933da84fe77b2b54619567ac21297</id>
<content type='text'>
Now that the governor table is in place and the macro allows to browse the
table, declare the governor so the entry is added in the governor table
in the init section.

The [un]register_thermal_governors function does no longer need to use the
exported [un]register thermal governor's specific function which in turn
call the [un]register_thermal_governor. The governors are fully
self-encapsulated.

The cyclic dependency is no longer needed, remove it.

Reviewed-by: Amit Kucheria &lt;amit.kucheria@linaro.org&gt;
Signed-off-by: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
Signed-off-by: Zhang Rui &lt;rui.zhang@intel.com&gt;
</content>
</entry>
<entry>
<title>thermal: power_allocator: fix one race condition issue for thermal_instances list</title>
<updated>2017-12-27T02:13:20Z</updated>
<author>
<name>Yi Zeng</name>
<email>yizeng@asrmicro.com</email>
</author>
<published>2017-12-26T11:22:26Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=a5de11d67dcd268b8d0beb73dc374de5e97f0caf'/>
<id>urn:sha1:a5de11d67dcd268b8d0beb73dc374de5e97f0caf</id>
<content type='text'>
When invoking allow_maximum_power and traverse tz-&gt;thermal_instances,
we should grab thermal_zone_device-&gt;lock to avoid race condition. For
example, during the system reboot, if the mali GPU device implements
device shutdown callback and unregister GPU devfreq cooling device,
the deleted list head may be accessed to cause panic, as the following
log shows:

[   33.551070] c3 25 (kworker/3:0) Unable to handle kernel paging request at virtual address dead000000000070
[   33.566708] c3 25 (kworker/3:0) pgd = ffffffc0ed290000
[   33.572071] c3 25 (kworker/3:0) [dead000000000070] *pgd=00000001ed292003, *pud=00000001ed292003, *pmd=0000000000000000
[   33.581515] c3 25 (kworker/3:0) Internal error: Oops: 96000004 [#1] PREEMPT SMP
[   33.599761] c3 25 (kworker/3:0) CPU: 3 PID: 25 Comm: kworker/3:0 Not tainted 4.4.35+ #912
[   33.614137] c3 25 (kworker/3:0) Workqueue: events_freezable thermal_zone_device_check
[   33.620245] c3 25 (kworker/3:0) task: ffffffc0f32e4200 ti: ffffffc0f32f0000 task.ti: ffffffc0f32f0000
[   33.629466] c3 25 (kworker/3:0) PC is at power_allocator_throttle+0x7c8/0x8a4
[   33.636609] c3 25 (kworker/3:0) LR is at power_allocator_throttle+0x808/0x8a4
[   33.643742] c3 25 (kworker/3:0) pc : [&lt;ffffff8008683dd0&gt;] lr : [&lt;ffffff8008683e10&gt;] pstate: 20000145
[   33.652874] c3 25 (kworker/3:0) sp : ffffffc0f32f3bb0
[   34.468519] c3 25 (kworker/3:0) Process kworker/3:0 (pid: 25, stack limit = 0xffffffc0f32f0020)
[   34.477220] c3 25 (kworker/3:0) Stack: (0xffffffc0f32f3bb0 to 0xffffffc0f32f4000)
[   34.819822] c3 25 (kworker/3:0) Call trace:
[   34.824021] c3 25 (kworker/3:0) Exception stack(0xffffffc0f32f39c0 to 0xffffffc0f32f3af0)
[   34.924993] c3 25 (kworker/3:0) [&lt;ffffff8008683dd0&gt;] power_allocator_throttle+0x7c8/0x8a4
[   34.933184] c3 25 (kworker/3:0) [&lt;ffffff80086807f4&gt;] handle_thermal_trip.part.25+0x70/0x224
[   34.941545] c3 25 (kworker/3:0) [&lt;ffffff8008680a68&gt;] thermal_zone_device_update+0xc0/0x20c
[   34.949818] c3 25 (kworker/3:0) [&lt;ffffff8008680bd4&gt;] thermal_zone_device_check+0x20/0x2c
[   34.957924] c3 25 (kworker/3:0) [&lt;ffffff80080b93a4&gt;] process_one_work+0x168/0x458
[   34.965414] c3 25 (kworker/3:0) [&lt;ffffff80080ba068&gt;] worker_thread+0x13c/0x4b4
[   34.972650] c3 25 (kworker/3:0) [&lt;ffffff80080c0a4c&gt;] kthread+0xe8/0xfc
[   34.979187] c3 25 (kworker/3:0) [&lt;ffffff8008084e90&gt;] ret_from_fork+0x10/0x40
[   34.986244] c3 25 (kworker/3:0) Code: f9405e73 eb1302bf d102e273 54ffc460 (b9402a61)
[   34.994339] c3 25 (kworker/3:0) ---[ end trace 32057901e3b7e1db ]---

Signed-off-by: Yi Zeng &lt;yizeng@asrmicro.com&gt;
Signed-off-by: Zhang Rui &lt;rui.zhang@intel.com&gt;
</content>
</entry>
<entry>
<title>thermal: fix race condition when updating cooling device</title>
<updated>2016-08-08T02:57:39Z</updated>
<author>
<name>Michele Di Giorgio</name>
<email>michele.digiorgio@arm.com</email>
</author>
<published>2016-06-02T14:25:31Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=d0b7306d203c82e7c04d6eb066ca4898f016ebdd'/>
<id>urn:sha1:d0b7306d203c82e7c04d6eb066ca4898f016ebdd</id>
<content type='text'>
When multiple thermal zones are bound to the same cooling device, multiple
kernel threads may want to update the cooling device state by calling
thermal_cdev_update(). Having cdev not protected by a mutex can lead to a race
condition. Consider the following situation with two kernel threads k1 and k2:

	    Thread k1				Thread k2
                                    ||
                                    ||  call thermal_cdev_update()
                                    ||      ...
                                    ||      set_cur_state(cdev, target);
    call power_actor_set_power()    ||
        ...                         ||
        instance-&gt;target = state;   ||
        cdev-&gt;updated = false;      ||
                                    ||      cdev-&gt;updated = true;
                                    ||      // completes execution
    call thermal_cdev_update()      ||
        // cdev-&gt;updated == true    ||
        return;                     ||
                                    \/
                                    time

k2 has already looped through the thermal instances looking for the deepest
cooling device state and is preempted right before setting cdev-&gt;updated to
true. Now, k1 runs, modifies the thermal instance state and sets cdev-&gt;updated
to false. Then, k1 is preempted and k2 continues the execution by setting
cdev-&gt;updated to true, therefore preventing k1 from performing the update.
Notice that this is not an issue if k2 looks at the instance-&gt;target modified by
k1 "after" it is assigned by k1. In fact, in this case the update will happen
anyway and k1 can safely return immediately from thermal_cdev_update().

This may lead to a situation where a thermal governor never updates the cooling
device. For example, this is the case for the step_wise governor: when calling
the function thermal_zone_trip_update(), the governor may always get a new state
equal to the old one (which, however, wasn't notified to the cooling device) and
will therefore skip the update.

CC: Zhang Rui &lt;rui.zhang@intel.com&gt;
CC: Eduardo Valentin &lt;edubezval@gmail.com&gt;
CC: Peter Feuerer &lt;peter@piie.net&gt;
Reported-by: Toby Huang &lt;toby.huang@arm.com&gt;
Signed-off-by: Michele Di Giorgio &lt;michele.digiorgio@arm.com&gt;
Reviewed-by: Javi Merino &lt;javi.merino@arm.com&gt;
Signed-off-by: Zhang Rui &lt;rui.zhang@intel.com&gt;
</content>
</entry>
<entry>
<title>thermal: power_allocator: req_range multiplication should be a 64 bit type</title>
<updated>2016-04-20T23:22:45Z</updated>
<author>
<name>Javi Merino</name>
<email>javi.merino@arm.com</email>
</author>
<published>2016-04-06T18:30:18Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=f9d038144a171d42e057143b247ff7a12a5b06f5'/>
<id>urn:sha1:f9d038144a171d42e057143b247ff7a12a5b06f5</id>
<content type='text'>
req_range is declared as a u64 to cope with overflows in the
multiplication of two u32.  As both req_power and power_range are u32,
we need to make sure the multiplication is done with u64 types.

Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Cc: Zhang Rui &lt;rui.zhang@intel.com&gt;
Cc: Eduardo Valentin &lt;edubezval@gmail.com&gt;
Signed-off-by: Javi Merino &lt;javi.merino@arm.com&gt;
Signed-off-by: Eduardo Valentin &lt;edubezval@gmail.com&gt;
</content>
</entry>
<entry>
<title>thermal: power_allocator: Use temperature reading from tz</title>
<updated>2015-11-12T18:47:24Z</updated>
<author>
<name>Kapileshwar Singh</name>
<email>kapileshwar.singh@arm.com</email>
</author>
<published>2015-10-13T11:30:01Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=bb404db47b8a4ade8c85d13fb44908b0ee15483c'/>
<id>urn:sha1:bb404db47b8a4ade8c85d13fb44908b0ee15483c</id>
<content type='text'>
All thermal governors use the temperature value stored in
struct thermal_zone_device.

   thermal_zone_device-&gt;temperature

power_allocator governor should not deviate from this and use
the same.

Cc: Javi Merino &lt;javi.merino@arm.com&gt;
Cc: Eduardo Valentin &lt;edubezval@gmail.com&gt;
Cc: Daniel Kurtz &lt;djkurtz@chromium.org&gt;
Cc: Zhang Rui &lt;rui.zhang@intel.com&gt;
Cc: Dmitry Torokhov &lt;dmitry.torokhov@gmail.com&gt;
Cc: Sascha Hauer &lt;s.hauer@pengutronix.de&gt;
Cc: Andrea Arcangeli &lt;aarcange@redhat.com&gt;
Acked-by: Javi Merino &lt;javi.merino@arm.com&gt;
Reported-by: Sugumar Natarajan &lt;sugumar.natarajan@arm.com&gt;
Signed-off-by: Kapileshwar Singh &lt;kapileshwar.singh@arm.com&gt;
Signed-off-by: Eduardo Valentin &lt;edubezval@gmail.com&gt;
</content>
</entry>
<entry>
<title>remove abs64()</title>
<updated>2015-11-09T23:11:24Z</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@linux-foundation.org</email>
</author>
<published>2015-11-09T22:58:13Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=79211c8ed19c055ca105502c8733800d442a0ae6'/>
<id>urn:sha1:79211c8ed19c055ca105502c8733800d442a0ae6</id>
<content type='text'>
Switch everything to the new and more capable implementation of abs().
Mainly to give the new abs() a bit of a workout.

Cc: Michal Nazarewicz &lt;mina86@mina86.com&gt;
Cc: John Stultz &lt;john.stultz@linaro.org&gt;
Cc: Ingo Molnar &lt;mingo@kernel.org&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Masami Hiramatsu &lt;masami.hiramatsu.pt@hitachi.com&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>thermal: avoid division by zero in power allocator</title>
<updated>2015-10-02T01:42:35Z</updated>
<author>
<name>Andrea Arcangeli</name>
<email>aarcange@redhat.com</email>
</author>
<published>2015-10-01T22:37:16Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=44241628bb207ec211bebd156aaf69470d90c209'/>
<id>urn:sha1:44241628bb207ec211bebd156aaf69470d90c209</id>
<content type='text'>
During boot I get a div by zero Oops regression starting in v4.3-rc3.

Signed-off-by: Andrea Arcangeli &lt;aarcange@redhat.com&gt;
Reviewed-by: Javi Merino &lt;javi.merino@arm.com&gt;
Cc: Zhang Rui &lt;rui.zhang@intel.com&gt;
Cc: Eduardo Valentin &lt;edubezval@gmail.com&gt;
Cc: Daniel Kurtz &lt;djkurtz@chromium.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>thermal: power_allocator: exit early if there are no cooling devices</title>
<updated>2015-09-20T07:37:16Z</updated>
<author>
<name>Javi Merino</name>
<email>javi.merino@arm.com</email>
</author>
<published>2015-09-14T13:23:54Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=97584d1838b7e2545c3b10aacef3327fcaa9531b'/>
<id>urn:sha1:97584d1838b7e2545c3b10aacef3327fcaa9531b</id>
<content type='text'>
Don't waste cycles in the power allocator governor's throttle function
if there are no cooling devices and exit early.

This commit doesn't change any functionality, but should provide better
performance for the odd case of a thermal zone with trip points but
without cooling devices.

Cc: Zhang Rui &lt;rui.zhang@intel.com&gt;
Cc: Eduardo Valentin &lt;edubezval@gmail.com&gt;
Reviewed-by: Daniel Kurtz &lt;djkurtz@chromium.org&gt;
Signed-off-by: Javi Merino &lt;javi.merino@arm.com&gt;
Signed-off-by: Eduardo Valentin &lt;edubezval@gmail.com&gt;
</content>
</entry>
<entry>
<title>thermal: power_allocator: don't require tzp to be present for the thermal zone</title>
<updated>2015-09-14T14:43:15Z</updated>
<author>
<name>Javi Merino</name>
<email>javi.merino@arm.com</email>
</author>
<published>2015-09-14T13:23:53Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=f5cbb182586ea36c6ad0e90e3534d18a5e9af094'/>
<id>urn:sha1:f5cbb182586ea36c6ad0e90e3534d18a5e9af094</id>
<content type='text'>
Thermal zones created using thermal_zone_device_create() may not have
tzp.  As the governor gets its parameters from there, allocate it while
the governor is bound to the thermal zone so that it can operate in it.
In this case, tzp is freed when the thermal zone switches to another
governor.

Cc: Zhang Rui &lt;rui.zhang@intel.com&gt;
Cc: Eduardo Valentin &lt;edubezval@gmail.com&gt;
Reviewed-by: Daniel Kurtz &lt;djkurtz@chromium.org&gt;
Signed-off-by: Javi Merino &lt;javi.merino@arm.com&gt;
Signed-off-by: Eduardo Valentin &lt;edubezval@gmail.com&gt;
</content>
</entry>
</feed>
