mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Venkat Yadlapati <venkat.yadlapati@yahoo.com>
To: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Cc: Sebastian Reichel <sre@kernel.org>,
	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 21:38:52 +0530	[thread overview]
Message-ID: <20261201160910.169252-1-venkat.yadlapati@yahoo.com> (raw)
In-Reply-To: <f86abf69-8e3c-47d1-ab73-b6847963142a@oss.qualcomm.com>

On 12/1/26 4:14 PM, Konrad Dybcio wrote:
> On 11/15/26 9:20 PM, Venkat Yadlapati via B4 Relay wrote:
>> Assisted-by: LLM
>
> This tag is no longer valid, please switch to linux-next/master as
> your base and run checkpatch

Thanks for the review. That line is already gone in v2 [1], which is
based on next-20261120 and otherwise has the same code as v1, so the
comments below apply to v2 as well. v3 will be on a current linux-next
and checked with checkpatch again.

>> +	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_...

Will do.

>> +	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

Agreed, and for the dwc3 case it looks like the cleaner fix. dwc3
already copes with a supply that shows up late: since 7c87ef27af79
("usb: dwc3: avoid probe deferral when USB power supply is not
available") it waits on the power supply notifier instead of deferring
its probe, and when the supply appears it sends the current it has
stored in the meantime. So with the supplies registered from the first
SERVREG_SERVICE_STATE_UP, the limit reaches the firmware without any
caching in battmgr, and dwc3 is not held back while the ADSP boots.

The other users I can think of (the userspace battery tools, power
supply links from other drivers) already have to deal with supplies
that appear later, but I may be missing a user on the laptops.

I would do that in v3: register the power supplies from the
enable work on the first "up" notification instead of in probe, keep
returning -EAGAIN while the service is down after that, and drop the
usb_icl_pending caching from this patch.

One thing I noticed in the current version: the pending limit is
applied right after the notifications are enabled, and with 2/2 the
charger type is read at that point. It can still be unknown then, in
which case 2/2 rejects the limit. The downstream driver sleeps 200 ms
before re-applying the limit for that reason. With late registration
dwc3 sets the limit only after the supply is registered, but the type
may still not be known yet, so I will look at that in v3 too.

v3 will take a while, as the phone is going in for repair and I
don't want to send it untested.

[1] https://lore.kernel.org/all/20261123-vantage-battmgr-v2-0-03a419078d0a@yahoo.com/

Thanks,
Venkat

  reply	other threads:[~2026-12-01 16:09 UTC|newest]

Thread overview: 7+ 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
2026-12-01 16:08     ` Venkat Yadlapati [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
2026-12-01 16:08     ` Venkat Yadlapati

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=20261201160910.169252-1-venkat.yadlapati@yahoo.com \
    --to=venkat.yadlapati@yahoo.com \
    --cc=26rote@gmail.com \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@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

all inboxes | Powered by JetHome®