<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/acpi/battery.c, branch v4.9.331</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v4.9.331</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v4.9.331'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2022-03-28T06:06:06+00:00</updated>
<entry>
<title>ACPI: battery: Add device HID and quirk for Microsoft Surface Go 3</title>
<updated>2022-03-28T06:06:06+00:00</updated>
<author>
<name>Maximilian Luz</name>
<email>luzmaximilian@gmail.com</email>
</author>
<published>2022-02-13T15:49:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=2ed6e1a08b04224a7dc6e5d089b4dc1ccaf6edab'/>
<id>urn:sha1:2ed6e1a08b04224a7dc6e5d089b4dc1ccaf6edab</id>
<content type='text'>
commit 7dacee0b9efc8bd061f097b1a8d4daa6591af0c6 upstream.

For some reason, the Microsoft Surface Go 3 uses the standard ACPI
interface for battery information, but does not use the standard PNP0C0A
HID. Instead it uses MSHW0146 as identifier. Add that ID to the driver
as this seems to work well.

Additionally, the power state is not updated immediately after the AC
has been (un-)plugged, so add the respective quirk for that.

Signed-off-by: Maximilian Luz &lt;luzmaximilian@gmail.com&gt;
Cc: All applicable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>ACPI: battery: Accept charges over the design capacity as full</title>
<updated>2021-11-26T10:48:30+00:00</updated>
<author>
<name>André Almeida</name>
<email>andrealmeid@collabora.com</email>
</author>
<published>2021-10-08T03:05:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a1d2c265c64f5389d2dae764e7731ef5b576ac45'/>
<id>urn:sha1:a1d2c265c64f5389d2dae764e7731ef5b576ac45</id>
<content type='text'>
[ Upstream commit 2835f327bd1240508db2c89fe94a056faa53c49a ]

Some buggy firmware and/or brand new batteries can support a charge that's
slightly over the reported design capacity. In such cases, the kernel will
report to userspace that the charging state of the battery is "Unknown",
when in reality the battery charge is "Full", at least from the design
capacity point of view. Make the fallback condition accepts capacities
over the designed capacity so userspace knows that is full.

Signed-off-by: André Almeida &lt;andrealmeid@collabora.com&gt;
Reviewed-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Reviewed-by: Sebastian Reichel &lt;sebastian.reichel@collabora.com&gt;
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>ACPI / battery: Add sysfs representation after checking _BST</title>
<updated>2016-08-30T22:35:16+00:00</updated>
<author>
<name>Carlos Garnacho</name>
<email>carlosg@gnome.org</email>
</author>
<published>2016-08-10T15:24:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=12c78ca2ab5e64b636ce085fb08f7685654a5f22'/>
<id>urn:sha1:12c78ca2ab5e64b636ce085fb08f7685654a5f22</id>
<content type='text'>
Thus move sysfs_add_battery() after acpi_battery_get_state(), which doesn't
require the power_supply. Prevents possible hanged tasks if
acpi_battery_get_state() fails consistently (and takes a long time in doing
so) when called inside acpi_battery_add().

In this situation the battery module first calls sysfs_add_battery(),
which creates a power_supply, which spawns an async
power_supply_deferred_register_work() task, which shall try to hold the
parent battery device mutex (being already held) so this register work
is set up after device initialization. If initialization takes long enough
the thread will be eventually run and try to hold the mutex before
acpi_battery_add() had the chance to finish.

Eventually the 5 retries in acpi_battery_update_retry() fail, the error
state is propagated, and results in sysfs_remove_battery() being called
within the error handling paths of acpi_battery_add(), and the power_supply
tear down too.

This triggers a cancel_delayed_work_sync() of the deferred_register_work
task, which ends up in schedule(). The end result is that the deferred
task is blocked trying to acquire the parent device mutex, which is not
released because the thread doing initialization (and failure handling)
went to sleep awaiting for the deferred task to be cancelled.

The hanged tasks look like this:

INFO: task kworker/u8:0:6 blocked for more than 120 seconds.
 ...
