i965: read CS timestamp frequency from the kernel on Gen10+
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Mon, 6 Nov 2017 11:11:42 +0000 (11:11 +0000)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Mon, 4 Dec 2017 18:05:20 +0000 (18:05 +0000)
We cannot figure this value out of the PCI-id anymore. Let's read it
from the kernel (which computes this from a few registers).

When running on a (upcoming) 4.16-rc1+ kernel, this will fixes piglit
tests on CNL :

    spec@arb_timer_query@query gl_timestamp
    spec@arb_timer_query@timestamp-get
    spec@ext_timer_query@time-elapsed

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
src/mesa/drivers/dri/i965/intel_screen.c

index db1552c1880d264739079f5083c605e5ee88b9f9..0c17b4050c4528930ca4ebe955126e01a9201c92 100644 (file)
@@ -1685,6 +1685,27 @@ intelDestroyBuffer(__DRIdrawable * driDrawPriv)
     _mesa_reference_framebuffer(&fb, NULL);
 }
 
+static void
+intel_cs_timestamp_frequency(struct intel_screen *screen)
+{
+   /* We shouldn't need to update gen_device_info.timestamp_frequency prior to
+    * gen10, PCI-id is enough to figure it out.
+    */
+   assert(screen->devinfo.gen >= 10);
+
+   int ret, freq;
+
+   ret = intel_get_param(screen, I915_PARAM_CS_TIMESTAMP_FREQUENCY,
+                         &freq);
+   if (ret < 0) {
+      _mesa_warning(NULL,
+                    "Kernel 4.15 required to read the CS timestamp frequency.\n");
+      return;
+   }
+
+   screen->devinfo.timestamp_frequency = freq;
+}
+
 static void
 intel_detect_sseu(struct intel_screen *screen)
 {
@@ -2405,6 +2426,9 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen)
    isl_device_init(&screen->isl_dev, &screen->devinfo,
                    screen->hw_has_swizzling);
 
+   if (devinfo->gen >= 10)
+      intel_cs_timestamp_frequency(screen);
+
    /* GENs prior to 8 do not support EU/Subslice info */
    if (devinfo->gen >= 8) {
       intel_detect_sseu(screen);