From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796143466; b=16yLIhhJgEhBPzDhX/RBfNwVdpAchInWemwWyOoQsgGm1s//ujmrkeQr+m9+dG9YdxYm jwJZ9tZyGDEPhtDFE7STja8XfGkbTBnJvsiMj7ZpR6SwDB8BLpezkpNL/QI6dER+KhMQ6 KyA/G7jnYzGadOXdBzLCoe984rx4j45B8dejm7G9fJ+a2RZ3ZocKSE78K2uLRtApV5ejc ou9Lvrlg5HAseBZnlAl6YqDhQRyjJLsmdXiMw7Yg2ekXb7tfiRkuP4IT9X0GwH3e35qxa P9mItx2DXiZG9iLdHbEE8DHvyTR+LlJvONnuH+c++ARGc2v3giD2EOgHwomBRB5N4mA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796143466; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Authority-Analysis: X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=3AAhOdxZe84t/XboePLgxLXG586yvVLmf1UwO8PucL4=; b=Zx5QJJ4YcHHlCR2YbWwWTcPu+AO7s+79EbKRyE+0GFSFIPrPO6TfO5S9wMS03CCYX6RM Eya5XKtBdGEykgZhBle2yoNYtMdaSiAe2gaoZoIkSFpxAgN3DvSN7LA/t4QPwlyAQ8Llp 4jh3jbUTxlt5jsuJaNrFBnY7OHkvLV/6FN1zxT4p+u2VD2e9CVudidmXnIVc0k094xhzs mI30hORcrKLMM2WFARjeYxjSu5JAFm6IoqvmV1ggXuVDEZdtHuSXwzimCev3JjY7f/G3n Y353epHiHoJyWMXcyHkqyYEUmBr8Zrr4V2GXHD6dnRX2v/3S0nJVPYMbJrjB+Y2eerQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=XYkzTcEz; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=A7SeGCK9; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C2B3606A31A for ; Tue, 1 Dec 2026 16:44:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8C2B3606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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.a=rsa-sha256 header.s=qcppdkim1 header.b=XYkzTcEz; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=A7SeGCK9 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 6B1F7Eln2931590 for ; Tue, 1 Dec 2026 16:44:24 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= 3AAhOdxZe84t/XboePLgxLXG586yvVLmf1UwO8PucL4=; b=XYkzTcEz3fX67mLA oG+Q9CI+/ZJjZ5zmfNoPErHQhCH/FNHa/4lBLF9pQt7v+vtEhG477ULZZ2W5Q9cp bUW0b5OE8LthJPoxGuAAigtFWCHpeKClny9tkx1VIT9a/0kJLXGxDDG5bvM3rQC8 3SoAdbep8RUy/oLr4an6uhnFewwUcFGvN16hYt8ubyA7Wjl5qtjkJ7xR/WVaKG5Z eek6Gmffe5NrBZ8CoFHvsyFryeEw13MSyhrhJN05fIKvpEA4BGPHBZxxcU14hVPF +tROrC1MufE5SEYLbLKdq6BV1RH/yQuHqeTp2AoB8NyHWsK2PCdNbsXeMshqwLev zguD3g== Received: from mail-yw1-f197.google.com (mail-yw1-f197.google.com [209.85.128.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j9nb63dew-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 01 Dec 2026 16:44:24 +0000 (GMT) Received: by mail-yw1-f197.google.com with SMTP id 00721157ae682-8b501e92b97so118397607b3.1 for ; Tue, 01 Dec 2026 08:44:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796143464; x=1796748264; darn=vger.kernel.org; h=content-transfer-encoding:content-type: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 :content-type; bh=3AAhOdxZe84t/XboePLgxLXG586yvVLmf1UwO8PucL4=; b=A7SeGCK9H9Sw7WMOUX/TPvuPS4HjDdjxJydDTycWqVtWSKs8XnN6oTO4eaNUxXomcL fD+3mY9zJwYiodlTEOoXJF5p9dcT8RFMwOFnBbCBb/VLNRD6E388JnA3Q+PTph9uBjYN VC/KuKK1t2sVvTm9Wn4Tws8yUi7vme3SUP6qVaukgixuU/ir3ItLvkRnaxJhQ9Y2h3wu SMAbLukHXM83BeBMFGLFuV6NN7AROwfTGtlN9w6PGvuVhfvub1uqti4xqAVRkSuyuXz5 eX62I8gRaPJtbmq3AdpnHUQpnb5L5fGwO8uyXkkG2sn9S1fW1s1vIK8yGLIZmGyJQJJk 1xCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796143464; x=1796748264; h=content-transfer-encoding:content-type: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:content-type; bh=3AAhOdxZe84t/XboePLgxLXG586yvVLmf1UwO8PucL4=; b=VgmrpTzbWbellPwg11wsPNpx+m+4C9PFb2/uE7gwfDyC8eaDCj8LD+wR2I8VmnCWzS KMooVtIKOTPQHP1ovnOpLpFBBTgUr+vgjCciYKQnkrGtLT9C/mfJVIMezN26Efr9MDy/ RElBF158IiGrBQAG8A8EImypTEY3rFaNYF6CFPQSvq7+yhb8kHUqg+abUxzpa+2lCWl1 vH3RB8t1Yb3dWS0mjF24neohBIqm8LP2dYE8B4alwkoZu87wY57AF2rUvdPWEZLeRa8c wO9Ph/h3hH6co8GZ0LXHQVkyMHUJ96VmgYVOxOrkLKLdnk/R6ZfO9eF31SDFPEP34J8B 1VsQ== X-Forwarded-Encrypted: i=1; AL+hErEWuRfrtr6a1/vfgZOlT8RC2hYnMAMCILm1VegEjNVuJxlMaIQZk/XHgq4e6jC7Rv6EtjHFahRgjizX9ZM=@vger.kernel.org X-Gm-Message-State: APuU4Z9m3H1PZXkEMVkk7dx2Ebj3VHbOeCJO2ei2ZS8yYzCDNcomu8Zz aFal1+4WXkTkj9n8Hks+0/KL6xztGp5qjRM37H2Gd0OXXF3NgKjIbafm25QFANxu5pa6nWIo3/F /nwxiB7uxy5XQpqee8+uDz4QhW5nHRG5vbno8THs5PePLVbF7qbzmKAb+lQD75kdUYIk= X-Gm-Gg: AZFdTZfq50dzUAcJLBa0b7z78ZUaSTTzyo3sy0UTIHFqD+Dk06U6wJEYXp/VDHmnAni vXoR66V2D+EsJqhA6gyoxTKDKjhZj9Mf3pNKpggPs2W8hStzkpMBKjMRiuWKnQU1PUAHd0nRcMU t6LOHq7sVE7KLFfDt0Wqtp2QILRtBBSTQ9M57zFUHPOUDHrakp7MuhD2kw275sZSGXJSpg004p/ rg7b0XuL4sIoIDSwtFvZIxYjJ300W7VjE+AUvpTa3dVcVlCBBhMI3xy2RFepLt+Pv6vURQBmeXK svEqZOgHFMmo10OOgIzcPkFE15ocJLl330glktWCTxTBX/GdRnTEf3DlzoDJ54sAUCz/wcvoDT5 KmkDZOned30cRZcwViwc22PZ64ULsf+ZIyJZq04/V3Sfs59TqIzWBbWO675iLiPZPVRz8+wZ/Wd L4KtGt/OpHGQHobZAMdeMLQjCLuZ8g2kBa+A== X-Received: by 2002:a05:690c:4806:b0:8b4:d8f4:8cd1 with SMTP id 00721157ae682-8b52047e643mr139434317b3.56.1796143463662; Tue, 01 Dec 2026 08:44:23 -0800 (PST) X-Received: by 2002:a05:690c:4806:b0:8b4:d8f4:8cd1 with SMTP id 00721157ae682-8b52047e643mr139434077b3.56.1796143462963; Tue, 01 Dec 2026 08:44:22 -0800 (PST) Received: from ?IPV6:2a05:6e02:1041:c10:d8da:78b0:ad48:3b53? ([2a05:6e02:1041:c10:d8da:78b0:ad48:3b53]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab658e2d60sm72565877f8f.3.2026.12.01.08.44.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 08:44:22 -0800 (PST) Message-ID: <3159e4be-597a-4bf3-b61b-1cd300be2f75@oss.qualcomm.com> Date: Tue, 1 Dec 2026 17:44:21 +0100 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/4] PCI: qcom: Recalibrate the PHY on temperature drift To: manivannan.sadhasivam@oss.qualcomm.com, "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Manivannan Sadhasivam , Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Abel Vesa Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org References: <20261125-glymur-thermal-fix-v1-0-b93a9feae156@oss.qualcomm.com> <20261125-glymur-thermal-fix-v1-3-b93a9feae156@oss.qualcomm.com> Content-Language: en-US From: Daniel Lezcano In-Reply-To: <20261125-glymur-thermal-fix-v1-3-b93a9feae156@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA2NiBTYWx0ZWRfX73KOSSLe8JlM 0izk+giVa44NlhczWwShIXNY1eT945z9WTR9UioypOSpo1EtSaz5jl4KrYp0d2ZbLNkQyHJrI2F zrvL4oB6xwHPAH4V3fTu4a/Lv80b7PQ= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA2NiBTYWx0ZWRfX5LYu+atY0id3 BayUJLRcaulch52tusNeYVW9nYqdHdvw0j5C1xpcJGl3EdR28vYNU80Tz5qMSNFTngDCOYpMU9G je26e6vPa+ZGrY/7tEW3L6ZIzMbS9DHZa6y7Vp7xceuEO1f0V02Z77GzU+tnB+dX3hJhV90VCFD EMG2wksYWKLMNVoeqCjvn3BcZJiVLCcNshm+vzEqcq3c9Gt6Mji4OeYkYIjCRWO8TPSjwxtWSAf 6ZbPDNfH3hy60KXfR5ljAxzTXES1GdnFVQqlO+UEAbbnVzGcLXiA7MoM7sS2Sm4aOFlobgfslzB 0pnFjApt6e4DuQ5bkkeeWWmmKfevs2KG+rOujxxRCHYvlTsGeWFRmeryVdJdfs1oUTztCFgyg8L Y8d+9QtXXCFtMcb7RLLsAIjYbYQG3wZ7H4xcMpg19uKQUCabSrY3MR8R1R3VtiWWI7hY4gCGs0I QyMIk6VDPrTwMFctuMg== X-Authority-Analysis: v=2.4 cv=fc44WEQF c=1 sm=1 tr=0 ts=6b0ef968 cx=c_pps a=0mLRTIufkjop4KoA/9S1MA==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=EUspDBNiAAAA:8 a=--itUQ8Ax_PAFucu8LMA:9 a=QEXdDO2ut3YA:10 a=WgItmB6HBUc_1uVUp3mg:22 X-Proofpoint-ORIG-GUID: lxY6-eX5YosJvHjbg_gizGs39y6Z-mS7 X-Proofpoint-GUID: lxY6-eX5YosJvHjbg_gizGs39y6Z-mS7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_03,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 adultscore=0 suspectscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010066 On 11/25/26 11:17, Manivannan Sadhasivam via B4 Relay wrote: > From: Manivannan Sadhasivam > > Some PCIe PHY instances on SoCs like Glymur benefit from periodic > recalibration to compensate for temperature-related drift and maintain > stable link operation. Otherwise there is a potential for a link drop. The > recalibration is performed by the hardware during a PCIe link speed > switch, which the driver initiates once the temperature change on a > polled sensor exceeds the defined threshold. For this purpose, the driver > needs to know which sensors track the PHY temperature and the drift > temperature. > > First, get the list of thermal zones and the drift temperature by parsing > the 'qcom,pcie-recalibration-thermal-zones' DT property. Then record the > current temperature of each zone, which is the reference the drift gets > measured against. Then schedule a delayed worker thread 'recalib_work' for > every 5s to monitor the temperature drift and initiate the recalibration if > the drift happens. > > qcom_pcie_recalib_work() does the actual work of reading the sensor > temperatures and performing recalibration when required. The worker > compares every zone against the reference recorded for it, and if none of > them has drifted far enough, it skips the recalibration. Otherwise the > worker performs the link speed switching by scaling down the Target Link > Speed to 2.5 GT/s and then restoring the original Target Link Speed. This > forces the link to run Equalization again, which recalibrates the PHY > against the current temperature, thereby maintaining stable link > operation. Equalization only runs on a speed change to 8.0 GT/s or above. > > Finally, the recalibration has to be stopped across system suspend as it > touches config space, which is not reachable once the interconnect paths > are powered down. So cancel the work in the noirq suspend callback and > rearm the recalib worker on resume. This implementation introduces a separate thermal monitoring mechanism in the PCIe driver, including temperature polling, threshold management and drift detection. Wouldn't it make more sense to handle the temperature monitoring in the thermal framework and notify the PCIe driver when the temperature deviates from a reference by a given amount? The PCIe driver would then only be responsible for performing the recalibration and updating the reference temperature upon successful completion. This would avoid duplicating thermal monitoring across drivers and potentially allow interrupt-driven temperature monitoring instead of periodic polling, whenever supported by the hardware. Temperature drift monitoring is not necessarily specific to PCIe PHYs and could benefit other devices requiring temperature-dependent recalibration. Another concern is the thermal zone lifetime management, which is currently a weakness of the thermal framework when thermal zones are accessed by external consumers. What happens if the module providing the thermal zone is unloaded while the PCIe driver still holds a pointer to it? Without proper lifetime management or a mechanism to notify consumers when a thermal zone is unregistered, the recalibration worker could dereference a stale pointer, potentially resulting in a use-after-free. How is the temperature drift threshold characterized? The implementation assumes that the PHY electrical drift depends solely on the absolute temperature difference since the last recalibration, regardless of the temperature variation rate, the absolute temperature or the thermal history. Is this assumption supported by hardware characterization? Could a slow temperature increase or prolonged exposure to a given temperature cause electrical drift that would remain undetected by this mechanism? Additionally, with a polling interval of five seconds, transient temperature excursions between two consecutive samples may remain undetected. Could such excursions affect the PHY calibration even if the temperature subsequently returns within the acceptable range? Finally, updating the reference temperature when the recalibration fails could mask an uncompensated drift, allowing it to accumulate over successive failed recalibrations without being detected.