Call Trace:
 [&lt;ffffffff815daec5&gt;] schedule+0x35/0x80
 [&lt;ffffffff815dda3c&gt;] schedule_timeout+0x1ec/0x250
 [&lt;ffffffff810a0572&gt;] ? check_preempt_curr+0x52/0x90
 [&lt;ffffffff810a05c9&gt;] ? ttwu_do_wakeup+0x19/0xe0
 [&lt;ffffffff815db915&gt;] wait_for_common+0xc5/0x190
 [&lt;ffffffff810a1500&gt;] ? wake_up_q+0x70/0x70
 [&lt;ffffffff815db9fd&gt;] wait_for_completion+0x1d/0x20
 [&lt;ffffffff8108ffb1&gt;] flush_work+0x111/0x1c0
 [&lt;ffffffff8108dfe0&gt;] ? flush_workqueue_prep_pwqs+0x1a0/0x1a0
 [&lt;ffffffff810909af&gt;] __cancel_work_timer+0x9f/0x1d0
 [&lt;ffffffff81090b13&gt;] cancel_delayed_work_sync+0x13/0x20
 [&lt;ffffffff8147ac67&gt;] power_supply_unregister+0x37/0xc0
 [&lt;ffffffffa058b03d&gt;] sysfs_remove_battery+0x3d/0x52 [battery]
 [&lt;ffffffffa058bf3a&gt;] acpi_battery_add+0x112/0x181 [battery]
 [&lt;ffffffff81366db6&gt;] acpi_device_probe+0x54/0x19b
 [&lt;ffffffff81427e9c&gt;] driver_probe_device+0x22c/0x440
 [&lt;ffffffff81428181&gt;] __driver_attach+0xd1/0xf0
 [&lt;ffffffff814280b0&gt;] ? driver_probe_device+0x440/0x440
 [&lt;ffffffff8142591c&gt;] bus_for_each_dev+0x6c/0xc0
 [&lt;ffffffff8142758e&gt;] driver_attach+0x1e/0x20
 [&lt;ffffffff81426fc3&gt;] bus_add_driver+0x1c3/0x280
 [&lt;ffffffff81428b00&gt;] driver_register+0x60/0xe0
 [&lt;ffffffff81366c80&gt;] acpi_bus_register_driver+0x3b/0x43
 [&lt;ffffffffa0591040&gt;] acpi_battery_init_async+0x1c/0x1e [battery]
 [&lt;ffffffff81099268&gt;] async_run_entry_fn+0x48/0x150
 [&lt;ffffffff81090d09&gt;] process_one_work+0x1e9/0x440
 [&lt;ffffffff81090fab&gt;] worker_thread+0x4b/0x4f0
 [&lt;ffffffff81090f60&gt;] ? process_one_work+0x440/0x440
 [&lt;ffffffff81096b58&gt;] kthread+0xd8/0xf0
 [&lt;ffffffff815de97f&gt;] ret_from_fork+0x1f/0x40
 [&lt;ffffffff81096a80&gt;] ? kthread_worker_fn+0x180/0x180

INFO: task kworker/u8:4:282 blocked for more than 120 seconds.
 ...
Call Trace:
 [&lt;ffffffff810ad745&gt;] ? put_prev_entity+0x35/0x8b0
 [&lt;ffffffff815daec5&gt;] schedule+0x35/0x80
 [&lt;ffffffff815db14e&gt;] schedule_preempt_disabled+0xe/0x10
 [&lt;ffffffff815dc533&gt;] __mutex_lock_slowpath+0xb3/0x120
 [&lt;ffffffff815dc5bf&gt;] mutex_lock+0x1f/0x30
 [&lt;ffffffff8147a59b&gt;] power_supply_deferred_register_work+0x2b/0x50
 [&lt;ffffffff81090d09&gt;] process_one_work+0x1e9/0x440
 [&lt;ffffffff81090fab&gt;] worker_thread+0x4b/0x4f0
 [&lt;ffffffff81090f60&gt;] ? process_one_work+0x440/0x440
 [&lt;ffffffff81090f60&gt;] ? process_one_work+0x440/0x440
 [&lt;ffffffff81096b58&gt;] kthread+0xd8/0xf0
 [&lt;ffffffff815de97f&gt;] ret_from_fork+0x1f/0x40
 [&lt;ffffffff81096a80&gt;] ? kthread_worker_fn+0x180/0x180

Making sysfs_add_battery() the last operation here means that the
power_supply won't be created yet when the acpi_add_battery() failure
handling happens, the deferred task won't even spawn, and
sysfs_remove_battery will just skip over the NULL battery-&gt;bat.

Signed-off-by: Carlos Garnacho &lt;carlosg@gnome.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI / battery: Correctly serialise with the pending async probe</title>
<updated>2016-05-20T23:25:07+00:00</updated>
<author>
<name>Chris Wilson</name>
<email>chris@chris-wilson.co.uk</email>
</author>
<published>2016-05-19T08:11:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=5dfa0c73953360e07a47731e412d33dfc896bf4e'/>
<id>urn:sha1:5dfa0c73953360e07a47731e412d33dfc896bf4e</id>
<content type='text'>
async_synchronize_cookie() only serialises all tasks up to the specified
cookie, and importantly does not wait for the task corresponding with
the cookie. [This is so that it can be trivially used from inside the
async_func_t in order to serialise with all preceding tasks.] In order
to serialise with acpi_battery_init_async() we need to compensate and
pass in the next cookie instead.

