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 53525366079 for ; Fri, 8 May 2026 12:09:18 +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=1778242159; cv=none; b=OR8qI969QmPDZ/UO8QYbbLUNPWpDoo0R/twwKdYGSn1WFXRXf1c9s5Apv+b4v7mG5jMP8bqg8NYDcW0FERzjs23/w27Curj3zcLNrIVOhnJ4kbPVbTr6KBeybMJ8VbSq+DzgdNvGrN+cVQ0ipBWTFVgfBoNwzDK68t84yYlqmh0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778242159; c=relaxed/simple; bh=9JXcMPi9klr0gVBugissvm3yubFoBeps+U+24lIoaAs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aOU9B9wSTQMcINeTG4p2gflHKCoOKxkOtMelziQ6aWCRHl/M+Y8ztpmP1qISI8V86w1yADmFIVTdV2K3ksSjKGi/tdxLdtexEB+BglBVovJag9/TSRqKKfRUnpPK5v/WZQF4NCUZAPbKE2JugOE/sp44sLDzGWW5/Sd0aAOS+cY= 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=HHZyhl9k; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Am52nWj7; 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="HHZyhl9k"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Am52nWj7" 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 648BwNTR2777831 for ; Fri, 8 May 2026 12:09:17 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= gQ+VgIMQeKAABKdVWfr6IhkQcf+KdfW+45aLUXYfA9A=; b=HHZyhl9k9V1/66Z/ +u16+1ckFqBBewZtAvFfgJ/Qo+lS8caKdHT16uAp74x4ZPmmkZTUB2Ti5ORjEYB8 R1ViM4LV42S9z4wTSm+rMnbtaq03QZY5giqnlekfvWr7ZBtX9VKSsyPob0zv2mqf j5KHIwJvAJuqXWh6+wQNI/y7Zxp8ZMH3a7ReMgjScgKNn+6BiUE4l3YntKUaJGWT Z1SpdZe7E8atwILSNuHoN3Te/5waRbKCgrMUtyhJ/XLw10UyUrgUa4dNGGFI3vNg OV/gJ3uncEIvXQws9TA/b4vbxtpwxV/SJ66GpRakgU3/9tUA6dyqqJmt/I5TfecR 6AiuiA== Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e1285k00t-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 08 May 2026 12:09:17 +0000 (GMT) Received: by mail-ua1-f69.google.com with SMTP id a1e0cc1a2514c-95ced01a58fso128172241.0 for ; Fri, 08 May 2026 05:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1778242157; x=1778846957; 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=gQ+VgIMQeKAABKdVWfr6IhkQcf+KdfW+45aLUXYfA9A=; b=Am52nWj72AHyDboZXbsEwHqV2KHcs/szowvPzBlmV1KNa6aBWkArEzRe9uClbWhYNw bgJIKitggV28bCSgYHBx1EiqU5xguZGEI2r08HFLpedeuWe8MRvKIobZti2BIDkyRqnu /p79+75YpGvg7kEisxk82Hu2SGShCX1MAsp4g1vOf5thjOR+14leNMEmYyJ3c743O4oi 3kkzDmS88isnHF/qIvDp6rz2ZTY9Ab6ayZyF1cvRshuik/czqXFuwHq30xltyZXTdbZx ahHEXpYQPAF81JwaYo8ivU2c064VCWMuxOyJzmGsSjVgCiLaesVpM4PBpxVFt+0TRQy9 SC/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778242157; x=1778846957; 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=gQ+VgIMQeKAABKdVWfr6IhkQcf+KdfW+45aLUXYfA9A=; b=NFwIvN2DQoPe9ZfsKn/jOquGTmHMAYJqw15cwdGGVci148lqh0cv3jqPTrCefVP7Xq zMtu+0ZjJQq5rnN6F2HRsGUea09vz5WPA6VjGCEghSkYGT3OGqlfMKdECmecpRtmWMmK la7nIFLH8meEcH70KqTi+agRPNO8fhHLUWvowFfU/spIWH/Nr7mBYHsGyK1EQj2YpJwt LhQI0oKPCOnGcc9KyEovSKkZsjWSYJ4wQrFH9kA4eqxtRA6WVFdI6g1+6KoPZqoVE9MO +Z+REEiptfCbcpdS93rt+L4+QpzO1dVsA0IonPZGWIKL0N783ioz14Biq/zoniEobDgy 7Jvg== X-Forwarded-Encrypted: i=1; AFNElJ/LR7Uj0+V/MSk2KfFUOJoUtSI3ery2E8ImtzDa6E9sg47EgvcquPIOKRIIopZypuXJjJW6oBvX69F+gmI=@vger.kernel.org X-Gm-Message-State: AOJu0YzPgyFExoRGzTRISCIaCezC4DhioxNj5mXm+ucEPi50ptttc3Bg 0oqkUReCY67riWxRDqdY5cz/a9NJWS7nJMurmc4AchudahGg9qqeAa7R6ZKpQE0HgG1x5drgpWg Z63O56zjtvTSkpIU0T7ZGBbC17Ggpp+9rjMyMXhLHV9aPvjkXSDIKL6k3Fnzl2UHiDwQ= X-Gm-Gg: Acq92OEpKKDy3yGRtDLUMoC6ClSbjSe4xpeq2Rvwx+mAFiDiqaLVxpeDIzDT2tUweII EPVMMJePQ840XZ2uh0ezEZGJRHqmayNdODI6GfsI7dmABlUJ/Zn1lgfeOVXzbHIC3tZ5XYi6/8o Wys2o6YeZlq7Qxnpf9aeXcihAzthqNTLlyCxlm8a/U/87mqXUttEB0q/qmV7qRELgehRonNmjYc jJ0WlxJ3rVaXj/czKPoA1NuKfIpJCxjf6JHB6T+zMgZXWpOyLqr7iMO1wVrPJrfTW5xGRZfTELz o9r/eAZhApFZhCuvjNiVqUf5CcasJ44P64tqCZFRWB7E42TplyS5OOXRDrWSbgrbN9ejOgwabSL SezO/c+NnqYbZr6/fHedn40xwP8l0Jj0bUnAAi3iotSgBCxuzMlKyVBwcfPSjxiaq7S08bFlSGo +lpXE= X-Received: by 2002:a05:6102:3588:b0:61c:7453:af7c with SMTP id ada2fe7eead31-630fad3a524mr2727058137.4.1778242156649; Fri, 08 May 2026 05:09:16 -0700 (PDT) X-Received: by 2002:a05:6102:3588:b0:61c:7453:af7c with SMTP id ada2fe7eead31-630fad3a524mr2727050137.4.1778242156271; Fri, 08 May 2026 05:09:16 -0700 (PDT) Received: from [192.168.119.254] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-bcac4359ea4sm73498566b.50.2026.05.08.05.09.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 May 2026 05:09:15 -0700 (PDT) Message-ID: <000ababe-5f9d-400c-b7b0-380ff25e9fad@oss.qualcomm.com> Date: Fri, 8 May 2026 14:09:13 +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 v2 1/2] thermal: qcom: tsens: atomic temperature read with hardware-guided retries To: Priyansh Jain , 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> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <20260508100700.772985-2-priyansh.jain@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA4MDEyNiBTYWx0ZWRfXyXuj0UjJaxDZ RfR9fg2vtqFHRy0bJqPtGiK+ZHfKCmLd5QFW1/nrU/tEHFizg72wRxElKzScO5p/N6sKmzwOZp1 sdMTov+ZfZ63BilFXd9FDDllI4QuwX6vLL182o/A5lAGiA/f14Jq76v4tP/X5I2Rmoysel8AR3p 2fWA7RpnS2TiWvrwcKQ/G9t6mvrBOHcOntfCsgI47fUI2U0G0It5WSrBs3B8ICnjFiS3vVGiQug hfaWiD0kORwQmv0nTSm7Ajw7Glb7hfxLvBkvGdjobHIbrKNn/LGl2f6uxbsrAE9W8mprcIooh3M kb39h1Y6s+jBIuN1DXLw658YvRoV32ewhM/F3ggsbKwEfNnBUSvtD9OnSrVdlo16oCezy3hluGb 9RoST1qKD41SIHAG+fHYmf20xnihZlxzyg8o+dQJwIkSuwOr2x7a7lxfa2vvoNMhAwTNQT/iys+ stUJJn5fXddRcj/2Dbw== X-Proofpoint-GUID: PVK-wL8El3AEg078eFZg_UPecUgchhah X-Proofpoint-ORIG-GUID: PVK-wL8El3AEg078eFZg_UPecUgchhah X-Authority-Analysis: v=2.4 cv=NKblPU6g c=1 sm=1 tr=0 ts=69fdd26d cx=c_pps a=UbhLPJ621ZpgOD2l3yZY1w==:117 a=FpWmc02/iXfjRdCD7H54yg==: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=6AAB0q3k6GC94sigMGcA:9 a=QEXdDO2ut3YA:10 a=TOPH6uDL9cOC6tEoww4z: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-07_02,2026-05-06_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 spamscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 suspectscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605080126 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 Konrad