Re: [PATCH igt v3 01/11] igt/perf: add i915 perf stream tests for Haswell

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 09, 2016 at 04:15:52PM +0000, Robert Bragg wrote:
> +static void
> +test_i915_ref_count(void)
> +{
> +        int oa_exponent = 13; /* 1 millisecond */
> +        uint64_t properties[] = {
> +                /* Include OA reports in samples */
> +                DRM_I915_PERF_PROP_SAMPLE_OA, true,
> +
> +                /* OA unit configuration */
> +                DRM_I915_PERF_PROP_OA_METRICS_SET, hsw_render_basic_id,
> +                DRM_I915_PERF_PROP_OA_FORMAT, I915_OA_FORMAT_A45_B8_C8,
> +                DRM_I915_PERF_PROP_OA_EXPONENT, oa_exponent,
> +        };
> +        struct drm_i915_perf_open_param param = {
> +                .flags = I915_PERF_FLAG_FD_CLOEXEC,
> +                .num_properties = sizeof(properties) / 16,
> +                .properties_ptr = (uint64_t)properties,
> +        };
> +        unsigned baseline, ref_count0, ref_count1;
> +        int stream_fd;
> +        uint32_t oa_report0[64];
> +        uint32_t oa_report1[64];
> +
> +        close(drm_fd);
> +        baseline = read_i915_module_ref();
> +        igt_debug("baseline ref count (drm fd closed) = %u\n", baseline);
> +
> +        drm_fd = drm_open_driver_render(DRIVER_INTEL);

Write this as a standalone (or first before igt_fixture) test and use
__drm_open_driver() (or export __drm_open_driver_render() if you insist)
so that we know that the extra driver ref taken by igt is not fouling up
your results..

> +        ref_count0 = read_i915_module_ref();
> +        igt_debug("initial ref count with drm_fd open = %u\n", ref_count0);
> +        igt_assert(ref_count0 > baseline);
> +
> +        stream_fd = __perf_open(drm_fd, &param);
> +        ref_count1 = read_i915_module_ref();
> +        igt_debug("ref count after opening i915 perf stream = %u\n", ref_count1);
> +        igt_assert(ref_count1 > ref_count0);
> +
> +        close(drm_fd);
> +        ref_count0 = read_i915_module_ref();
> +        igt_debug("ref count after closing drm fd = %u\n", ref_count0);
> +
> +        igt_assert(ref_count0 > baseline);
> +
> +        read_2_oa_reports(stream_fd,
> +                          I915_OA_FORMAT_A45_B8_C8, 256,
> +                          oa_exponent,
> +                          oa_report0,
> +                          oa_report1,
> +                          false); /* not just timer reports */
> +
> +        close(stream_fd);
> +        ref_count0 = read_i915_module_ref();
> +        igt_debug("ref count after closing i915 perf stream fd = %u\n", ref_count0);
> +        igt_assert_eq(ref_count0, baseline);
> +
> +        drm_fd = drm_open_driver_render(DRIVER_INTEL);
> +}

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux