On 19/02/2020 00:03, Chris Wilson wrote:
Quoting Lionel Landwerlin (2020-02-18 21:54:03)
On 16/02/2020 18:17, Chris Wilson wrote:
Since we use a HW readback or estimation of the CS timestamp frequency,
sometimes it may result in 0. Avoid the division-by-zero in computing
its reciprocal, the timestamp period.

Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
---
   drivers/gpu/drm/i915/intel_device_info.c | 18 +++++++++++-------
   1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_device_info.c 
b/drivers/gpu/drm/i915/intel_device_info.c
index a97437fac884..18d9de488593 100644
--- a/drivers/gpu/drm/i915/intel_device_info.c
+++ b/drivers/gpu/drm/i915/intel_device_info.c
@@ -1044,13 +1044,17 @@ void intel_device_info_runtime_init(struct 
drm_i915_private *dev_priv)
       }
/* Initialize command stream timestamp frequency */
-     runtime->cs_timestamp_frequency_khz = read_timestamp_frequency(dev_priv);
-     runtime->cs_timestamp_period_ns =
-             div_u64(1e6, runtime->cs_timestamp_frequency_khz);
-     drm_dbg(&dev_priv->drm,
-             "CS timestamp wraparound in %lldms\n",
-             div_u64(mul_u32_u32(runtime->cs_timestamp_period_ns, S32_MAX),
-                     USEC_PER_SEC));
+     runtime->cs_timestamp_frequency_khz =
+             read_timestamp_frequency(dev_priv);
+     if (runtime->cs_timestamp_frequency_khz) {
+             runtime->cs_timestamp_period_ns =
+                     div_u64(1e6, runtime->cs_timestamp_frequency_khz);
+             drm_dbg(&dev_priv->drm,
+                     "CS timestamp wraparound in %lldms\n",
+                     div_u64(mul_u32_u32(runtime->cs_timestamp_period_ns,
+                                         S32_MAX),
+                             USEC_PER_SEC));
+     }
Arg this is used in i915-perf in at least one place as denominator too...
This was a quick fix for BAT. See
https://patchwork.freedesktop.org/patch/353455/?series=73507&rev=1
then there are only a handful of platforms for which we don't know the
frequency, none of which matter for i915-perf.
-Chris

Ah, you got me worried :)


Acked-by: Lionel Landwerlin <lionel.g.landwer...@intel.com>

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to