mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Jan-Michael Brummer <jan.brummer@tabos.org>, sre@kernel.org
Cc: andersson@kernel.org, neil.armstrong@linaro.org,
	linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] power: supply: qcom_battmgr: fix CHARGE_FULL* on SM8350-class firmware
Date: Wed, 2 Sep 2026 16:35:53 +0200	[thread overview]
Message-ID: <838a68e1-c12d-4f1d-ad89-24b799f02a5e@oss.qualcomm.com> (raw)
In-Reply-To: <20260829054546.86210-2-jan.brummer@tabos.org>

On 8/29/26 7:45 AM, Jan-Michael Brummer wrote:
> battmgr->unit is only ever assigned in the BATTMGR_BAT_INFO handler of
> the SC8280XP callback. The SM8350-class firmware does not implement that
> request - every property is fetched individually via
> BATTMGR_BAT_PROPERTY_GET - so unit keeps its zero-initialised value,
> QCOM_BATTMGR_UNIT_mWh.
> 
> POWER_SUPPLY_PROP_CHARGE_FULL and POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN
> are guarded by 'if (unit != QCOM_BATTMGR_UNIT_mAh) return -ENODATA;',
> hence both properties always fail on these platforms, even though the
> values are requested from the firmware and stored in
> info.last_full_capacity and info.design_capacity on every access:
> 
>   $ cat /sys/class/power_supply/qcom-battmgr-bat/charge_full
>   cat: read error: No data available
> 
> Without a full charge value userspace cannot derive an absolute energy
> level, so UPower reports a zero energy level and never computes a
> time-to-empty/time-to-full estimate:
> 
>     energy:              0 Wh
>     energy-full:         0 Wh
>     energy-rate:         12.4713 W
>     percentage:          59%
> 
> The firmware of this class reports charge domain values, so set the unit
> statically when registering the SM8350/SM8550 power supplies. With this
> patch the properties read back consistently on a Fairphone 5:
> 
>   charge_full         4116000
>   charge_full_design  4260000
>   capacity            85
> 
> Fixes: 29e8142b5623 ("power: supply: Introduce Qualcomm PMIC GLINK power supply")
> Signed-off-by: Jan-Michael Brummer <jan.brummer@tabos.org>
> ---

This also implicitly unlocks reporting

POWER_SUPPLY_PROP_CHARGE_EMPTY
POWER_SUPPLY_PROP_CHARGE_NOW

which are not populated and will always report 0.

We should probably further limit that.

Konrad

  reply	other threads:[~2026-09-02 14:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-29  5:45 [PATCH 0/2] power: supply: qcom_battmgr: report charge levels " Jan-Michael Brummer
2026-08-29  5:45 ` [PATCH 1/2] power: supply: qcom_battmgr: fix CHARGE_FULL* " Jan-Michael Brummer
2026-09-02 14:35   ` Konrad Dybcio [this message]
2026-08-29  5:45 ` [PATCH 2/2] power: supply: qcom_battmgr: expose CHARGE_NOW " Jan-Michael Brummer
2026-09-02 15:02   ` Konrad Dybcio
2026-09-02 16:21     ` Konrad Dybcio
2026-10-07 20:06       ` Jan-Michael Brummer

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=838a68e1-c12d-4f1d-ad89-24b799f02a5e@oss.qualcomm.com \
    --to=konrad.dybcio@oss.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=jan.brummer@tabos.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=neil.armstrong@linaro.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

all inboxes | Powered by JetHome®