From 007be58ade2db4b2f7ed2e45cb7b13ba72fba520 Mon Sep 17 00:00:00 2001 From: Casey Bowman Date: Tue, 31 Mar 2026 15:00:39 -0700 Subject: [PATCH] intel/ds: Modify rejection threshold to scale with requested sample period Previously, we only checked if the hardware duration was greater than the requested sample period by 1000 ns. This can lead the hardware duration to be rejected and use the next cycle, which is double the size of the current duration. At larger requested sample size, this can mean getting a hardware duration of 1.7 ms for a requested sample period of 1 ms. To fix this, we'll scale the check so that it uses 67% of the requested sample period as the reject threshold. This way, if the hardware duration is below 67%, it's guaranteed to be within 100%-133% of the requested sample period on the next hardware interval. Signed-off-by: Casey Bowman Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/ds/intel_pps_driver.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/intel/ds/intel_pps_driver.cc b/src/intel/ds/intel_pps_driver.cc index b13459ae916..e8e257af60a 100644 --- a/src/intel/ds/intel_pps_driver.cc +++ b/src/intel/ds/intel_pps_driver.cc @@ -182,7 +182,13 @@ void IntelDriver::disable_perfcnt() /// @return True if the duration is at least close to the sampling period static bool close_enough(uint64_t duration, uint64_t sampling_period) { - return duration > sampling_period - 1000; + /* If the duration isn't greater than 67% of the request, we will use + * the next hw sampling period, which will be double the current duration. + * That value will fall somewhere between 100%-133%, guaranteeing a duration + * that falls closer to the requested sampling period overall, while scaling + * to accomodate relatively larger requested sample periods. + */ + return duration > sampling_period * 0.67; } /// @brief Transforms the raw data received in from the driver into records