Commit d194314d authored by Chris Wilson's avatar Chris Wilson

drm/i915: Avoid potential division-by-zero in computing CS timestamp period

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: default avatarChris Wilson <chris@chris-wilson.co.uk>
Acked-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200216161746.500258-1-chris@chris-wilson.co.uk
parent 1883a0a4
...@@ -1044,13 +1044,17 @@ void intel_device_info_runtime_init(struct drm_i915_private *dev_priv) ...@@ -1044,13 +1044,17 @@ void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
} }
/* Initialize command stream timestamp frequency */ /* Initialize command stream timestamp frequency */
runtime->cs_timestamp_frequency_khz = read_timestamp_frequency(dev_priv); runtime->cs_timestamp_frequency_khz =
read_timestamp_frequency(dev_priv);
if (runtime->cs_timestamp_frequency_khz) {
runtime->cs_timestamp_period_ns = runtime->cs_timestamp_period_ns =
div_u64(1e6, runtime->cs_timestamp_frequency_khz); div_u64(1e6, runtime->cs_timestamp_frequency_khz);
drm_dbg(&dev_priv->drm, drm_dbg(&dev_priv->drm,
"CS timestamp wraparound in %lldms\n", "CS timestamp wraparound in %lldms\n",
div_u64(mul_u32_u32(runtime->cs_timestamp_period_ns, S32_MAX), div_u64(mul_u32_u32(runtime->cs_timestamp_period_ns,
S32_MAX),
USEC_PER_SEC)); USEC_PER_SEC));
}
} }
void intel_driver_caps_print(const struct intel_driver_caps *caps, void intel_driver_caps_print(const struct intel_driver_caps *caps,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment