New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 899120 link

Starred by 1 user

Issue metadata

Status: Closed
Owner:
Closed: Nov 17
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

"display percentage" discrepancy between AC / no AC

Project Member Reported by mqg@chromium.org, Oct 26

Issue description

Version:
OS	nami-release/R71-11151.11.0
EC	nami_v1.1.8834-a1fa5af5d
FW	Google_Nami.10775.21.0

Summary:
When using "power_supply_info" to query powerd for battery info, "percentage" is different depending on whether DUT is on AC. "Display percentage" is also different depending on whether DUT is on AC. 

Behavior:

  1. On ec battery percentage 92->100, when AC is plugged, "power_supply_info" ec battery "percentage" jumps to 100 from 94, suspect is probably this CL: https://chromium-review.googlesource.com/c/chromiumos/third_party/coreboot/+/169549

  2. On ec battery percentage 92->100, when AC is not plugged, "display percentage" (OS taskbar icon) reaches 100 when ec battery reaches 97. This is determined by "power_supply_full_factor" which I set to 97

This means, for example, when EC reports 95% battery, "display percentage" is full on DUT is on AC, and "97%" when DUT is not on AC. This might be confusing to users. 

Question: why is CL in 1 and "power_supply_full_factor" in 2 set to different values? Should they be the same? Is this WAI? 

There's lots of different ways to read battery percentage, so if anything is unclear I am happy to explain. 

 
Cc: derat@chromium.org
Components: OS>Firmware>EC
Labels: OS-Chrome
Owner: ----
This code hasn't changed in many years, but my recollection is:

1. The full_factor pref and behavior exists because a bunch of devices have batteries that charge much more slowly as they approach a full charge or stop charging altogether before reaching a full charge. We report charges above this threshold as full since otherwise it's impossible for the user to know when to stop charging.

2. We don't use the same behavior when line power isn't connected since it'd be weird if a device continued to report that its battery was full after running on battery power for an extended period of time and then suddenly started dropping at a constant rate.

I agree that the discrepancy is weird, but the obvious alternatives seem at least as weird. I'm not excited about switching to a complicated approach that yields less-deterministic behavior, either.
Cc: dnojiri@chromium.org
on 1. Dai noted crrev.com/c/169549 in his investigation of b/109954565 issue as well.  

I think the CL was introduced before the time of power_supply_full_factor and ultimately should be removed.
There is a third value that also plays into this: 

In EC, ec/include/battery.h
L35: #define BATTERY_LEVEL_NEAR_FULL		 97

This controls the LED indicating fully charged. 
Adding two screenshots of my observations

First screenshot is in the order of ec battery percentage first going up then going down, second is the same measurement but split by whether AC is plugged. 

The discrepancy between battery.als level (94% as full when AC plugged) and EC BATTERY_LEVEL_NEAR_FULL (97% when LED indicate full charge) is confusing to users. 
Screenshot from 2018-10-26 12-18-13.png
210 KB View Download
Screenshot from 2018-10-26 12-18-40.png
182 KB View Download
Cc: drinkcat@chromium.org
Here is a test CL: when AC is plugged, "power_supply_info" percentage jumps to 100 at 98.5, instead of 94.

https://chromium-review.googlesource.com/c/chromiumos/third_party/coreboot/+/1303453
This is the CL where battery.asl is originally uploaded:
https://review.coreboot.org/c/coreboot/+/2481

This CL already has the part to set the "battery percentage" jumping point:
https://review.coreboot.org/c/coreboot/+/2481/2/src/ec/google/chromeec/acpi/battery.asl#205

Comment 8 Deleted

Here is another test CL:

https://chromium-review.googlesource.com/c/chromiumos/third_party/coreboot/+/1310974

When AC connected, percentage goes up to 99.0035 and stays there for a very long time. After leaving device charging for a long time, battery
reaches 100, and battery stopped allowing charging, which is expected behavior. 
Owner: dnojiri@chromium.org
Status: Assigned (was: Untriaged)
Project Member

Comment 11 by bugdroid1@chromium.org, Nov 8

Labels: merge-merged-chromeos-2016.05
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/coreboot/+/0a641f1f03af57818b62d96e9b85648cbc0c14e2

commit 0a641f1f03af57818b62d96e9b85648cbc0c14e2
Author: Daisuke Nojiri <dnojiri@chromium.org>
Date: Thu Nov 08 08:48:03 2018

