Linux Power Management development
 help / color / mirror / Atom feed
From: Sicelo <absicsz@gmail.com>
To: "H. Nikolaus Schaller" <hns@goldelico.com>
Cc: Sebastian Reichel <sre@kernel.org>,
	linux-pm@vger.kernel.org, pali@kernel.org,
	phone-devel@vger.kernel.org,
	Discussions about the Letux Kernel <letux-kernel@openphoenux.org>,
	akemnade@kernel.org
Subject: Re: [PATCH v2] power: supply: bq27xxx: do not report incorrect zero values
Date: Mon, 24 Mar 2025 17:42:27 +0200	[thread overview]
Message-ID: <Z-F9Y16PqwK6GOXY@tp440p.steeds.sam> (raw)
In-Reply-To: <A77FAC9F-3CA2-4E53-9A36-8ADB5E16D17C@goldelico.com>

Hi

> > 
> > +static bool bq27xxx_value_is_valid(struct bq27xxx_device_info *di, int value)
> > +{
> > + /*
> > + * On bq27xxx_0_zero, consider zero values invalid if EDVF is not set
> > + */
> > + return value || !(di->opts & BQ27XXX_O_ZERO) ||
> > +       (di->cache.flags & BQ27000_FLAG_EDVF);
> 
> Hm. This still can return -EINVAL for a valid and successful readout of value == 0 which
> could happen for a fully drained HF08 in the GTA04 with bq27000.
> 
> Here is an excerpt from running a battery until depletion:
> 
> root@letux:~# echo off >/sys/class/power_supply/twl4030_usb/mode
> root@letux:~# while true; do echo $(date) $(cat /sys/class/power_supply/bq27000-battery/capacity)%; sleep 1; done
> 
> Mon Mar 24 14:37:11 UTC 2025 1%
> Mon Mar 24 14:37:12 UTC 2025 1%
> Mon Mar 24 14:37:13 UTC 2025 1%
> ...
> 
> Mon Mar 24 14:38:24 UTC 2025 1%
> Mon Mar 24 14:38:25 UTC 2025 1%
> Mon Mar 24 14:38:26 UTC 2025 1%
> Mon Mar 24 14:38:27 UTC 2025 1%
> cat: /sys/class/power_supply/bq27000-battery/capacity: Invalid argument
> Mon Mar 24 14:38:28 UTC 2025 %
> cat: /sys/class/power_supply/bq27000-battery/capacity: Invalid argument
> Mon Mar 24 14:38:29 UTC 2025 %
> cat: /sys/class/power_supply/bq27000-battery/capacity: Invalid argument
> Mon Mar 24 14:38:30 UTC 2025 %
> cat: /sys/class/power_supply/bq27000-battery/capacity: Invalid argument
> Mon Mar 24 14:38:32 UTC 2025 %
> ...
> cat: /sys/class/power_supply/bq27000-battery/capacity: Invalid argument
> Mon Mar 24 14:53:39 UTC 2025 %
> cat: /sys/class/power_supply/bq27000-battery/capacity: Invalid argument
> Mon Mar 24 14:53:40 UTC 2025 %
> cat: /sys/class/power_supply/bq27000-battery/capacity: Invalid argument
> Mon Mar 24 14:53:41 UTC 2025 %
> cat: /sys/class/power_supply/bq27000-battery/capacity: Invalid argument
> Mon Mar 24 14:53:42 UTC 2025 %
> Mon Mar 24 14:53:43 UTC 2025 0%
> Mon Mar 24 14:53:44 UTC 2025 0%
> Mon Mar 24 14:53:45 UTC 2025 0%
> Mon Mar 24 14:53:46 UTC 2025 0%
> Mon Mar 24 14:53:47 UTC 2025 0%
> Mon Mar 24 14:53:48 UTC 2025 0%
> Mon Mar 24 14:53:49 UTC 2025 0%
> Mon Mar 24 14:53:50 UTC 2025 0%
> Mon Mar 24 14:53:51 UTC 2025 0%
> Mon Mar 24 14:53:53 UTC 2025 0%
> 
> ...
> 
> Mon Mar 24 15:10:12 UTC 2025 0%
> Mon Mar 24 15:10:14 UTC 2025 0%
> Mon Mar 24 15:10:15 UTC 2025 0%
> --- here device did shut down ---
> 
> This means that the capacity can go to 0% for approx. 15 minutes before
> the BQ27000_FLAG_EDVF becomes set and 0% is reported. I would prefer not
> to see the EINVAL in between.
> 
> This all may end that we have to add another DT property to tell the driver
> if the bq27xxx is inside a battery or the battery is removeable and only check
> for value=0 in the latter case?
> 
> Or can you limit this logic to the bq27200 because it is unlikely that the
> i2c variant is used inside a battery pack and the HF08 battery uses the hdq
> variant?

I can see the problem. Thanks for testing. Let us retract this patch. I
think we can solve the issue in userspace.

Sincerely
Sicelo

      reply	other threads:[~2025-03-24 15:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-22 15:43 [PATCH v2] power: supply: bq27xxx: do not report incorrect zero values Sicelo A. Mhlongo
2025-03-24 15:12 ` H. Nikolaus Schaller
2025-03-24 15:42   ` Sicelo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z-F9Y16PqwK6GOXY@tp440p.steeds.sam \
    --to=absicsz@gmail.com \
    --cc=akemnade@kernel.org \
    --cc=hns@goldelico.com \
    --cc=letux-kernel@openphoenux.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pali@kernel.org \
    --cc=phone-devel@vger.kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox