From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: venkat.yadlapati@yahoo.com, Sebastian Reichel <sre@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, Joonhoe Kim <26rote@gmail.com>
Subject: Re: [PATCH 1/2] power: supply: qcom_battmgr: Apply a USB input current limit set early
Date: Tue, 1 Dec 2026 11:44:05 +0100 [thread overview]
Message-ID: <f86abf69-8e3c-47d1-ab73-b6847963142a@oss.qualcomm.com> (raw)
In-Reply-To: <20261116-vantage-battmgr-v1-1-7b59157377b7@yahoo.com>
On 11/15/26 9:20 PM, Venkat Yadlapati via B4 Relay wrote:
> From: Venkat Yadlapati <venkat.yadlapati@yahoo.com>
>
> The USB controller can report the current a USB host grants, e.g. with
> the usb-psy-name property of dwc3, before the battery manager service
> is up. The input current limit is then rejected with -EAGAIN and the
> firmware keeps the 100 mA allowed before enumeration, so a phone that is
> in use discharges while it is connected to a computer.
>
> Remember the limit while the service is down and send it once the
> service comes up.
>
> Assisted-by: LLM
This tag is no longer valid, please switch to linux-next/master as
your base and run checkpatch
> Signed-off-by: Venkat Yadlapati <venkat.yadlapati@yahoo.com>
> ---
[...]
> +static int qcom_battmgr_usb_set_icl(struct qcom_battmgr *battmgr, u32 icl)
> +{
> + int ret;
> +
> + mutex_lock(&battmgr->lock);
> + ret = qcom_battmgr_request_property(battmgr, BATTMGR_USB_PROPERTY_SET,
> + USB_INPUT_CURR_LIMIT, icl);
> + mutex_unlock(&battmgr->lock);
> +
> + return ret;
guard(mutex)(&battmgr->lock)
return qcom_battmgr_...
> +}
> +
> static int qcom_battmgr_usb_set_property(struct power_supply *psy,
> enum power_supply_property psp,
> const union power_supply_propval *pval)
> {
> struct qcom_battmgr *battmgr = power_supply_get_drvdata(psy);
> - int ret;
> -
> - if (!battmgr->service_up)
> - return -EAGAIN;
>
> if (psp != POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT || pval->intval < 0)
> return -EINVAL;
>
> - mutex_lock(&battmgr->lock);
> - ret = qcom_battmgr_request_property(battmgr, BATTMGR_USB_PROPERTY_SET,
> - USB_INPUT_CURR_LIMIT, pval->intval);
> - mutex_unlock(&battmgr->lock);
> + /*
> + * The USB controller can report the current a host grants before the
> + * firmware service is up, apply it once the service comes up.
> + */
> + if (!battmgr->service_up) {
> + battmgr->usb_icl = pval->intval;
> + battmgr->usb_icl_pending = true;
> + return 0;
> + }
This is the easiest workaround, but I fear this may spiral out of
control, as the same would apply to essentially any parameter
that's writeable.
I'm thinking about whether we should perhaps defer the
registration of the power supplies until the service first appears.
I'm not sure of how much collateral damage that would cause. Upon
a "service goes down" event, we could keep the "return -EAGAIN"
behavior
Konrad
next prev parent reply other threads:[~2026-12-01 10:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 20:20 [PATCH 0/2] power: supply: qcom_battmgr: Apply the USB host current limit early Venkat Yadlapati via B4 Relay
2026-11-15 20:20 ` [PATCH 1/2] power: supply: qcom_battmgr: Apply a USB input current limit set early Venkat Yadlapati via B4 Relay
2026-12-01 10:44 ` Konrad Dybcio [this message]
2026-11-15 20:20 ` [PATCH 2/2] power: supply: qcom_battmgr: Don't limit the input current of chargers Venkat Yadlapati via B4 Relay
2026-12-01 11:09 ` 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=f86abf69-8e3c-47d1-ab73-b6847963142a@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=26rote@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
--cc=venkat.yadlapati@yahoo.com \
/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®