From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 D1F9623D291 for ; Mon, 11 May 2026 06:15:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778480146; cv=none; b=KnKN4KIAaVdyOwudf4+KHRk6AIU9UbbDERu5HYQewDpVEAlAkaPdtT7i3wqPS+SbJhC8tiixnql4frf2QIqjcuZ5/t5BJC9AiWNzpqdYMmRs0OjDyLbaZiTflypAUE8AnHH0rr+i50Xety5mPSVbLgbuFTvb08XPKMCeR8v3xxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778480146; c=relaxed/simple; bh=nMNNMgNt0qQdYKCR7rqoHv/euvrL2jsocSLSsD4h6fw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TW9W1uyyC2kfBYSkVs/VaxUvljz0M0OTOUCj5yw6cFYlJ6dJJPtpkWivPXUdlyUrOiDUmO6oG9qJQ2PG7DdSgrmwph+5/PTZA81vUT9W9ZrvimeLBKHOmRPIMdd+2ERdgiAqhbU7MwlDRkUpVCq/ie4jovQlIq4kgyBKOOz7IDc= 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=EK9LmJ38; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=hIhrbZg+; arc=none smtp.client-ip=205.220.168.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="EK9LmJ38"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="hIhrbZg+" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64AJJlvA3152331 for ; Mon, 11 May 2026 06:15:44 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= tiqxzGqdJED19gib91pm/fKKRdfR7tXGS5FzfvQm0To=; b=EK9LmJ38kWQuZnuL /1pZnSBwVKgBb5Ut8kv96k2d9rMiok4HSQqvPM5D5rP6weIiBypL3N4lxCzW+pnT B2KlJLsJnIVv/jVz0ZEWbkvfHHxFMvgJaWGaxwY618q/TGKvoSh9zI/kr6sjz1o0 xOCfyLe/7BQd0jQx9Z8ZB0jZQlJCuTYIcztHD0ZJtaqUdP19wHU12aHQa4r8nLAk mvIL83mc33R/mLWCDR15ALqtEJTy/58D8th7cHrPCBaXRg0/ckhiObCmNptITvAW WT/9nfQP+bEA+y3ReybGgPcpZWRPYrFBsUqSX7pi5QAdTGuTydw5gMvJ28lnxFb+ i/K6eQ== Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e2dksjwct-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 11 May 2026 06:15:44 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2ba7662827fso36491505ad.1 for ; Sun, 10 May 2026 23:15:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1778480143; x=1779084943; 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=tiqxzGqdJED19gib91pm/fKKRdfR7tXGS5FzfvQm0To=; b=hIhrbZg+xm0yaYtJ6qjACXTDOyExSR8uJkUhfXtg5ZpjhCzzsKumhnEeZblPvA7PoN IBoMfv4yGsXtoSbiz5gShsbCX7z/pmiWrDH0/recVSnTYUUco54oJbqJpooPXaSxM142 y6fHhkLrFC6CQh2cLGv0DAgfO3/j/+luwiAbY6v5pQcSFqODdnXeODhpD+mB9hg7U6oP ll6kojK8ds+pUnlyUSsQnWEfZ4cB65qrcvk35U4x7mwXKiMh1ixZkL/ftGf+S5ZeuX8k 3R83WhCxPwBbNPzOkWMqdmLWF4xUH0os8rvPvTKCtUHXDIJsDd1ufFhkT0De5Eqg88E2 7OSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778480143; x=1779084943; 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=tiqxzGqdJED19gib91pm/fKKRdfR7tXGS5FzfvQm0To=; b=V9p90N3IF3j9qX6UuLceCtdzRgtATmpgiwVJ21Tbu3oBlfKfA7XXskVzDoyAfSpngM PT6V2WYT+SimcrSsR2dkoZT7RKUVYFBxZ+pvdZi4DKRoWETUTF1e3SU8FhP6bhbA2okk k6m5CwbugKt5pEg4g2sRlxBH6US7/XtwKByW6rp1FiOH+v8zT9VL7Ca2IG1hA2b1DMhd VJoedVj4zgri322OqFQHqEoao8WSJTHrA2YP3P/UpmtyA1JqJFOHEacvwsRCL41NBNul bM7zOEmjloL+ZPFNdppzobq0Kb8r6fzAhaLOKF3kOUVwX83jpgAHQUyTyq1cGQYMm3Je hyYA== X-Forwarded-Encrypted: i=1; AFNElJ+uyStPbB/97rsg5niGTsByjTtKWkgUxCZUJ8bAImCFkt8wKFF7A/quWlxjt0dhc+ukgMpeH7+cUCHDPaI=@vger.kernel.org X-Gm-Message-State: AOJu0YxK/w6mg+MZuKh2qKY9Z9F2VqzyQjUpCqgFqSyo0nmNBW7UQERt 9eqcnt06mDVCL6v5CP8gRu1b7qJaafGilan/pPk/EY1fqW3Z9DWg4rSESlx/3tp9+HU/w6GV0Pu RYbL4mwRHuPApREPOQJMtC0getWxn2i1s2X0KTrmNObXFQjTeaQgsLux8WLc0ch+KPxg= X-Gm-Gg: Acq92OHs5kaeCslH5RA6hnaZkWuEv4hI8gOUMvcEn/fB9XhmH5pxetGq2ORV28pPAvI U9O1YpCWe2cyJwaSv2u8AUzFFrx3ZwptVJVzOG8vKL/xxHsuokN/Mw3sCHehsvlozU4CZf3zKTM NQjpUNfzuiB5jWOjoIXAjmkNmEezoHaZSL+mETnppt3e9bWHD0LQQ6KdI3mkZ2KSKj+uSloejVs GXmKV7eKe6NsFyaxbYg/yvNZ/ST+AqEiXyKhW3mJs9Ywdl2xgPBCULB+MVIfrWi56Lde3kMwE5W fwuH6CpxTsUI/zbkz4ArdrbTpyS668GFcUrxU2MRY5edSOZa++uKoKdiDul0LGzHReYpbjDwqGO Q1ymd0cZZtgdIYEqcYWaeVH5XAqiOL5NxQT3zmJJg3an/mzydM1k= X-Received: by 2002:a17:903:1a86:b0:2b2:4bbc:14b0 with SMTP id d9443c01a7336-2babd4cd7fdmr142843515ad.20.1778480143251; Sun, 10 May 2026 23:15:43 -0700 (PDT) X-Received: by 2002:a17:903:1a86:b0:2b2:4bbc:14b0 with SMTP id d9443c01a7336-2babd4cd7fdmr142842995ad.20.1778480142633; Sun, 10 May 2026 23:15:42 -0700 (PDT) Received: from [10.218.50.10] ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e36c65sm92563845ad.40.2026.05.10.23.15.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 May 2026 23:15:42 -0700 (PDT) Message-ID: <6e0081a3-a28b-49e5-825d-405cc157254f@oss.qualcomm.com> Date: Mon, 11 May 2026 11:45:36 +0530 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 v2 1/2] thermal: qcom: tsens: atomic temperature read with hardware-guided retries To: Konrad Dybcio , Amit Kucheria , Thara Gopinath , "Rafael J . Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba Cc: linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, manaf.pallikunhi@oss.qualcomm.com References: <20260508100700.772985-1-priyansh.jain@oss.qualcomm.com> <20260508100700.772985-2-priyansh.jain@oss.qualcomm.com> <000ababe-5f9d-400c-b7b0-380ff25e9fad@oss.qualcomm.com> Content-Language: en-US From: Priyansh Jain In-Reply-To: <000ababe-5f9d-400c-b7b0-380ff25e9fad@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTExMDA2NyBTYWx0ZWRfX0tXOJBTGBR1n acYMZVUO6VLVj7Ueaz5Te/3jLmTMkFock7ROwayd7LuP9dye6WqoklzcURxAmUxmYNigukt+WKr N0ULgE21OkS/GfyQhKbWW36hJubRdPIhWGoz3KLxPjfVlfL9xF9EM7MZbZZdqfMFicSMaCekqd9 9qTO+iqfbiUG+sJjVps46DKLAfOuVDXZYhqF/xytfO0o174oaC6qs/Sspcay8o1AR7xpQ/XzTyX d0uYTHG1EJetOrsFVdwW1BpgmHz7jn/iMwLQ5/3BOGwtrv1kERzmQfGjxXgws0k2qy+cRApnEZg Ogfxmrf2l8m0KW+p8YlAGSMrA2wdvKWrnXNoXSfAel7H3M51joFOyGfEjDeXNDH5ZwSuIgxtDOa Am5kAr0lMnHnmWFhV3k8BXYKGTn64ads7KIUtcRv8h8rfuOomXnKLc8Wvg7dBy5dMwi+w7Yl/eY xVw5oIdJJGC0zwTGemQ== X-Proofpoint-ORIG-GUID: vHJLuiEMtEg6aIcoapear5UISDqx1fyp X-Proofpoint-GUID: vHJLuiEMtEg6aIcoapear5UISDqx1fyp X-Authority-Analysis: v=2.4 cv=cKjQdFeN c=1 sm=1 tr=0 ts=6a017410 cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=EUspDBNiAAAA:8 a=c8u1hPl0b-36Wx5Zf68A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=1OuFwYUASf3TG4hYMiVC:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-11_02,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 clxscore=1015 spamscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605110067 On 08-05-2026 05:39 pm, Konrad Dybcio wrote: > On 5/8/26 12:06 PM, Priyansh Jain wrote: >> The existing TSENS temperature read logic polls the valid bit and then >> reads the temperature register. When temperature reads are triggered >> at very short intervals, this can race with hardware updates and allow >> the temperature field to be read while it is still being updated. >> >> In this case, the valid bit may already be asserted even though the >> temperature value is transitioning, resulting in an incorrect reading. >> >> Hardware programming guidelines require the temperature value and the >> valid bit to be sampled atomically in the same read transaction. A >> reading is considered valid only if the valid bit is observed set in >> that same sample. >> >> The guidelines further specify that software should attempt the >> temperature read up to three times to account for transient update >> windows. If none of the attempts observe a valid sample, a stable >> fallback value must be returned: if the first and second samples match, >> the second value is returned; otherwise, if the second and third >> samples match, the third value is returned. >> >> Update the TSENS sensor read logic to implement atomic sampling along >> with the recommended retry-and-compare fallback behavior. This removes >> the race window and ensures deterministic temperature values in >> accordance with hardware requirements. >> >> Signed-off-by: Priyansh Jain >> --- > > [...] > >> struct tsens_features { >> unsigned int ver_major; >> @@ -522,6 +526,9 @@ struct tsens_features { >> unsigned int max_sensors; >> int trip_min_temp; >> int trip_max_temp; >> + int valid_bit; >> + int last_temp_mask; >> + u32 last_temp_resolution; > > You don't need this now that you aren't altering the regfield > definitions > Yes, that's correct. Thanks for pointing this out — I will update the code accordingly in the next patch version. Thanks, Priyansh > Konrad