* [PATCH 0/1] acpi: battery: Accept charges over the design capacity as full
@ 2021-10-08 3:05 André Almeida
2021-10-08 3:05 ` [PATCH 1/1] " André Almeida
0 siblings, 1 reply; 5+ messages in thread
From: André Almeida @ 2021-10-08 3:05 UTC (permalink / raw)
To: rjw, lenb, linux-acpi
Cc: linux-kernel, kernel, krisman, sebastian.reichel, pgriffais,
hdegoede, André Almeida
Hi,
We have come across a battery that, when brand new, can go above the
reported maximum charge, leading to reports like this:
$ cat /sys/class/power_supply/BAT1/uevent
POWER_SUPPLY_NAME=BAT1
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Unknown
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_CHARGE_FULL_DESIGN=4160000
POWER_SUPPLY_CHARGE_FULL=4538000
POWER_SUPPLY_CHARGE_NOW=4539000
POWER_SUPPLY_CAPACITY=100
POWER_SUPPLY_CAPACITY_LEVEL=Full
[...]
And then userspace get confused by Unknown and some programs even say
"Charging: 100%". After applying this patch, kernel reports "Full",
which for practical reasons is true, even if the battery will charge a
bit more. After some time, the battery health degrades and the maximum
charge meets the design expectation. Ideally this would be fixed in the
battery firmware, but it's not always possible to do that.
André Almeida (1):
acpi: battery: Accept charges over the design capacity as full
drivers/acpi/battery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--
2.33.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/1] acpi: battery: Accept charges over the design capacity as full
2021-10-08 3:05 [PATCH 0/1] acpi: battery: Accept charges over the design capacity as full André Almeida
@ 2021-10-08 3:05 ` André Almeida
2021-10-08 6:58 ` Hans de Goede
2021-10-13 11:33 ` Sebastian Reichel
0 siblings, 2 replies; 5+ messages in thread
From: André Almeida @ 2021-10-08 3:05 UTC (permalink / raw)
To: rjw, lenb, linux-acpi
Cc: linux-kernel, kernel, krisman, sebastian.reichel, pgriffais,
hdegoede, André Almeida
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 <andrealmeid@collabora.com>
---
drivers/acpi/battery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index dae91f906cea..8afa85d6eb6a 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -169,7 +169,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery)
return 1;
/* fallback to using design values for broken batteries */
- if (battery->design_capacity == battery->capacity_now)
+ if (battery->design_capacity <= battery->capacity_now)
return 1;
/* we don't do any sort of metric based on percentages */
--
2.33.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] acpi: battery: Accept charges over the design capacity as full
2021-10-08 3:05 ` [PATCH 1/1] " André Almeida
@ 2021-10-08 6:58 ` Hans de Goede
2021-10-13 11:33 ` Sebastian Reichel
1 sibling, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2021-10-08 6:58 UTC (permalink / raw)
To: André Almeida, rjw, lenb, linux-acpi
Cc: linux-kernel, kernel, krisman, sebastian.reichel, pgriffais
Hi,
On 10/8/21 5:05 AM, André Almeida wrote:
> 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 <andrealmeid@collabora.com>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
> ---
> drivers/acpi/battery.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index dae91f906cea..8afa85d6eb6a 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -169,7 +169,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery)
> return 1;
>
> /* fallback to using design values for broken batteries */
> - if (battery->design_capacity == battery->capacity_now)
> + if (battery->design_capacity <= battery->capacity_now)
> return 1;
>
> /* we don't do any sort of metric based on percentages */
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] acpi: battery: Accept charges over the design capacity as full
2021-10-08 3:05 ` [PATCH 1/1] " André Almeida
2021-10-08 6:58 ` Hans de Goede
@ 2021-10-13 11:33 ` Sebastian Reichel
2021-10-13 17:54 ` Rafael J. Wysocki
1 sibling, 1 reply; 5+ messages in thread
From: Sebastian Reichel @ 2021-10-13 11:33 UTC (permalink / raw)
To: André Almeida
Cc: rjw, lenb, linux-acpi, linux-kernel, kernel, krisman, pgriffais,
hdegoede
[-- Attachment #1: Type: text/plain, Size: 1305 bytes --]
Hi,
On Fri, Oct 08, 2021 at 12:05:29AM -0300, André Almeida wrote:
> 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 <andrealmeid@collabora.com>
> ---
> drivers/acpi/battery.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index dae91f906cea..8afa85d6eb6a 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -169,7 +169,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery)
> return 1;
>
> /* fallback to using design values for broken batteries */
> - if (battery->design_capacity == battery->capacity_now)
> + if (battery->design_capacity <= battery->capacity_now)
> return 1;
>
> /* we don't do any sort of metric based on percentages */
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] acpi: battery: Accept charges over the design capacity as full
2021-10-13 11:33 ` Sebastian Reichel
@ 2021-10-13 17:54 ` Rafael J. Wysocki
0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2021-10-13 17:54 UTC (permalink / raw)
To: Sebastian Reichel, André Almeida
Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List,
Linux Kernel Mailing List, Collabora Kernel ML, krisman,
Pierre-Loup A . Griffais, Hans de Goede
On Wed, Oct 13, 2021 at 1:34 PM Sebastian Reichel
<sebastian.reichel@collabora.com> wrote:
>
> Hi,
>
> On Fri, Oct 08, 2021 at 12:05:29AM -0300, André Almeida wrote:
> > 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 <andrealmeid@collabora.com>
> > ---
> > drivers/acpi/battery.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> > index dae91f906cea..8afa85d6eb6a 100644
> > --- a/drivers/acpi/battery.c
> > +++ b/drivers/acpi/battery.c
> > @@ -169,7 +169,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery)
> > return 1;
> >
> > /* fallback to using design values for broken batteries */
> > - if (battery->design_capacity == battery->capacity_now)
> > + if (battery->design_capacity <= battery->capacity_now)
> > return 1;
> >
> > /* we don't do any sort of metric based on percentages */
>
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Applied as 5.16 material, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-10-13 17:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-08 3:05 [PATCH 0/1] acpi: battery: Accept charges over the design capacity as full André Almeida
2021-10-08 3:05 ` [PATCH 1/1] " André Almeida
2021-10-08 6:58 ` Hans de Goede
2021-10-13 11:33 ` Sebastian Reichel
2021-10-13 17:54 ` Rafael J. Wysocki
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.