UPSTREAM: chromeec: Disable battery remaining capacity workaround

If remaining charge is more than x% of the full capacity, the
remaining charge is raised to the full capacity before it's
reported to the rest of the system.

Some batteries don't update full capacity timely or don't update it
at all. On such systems, compensation is required to guarantee
the remaining charge will be equal to the full capacity eventually.

On some systems, Rohm charger generates audio noise when the battery
is fully charged and AC is plugged. A workaround is to do charge-
discharge cycles between 93 and 100%. On such systems, compensation
was also applied to mask this cycle from users.

This used to be done in ACPI, thus, all software components except EC
was able to see the compensated charge. This patch is part of the
effort of moving the logic to EC. With this and the EC changes, EC
can see what the rest of the system sees, thus, can control LEDs
synchronously (to the display percentage).

Another rationale of this move is EC can perform more granular and
precise compensation than ACPI since it has more knowledge about the
battery and the charger.

CQ-DEPEND=CL:1312204
BUG=b:109954565,b:80270446, chromium:899120 
BRANCH=none
TEST=Verify charge LED changes to white (full) on Sona synchronously
to the display percentage.
TEST=Verify charge LED changes to blinking white (low) on Sona
within 30 seconds synchronously to the display percentage.

Change-Id: I6718ec3fd2853f61d82b7c3921328e157cf31688
Signed-off-by: Furquan Shaikh <furquan@google.com>
Original-Commit-Id: 55a972236ee93d36bd3df4e8e5680ba447242bd7
Original-Change-Id: I0b51911b90dc2e7fcf5c730c54d9fda1fea76aa9
Original-Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/29441
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1320195
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>

[modify] https://crrev.com/0a641f1f03af57818b62d96e9b85648cbc0c14e2/src/ec/google/chromeec/acpi/battery.asl

Project Member

Comment 12 by bugdroid1@chromium.org, Nov 8

Labels: merge-merged-firmware-nami-10775.B
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/coreboot/+/297d51d8a3664bc362ac7f5ae75ab4692ee43518

commit 297d51d8a3664bc362ac7f5ae75ab4692ee43518
Author: Daisuke Nojiri <dnojiri@chromium.org>
Date: Thu Nov 08 19:33:39 2018

UPSTREAM: chromeec: Disable battery remaining capacity workaround

If remaining charge is more than x% of the full capacity, the
remaining charge is raised to the full capacity before it's
reported to the rest of the system.

Some batteries don't update full capacity timely or don't update it
at all. On such systems, compensation is required to guarantee
the remaining charge will be equal to the full capacity eventually.

On some systems, Rohm charger generates audio noise when the battery
is fully charged and AC is plugged. A workaround is to do charge-
discharge cycles between 93 and 100%. On such systems, compensation
was also applied to mask this cycle from users.

This used to be done in ACPI, thus, all software components except EC
was able to see the compensated charge. This patch is part of the
effort of moving the logic to EC. With this and the EC changes, EC
can see what the rest of the system sees, thus, can control LEDs
synchronously (to the display percentage).

Another rationale of this move is EC can perform more granular and
precise compensation than ACPI since it has more knowledge about the
battery and the charger.

CQ-DEPEND=CL:1312204
BUG=b:109954565,b:80270446, chromium:899120 
BRANCH=none
TEST=Verify charge LED changes to white (full) on Sona synchronously
to the display percentage.
TEST=Verify charge LED changes to blinking white (low) on Sona
within 30 seconds synchronously to the display percentage.

Change-Id: I6718ec3fd2853f61d82b7c3921328e157cf31688
Signed-off-by: Furquan Shaikh <furquan@google.com>
Original-Commit-Id: 55a972236ee93d36bd3df4e8e5680ba447242bd7
Original-Change-Id: I0b51911b90dc2e7fcf5c730c54d9fda1fea76aa9
Original-Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/29441
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1320195
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
(cherry picked from commit 0a641f1f03af57818b62d96e9b85648cbc0c14e2)
Reviewed-on: https://chromium-review.googlesource.com/c/1327384
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>

[modify] https://crrev.com/297d51d8a3664bc362ac7f5ae75ab4692ee43518/src/ec/google/chromeec/acpi/battery.asl

Status: Closed (was: Assigned)
See b:109954565 for details.

Sign in to add a comment