From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: DhruvinRajpura <dhruvin.rajpura@oss.qualcomm.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Sebastian Reichel <sre@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
kamal.wadhwa@oss.qualcomm.com, jishnu.prakash@oss.qualcomm.com,
Dhruvin Rajpura <drajpura@qti.qualcomm.com>,
Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>,
Umang Chheda <quic_uchheda@quicinc.com>
Subject: Re: [PATCH 2/2] power: supply: qcom_battmgr: Add thermal mitigation support
Date: Tue, 9 Jun 2026 11:42:32 +0200 [thread overview]
Message-ID: <d99447c8-f140-4ac1-85e1-a235c37eecde@oss.qualcomm.com> (raw)
In-Reply-To: <20260609-cooling_device_reg-v1-2-e15bddcb0086@qti.qualcomm.com>
On 6/9/26 11:16 AM, DhruvinRajpura wrote:
> From: Dhruvin Rajpura <drajpura@qti.qualcomm.com>
>
> Earlier commit c85c191694cb ("power: supply: remove faulty cooling
> logic") removed the automatic cooling device registration from
> the power supply framework due to inverted cooling logic and
> missing CHARGE_CONTROL_LIMIT_MAX validation across drivers. As
> a result, drivers that need thermal mitigation support must now
> explicitly register their own cooling devices with correct
> semantics.
>
> The battery charger firmware exposes a fast charge current (FCC)
> limit property that can be used to throttle charging current in
> response to thermal events. Without explicit cooling device
> registration, the thermal framework has no way to reduce charging
> current when the device is under thermal stress, which can lead
> to excessive heat buildup during charging. Register a thermal
> cooling device that maps discrete current levels defined in the
> qcom,thermal-mitigation DT property to cooling states, where
> level 0 represents the hardware maximum current queried from
> firmware and each subsequent level reduces current to the next
> DT-defined value. Track the last applied FCC value so thermal
> limits are preserved across firmware protection domain restart
> (PDR) events. Expose CHARGE_CONTROL_LIMIT and
> CHARGE_CONTROL_LIMIT_MAX as power supply properties to allow
> userspace to observe and control the current throttle level.
>
> Co-developed-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
> Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
> Co-developed-by: Umang Chheda <quic_uchheda@quicinc.com>
> Signed-off-by: Umang Chheda <quic_uchheda@quicinc.com>
> Signed-off-by: Dhruvin Rajpura <drajpura@qti.qualcomm.com>
> ---
[...]
> +static int __battery_psy_set_charge_current(struct qcom_battmgr *battmgr,
> + u32 fcc_ua)
> +{
> + int ret;
> +
> + mutex_lock(&battmgr->lock);
> + ret = qcom_battmgr_request_property(battmgr, BATTMGR_BAT_PROPERTY_SET,
> + BATT_CHG_CTRL_LIM, fcc_ua);
> + mutex_unlock(&battmgr->lock);
I think the entirety of this function, particularly the assignment,
could use this lock
[...]
> + if (ret < 0) {
> + dev_err(battmgr->dev, "Unable to read CHG_CTRL_LIMIT_MAX ret :%d\n", ret);
style: "ret: %d"
[...]
> +static int qcom_battmgr_parse_dt(struct qcom_battmgr *battmgr)
> +{
> + struct device_node *node = battmgr->dev->of_node;
> + int len, ret;
> +
> + ret = of_property_count_elems_of_size(node, "qcom,thermal-mitigation", sizeof(u32));
> + if (ret == -EINVAL)
> + return 0; /* property not defined, thermal mitigation disabled */
> + if (ret <= 0)
> + return ret; /* real error, propagate */
Does battmgr really expect the OS to house this information? Can we not
retrieve it from the running firmware?
[...]
> + /*
> + * Element 0 is for normal charging current. Elements from index 1
> + * onwards is for thermal mitigation charging currents.
> + */
Documentation/ABI/testing/sysfs-class-power:
What: /sys/class/power_supply/<supply_name>/charge_control_limit
Date: Oct 2012
Contact: linux-pm@vger.kernel.org
Description:
Maximum allowable charging current. Used for charge rate
throttling for thermal cooling or improving battery health.
Access: Read, Write
Valid values: Represented in microamps
My reading of your patch is that you expect a level to be passed, not a
uA value
Konrad
next prev parent reply other threads:[~2026-06-09 9:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 9:16 [PATCH 0/2] " DhruvinRajpura
2026-06-09 9:16 ` [PATCH 1/2] bindings: power: supply: qcom,pmic-glink: Document thermal-mitigation DhruvinRajpura
2026-06-10 9:04 ` Krzysztof Kozlowski
[not found] ` <CAB8MRjTwN6J3oSFVeF-w7WpZQamEyyQ6Ckyd=TAB=-N22b8k1g@mail.gmail.com>
2026-06-16 4:35 ` Krzysztof Kozlowski
2026-06-09 9:16 ` [PATCH 2/2] power: supply: qcom_battmgr: Add thermal mitigation support DhruvinRajpura
2026-06-09 9:42 ` Konrad Dybcio [this message]
[not found] ` <CAB8MRjTAbpwcrD==eZuaJdaprQoEsgr2L1EEU6x+gEu8tAVijQ@mail.gmail.com>
2026-06-19 15:15 ` Konrad Dybcio
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=d99447c8-f140-4ac1-85e1-a235c37eecde@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dhruvin.rajpura@oss.qualcomm.com \
--cc=drajpura@qti.qualcomm.com \
--cc=jishnu.prakash@oss.qualcomm.com \
--cc=kamal.wadhwa@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=quic_subbaram@quicinc.com \
--cc=quic_uchheda@quicinc.com \
--cc=robh@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
all inboxes | Powered by JetHome®