From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796209831; b=nG68xKnXb2yIsyEKBrXbAwNChsYScCHj8EEP4A99EXEOHoW4A8uSepH60HQRk0fp3i/f aIviQv0rSgR4QgtyaMk1rKmx/eCHQ9qy7Zkn5cZm/k3IIXhI5Yuiz07BancPeQV4wPIzX obuQOlo82r9HGTLPUk41tqG9SdeRA0E3UsGe3avvMqa8mVPUCEOCQQhANc+6pFMCOAYeH 8NnqO0QTLxN8pB9gz9xNI8CY7q3P5lYOyWBP+GuXQWW8epaH/thvCcWpyOiolrr/KvZmS /Azf0wZvwfq8wYYetSSjha2lBdjRy29XrblCb0lOhuVdlLjxW2zbKjx5ypLxyfuL7DA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796209831; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-Authority-Analysis:X-Proofpoint-GUID: X-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=KZxc7m/By/6X3fbvYjsmvy7oxWC54R6qtfppKcdZPTg=; b=5TS0nOG2Wh5SO3TIqRiyFpoLWzhB5EB7JxXI8xZe7YDYesLCroskmm3IkagAUomNAATi t4GlhpjnWePJn++7cQpV0kHaV3EAPYNv2VAdBvZTBzG00ejs9uHWEia6y9v3XmUaZajUH o5zTsfhcz7O2oaAqYMg8AA5K8scyQBGSg4Tkw4PX0WN8LAztsvOoUaC9Xk3gfvHeaD2+F v0BCY9saTWCz6ptdVvdbMzh+TAnpyWhHIkwZavhjEjGNhjXN++61tIjFLI62x4v4T/D8i r1wbLw5vhuIRUvXU/AluCgcdKlrK+VpozZLCSwVHZ0X9u5+4Qle7BmXQL4C3HzJ/k1A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b="I7OS/xqF"; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=eP+S10Fq; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7793D606A32D for ; Wed, 2 Dec 2026 11:10:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7793D606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=I7OS/xqF; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=eP+S10Fq Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2AB8Jr3653881 for ; Wed, 2 Dec 2026 11:10:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= KZxc7m/By/6X3fbvYjsmvy7oxWC54R6qtfppKcdZPTg=; b=I7OS/xqF2us56far fYROflEgvEV6K0SVnXR9R3IToft+BqwIp/G6fbANDpq5Ha4XBv4iOiAfjKy+nwg9 dOar0dHYeS4kSW18OHmDrVb5M86U4kttASREMEslIWucTth7LGIyAjOdgsVPbUi9 3cC1WGwYan7JVCXzrlrT4D1KuaUH4lVWlPY2M75hKYhCbMzA3RGTeBa0BumlYVCF wF23SSlW9vraMbNglqQjuikJgYHRiCNAZiMgjjIx700lDHjWRp7QRbXoy1WlM3r5 QgY4zUby2FeNweRhTNeP6OAYXAt/0J8p3cnZnfXsJW6tFEmHi4dMt6sSmv+3r4lP ivU/Jw== Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4jahbx07se-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 02 Dec 2026 11:10:30 +0000 (GMT) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-94a39a014daso32842585a.1 for ; Wed, 02 Dec 2026 03:10:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796209829; x=1796814629; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KZxc7m/By/6X3fbvYjsmvy7oxWC54R6qtfppKcdZPTg=; b=eP+S10Fq7OiMU93P81aALPD28RocJIBnQBilJOoQRbFSJ4exsWzMdwVtBVOitdPd1W Ty6OjHVm5dg5lmCqSF+Wo3iADzfZ41e2eT50PrexSyJ+/DHUSh9Z30kyf0hpupNIMqt7 g2MtjrXfeybYU0bTz3JjYgumVaBoKBexia/A9GXydWAfCh9BhXf8MNDcEvHiPqsZW2u0 EB8MfMWj/7Xd7J7mpkYOTBoaX+k+pmVmaNem4W9yDsC6/Ld+ROe8HN6d6nUOX6x5K7BW fHM2VbCq5AtV69Xivs+2SDr3US6iuvOEFeISrQfkuq05xkU72U/aQ3OrVYnuiWZ2pM55 cgtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796209829; x=1796814629; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KZxc7m/By/6X3fbvYjsmvy7oxWC54R6qtfppKcdZPTg=; b=tV8KwFhlkOXSWnIuO3ceq6rho+9DILdu4P6BiJgIKoL2SCthi21dk4xnH84hYz6DwN zHW0TCfSa6sg7uOvC1P8Pt09c74so60O2dEO621ovNVcPVn+ACST8e15duViXb0PX1u3 /0Q653f/loR/GilHoKXVHO5hzxt8OIyvKLqYFnt+nEIu4SwUN6nXRCM3Cg+0pJzsudJL 6f/f3s8gv4lab1txSv/O+xeh9TPt1julmOJaCOOLhjt4WvsPAtQnYwTNkblW/8Db+UNe AhXjiK87uagxvqf5HaWQ1b3z77oWwdmwEs4T4KMbr7zBxEElJipocDjzYuc2bWfP50Un a6bQ== X-Forwarded-Encrypted: i=1; AL+hErHRHUPXWGuuMo2C8kTOQwqI6Mh20XBT9dws4fuPjEFMgr6dslfYctUlfX26zwM3hB8hnjSTq21bkfAKBB0=@vger.kernel.org X-Gm-Message-State: APuU4Z9td2z9QkSk8PS3RVGqzCvdTSRilBdNI2iWp6v5MvcSrKA5MBte JMYgRnRjQpFYz1eD8Ti6WWZh6LKDMLYwCbxK4ZWNOribQuZLxRYxgcIAxHiCXnnX//3k8OUmZY7 W0oPYfQZy/mB6lpNQX2JPlsR8FKCI8KKEUysVDzlLR72lGPdDV10KJ3O4fWMBuRGydto= X-Gm-Gg: AZFdTZfR05ogS65g3uP3gaF+LmwnhH+hkG582kuifcDc5JxuTEbkdhbz5rFKoYjMoaP n3EP7fMjIIgtnFTYewEJvtH9Pahb6iqMi68yfjBtzmSymZ3+Frw9EqAZqAKTqxm/g0BK9tJHbsB 5+xN15o8aqxyIeCnAmOddmb0pzShFPcISOp0HU9p5qi7oB/9qhjk05Ql0l083CoA7asQNVSFQI5 MB2uMOhTF9o7i/ZrfU7V2auM/h9QVS1MR0THGo7O6tDdLrViyUg1VSHagC8CXPpHZeaIG93BOfQ 7i2/Xyq40wQ2DXRPAAsIMwcCcmNMwCzASO1NiGAfeCsmBc3bPH11hodxNJlZ+ON8lq2ZzbM2GbO LBd6vv/RIyU+wn6dehQtU+2/EUaic58JDKIdTRiCANG2EWa6orKuwGo476aUlqjN+zMoJaQ== X-Received: by 2002:a05:620a:5636:b0:949:436e:45f1 with SMTP id af79cd13be357-949ba6c7b41mr7518684685a.0.1796209829223; Wed, 02 Dec 2026 03:10:29 -0800 (PST) X-Received: by 2002:a05:620a:5636:b0:949:436e:45f1 with SMTP id af79cd13be357-949ba6c7b41mr7518679385a.0.1796209828649; Wed, 02 Dec 2026 03:10:28 -0800 (PST) Received: from [192.168.226.72] ([178.235.128.140]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513ae688f8sm1367317966b.25.2026.12.02.03.10.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2026 03:10:27 -0800 (PST) Message-ID: <6ea8c987-c1d1-4f6f-bce0-835384692498@oss.qualcomm.com> Date: Wed, 2 Dec 2026 12:10:25 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] power: supply: qcom_battmgr: treat a start threshold of 0 as none To: turbinebmw , Sebastian Reichel , linux-pm@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Val Packett , Fenglin Wu References: <20261128012449.323479-1-turbine.bmw@gmail.com> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <20261128012449.323479-1-turbine.bmw@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=K5+3jCWI c=1 sm=1 tr=0 ts=6b0ffca6 cx=c_pps a=qKBjSQ1v91RyAK45QCPf5w==:117 a=PRfkaYvzSr8QmIIGAkY2Sg==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=e5mUnYsNAAAA:8 a=pGLkceISAAAA:8 a=EUspDBNiAAAA:8 a=VwQbUJbxAAAA:8 a=ofIOSlU0oNnTgC1vPo0A:9 a=QEXdDO2ut3YA:10 a=NFOGd7dJGGMPyQGDc5-O:22 a=Vxmtnl_E_bksehYqCbjh:22 X-Proofpoint-GUID: ZtdkN06_G1nFeKmRfowgospKJZchX5uC X-Proofpoint-ORIG-GUID: ZtdkN06_G1nFeKmRfowgospKJZchX5uC X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAyMDA0NCBTYWx0ZWRfXyopEf1QbnsHb CK9IsnEoHZoYG+UgTBlUbSPVankd8ZjybnG1xZUVInsXYPD5NpXggn+aASz7AFAATULRGE09M7d KQ4iNl4pf5u+8FVwZb4OKrFmA04O4es= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA0NCBTYWx0ZWRfX9ekf70YoEmGk rrQzuTlsKZF8twPihsrdYmAHOd6uPWQRr1sTt/qTUKjvhGjWyA3EwAZhk1rOJzRoX7mWzb6KmC4 AADK6QRA/cFOVYbLNWnfujIq98CNpRwhwBNfQ1xLTwvFa4DwBW19ES4DyEj1FQ5OkMqXo1cRq1T HB1+JkNom/4St3jqYPiLe8D4kw4J5D8148ylAb1gUPJROVn+mzF3oG5pUb/tJ2NPzTaELosQx5I zBO9oRY7gTVXKFDNbGBy3LOaBqgQvljc78FSsheugZkRGml0r1oA/7mz++OqVaUi9NrCvYZo/W3 LBWmZl7Y9e+ILPvmLXkU6yJ7sB/NMhmaPO5gWdH4VHMCJcjFUmQGROyt4sMjdOC+PM1UsGaoVMr UBi9yxOMN768XQNt914vcoSF+Y+BfDP1gKD6Z95LRJYEUeg2j19+m69Ys/URIR9ezyXDL8EmCeg Um6/WlxPHq51CosHhww== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-02_02,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612020044 On 11/28/26 2:24 AM, turbinebmw wrote: > From: Brandon Williams > > UPower turns a charge limit off by writing 0 to > charge_control_start_threshold and 100 to charge_control_end_threshold. > Since commit 8809980fdc8a ("power: supply: qcom_battmgr: clamp charge > control thresholds") the driver raises the 0 to > CHARGE_CTRL_START_THR_MIN, so the firmware is told to charge to 100% > but resume only below 50%. A battery that the limit had stopped at its > end threshold, say 80%, then stays at "Not charging" until it drains > below 50%, and turning the limit off appears to do nothing. > > Disabling charge control through the request's enable bit was tried > and reverted, as the firmware did not behave as expected with it. > Instead, take a start threshold of 0 to mean that there is none: keep > the end threshold and use the smallest step, CHARGE_CTRL_DELTA_SOC, so > that charging resumes as soon as the level drops below it. The start > sent to the firmware stays within [50, 95], as the end threshold is at > least 55. The start is remembered as 0, so a following end threshold > write keeps the small step, whichever order userspace writes them in. > > Tested on a Microsoft Surface Pro 11 (X1E80100) with UPower 1.91.5: with > the battery held at 80% on a 75-80 window, turning the limit off set > 95-100 and the battery charged at once; turning it back on restored > 75-80. > > Link: https://gitlab.freedesktop.org/upower/upower/-/issues/327 > Fixes: 8809980fdc8a ("power: supply: qcom_battmgr: clamp charge control thresholds") > Cc: Val Packett > Cc: Fenglin Wu > Cc: Konrad Dybcio > Assisted-by: Claude:claude-opus-5-5 This tag is deprecated, checkpatch should have pointed that out > Signed-off-by: Brandon Williams > --- > Based on sre/linux-power-supply for-next. Hardware-tested as a backport > to 7.3.6 (the same logic laid out with a goto, on top of a local change > that returns the request status like ffce9bb777f2); a userspace harness > running both versions' setters over 120000 random threshold writes gave > identical firmware requests and sysfs values. Compile-tested with W=1. > > This keeps the 50% floor Fenglin explained in the thread on Val's series > and does not use the enable bit, whose removal is 8e8856396b54. > > drivers/power/supply/qcom_battmgr.c | 43 +++++++++++++++++++---------- > 1 file changed, 29 insertions(+), 14 deletions(-) > > diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c > index 0789303..45bd1ff 100644 > --- a/drivers/power/supply/qcom_battmgr.c > +++ b/drivers/power/supply/qcom_battmgr.c > @@ -762,21 +762,36 @@ static int qcom_battmgr_set_charge_start_threshold(struct qcom_battmgr *battmgr, > u32 target_soc, delta_soc; > int ret; > > - start_soc = clamp(start_soc, CHARGE_CTRL_START_THR_MIN, CHARGE_CTRL_START_THR_MAX); > - > - /* > - * If the new start threshold is larger than the old end threshold, > - * move the end threshold one step (DELTA_SOC) after the new start > - * threshold. > - */ > - if (start_soc > battmgr->info.charge_ctrl_end) { > - target_soc = start_soc + CHARGE_CTRL_DELTA_SOC; > - target_soc = min_t(u32, target_soc, CHARGE_CTRL_END_THR_MAX); > - delta_soc = target_soc - start_soc; > - delta_soc = min_t(u32, delta_soc, CHARGE_CTRL_DELTA_SOC); > + if (start_soc <= 0) { >From Documentation/ABI/testing/sysfs-class-power: What: /sys/class/power_supply//charge_control_start_threshold Date: April 2019 Contact: linux-pm@vger.kernel.org Description: Represents a battery percentage level, below which charging will begin. Access: Read, Write Valid values: 0 - 100 (percent) so let's test for if start_soc == 0 > + /* > + * A start threshold of 0 means there is none: charging resumes > + * as soon as the level drops below the end threshold. Userspace > + * writes it, with an end threshold of 100, to turn the limit > + * off. Use the smallest step below the end threshold, which > + * keeps the start within the firmware's range, and remember 0 > + * so that a following end threshold write keeps that step. > + */ Opus is of course very chatty, please drop the comments Konrad