mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: manivannan.sadhasivam@oss.qualcomm.com,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Daniel Lezcano" <daniel.lezcano@kernel.org>,
	"Zhang Rui" <rui.zhang@intel.com>,
	"Lukasz Luba" <lukasz.luba@arm.com>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Bjorn Andersson" <andersson@kernel.org>,
	"Konrad Dybcio" <konradybcio@kernel.org>,
	"Abel Vesa" <abelvesa@kernel.org>
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
Subject: Re: [PATCH 3/4] PCI: qcom: Recalibrate the PHY on temperature drift
Date: Tue, 1 Dec 2026 17:44:21 +0100	[thread overview]
Message-ID: <3159e4be-597a-4bf3-b61b-1cd300be2f75@oss.qualcomm.com> (raw)
In-Reply-To: <20261125-glymur-thermal-fix-v1-3-b93a9feae156@oss.qualcomm.com>

On 11/25/26 11:17, Manivannan Sadhasivam via B4 Relay wrote:
> From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> 
> 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.

  reply	other threads:[~2026-12-01 16:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 10:17 [PATCH 0/4] " Manivannan Sadhasivam via B4 Relay
2026-11-25 10:17 ` [PATCH 1/4] thermal/of: Add thermal_zone_get_zone_by_node() API Manivannan Sadhasivam via B4 Relay
2026-12-01 16:18   ` Daniel Lezcano
2026-11-25 10:17 ` [PATCH 2/4] dt-bindings: PCI: qcom,pcie-x1e80100: Add qcom,pcie-recalibration-thermal-zones Manivannan Sadhasivam via B4 Relay
2026-11-25 10:17 ` [PATCH 3/4] PCI: qcom: Recalibrate the PHY on temperature drift Manivannan Sadhasivam via B4 Relay
2026-12-01 16:44   ` Daniel Lezcano [this message]
2026-11-25 10:17 ` [PATCH 4/4] arm64: dts: qcom: glymur: Describe the PCIe thermal inputs Manivannan Sadhasivam via B4 Relay
2026-11-25 10:33   ` Konrad Dybcio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3159e4be-597a-4bf3-b61b-1cd300be2f75@oss.qualcomm.com \
    --to=daniel.lezcano@oss.qualcomm.com \
    --cc=abelvesa@kernel.org \
    --cc=andersson@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=conor+dt@kernel.org \
    --cc=daniel.lezcano@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kwilczynski@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=mani@kernel.org \
    --cc=manivannan.sadhasivam@oss.qualcomm.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®