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 E48933CFF66 for ; Tue, 23 Jun 2026 10:41:46 +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=1782211308; cv=none; b=cnf8F2dM76WF9hnxf4wA1EyUSFtOSE25+8wR1bFYN3n3cZbd8VciP7m164RLicMOITo/WO+aNUhXYh+TUoZK1tpWsfsMRUY7twDqshcQ6T1ycQUPsKp86MTcl2F4hPLdrKoY5KzEk0CHS5d8ImSuPQ4s+DZ7PfTqvF2unHrFjGA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782211308; c=relaxed/simple; bh=2VgH5KfDdlzlPIz+sChiqqNUH5YO3RGqBq0ILzjT9gs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Y02mf19Cq/sfVcLDtMJswqfJRnFCENxEhzboG/7TfW6UAepdfct6Lpof5YrodhAQ0iIngFMCT4Umom3cc2+3WhtXWjt/iAKpe8YkH6LT1kI7wmqu51xKoPbTZ5PGNnV2Ng6cD6kCQZ3JyittItRJYZLl1EqZ6m60Sv8nVYUp/iI= 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=YUGZ9eSL; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=HXKGHZbZ; 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="YUGZ9eSL"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="HXKGHZbZ" 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 65N9KXxV3919066 for ; Tue, 23 Jun 2026 10:41:46 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= qW0iDkDs1LGQ0Qr0sk+Hgc/v7XkJCMVmkF2ubdjfZPA=; b=YUGZ9eSL3yRCoXVS pbTafCobY+0E5kfukaWwl/XL85wJaPhO+G4h2wYAG91TY3FAFOzbAh/imY6FzCKq tybb+CyrFX4Ygpo4ZT18u1UwuBvdTJWLe/8tw1sEx4Yc7ysbOvRbD+OY6tjLSSq6 2HrA64UtmDlGDJb+cNoUAtxKTQ2DpxC/8xlU4/Bn2d86xN34N5Su2bIhHwCHKYLU gynrCyvk9V9a+CN0AfBYTwakPKUDZ3ymEUkaUJM4TQwUK3FJldiAV17hyC6d/3GX FYrpUzTnW/kcxWY+DqnW5ZR7JH9ZXINGp0TVTb7dSRtCSsxDXXb9Cj4ga2YrL5ox vO+89Q== Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4eyqe68cnb-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 23 Jun 2026 10:41:45 +0000 (GMT) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-92585d4237dso12518585a.3 for ; Tue, 23 Jun 2026 03:41:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1782211305; x=1782816105; 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=qW0iDkDs1LGQ0Qr0sk+Hgc/v7XkJCMVmkF2ubdjfZPA=; b=HXKGHZbZ3ddZMslINCf1uj9qGqfVLuTnBWhDpdFuwlzI4LE4ogzj+QJRswQUwDehEr Hx0df9RssKgSa3IBaeJXcockBc/sAdDae6v7f7L7UgYBSYwc4x0TIZwsgA9CoxETvfvf 33qWXh338UX95zqEtQVtdglibv/jE4tq5EdhlMyKXotX/I/wNvauCIORwhOVed5EKyPF kPgjOTKTIRQOfX3lSC0/VKvdrGSoaoN+UFkGAPwhpGdhcNCILwPa9/OPQT3M0Ndt5BZ4 pB1EJK4TZti5sRxBVjd+3u2O+4MkGZfU3PVZn654KPxr16yuKFL2eSXGTl0ISQ7BTsA6 y/gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782211305; x=1782816105; 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=qW0iDkDs1LGQ0Qr0sk+Hgc/v7XkJCMVmkF2ubdjfZPA=; b=Vw59cVbq7ylkDwYgaEYA5OkHj5nuGlhV5nSixgc2uwoEmNENvnMspe1iqlkWvkm8+H KlbxhCt7EkIs3DSUROpUrPiiCPzCibJJQF1Z/wDky5Wz0oI5wJECfDOTDGpRcb38L7dd VUGBE33IuJwYv6P5+SgyOf6CnIpOCDbuAF9YeAo4FNKwts4XnXSnx49PEbFM4ynQoFJc Wn2feWoAxoLntxxXcrbhowzAvnLgK+fNFzAQAjr6uWSxeO/JxoIm6ytBr0gtn81tmAYG ZSHdizzrkwYNPiEsoD37/KkY1xdUUW0KLot574pIrUNz8PANYjP1/1g03xAXvKzG7OcW JXZw== X-Forwarded-Encrypted: i=1; AFNElJ+875EAe7fVsmAdqDP+LNAnmpt3CvwBXG25i0MBQlnPw25R7XpASKnowQ5ok0VdD4tA6uV5pcLMpleSFXg=@vger.kernel.org X-Gm-Message-State: AOJu0YwRycw5qJ7E3LFNwgF2Xy/6Y4HpcH5d+iN3bwvWqoPoVEQ80Spv gQa/ZecYBhyU3LHG7aptGxZyAEmsqlAd/WUZWyJyBzRqnD+FPfZJHHBzux6VlB7QAyamnHtyDe7 bLlmrZlrmfNn3L5YlO+hu/v7racsgavdUCinAUS0A2KAixc7HSGTDiYwxRBp8Jdlhg3E= X-Gm-Gg: AfdE7ckEpJBQ+ybete0tEtfBQHnQTy35uy6l+Cx1jIbKdg5BHs4fC2OCFBzt50AwnVr RDIgwMFySGksgHLPBo1F+7Xru0bDPV4tjmqk3AZfpBFGBhrhOCUGQ8hLerXwl4zBYdexbHxTXdh QZa1mUDjmCOd+Hj8uYA5M1OGsjXfASnoosuV89bMnlr6HgLNKUaEgcuzVngdkPUPEFHEIgAWj7+ FbZiMlASUK8V+K4mY5ma+T+F2/mdedIWQQ7Go2FBexoLt9h6LIkz5RnG2bChC5NQs5wISSFkU2s 3Pryfu2WZCFYwC8atB9r5RySQfpY53XJwF1RQwrxNFkolOI5E9hwAfdV42iNz1CP6/iKlIMOXN2 NOc5Df6lnwVzsMFZ3XU+DPydlJhlcloAwNr0= X-Received: by 2002:a05:620a:4107:b0:90d:11b2:80f3 with SMTP id af79cd13be357-925c8ecdc9bmr475961085a.7.1782211305201; Tue, 23 Jun 2026 03:41:45 -0700 (PDT) X-Received: by 2002:a05:620a:4107:b0:90d:11b2:80f3 with SMTP id af79cd13be357-925c8ecdc9bmr475959585a.7.1782211304705; Tue, 23 Jun 2026 03:41:44 -0700 (PDT) Received: from [192.168.120.170] ([178.235.128.140]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c0c6161595csm496121466b.62.2026.06.23.03.41.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jun 2026 03:41:43 -0700 (PDT) Message-ID: <8386c50c-42ad-47f5-979d-54cbaa5109d3@oss.qualcomm.com> Date: Tue, 23 Jun 2026 12:41:40 +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] thermal: qcom: Add support for Qualcomm MBG thermal monitoring To: Sachin Gupta , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Stephen Boyd , Jishnu Prakash , Kamal Wadhwa , Amit Kucheria , Thara Gopinath Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Satya Priya Kakitapalli , Ajit Pandey , Imran Shaik , Taniya Das , Jagadeesh Kona References: <20260601-spmi-mbg-driver-v1-0-b4892b55a17f@oss.qualcomm.com> <20260601-spmi-mbg-driver-v1-2-b4892b55a17f@oss.qualcomm.com> <7478c540-a5fc-4238-bba0-5b04547f57c7@oss.qualcomm.com> <487f0ed1-dfc2-4f7b-94ce-60045017a663@oss.qualcomm.com> <5ad33cf2-3168-44f2-89fe-a7fe1420f8f4@oss.qualcomm.com> <4d0f96d7-3848-4442-a8e9-243a6c4a3495@oss.qualcomm.com> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <4d0f96d7-3848-4442-a8e9-243a6c4a3495@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Proofpoint-GUID: Ohlw-sj87uil9rITWjgcuyKrN0-j7aa3 X-Proofpoint-ORIG-GUID: Ohlw-sj87uil9rITWjgcuyKrN0-j7aa3 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjIzMDA4NiBTYWx0ZWRfX3nysgrqJThjh 1CH3G2bt6MdBXB/wUOipAN5h0BrsHhvBoPUpKJiEwbZDUvUtd8aT2VPJvOZUCrQ5d4sATQa6pSI bWz66fWztzBxKIcVisqi74HDJzVFudM= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjIzMDA4NiBTYWx0ZWRfXypOxz4ELWSUR tIUl30rB7tjpOis/J8OrO0QeNua4srCXOki66NNOEPa+Jbwad738kL8IfB12pHa2aaKAgt3xyuY L+rU4fpHLo55iHLiTA/45rh+su3ZbfvTkYYHehbdbysbExm8RzpR9JkFQNJsh8PtxA3foT2L7Cp HPN6vJGSL3rY0NY2WEly1fUr3EryzOXlai2MyK7e+xmkZFXkI0BTMnncKHDVbkz+LFZnA+2ri3r shIMT0L+1coVfcay/fezz6ThhSqvKek1dBNiP/eA9d7UVv3JjFoAhGLu9uA41Vj7VLA+5wxWZkj uI95JhI7mnTgBMlFlYThuM2lKLvPpjBmJeLiNlLbMfKOC94mazwUVzL3F2G/yBLDub3tuPAOSh1 29GidtgdFBDGVXmf2h33UNsM6aQ0c5LgKn7YxjmUzL8TUzVvleoaHAgljqVkE43sT2eGzaX6OpE 9iRygZELxUhDnDMMKtg== X-Authority-Analysis: v=2.4 cv=OeKoyBTY c=1 sm=1 tr=0 ts=6a3a62e9 cx=c_pps a=50t2pK5VMbmlHzFWWp8p/g==: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=COk6AnOGAAAA:8 a=EUspDBNiAAAA:8 a=oS_SqjwSy1YzO6rVN58A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=IoWCM6iH3mJn3m4BftBB:22 a=TjNXssC_j7lpFel5tvFf:22 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-23_02,2026-06-22_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 spamscore=0 malwarescore=0 adultscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606230086 On 6/23/26 12:14 PM, Sachin Gupta wrote: > > > On 6/19/2026 5:44 PM, Konrad Dybcio wrote: >> On 6/19/26 8:45 AM, Sachin Gupta wrote: >>> >>> >>> On 6/16/2026 3:40 PM, Konrad Dybcio wrote: >>>> On 6/1/26 1:01 PM, Sachin Gupta wrote: >>>>> From: Satya Priya Kakitapalli >>>>> >>>>> Add driver for the Qualcomm MBG thermal monitoring device. It monitors >>>>> the die temperature, and when there is a level 1 upper threshold >>>>> violation, it receives an interrupt over spmi. The driver reads >>>>> the fault status register and notifies thermal accordingly. >>>>> >>>>> Signed-off-by: Satya Priya Kakitapalli >>>>> Co-developed-by: Sachin Gupta >>>>> Signed-off-by: Sachin Gupta >>>>> --- >> >> [...] >> >>>>> +    /* >>>>> +     * Configure the last_temp one degree higher, to ensure the >>>>> +     * violated temp is returned to thermal framework when it reads >>>>> +     * temperature for the first time after the violation happens. >>>>> +     * This is needed to account for the inaccuracy in the conversion >>>>> +     * formula used which leads to the thermal framework setting back >>>>> +     * the same thresholds in case the temperature it reads does not >>>>> +     * show violation. >>>>> +     */ >>>>> +    chip->last_temp = temp + MBG_TEMP_CONSTANT; >>>> >>>> Will this work fine if the user tries to set the max temp supported >>>> by the hardware (i.e. is there headroom for max+1)? >>>> >>> >>> In the current implementation, temp == MBG_MAX_SUPPORTED_TEMP is not accepted (temp < MBG_MAX_SUPPORTED_TEMP), so the last_temp = temp + MBG_TEMP_CONSTANT path is never taken at absolute max. For accepted trips (strictly below max), there is headroom for the +1C adjustment. >> >> You check for `temp < MBG_MAX_SUPPORTED_TEMP` and there's: >> >> #define MBG_MAX_SUPPORTED_TEMP 160000, >> >> so passing temp=159999 is "valid" and after the addition it becomes 160999, >> which in my understanding is outside the range >> >> Konrad > > chip->last_temp is only a software cache used in one place, mbg_tm_get_temp(), to return a synthetic “trip violated” reading once after the IRQ. It is not programmed into any hardware register. So temp + MBG_TEMP_CONSTANT exceeding MBG_MAX_SUPPORTED_TEMP does not cause a hardware out-of-range condition. > > Do you see this as an issue? Right, I zoomed in too much Konrad