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 AF34830BF4F for ; Thu, 23 Apr 2026 15:17:17 +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=1776957439; cv=none; b=iB0cI36bCNvxUFWFqSB+l4mccX6A+lBoBI3LEep0JpUtIiQVi+TiguKwusoTyBxKEDxo8KeZYU9sTuFrv1kVqZJl7fqpLZQv5KoTBjGohtVtDQDtBLeMft75cNmifBhf92QnUuVaPEkE9g3WhOJDTMeX/VzD9GwM0x802F6ctjs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776957439; c=relaxed/simple; bh=gaE8mNQT6IPknLkLLO6v/or9S4a6F9swdPDSRgxH6eI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MLgn4staSX5tZADhQ936UCi7fX0yWGYkUR+jF2KCRRNAUzTGiNEil/gilX9JLO+gySioGBDa4FkOUlVYq1ztWGBZg8gr2jCEb/36aWkQd9Gq2bZn0inBb9Gn8XlwxNyJvx0YI6WhPDplXnbNO8x1jvvdvbCWYnbVxsnruXjaA3I= 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=PA6gL6/3; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Xo0BsJ62; 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="PA6gL6/3"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Xo0BsJ62" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63N8uPUS1565879 for ; Thu, 23 Apr 2026 15:17:16 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= Eze/1plM2v1qn5QnTvk0ysvssVshSt8k0/rXfQex3Xg=; b=PA6gL6/3dqpWMUfW jEkt63+YX5zSJ4fDKeSX6I0cS9gGGPnzeX0g16rPwysV6c1G3Sdxr9/EHJgS61BH apN6HLXVpgRHrhjy35HCYO74wSh5ud8aQgRrhIXzQPhxd3cgcnO2z8OpxaN5qy2u PQGatrXMIpHgAeakubttffluTsQzVZbQfsMPtjxWs6TgwoSa4VFpwQZvKcTQ5m9x Xr77nDCX+F4E4QA10o08WcIcwVL6ERjkHSKgVCRoskcpUDop90IAJVlfIze1gstY egS/4r8ycsjCO7Ed0HaMQAahN0mSwVRKQTIWM9dghK2WiZNdZo32t3lTTZHLhceh uBnBpQ== Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dq16wvpbf-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 23 Apr 2026 15:17:16 +0000 (GMT) Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-479d4674399so3132143b6e.2 for ; Thu, 23 Apr 2026 08:17:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1776957436; x=1777562236; 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=Eze/1plM2v1qn5QnTvk0ysvssVshSt8k0/rXfQex3Xg=; b=Xo0BsJ62Hxjv46R7YE4QCdMgwn+ifZsRAlOnsNyqygEMwgo7mkpAYLjjvnPIZorueF /mmKomef6lTnP1zBsQ5SJPBzeJNe5zYEGvobw8UXlDzukdEXF1dn3r7VaRbeoAL3V0de p9oousPnAKcd3lTGtWaVu4VeQDLuSZ3D6wK3RADjc3Whv75VYKAn3FC+D4C8EPrmK3AB Ht71rsjHEkRStoYHWyvp/r3c1z4pKfd1DrAcItG5iLe178+tJUz8VYdWw5kBnUhf6L2u eTOUD4yxBhf2jiNfm9oLk7glHQqEc/0BRJ6OgNfnZwBTL2SSFthkkv1V2cYa6HyZ/X5A UPVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776957436; x=1777562236; 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=Eze/1plM2v1qn5QnTvk0ysvssVshSt8k0/rXfQex3Xg=; b=QJ2hYUq0MizvV/iGyBRNrRltdKk9M0cE/cG/oxwE+XwlEbCBs7kIs4Mtxqi6KfYOmD 24v/s1rbJxHINBzOfNg7VV02EGtYLglBOQ2nK5Ghpd1GkimGTaOw1tetC6AMnu7vfkSs uZMKMTO8mdsAIImtAU8n3iD1BpjCY9CEqCVu57MS7X1xCsV8Vrz3MoEIaInnyn2dgg0F PoqLvIVxuMiWX5muKIJRN2pw8RMWDJ2BdMUtpNJcy2JVk0WfOlQsteZPwMZ3MTk1mhlZ fI0G+lMA/iEjwS2oyU+hgBDxKIJ+hg2iPtqWhuMCQcD7UU1Fisn1sVaEbGrkt5Y41KEQ yXDQ== X-Forwarded-Encrypted: i=1; AFNElJ/GzQnQ5r8brV3wam/n74V0mWUBoYcKbZHtp35k7xr8yHljguRf2ZcWVkycHGXJyejCJiVq5xNNCzra@vger.kernel.org X-Gm-Message-State: AOJu0YzpeE8+BQyHjZDvAMrwGNt0zTL1hzxXBL71ZG1HjJSlyCi2AM8Y je19DZ2xyoOq+To57YKUtkTeZQvAT8LTVn9No1uJliU2MR5oAifmMPTVTj5faU2kt94mQiYzWR5 HFVe5g1UM32TFmfhkD8eNN9bzDDTT3T/iC0ooy5UC00voWdxjIAGpvN0vXjVfml70 X-Gm-Gg: AeBDieu6QXTMT9bdkj7xrREMUSU/pE9lGHThBL/ywe2RV+fLrXOYyFdIHZAMrNTycM1 yfsvoMNy7IcrlcGjoBxIu7uiopYwa7H/sxLAiL/y9yxg0HEaT43yJmfIGYzsEbz6VyqTqbJPOFt xcUsFoVcviGDpr1OsWNPACxkVrj5zqGjCCk3s+ONXtCDHG9cg3eaggfKfiTNTvWZgU7oSqh+8sG ZZsa7a6jaIPwUPsFaowOjS96Hu2vT4EZCNLy/c5pq64/0d5CiRwu/2Y4tsfm4PcLrzzmG1jIKyS Nz+WxdDGahQXB32wF/em6ggJkl6gwilI9vc3eNIBTyr1yGUOAF+B7NUKGoR26IQZ7zCNuDlQOF+ /Rp6yj1kFxXnUbklKQdYPBnvL5igSsZpT/gFIXSn64i+Fizt/tSfiy5cUVTt/g2lGTSezjZ554T khkm1eddYlkVWCmR0bE8g= X-Received: by 2002:a05:6808:50a0:b0:47a:8c2:a558 with SMTP id 5614622812f47-47a08c2b6a8mr4055143b6e.43.1776957435926; Thu, 23 Apr 2026 08:17:15 -0700 (PDT) X-Received: by 2002:a05:6808:50a0:b0:47a:8c2:a558 with SMTP id 5614622812f47-47a08c2b6a8mr4055087b6e.43.1776957435470; Thu, 23 Apr 2026 08:17:15 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:8a9b:1477:c29c:4bcb? ([2a05:6e02:1041:c10:8a9b:1477:c29c:4bcb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc0b4c85sm502913835e9.0.2026.04.23.08.17.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Apr 2026 08:17:14 -0700 (PDT) Message-ID: <8a4dcb94-ab88-4559-9027-49308ad02b73@oss.qualcomm.com> Date: Thu, 23 Apr 2026 17:17:13 +0200 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 4/8] thermal: amlogic: Add support for secure monitor calibration readout To: Ronald Claveau Cc: linux-pm@vger.kernel.org, linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Guillaume La Roque , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl References: <20260421-add-thermal-t7-vim4-v3-0-a2e7215ed003@aliel.fr> <20260421-add-thermal-t7-vim4-v3-4-a2e7215ed003@aliel.fr> <7aaa7873-9274-48d8-a6fe-cff4239b03b4@oss.qualcomm.com> <19d70883-21db-4963-841d-7c00505e0d9e@aliel.fr> Content-Language: en-US From: Daniel Lezcano In-Reply-To: <19d70883-21db-4963-841d-7c00505e0d9e@aliel.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDIzMDE1MiBTYWx0ZWRfXyOYqQR+uP1N5 TjH7IB7bEltf5vxZdIaKHwbLe7b3LazpKhsaJvixq/5cNncQvHbqmvj3oRwW8hYM45pxx4Pm0HM qaKd9Iem9SunSmEHmyKpP3wwS1zr15AH8yVYPKsb20H4qfsEKiZyEmqcs53f/Wb5c7Jlf4+Quy6 sPg6yTB/EhLhFuuqNbuUGN86KHdWACR0+gTMWuneI7KdxRdqNzxEK+IUCISicKpjexWFPbvWvXI 2DBr5fsWiMbdQpZlgYbhoP9QT2fwV90FoJm2+9PaFRqMp98TQmYumSE3JBnxR8o4aAeRIx8faLX g5Qupax4NcWM9AZO4PpsizU1hsDI0HZgYDGNDjvOkYQRhFWu3mnSgzin3z0HlRrKd5bxa6GqGCL +bKt/nxaiCgHrt85kVGRhwq91Q1m3nw5MTvmUsBZ9Nxff0QgTQJa8n4p4JukJ+V994qgqdG5Uhq Y3Aq+fYI7OwRXrmxE5g== X-Authority-Analysis: v=2.4 cv=dL+WXuZb c=1 sm=1 tr=0 ts=69ea37fc cx=c_pps a=AKZTfHrQPB8q3CcvmcIuDA==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=pD_S-A0WoN6OyM3pGvIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=pF_qn-MSjDawc0seGVz6:22 X-Proofpoint-GUID: xP7ir0druQsPk0xWUoyRkg6iSe_FDsSe X-Proofpoint-ORIG-GUID: xP7ir0druQsPk0xWUoyRkg6iSe_FDsSe 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-04-23_03,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 spamscore=0 priorityscore=1501 malwarescore=0 adultscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604230152 On 4/23/26 17:09, Ronald Claveau wrote: > Hi Daniel, > > Thanks for your feedback. > > On 4/23/26 12:25 PM, Daniel Lezcano wrote: >> >> Hi Ronald, >> function1() { >>> +    if (pdata->data->use_sm) { >>> +        struct device_node *sm_np; >>> +        struct of_phandle_args ph_args; >>> + >>> +        ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node, >>> +                               "amlogic,secure-monitor", >>> +                               1, 0, &ph_args); >>> +        if (ret) >>> +            return ret; >>> + >>> +        sm_np = ph_args.np; >>> +        if (!sm_np) { >>> +            dev_err(dev, >>> +                "Failed to parse secure monitor phandle\n"); >>> +            return -ENODEV; >>> +        } >>> + >>> +        pdata->sm_fw = meson_sm_get(sm_np); >>> +        of_node_put(sm_np); >>> +        if (!pdata->sm_fw) { >>> +            dev_err(dev, "Failed to get secure monitor firmware\n"); >>> +            return -EPROBE_DEFER; >>> +        } >>> + >>> +        pdata->tsensor_id = ph_args.args[0]; >>> +    } } function2() { else { >>> +        pdata->sec_ao_map = syscon_regmap_lookup_by_phandle >>> +            (pdev->dev.of_node, "amlogic,ao-secure"); >>> +        if (IS_ERR(pdata->sec_ao_map)) { >>> +            dev_err(dev, "syscon regmap lookup failed.\n"); >>> +            return PTR_ERR(pdata->sec_ao_map); >>> +        } >>>       } } > Sure, I will do that. > >>>       pdata->tzd = devm_thermal_of_zone_register(&pdev->dev >> >> The thermal zone is registered before calling >> amlogic_thermal_initialize(), thus pdata->trim_info is not initialized. >> When a thermal zone is registered the thermal framework reads the >> temperature, so it reads an invalid value because: >> >> devm_thermal_of_zone_register() >>  -> thermal_of_zone_register() >>    -> thermal_zone_device_register_with_trips() >>    -> thermal_zone_device_enable() >>       -> __thermal_zone_device_update() >>         -> __thermal_zone_get_temp() >>           -> amlogic_thermal_get_temp() >>              -> amlogic_thermal_code_to_millicelsius() >>                  [ Use of uninitialized pdata->trim_info ] >> >> Right ? >> > > Yes, I will move the initialize before the register. > >> IIUC, amlogic_thermal_initialize() can be also split and moved the >> corresponding blocks to the functions to be created in the comment above. >> > > The SM and syscon setup will be extracted into two functions. > amlogic_thermal_initialize() itself is kept as-is but moved before > devm_thermal_of_zone_register(). > Let me know if you'd prefer a different approach. In the initialize function the following chunk is added: + if (pdata->data->use_sm) { + return meson_sm_get_thermal_calib(pdata->sm_fw, + &pdata->trim_info, + pdata->tsensor_id); + } I was suggesting to move it to function1() and the rest of code from initialize in function2() That results in amlogic_thermal_initialize() to be dissolved in function1() and function2()