From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76C6A3DFC61 for ; Tue, 9 Jun 2026 09:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780998160; cv=none; b=XlyCRS5JZSBQVZfzt5bHTgymMf2rY4TJPkOCEcoT0QOQclW+84xeyrMTR8ZinfafwTS0mCRV1mHCp50+pT+P12CxgVqCSv5Q4/QGJ5UJD4J6ryb8V9Wfotn007M4M3GsiOneRR9+BEStmio7+13pvB0UdtFV2AHZBSqsbBACerE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780998160; c=relaxed/simple; bh=pRLtaagejePOW2Fg2YPKRLjIDCmXJrayZ7Q5GXWYh/Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=pfNCpm4zBwGJQ5a8UR8nnm1qIQHvs3EA+pthdpuL6Zhgq25b/B1M+wCe2So3bdEsTwcOcs7I8BQD2u5dn8bYew9AmdOpSNcJS7C6cTah48xBoH/SUutVP5BX3bdJ6vLfw/ORb5mGgZx3gp6hXFU1dSoB2kLzp75Edoyn5e1uh/c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=K/WrcX8E; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=RC4XuI/g; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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.b="K/WrcX8E"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="RC4XuI/g" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6599JmwT2223215 for ; Tue, 9 Jun 2026 09:42:38 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= n3JNmHHdS4gAWMcgDN6ouymySktpffftWHFLxG6U5y0=; b=K/WrcX8E0ZBjISFp zvEvM2wWb6aedQVrpP1VJP7o/C2QZcd1L+J1uvQHY5Skc/GuVZUHIN+ohIPkyLnu UBBj8a/TkMuSDa0lnqUSXLsLbeNMxOSOllhLSgaNTIEQ5RaqIhJNSjnQwhjatAzy G/0tMUurbiV2rUQx7Mu2fay8naZ0d0GcaWY5He5Wc+UvP19Fhc3L6lxUNkJnA9Bi 2B+Rv5bog9rDlUuyBzJ3/bXCBrir7s1eK0FonUZG0bSEYv3b0wVzjtReGPRhnBjD yyFpLMSKVTfY8WOja+ouWLEvt3PdJRXbrhpp/URUa97LmiCc72kCYOdK5g/RCh9d +dveCw== Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4epg3v0306-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 09 Jun 2026 09:42:38 +0000 (GMT) Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-8ccd9683350so15853376d6.0 for ; Tue, 09 Jun 2026 02:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1780998158; x=1781602958; darn=vger.kernel.org; h=content-transfer-encoding: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; bh=n3JNmHHdS4gAWMcgDN6ouymySktpffftWHFLxG6U5y0=; b=RC4XuI/gZLQzmRg83obQIGes8v3y0q/Fj3h/7rPBdKrKODQIoNOQui8d6Tb4ITz2li wWp5E8IQ6srPxRlWcornXdaDPlamIYQOP0Dq92+Z4mTCT+xNduoxnPHo2YI9+d4oGKWT AER0MMGBHDGbK8yXYrLF2YNu0unekubKKgGpOFARRwId7R9S9RV/RAqVm7Np+Wo4WavW jtHYBnTDRPxubkKhTFGJfrmPC4rwH64TsyfDF46C6mdmQgoNeNgkpfByJF4zgU5U3qoF ++fDguDSh4paEDB5OdPprSMRIXcqYhKPbUHA7HzatzWrRyoWdhAR+gvAhaPe/gZt3aim zH+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780998158; x=1781602958; h=content-transfer-encoding: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; bh=n3JNmHHdS4gAWMcgDN6ouymySktpffftWHFLxG6U5y0=; b=aDZHhJteamz6uGQL7dMGZ2hCuD79tvPnpNa33iKJy1MqHSZixYHvN/yesTN+BJCYV3 GPP2AnY/BBSjDOwCmMtrLzGML+Eds3FGJaWCvlj10vgJYu2ghdbKzdn76/+PNSrJ27Kf //IvkMy1fxA7QfPRh5xB8mUQyJpEPnHT9mqZa7iqHN0k/rlsqhUFncURbaonGD1OBGPh f1CfTjkxZ6vxDvTgvh5VvRxYIrgcCkGrSP10CVXaDN+xZPd0D0391w+Fjp+v+2bSz87N zap+NWIJFQzTp3yfyYGFWSKhJcUBrMccnJHDqCFkCzG1fmEdMwxBupVgqH1dnnRO8bpw skQw== X-Forwarded-Encrypted: i=1; AFNElJ9BIBMmteJLm/UocnlbM194RaQxjqcckLNJ4ds/Q8Lqy3sBNdSlT+ThgG6Zwt62o0x6cl8azLVTA1r4Wtc=@vger.kernel.org X-Gm-Message-State: AOJu0YyMMEzu2l34OYTko4axdRMquJr6FdH0srJCQLN88Uhy46y99StG hfWZA0F3UZuTlkfLJNf1Scv9yIRLZpav7qKOfAaT2GI05nYA2TaE0BjeGBfgEH66p+dfld4GXQY 5aIlQhQNxwkoLSB0BZPm4kHOGd/gJo2ymmVbeQRohV2osJi8FBvIoFgeIUVWgS7hT1+w= X-Gm-Gg: Acq92OE8kNekgw65dqPHJADEvqEv9zu9+J+7HTtcaqbYUVi1DOlFZipkVuzvDHc8NWu Q2T9lTkXyWDVpe70Lg8cL76ARj59F0pV6L5Cxii/oD28ABmHu/mFwNnFXoVst1s2BNCm8ikQFRG eee6jEbnjobiJAzUyaFCjmvUcSMtsuOXokkcpkTkBBp9/0IWfc1uCc0vlWgdqNO5x8+oyV2yPb+ +RQTeKjJd/PDGdQGK/NUFg5LqVGqYrvPI8u3WkhqGJiRN9csTCrx21wWSZUj3+NMLgdK38KcxTG x89v4Wopql3PK09HPYVqaqJGv1PVsk7GPWHAmoVQjqJdPDL5RfeguqbePTv4HwHDzUqQp6XbrjM JdO/394HYMvIuoQCHnIRUXyBjYYod7gDkD8cdUPjf1CnMDN+dd3UP55d/ X-Received: by 2002:ac8:7dcd:0:b0:517:8999:6c50 with SMTP id d75a77b69052e-517ca4855a0mr16784601cf.8.1780998157582; Tue, 09 Jun 2026 02:42:37 -0700 (PDT) X-Received: by 2002:ac8:7dcd:0:b0:517:8999:6c50 with SMTP id d75a77b69052e-517ca4855a0mr16784311cf.8.1780998157110; Tue, 09 Jun 2026 02:42:37 -0700 (PDT) Received: from [192.168.120.170] ([178.235.128.140]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-bf0559f1464sm1022558266b.55.2026.06.09.02.42.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jun 2026 02:42:35 -0700 (PDT) Message-ID: Date: Tue, 9 Jun 2026 11:42:32 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] power: supply: qcom_battmgr: Add thermal mitigation support To: DhruvinRajpura , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sebastian Reichel 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 , Subbaraman Narayanamurthy , Umang Chheda References: <20260609-cooling_device_reg-v1-0-e15bddcb0086@qti.qualcomm.com> <20260609-cooling_device_reg-v1-2-e15bddcb0086@qti.qualcomm.com> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <20260609-cooling_device_reg-v1-2-e15bddcb0086@qti.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=St6gLvO0 c=1 sm=1 tr=0 ts=6a27e00e cx=c_pps a=wEM5vcRIz55oU/E2lInRtA==:117 a=PRfkaYvzSr8QmIIGAkY2Sg==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=COk6AnOGAAAA:8 a=VwQbUJbxAAAA:8 a=yrFiz102X7FNP_QAQpQA:9 a=QEXdDO2ut3YA:10 a=OIgjcC2v60KrkQgK7BGD:22 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: 9JUPmCZlDjpWdcbETGiHsyovo75jmlez X-Proofpoint-GUID: 9JUPmCZlDjpWdcbETGiHsyovo75jmlez X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA5MDA4OSBTYWx0ZWRfX80i+NjpZjV5M qQrTzkzeHDJ5aUV6SbC3OyoJe7WNaXhxDevEVYaQTzs3xCmcJNk2M+CgyF+S7zPzGdLbzaiLOnP 3wwdSYuT00gIp1SG0VxESNxQbLjHCrXHEs0Y+Yesa3NZWuFF6CTScWr3/GmHyglSUo4+IIpcZ0r ZFvpBEdeJpGTSzjyuYfolki22xz55iFQZsJgFAhrIPvq1KcCD5Gc8x8G/9gpj6aEHjNjesHspQf VFEOUIy7CHLkCFqZ5E1RNCqJsAcyORUGANx1e69Jj3JqMrHeNHGTJb1AsuoFHpU+wVc4SfXEBUO lGtpL191dYtFvjpV2ridjQBHlUjhgehKx3pF5786dtYpiicYBw930Jm82mbUE9N1lkU5d/GGH2o eX8YBlklHc6FNF/S50jwvDS3M5sW+VA+R/EggKL/m6KI4KpmbfwMjtOKGOGzJV0N0XOJwUXxFfq bNlQ6dNBniWeH1IpWAA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-09_02,2026-06-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 bulkscore=0 phishscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606090089 On 6/9/26 11:16 AM, DhruvinRajpura wrote: > From: Dhruvin Rajpura > > 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 > Signed-off-by: Subbaraman Narayanamurthy > Co-developed-by: Umang Chheda > Signed-off-by: Umang Chheda > Signed-off-by: Dhruvin Rajpura > --- [...] > +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//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