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 8BC551A683E for ; Thu, 23 Apr 2026 15:17:17 +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=1776957438; cv=none; b=fAFjH/jlS90jcNFiIMCPsGpxhNEVsH6eJd8eT6XcMalA4C2HCo57ejA4zMf6k7RhsuR3DH3UX3NF/cDL+MpkLjGMIJZ75a7if55UeTOMY8LGhVFfCjMf77O3UIHoUJ7h/LQfPVeWoKaATC3ZoSucc5Y5rf5x3WxYlRwBPlHVj30= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776957438; c=relaxed/simple; bh=gaE8mNQT6IPknLkLLO6v/or9S4a6F9swdPDSRgxH6eI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=R6K0cIQQHOoYy0naVGONm/LqBVSp4I9OAgx0UgzIlqykSsMGQcJXVzYtPe36436WK+mStX2q60ABVPtBJVV0n7itPyn6HKCgiUmSITHynhnKMYsVZZDv9WE3I3v6dN0PZw12GMzSIh+PjiSxVqDZZu/6nAoM4efWeCXQ67boC7o= 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.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="PA6gL6/3"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Xo0BsJ62" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63N94nhJ2319525 for ; Thu, 23 Apr 2026 15:17: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= Eze/1plM2v1qn5QnTvk0ysvssVshSt8k0/rXfQex3Xg=; b=PA6gL6/3dqpWMUfW jEkt63+YX5zSJ4fDKeSX6I0cS9gGGPnzeX0g16rPwysV6c1G3Sdxr9/EHJgS61BH apN6HLXVpgRHrhjy35HCYO74wSh5ud8aQgRrhIXzQPhxd3cgcnO2z8OpxaN5qy2u PQGatrXMIpHgAeakubttffluTsQzVZbQfsMPtjxWs6TgwoSa4VFpwQZvKcTQ5m9x Xr77nDCX+F4E4QA10o08WcIcwVL6ERjkHSKgVCRoskcpUDop90IAJVlfIze1gstY egS/4r8ycsjCO7Ed0HaMQAahN0mSwVRKQTIWM9dghK2WiZNdZo32t3lTTZHLhceh uBnBpQ== Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dqgfssfph-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-f199.google.com with SMTP id 5614622812f47-463ee33f9b2so2898229b6e.3 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=jvhgpJVlkf7Yq13h5+MMPL7Z6jszYRfKa+FhwZkHc0Pf5AGieRK3pI57xFNO/lc241 1aOdHEcHQhI2IOmYz7bhTvArbKvaHk2/GjV3LcF8J1BLiFYEAGatoxpWgZBHfS/HsZZb h26uQsohZ5ja4GkRHxLxrFqLhbAn9D/REtHkwmV4l25Mvg2mJfwVvysEVjOFMmxsmoEK 8LU+IPtbWVvTy4+M/5WjMVkUT0FFVpPxYaJ39MMmOAVQemFZfFMeduRXEw9dSsoNzN9J MwQV48ZSYBLnFObqHJ4AXLQFihrtbamuXLDx7fIGtEBd6obIFj+hL96qR2EVVLU7pZAF hOmQ== X-Forwarded-Encrypted: i=1; AFNElJ8bZDWADlbBT4NGf3sTPmGVLy4gLIO82/D2LBjjyF+KEQyh1UTMMnbTlWCN37q6ozNKEsWVdAZ/v8HSia8=@vger.kernel.org X-Gm-Message-State: AOJu0Yxb9z7tGMGx5okOtCZ1qYSblQQjyUH7MLpCM3stQTqdvMgSiGJR R3X2lHOE56gHBYkjwH4rhgd/vz2jRg1Ss2CRUl/y2L9UA6/ccz22YBKh6IC63Iwml2zUgRVAedx H9x8DNCjrpDAYBfXv50netM7ZIJsJ5HECu+uzRAxGbQpuIeRl+mMBT1bh3il68JbixtQ= X-Gm-Gg: AeBDieuxRAl/g7/7CM5rYRBFXufnSRJsbFL9RCrTxLpkCaEoy8ZwtfXsLDRAushAi5t NSDYikoK3fU9ls2bbh0CHdlpIfjBFsxYBOgzwdipw6xv+F+4cVb9dhtzWhWIomerX1vep4RkxGs HvFqmwIfh23gn9rybdXbuYxxlDJBGZbB0Du4jlb4I4lAyJBApief+ds0UqxmN9m+DTlraWaR1Pz qCa0v9pt6dmlmavOlGF7O0bnPbZs8vy514Bev76+ATnyKth+i66ArRrHgrzuNcfGXgO9LkBzDfd Xc19o55Qu9bVkpgH2sbtbZB0ZohNdQjzjNJThzggIOgs34r654vRphJPpNb883Fhmjwq0jfC77H R4G632j+JJQrhE/GUE4aCenjiZDRs5cGT6DZ0HmRtUxosWWXNgepoQF6kkx5iW5Yy2g+JEg2nO3 PqnIyFOuZuoP5hcJWguOg= X-Received: by 2002:a05:6808:50a0:b0:47a:8c2:a558 with SMTP id 5614622812f47-47a08c2b6a8mr4055132b6e.43.1776957435915; 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: linux-kernel@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-ORIG-GUID: WGpMRqeeSZL_k1d_baVkIQnkbg26ytFw X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDIzMDE1MiBTYWx0ZWRfX+FUkodsTB/vn g8YW9+By2WDPqNdyMgWqLMKSgkJuREtKzmyZ00DkhRdkW75Pm5fVA2Mj0QzBX1XKVl3EiCqukSa 36ExQLNx3/m0iwzbdpG4O+N2riFY2w7ewh9re526fVm2a6YVhpen9AMXtkD71Yt9VVzhDJWrhOM +7xTuGTucWPf1JTp2zpvhhPHPsIV7RbFPXfeiW+lutrmIORCMb1s7Abnf3cJw8JrmbtngucyIyh 9BKGzpkmcHkHXzDeftp7qzChJ/3JxvYj21u9j7VipXlgAtHEFfSS7nHUNIlZo1QvPnOoDqqUkjf 3KLop/m1iP1O5GqwtCxcweTxxbdZog2VMeOOxTpAjL9K9vcVXw1QglCnC7ppWEdlnzgzNLf6xN4 ZmX4npKZWiLVNmX8/iY858MsXKSdSGn4KqLEi+7lDIg0IAGsUjvhyPyMem10budbgND0C3yCQdH 88/66EeY1Cvv9+U4Vaw== X-Authority-Analysis: v=2.4 cv=AvbeGu9P c=1 sm=1 tr=0 ts=69ea37fc cx=c_pps a=yymyAM/LQ7lj/HqAiIiKTw==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=pD_S-A0WoN6OyM3pGvIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=efpaJB4zofY2dbm2aIRb:22 X-Proofpoint-GUID: WGpMRqeeSZL_k1d_baVkIQnkbg26ytFw 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 priorityscore=1501 impostorscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 malwarescore=0 bulkscore=0 adultscore=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()