The impact today is zero since performing an async_schedule() from inside
a module init function will trigger an async_synchronize_full() prior to
the module loader's completion. However, if the probe was moved to its
own unregistered async_domain, then the async_synchronize_cookie would
be replaced with an async_synchronize_full_domain.

Signed-off-by: Chris Wilson &lt;chris@chris-wilson.co.uk&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI: Remove FSF mailing addresses</title>
<updated>2015-07-08T00:27:32+00:00</updated>
<author>
<name>Jarkko Nikula</name>
<email>jarkko.nikula@linux.intel.com</email>
</author>
<published>2015-06-26T08:27:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=4c62dbbce902cf2afa88cac89ec67c828160f431'/>
<id>urn:sha1:4c62dbbce902cf2afa88cac89ec67c828160f431</id>
<content type='text'>
There is no need to carry potentially outdated Free Software Foundation
mailing address in file headers since the COPYING file includes it.

Signed-off-by: Jarkko Nikula &lt;jarkko.nikula@linux.intel.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI / battery: mark DMI table as __initconst</title>
<updated>2015-06-15T12:23:44+00:00</updated>
<author>
<name>Mathias Krause</name>
<email>minipli@googlemail.com</email>
</author>
<published>2015-06-13T12:26:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=048d16da75cc3ae1a75455c0e7b2bf107c4f0f84'/>
<id>urn:sha1:048d16da75cc3ae1a75455c0e7b2bf107c4f0f84</id>
<content type='text'>
The bat_dmi_table[] DMI table is referenced from the __init function
acpi_battery_init_async() only. It and its referenced functions can
therefore be marked __initconst to free up ~1kB of runtime memory after
initialization is done.

Signed-off-by: Mathias Krause &lt;minipli@googlemail.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI / battery: minor tweaks to acpi_battery_units()</title>
<updated>2015-06-15T12:23:06+00:00</updated>
<author>
<name>Mathias Krause</name>
<email>minipli@googlemail.com</email>
</author>
<published>2015-06-13T12:26:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=27059b9132880f4211c41dfbf7665671cbf1ac91'/>
<id>urn:sha1:27059b9132880f4211c41dfbf7665671cbf1ac91</id>
<content type='text'>
Make the acpi_battery_units() function take a const argument and return
a const char*, too. Also make it static. It probably doesn't matter, as
gcc will be clever enough to optimize and inline the code even without
these hints. However, we also get rid of a #ifdef block by moving the
function closer to its usage location, so it's at least a small gain in
code readability.

Signed-off-by: Mathias Krause &lt;minipli@googlemail.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI / battery: constify the offset tables</title>
<updated>2015-06-15T12:21:22+00:00</updated>
<author>
<name>Mathias Krause</name>
<email>minipli@googlemail.com</email>
</author>
<published>2015-06-13T12:26:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a465878455a06a8d52599be25459ba23cec3fd09'/>
<id>urn:sha1:a465878455a06a8d52599be25459ba23cec3fd09</id>
<content type='text'>
The offset tables are only read, not modified. Make them const.

Signed-off-by: Mathias Krause &lt;minipli@googlemail.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI / battery: ensure acpi_battery_init() has finish</title>
<updated>2015-05-13T22:58:40+00:00</updated>
<author>
<name>Luis Henriques</name>
<email>luis.henriques@canonical.com</email>
</author>
<published>2015-05-11T21:49:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=eca21d9167213bc9217450613a671553ab45c225'/>
<id>urn:sha1:eca21d9167213bc9217450613a671553ab45c225</id>
<content type='text'>
Make sure that async function scheduled with async_schedule() has already
been executed.

Signed-off-by: Luis Henriques &lt;luis.henriques@canonical.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>ACPI / battery: drop useless return statements</title>
<updated>2015-05-13T22:58:40+00:00</updated>
<author>
<name>Luis Henriques</name>
<email>luis.henriques@canonical.com</email>
</author>
<published>2015-05-11T21:48:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=479faaf00fde35e80a5be1389938b38e422d799d'/>
<id>urn:sha1:479faaf00fde35e80a5be1389938b38e422d799d</id>
<content type='text'>
Signed-off-by: Luis Henriques &lt;luis.henriques@canonical.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
</feed>
