IGT Testcases for i915 DAPC feature
cover IGT Testcases for i915 DAPC feature
This series implements set of testcases for verifying data sampled through i915 perf/DAPC feature. It tests validity of association of OA with correct engine/stream, ctx id, pid, tag, timestamps, mmio samples w.r.t execbuf begin and end. It also adds a testcase to verify concurrent operation of two stream.
Currently MMIO testcase is failing as HW is reading the RC6 register as zero if the stream has OA sampling also ON. Testcase however passes if we sample MMIO along with Timestamps. Need to investigate this more.
v2: Updated MMIO subtest to consider only read value of RC6 register.
Added new testcase to check the sequencing and association of CS properties with OA samples.
Sagar Arun Kamble (9):
tests/perf: Rename perf test to intel_perf
tests/perf: Test i915 assisted command stream based perf metrics
capture
tests/perf: Add testcase to verify ctx id
tests/perf: Add testcase to verify pid
tests/perf: Add testcase to verify tag
tests/perf: Add testcase to verify timestamps tests/perf: Add testcase to verify mmio
tests/perf: Add testcase to verify concurrent streams tests/perf: Add testcase to verify association of OABUFFER reports
with CS properties
lib/ioctl_wrappers.h | 1 + tests/Makefile.sources | 3 +- tests/intel_perf.c | 3353 +++++++++++++++++++++++++++++++++++++++++++++++ tests/intel_perf_dapc.c | 1813 +++++++++++++++++++++++++ tests/perf.c | 3353 ----------------------------------------------- 5 files changed, 5169 insertions(+), 3354 deletions(-) create mode 100644 tests/intel_perf.c create mode 100644 tests/intel_perf_dapc.c delete mode 100644 tests/perf.c
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/9 tests/perf: Rename perf test to intel_perf
--- tests/Makefile.sources | 2 +- tests/intel_perf.c | 3353 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/perf.c | 3353 ------------------------------------------------ 3 files changed, 3354 insertions(+), 3354 deletions(-) create mode 100644 tests/intel_perf.c delete mode 100644 tests/perf.c
tests/Makefile.sources +1 -1
@@ -169,6 +169,7 @@ TESTS_progs = \ gen3_render_tiledy_blits \ gen7_forcewake_mt \ gvt_basic \ + intel_perf \ kms_3d \ kms_addfb_basic \ kms_atomic \
@@ -216,7 +217,6 @@ TESTS_progs = \ kms_universal_plane \ kms_vblank \ meta_test \ - perf \ pm_backlight \ pm_lpsp \ pm_rc6_residency \
tests/intel_perf.c new file +3353 -0
2,986 lines not on this page · raw message
tests/perf.c deleted +0 -3353
3,353 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Part of the diff is not shown here. View the raw message.
PATCH 2/9 tests/perf: Test i915 assisted command stream based perf metrics capture
In reply to Sagar Arun KambleThis tests different performance metrics being streamed by i915 driver. This feature in i915 also referred as Driver Assisted Performance Capture (DAPC) provides userspace an ability to sample the OA reports at execbuf boundaries and associate other metadata like CTX ID, PID, TAG with each sample. Further, ability to capture engine timestamps and MMIO reads is also provided.
v2: Defining the enums for OA_SOURCE and PERF_PROP locally till the libdrm changes are merged.
--- tests/Makefile.sources | 1 + tests/intel_perf_dapc.c | 811 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 812 insertions(+) create mode 100644 tests/intel_perf_dapc.c
tests/Makefile.sources +1 -0
@@ -170,6 +170,7 @@ TESTS_progs = \ gen7_forcewake_mt \ gvt_basic \ intel_perf \ + intel_perf_dapc \ kms_3d \ kms_addfb_basic \ kms_atomic \
tests/intel_perf_dapc.c new file +811 -0
811 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/9] tests/perf: Test i915 assisted command stream based perf metrics capture
Quoted 7 lines · Sagar Arun Kamble
This tests different performance metrics being streamed by i915 driver. This feature in i915 also referred as Driver Assisted Performance Capture (DAPC) provides userspace an ability to sample the OA reports at execbuf boundaries and associate other metadata like CTX ID, PID, TAG with each sample. Further, ability to capture engine timestamps and MMIO reads is also provided.
Quoted 5 lines
v2: Defining the enums for
OA_SOURCEandPERF_PROPlocally till the libdrm changes are merged.Cc Lionel Landwerlin <[email protected]>Signed-off-by Sagar Arun Kamble <[email protected]>
Quoted 239 lines
--- tests/Makefile.sources | 1 + tests/intel_perf_dapc.c | 811 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 812 insertions(+) create mode 100644 tests/intel_perf_dapc.ctests/Makefile.sources +1
-0@@ -170,6 +170,7 @@ TESTS_progs = \ gen7_forcewake_mt \ gvt_basic \ intel_perf \ + intel_perf_dapc \ kms_3d \ kms_addfb_basic \ kms_atomic \tests/intel_perf_dapc.c new file +215
-0@@ -0,0 +1,811 @@ +/* +* Copyright © 2017 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +* +*/ +#include <fcntl.h> + +#include "igt.h" +#include "drm.h" + +IGT_TEST_DESCRIPTION ("Test the i915 command stream based perf metrics streaming interface" ); + +/* Temporarily copy i915-perf uapi here to avoid a dependency on libdrm's +* i915_drm.h copy being updated with the i915-perf interface before this +* test can land in i-g-t. +* +* TODO: remove this once the interface lands in libdrm +*/ +#ifndef DRM_I915_PERF_OPEN +#define DRM_I915_PERF_OPEN 0x36 +#define DRM_IOCTL_I915_PERF_OPEN DRM_IOW(DRM_COMMAND_BASE + \ + DRM_I915_PERF_OPEN, \ + struct drm_i915_perf_open_param) + +enum drm_i915_oa_format { +I915_OA_FORMAT_A13 =1 ,/* HSW only */ +I915_OA_FORMAT_A29 ,/* HSW only */ +I915_OA_FORMAT_A13_B8_C8 ,/* HSW only */ +I915_OA_FORMAT_B4_C8 ,/* HSW only */ +I915_OA_FORMAT_A45_B8_C8 ,/* HSW only */ +I915_OA_FORMAT_B4_C8_A16 ,/* HSW only */ +I915_OA_FORMAT_C4_B8 ,/* HSW+ */ + +/* Gen8+ */ +I915_OA_FORMAT_A12 , +I915_OA_FORMAT_A12_B8_C8 , + I915_OA_FORMAT_A32u40_A4u32_B8_C8, + +I915_OA_FORMAT_MAX /* non-ABI */ +}; + +enum drm_i915_perf_sample_oa_source { +I915_PERF_SAMPLE_OA_SOURCE_OABUFFER , +I915_PERF_SAMPLE_OA_SOURCE_CS , +I915_PERF_SAMPLE_OA_SOURCE_MAX /* non-ABI */ +}; + +#define I915_PERF_MMIO_NUM_MAX 8 +struct drm_i915_perf_mmio_list { +__u32 num_mmio; +__u32 mmio_list[I915_PERF_MMIO_NUM_MAX ]; +}; + +enum drm_i915_perf_property_id { +DRM_I915_PERF_PROP_CTX_HANDLE =1 , +DRM_I915_PERF_PROP_SAMPLE_OA , +DRM_I915_PERF_PROP_OA_METRICS_SET , +DRM_I915_PERF_PROP_OA_FORMAT , +DRM_I915_PERF_PROP_OA_EXPONENT , +DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE , +DRM_I915_PERF_PROP_ENGINE , +DRM_I915_PERF_PROP_SAMPLE_CTX_ID , +DRM_I915_PERF_PROP_SAMPLE_PID , +DRM_I915_PERF_PROP_SAMPLE_TAG , +DRM_I915_PERF_PROP_SAMPLE_TS , +DRM_I915_PERF_PROP_SAMPLE_MMIO , +DRM_I915_PERF_PROP_MAX /* non-ABI */ +}; + +struct drm_i915_perf_open_param { +__u32 flags; +#define I915_PERF_FLAG_FD_CLOEXEC (1<<0) +#define I915_PERF_FLAG_FD_NONBLOCK (1<<1) +#define I915_PERF_FLAG_DISABLED (1<<2) + +__u32 num_properties; +__u64 properties_ptr; +}; + +#define I915_PERF_IOCTL_ENABLE _IO('i', 0x0) +#define I915_PERF_IOCTL_DISABLE _IO('i', 0x1) + +struct drm_i915_perf_record_header { +__u32 type; +__u16 pad; +__u16 size; +}; + +enum drm_i915_perf_record_type { +DRM_I915_PERF_RECORD_SAMPLE =1 , +DRM_I915_PERF_RECORD_OA_REPORT_LOST =2 , +DRM_I915_PERF_RECORD_OA_BUFFER_LOST =3 , +DRM_I915_PERF_RECORD_MAX /* non-ABI */ +}; +#endif /* !DRM_I915_PERF_OPEN */ + +/* There is no ifdef we can use for those formats :( */ +enum { + local_I915_OA_FORMAT_A12 =I915_OA_FORMAT_C4_B8 +1 , + local_I915_OA_FORMAT_A12_B8_C8 =I915_OA_FORMAT_C4_B8 +2 , + local_I915_OA_FORMAT_A32u40_A4u32_B8_C8 =I915_OA_FORMAT_C4_B8 +3 , +}; + +#define local_I915_OA_FORMAT_MAX (local_I915_OA_FORMAT_A32u40_A4u32_B8_C8 + 1) + +enum { + local_I915_PERF_SAMPLE_OA_SOURCE_OABUFFER, + local_I915_PERF_SAMPLE_OA_SOURCE_CS, + local_I915_PERF_SAMPLE_OA_SOURCE_MAX/* non-ABI */ +}; + +enum { + local_DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE =DRM_I915_PERF_PROP_OA_EXPONENT +1 , + local_DRM_I915_PERF_PROP_ENGINE =DRM_I915_PERF_PROP_OA_EXPONENT +2 , + local_DRM_I915_PERF_PROP_SAMPLE_CTX_ID =DRM_I915_PERF_PROP_OA_EXPONENT +3 , + local_DRM_I915_PERF_PROP_SAMPLE_PID =DRM_I915_PERF_PROP_OA_EXPONENT +4 , + local_DRM_I915_PERF_PROP_SAMPLE_TAG =DRM_I915_PERF_PROP_OA_EXPONENT +5 , + local_DRM_I915_PERF_PROP_SAMPLE_TS =DRM_I915_PERF_PROP_OA_EXPONENT +6 , + local_DRM_I915_PERF_PROP_SAMPLE_MMIO =DRM_I915_PERF_PROP_OA_EXPONENT +7 , + local_DRM_I915_PERF_PROP_MAX/* non-ABI */ +}; + +static struct { +const char *name; +size_t size; +int a40_high_off;/* bytes */ +int a40_low_off; +int n_a40; +int a_off; +int n_a; +int first_a; +int b_off; +int n_b; +int c_off; +int n_c; +int min_gen; +int max_gen; +} oa_formats[local_I915_OA_FORMAT_MAX] = { + [I915_OA_FORMAT_A13 ] = {/* HSW only */ +"A13" , .size =64 , + .a_off =12 , .n_a =13 , + .max_gen =7 }, + [I915_OA_FORMAT_A29 ] = {/* HSW only */ +"A29" , .size =128 , + .a_off =12 , .n_a =29 , + .max_gen =7 }, + [I915_OA_FORMAT_A13_B8_C8 ] = {/* HSW only */ +"A13_B8_C8" , .size =128 , + .a_off =12 , .n_a =13 , + .b_off =64 , .n_b =8 , + .c_off =96 , .n_c =8 , + .max_gen =7 }, + [I915_OA_FORMAT_A45_B8_C8 ] = {/* HSW only */ +"A45_B8_C8" , .size =256 , + .a_off =12 , .n_a =45 , + .b_off =192 , .n_b =8 , + .c_off =224 , .n_c =8 , + .max_gen =7 }, + [I915_OA_FORMAT_B4_C8 ] = {/* HSW only */ +"B4_C8" , .size =64 , + .b_off =16 , .n_b =4 , + .c_off =32 , .n_c =8 , + .max_gen =7 }, + [I915_OA_FORMAT_B4_C8_A16 ] = {/* HSW only */ +"B4_C8_A16" , .size =128 , + .b_off =16 , .n_b =4 , + .c_off =32 , .n_c =8 , + .a_off =60 , .n_a =16 , .first_a =29 , + .max_gen =7 }, + [I915_OA_FORMAT_C4_B8 ] = {/* HSW+ (header differs from HSW-Gen8+) */ +"C4_B8" , .size =64 , + .c_off =16 , .n_c =4 , + .b_off =28 , .n_b =8 }, + +/* Gen8+ */ + + [local_I915_OA_FORMAT_A12] = { +"A12" , .size =64 , + .a_off =12 , .n_a =12 , .first_a =7 , + .min_gen =8 }, + [local_I915_OA_FORMAT_A12_B8_C8] = { +"A12_B8_C8" , .size =128 , + .a_off =12 , .n_a =12 , + .b_off =64 , .n_b =8 , + .c_off =96 , .n_c =8 , .first_a =7 , + .min_gen =8 }, + [local_I915_OA_FORMAT_A32u40_A4u32_B8_C8] = { +"A32u40_A4u32_B8_C8" , .size =256 , + .a40_high_off =160 , .a40_low_off =16 , .n_a40 =32 , + .a_off =144 , .n_a =4 , .first_a =32 , + .b_off =192 , .n_b =8 , + .c_off =224 , .n_c =8 , + .min_gen =8 }, + [I915_OA_FORMAT_C4_B8 ] = { +"C4_B8" , .size =64 , + .c_off =16 , .n_c =4 , + .b_off =32 , .n_b =8 ,
tests/intel_perf_dapc.c line 225
Quoted 10 lines
tests/intel_perf_dapc.c new file +10
-0+ .min_gen = 8 }, +}; + +static int drm_fd =-1 ; +static uint32_t devid; +static int card =-1 ; + +static uint64_t test_metric_set_id =UINT64_MAX ; + +static uint64_t timestamp_frequency =12500000 ;
Please avoid magic numbers, we probably should define those somewhere.
Quoted 63 lines
tests/intel_perf_dapc.c new file +63
-0+static enum drm_i915_oa_format test_oa_format; +static uint64_t oa_exp_1_millisec; + +static igt_render_copyfunc_t render_copy =NULL ; + +static uint64_t +timebase_scale (uint32_t u32_delta) +{ +return ((uint64_t )u32_delta *NSEC_PER_SEC ) / timestamp_frequency; +} + +/* Returns: the largest OA exponent that will still result in a sampling period +* less than or equal to the given @period. +*/ +static int +max_oa_exponent_for_period_lte (uint64_t period) +{ +/* NB: timebase_scale() takes a uint32_t and an exponent of 30 +* would already represent a period of ~3 minutes so there's +* really no need to consider higher exponents. +*/ +for (int i =0 ; i <30 ; i++) { +uint64_t oa_period =timebase_scale (2 << i); + +if (oa_period > period) +return max (0 , i -1 ); + } + +igt_assert (!"reached" ); +return -1 ; +} + +static bool +try_read_u64_file (const char *file,uint64_t *val) +{ +char buf[32 ]; +int fd, n; + + fd =open (file,O_RDONLY ); +if (fd <0 ) +return false; + +while ((n =read (fd, buf,sizeof (buf) -1 )) <0 && errno ==EINTR ) + ; +igt_assert (n >=0 ); + +close (fd); + + buf[n] ='\0' ; + *val =strtoull (buf,NULL ,0 ); + +return true; +} + +static void +write_u64_file (const char *file,uint64_t val) +{ +char buf[32 ]; +int fd, len, ret; + + fd =open (file,O_WRONLY ); +igt_assert (fd >=0 ); +
tests/intel_perf_dapc.c line 298
Quoted 10 lines
tests/intel_perf_dapc.c new file +10
-0+ len =snprintf (buf,sizeof (buf),"%" PRIu64, val); +igt_assert (len >0 ); + +while ((ret =write (fd, buf, len)) <0 && errno ==EINTR ) + ; +igt_assert_eq (ret, len); + +close (fd); +} +
Write/read helpers are used only once so maybe those functions are redundant? Or if we want those helpers we could move them to libs.
tests/intel_perf_dapc.c line 309
Quoted 11 lines
tests/intel_perf_dapc.c new file +11
-0+static bool +init_sys_info (void ) +{ +const char *test_set_name =NULL ; +const char *test_set_uuid =NULL ; +char buf[256 ]; + +igt_assert_neq (card,-1 ); +igt_assert_neq (devid,0 ); + + timestamp_frequency =12500000 ;
The same here - magic number
Quoted 25 lines
tests/intel_perf_dapc.c new file +25
-0+ +if (IS_HASWELL (devid)) { +/* We don't have a TestOa metric set for Haswell so use +* RenderBasic +*/ + test_set_name ="RenderBasic" ; + test_set_uuid ="403d8832-1a27-4aa6-a64e-f5389ce7b212" ; + test_oa_format =I915_OA_FORMAT_A45_B8_C8 ; + }else { + test_set_name ="TestOa" ; + test_oa_format = local_I915_OA_FORMAT_A32u40_A4u32_B8_C8; + +if (IS_BROADWELL (devid)) { + test_set_uuid ="d6de6f55-e526-4f79-a6a6-d7315c09044e" ; + }else if (IS_CHERRYVIEW (devid)) { + test_set_uuid ="4a534b07-cba3-414d-8d60-874830e883aa" ; + }else if (IS_SKYLAKE (devid)) { +switch (intel_gt (devid)) { +case 1 : + test_set_uuid = +"1651949f-0ac0-4cb1-a06f-dafd74a407d1" ; +break ; +case 2 : + test_set_uuid = +"2b985803-d3c9-4629-8a4f-634bfecba0e8" ;
tests/intel_perf_dapc.c line 344
Quoted 10 lines
tests/intel_perf_dapc.c new file +10
-0+break ; +case 3 : + test_set_uuid = +"882fa433-1f4a-4a67-a962-c741888fe5f5" ; +break ; +default : +igt_debug ("unsupported Skylake GT size\n" ); +return false; + } + timestamp_frequency =12000000 ;
And here :)
Quoted 147 lines
tests/intel_perf_dapc.c new file +147
-0+ }else if (IS_BROXTON (devid)) { + test_set_uuid ="5ee72f5c-092f-421e-8b70-225f7c3e9612" ; + timestamp_frequency =19200000 ; + }else if (IS_KABYLAKE (devid)) { +switch (intel_gt (devid)) { +case 1 : + test_set_uuid = +"baa3c7e4-52b6-4b85-801e-465a94b746dd" ; +break ; +case 2 : + test_set_uuid = +"f1792f32-6db2-4b50-b4b2-557128f1688d" ; +break ; +default : +igt_debug ("unsupported Kabylake GT size\n" ); +return false; + } + timestamp_frequency =12000000 ; + }else if (IS_GEMINILAKE (devid)) { + test_set_uuid ="dd3fd789-e783-4204-8cd0-b671bbccb0cf" ; + timestamp_frequency =19200000 ; + }else { +igt_debug ("unsupported GT\n" ); +return false; + } + } + +igt_debug ("%s metric set UUID = %s\n" , + test_set_name, + test_set_uuid); + + oa_exp_1_millisec =max_oa_exponent_for_period_lte (1000000 ); + +snprintf (buf,sizeof (buf), +"/sys/class/drm/card%d/metrics/%s/id" , + card, + test_set_uuid); + +return try_read_u64_file (buf, &test_metric_set_id); +} + +static int +__perf_open (int fd,struct drm_i915_perf_open_param *param) +{ +int ret =igt_ioctl (fd,DRM_IOCTL_I915_PERF_OPEN , param); + +igt_assert (ret >=0 ); + errno =0 ; + +return ret; +} + +static void +test_cs_oa_stream_create (void ) +{ + igt_fork(child, 1) { +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 , test_metric_set_id, +DRM_I915_PERF_PROP_OA_FORMAT , test_oa_format, +DRM_I915_PERF_PROP_OA_EXPONENT , oa_exp_1_millisec, + +/* CS parameters */ + local_DRM_I915_PERF_PROP_SAMPLE_CTX_ID, true, + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_BSD , + }; +struct drm_i915_perf_open_param param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC | +I915_PERF_FLAG_FD_NONBLOCK , + .num_properties =sizeof (properties) /16 , + .properties_ptr =to_user_pointer (properties), + }; +int stream_fd; + +do_ioctl_err (drm_fd,DRM_IOCTL_I915_PERF_OPEN , ¶m,EINVAL ); + +/* Send Render Engine as PROP_ENGINE */ + properties[ARRAY_SIZE (properties)-1 ] =I915_EXEC_RENDER ; + + stream_fd =__perf_open (drm_fd, ¶m); +close (stream_fd); + } + +igt_waitchildren (); +} + +static void +scratch_buf_init (drm_intel_bufmgr *bufmgr, +struct igt_buf *buf, +int width,int height, +uint32_t color) +{ +size_t stride = width *4 ; +size_t size = stride * height; +drm_intel_bo *bo =drm_intel_bo_alloc (bufmgr,"" , size,4096 ); +int ret; + + ret =drm_intel_bo_map (bo, true/* writable */ ); +igt_assert_eq (ret,0 ); + +for (int i =0 ; i < width * height; i++) + ((uint32_t *)bo->virtual)[i] = color; + +drm_intel_bo_unmap (bo); + + buf->bo = bo; + buf->stride = stride; + buf->tiling =I915_TILING_NONE ; + buf->size = size; +} + +/* +* Given a set of CS properties including DRM_I915_PERF_PROP_SAMPLE_OA +* this function returns the offset in the sample where OA report will +* be located. +*/ +static size_t +get_oa_report_offset (uint64_t *properties,int prop_size) +{ +size_t offset =0 ; +int i =0 ; + + do { + switch (properties[i]) { + case local_DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE: + if (properties[i+1]) { + offset += 8; + i += 2; + } + break; + case local_DRM_I915_PERF_PROP_SAMPLE_CTX_ID: + if (properties[i+1]) { + offset += 8; + i += 2; + } + break; + case local_DRM_I915_PERF_PROP_SAMPLE_PID: + if (properties[i+1]) { + offset += 8; + i += 2; + } + break; + case local_DRM_I915_PERF_PROP_SAMPLE_TAG: + if (properties[i+1]) {
tests/intel_perf_dapc.c line 501
Quoted 10 lines
tests/intel_perf_dapc.c new file +10
-0+ offset +=8 ; + i +=2 ; + } +break ; +case local_DRM_I915_PERF_PROP_SAMPLE_TS: +if (properties[i+1 ]) { + offset +=8 ; + i +=2 ; + } +break ;
Why are you doing the same thing for each case separately?
Quoted 313 lines
tests/intel_perf_dapc.c new file +310
-0+case DRM_I915_PERF_PROP_CTX_HANDLE : +case DRM_I915_PERF_PROP_SAMPLE_OA : +case DRM_I915_PERF_PROP_OA_METRICS_SET : +case DRM_I915_PERF_PROP_OA_FORMAT : +case DRM_I915_PERF_PROP_OA_EXPONENT : +case local_DRM_I915_PERF_PROP_ENGINE: + i +=2 ; +break ; + } + +if (properties[i] == local_DRM_I915_PERF_PROP_SAMPLE_MMIO) { +uint32_t num_mmio = *((uint32_t *)properties[i+1 ]); + + offset += (num_mmio *4 ); + i +=2 ; + } + }while (i < prop_size); + +return offset; +} + +static size_t +get_perf_report_size (uint64_t *properties,int prop_size,int format_id) +{ +size_t format_size = oa_formats[format_id].size; +size_t sample_size =0 ; + + sample_size +=get_oa_report_offset (properties, prop_size); + sample_size += format_size; + +return sample_size; +} + +static bool +read_perf_reports (int stream_fd, +uint8_t *perf_reports, +int num_reports, +size_t report_size, +bool retry_on_loss) +{ +size_t sample_size = (sizeof (struct drm_i915_perf_record_header ) + + report_size); +const struct drm_i915_perf_record_header *header; +uint8_t *base_perf_reports = perf_reports; +int i =0 ; + +/* Note: we allocate a large buffer so that each read() iteration +* should scrape *all* pending records. +* +* The largest buffer the OA unit supports is 16MB and the smallest +* perf report format is 64bytes + 8bytes allowing up to 233016 +* reports to be buffered. +* +* Being sure we are fetching all buffered reports allows us to +* potentially throw away / skip all reports whenever we see +* a _REPORT_LOST notification as a way of being sure are +* measurements aren't skewed by a lost report. +* +* Note: that is is useful for some tests but also not something +* applications would be expected to resort to. Lost reports are +* somewhat unpredictable but typically don't pose a problem - except +* to indicate that the OA unit may be over taxed if lots of reports +* are being lost. +*/ +int buf_size =233016 * + (72 +sizeof (struct drm_i915_perf_record_header )); +uint8_t *buf =malloc (buf_size); + +igt_assert (buf); + +do { +ssize_t len; + +while ((len =read (stream_fd, buf, buf_size)) <0 && + errno ==EINTR ) + ; + +igt_assert (len >0 ); + +for (size_t offset =0 ; offset < len; offset += header->size) { +const uint8_t *report; +size_t sample_offset =0 ; + + header = (void *)(buf + offset); + +igt_assert_eq (header->pad,0 );/* Reserved */ + +/* Currently the only test that should ever expect to +* see a _BUFFER_LOST error is the buffer_fill test, +* otherwise something bad has probably happened... +*/ +igt_assert_neq (header->type, +DRM_I915_PERF_RECORD_OA_BUFFER_LOST ); + +/* At high sampling frequencies the OA HW might not be +* able to cope with all write requests and will notify +* us that a report was lost. We restart our read of +* two sequential reports due to the timeline blip this +* implies +*/ +if (header->type == +DRM_I915_PERF_RECORD_OA_REPORT_LOST ) { +igt_debug ("read restart: OA trigger collision " +"/ report lost\n" ); +if (!retry_on_loss) { +igt_debug ("Freeing memory\n" ); +free (buf); +return false; + } + i =0 ; + perf_reports = base_perf_reports; + +/* XXX: break, because we don't know where +* within the series of already read reports +* there could be a blip from the lost report. +*/ +break ; + } + +/* Currently the only other record type expected is a +* _SAMPLE. Notably this test will need updating if +* i915-perf is extended in the future with additional +* record types. +*/ +igt_assert_eq (header->type, +DRM_I915_PERF_RECORD_SAMPLE ); + +igt_assert_eq (header->size, sample_size); + + sample_offset = offset + +sizeof (struct drm_i915_perf_record_header ); + report = (const uint8_t *)(buf + sample_offset); + +memcpy (perf_reports, report, report_size); + perf_reports += report_size; + i++; +if (i == num_reports) +break ; + } + }while (i < num_reports); + +free (buf); +return true; +} + +static void +perf_stream_capture_workload_samples (struct drm_i915_perf_open_param *param, +uint8_t *perf_reports, +int num_reports,int report_size) +{ +drm_intel_bufmgr *bufmgr; +drm_intel_context *context0; +struct intel_batchbuffer *batch; +struct igt_buf src, dst; +int width =800 ; +int height =600 ; +uint32_t ctx_id =0xffffffff ;/* invalid id */ +int stream_fd; +int ret; +bool valid_data = false; + +retry: + bufmgr =drm_intel_bufmgr_gem_init (drm_fd,4096 ); +drm_intel_bufmgr_gem_enable_reuse (bufmgr); + +scratch_buf_init (bufmgr, &src, width, height,0xff0000ff ); +scratch_buf_init (bufmgr, &dst, width, height,0x00ff00ff ); + + batch =intel_batchbuffer_alloc (bufmgr, devid); + + context0 =drm_intel_gem_context_create (bufmgr); +igt_assert (context0); + + ret =drm_intel_gem_context_get_id (context0, &ctx_id); +igt_assert_eq (ret,0 ); +igt_assert_neq (ctx_id,0xffffffff ); + +igt_debug ("opening i915-perf stream\n" ); + stream_fd =__perf_open (drm_fd, param); + +render_copy (batch, + context0, + &src,0 ,0 , width, height, + &dst,0 ,0 ); + +intel_batchbuffer_flush_with_context (batch, context0); + +drm_intel_bo_unreference (src.bo); +drm_intel_bo_unreference (dst.bo); + +intel_batchbuffer_free (batch); +drm_intel_gem_context_destroy (context0); +drm_intel_bufmgr_destroy (bufmgr); + + valid_data =read_perf_reports (stream_fd, perf_reports, + num_reports, report_size, + false); +if (!valid_data) { +close (stream_fd); + goto retry; + } +} + +struct oa_source_sample { +uint64_t source; +uint64_t ctx_id; +uint8_t oa_report[]; +}; + +#define SOURCE (i) (i == 0) ? "OABUFFER" : "CS" + +static void +verify_source (uint8_t *perf_reports,int num_reports,size_t report_size) +{ +struct oa_source_sample *sample; +uint32_t *oa_report; + +for (int i =0 ; i < num_reports; i++) { +size_t offset = i * report_size; + + sample = (struct oa_source_sample *) (perf_reports + offset); + oa_report = (uint32_t *) sample->oa_report; + +igt_debug ("read report: source= %s, reason = %x, " +"timestamp = %x\n" , +SOURCE (sample->source), oa_report[0 ], oa_report[1 ]); + +igt_assert ((sample->source == + local_I915_PERF_SAMPLE_OA_SOURCE_OABUFFER) || + (sample->source == + local_I915_PERF_SAMPLE_OA_SOURCE_CS)); + +if (sample->source == local_I915_PERF_SAMPLE_OA_SOURCE_CS) +igt_assert (!oa_report[0 ]); + +/* Don't expect zero for timestamps */ +igt_assert_neq (oa_report[1 ],0 ); + } +} + +static void +test_oa_source (void ) +{ +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 , test_metric_set_id, +DRM_I915_PERF_PROP_OA_FORMAT , test_oa_format, +DRM_I915_PERF_PROP_OA_EXPONENT , oa_exp_1_millisec, + +/* CS parameters */ + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_RENDER , + local_DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE, true, + local_DRM_I915_PERF_PROP_SAMPLE_CTX_ID, true, + }; +struct drm_i915_perf_open_param param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC , + .num_properties =sizeof (properties) /16 , + .properties_ptr =to_user_pointer (properties), + }; + +/* should be default, but just to be sure... */ +write_u64_file ("/proc/sys/dev/i915/perf_stream_paranoid" ,1 ); + + igt_fork(child, 1) { +int prop_size =ARRAY_SIZE (properties); +int num_reports =10 ; +int report_size =get_perf_report_size (properties, prop_size, + test_oa_format); +int total_size = num_reports * report_size; +uint8_t *perf_reports =malloc (total_size); + +igt_assert (perf_reports); + +perf_stream_capture_workload_samples (¶m, perf_reports, + num_reports, report_size); +verify_source (perf_reports, num_reports, report_size); +free (perf_reports); + } + +igt_waitchildren (); +} + +igt_main +{ +igt_skip_on_simulation (); + + igt_fixture { + drm_fd =drm_open_driver_render (DRIVER_INTEL ); + devid =intel_get_drm_devid (drm_fd); + card =drm_get_card (); + +igt_require (init_sys_info ()); + + render_copy =igt_get_render_copyfunc (devid); +igt_require_f (render_copy,"no render-copy function\n" ); + } + + igt_subtest("cs-oa-stream-create") +test_cs_oa_stream_create (); + + igt_subtest("oa-source") +test_oa_source (); + + igt_fixture { +close (drm_fd); + } +}Signature · 1 line
1.9.1
--
Cheers,
Ewelina
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/9 tests/perf: Add testcase to verify ctx id
In reply to Sagar Arun KambleThis subtest verifies that the CS perf samples contains proper HW context ID as captured through CONTEXT_PARAM_HW_ID.
v2: Updated property enum names.
--- lib/ioctl_wrappers.h | 1 + tests/intel_perf_dapc.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 2 deletions(-)
lib/ioctl_wrappers.h +1 -0
@@ -131,6 +131,7 @@ struct local_i915_gem_context_param {#define LOCAL_CONTEXT_PARAM_GTT_SIZE 0x3#define LOCAL_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4#define LOCAL_CONTEXT_PARAM_BANNABLE 0x5 +#define LOCAL_CONTEXT_PARAM_HW_ID 0x6uint64_t value; };void gem_context_require_bannable (int fd);
tests/intel_perf_dapc.c +100 -2
135 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 3/9] tests/perf: Add testcase to verify ctx id
Quoted 6 lines · Sagar Arun Kamble
This subtest verifies that the CS perf samples contains proper HW context ID as captured through
CONTEXT_PARAM_HW_ID.v2: Updated property enum names.
Signed-off-by Sagar Arun Kamble <[email protected]>
Quoted 116 lines
--- lib/ioctl_wrappers.h | 1 + tests/intel_perf_dapc.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 2 deletions(-)lib/ioctl_wrappers.h +1
-0@@ -131,6 +131,7 @@ struct local_i915_gem_context_param {#define LOCAL_CONTEXT_PARAM_GTT_SIZE 0x3#define LOCAL_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4#define LOCAL_CONTEXT_PARAM_BANNABLE 0x5 +#define LOCAL_CONTEXT_PARAM_HW_ID 0x6uint64_t value; };void gem_context_require_bannable (int fd);tests/intel_perf_dapc.c +65
-2@@ -644,10 +644,28 @@ read_perf_reports(int stream_fd,return true; } +static unsigned int +context_get_hw_ctx_id (int fd,unsigned int ctx) +{ +struct local_i915_gem_context_param param; + +memset (¶m,0 ,sizeof (param)); + param.context = ctx; + param.param =LOCAL_CONTEXT_PARAM_HW_ID ; + param.value =0 ; + param.size =0 ; + +if (__gem_context_get_param (fd, ¶m) == -EINVAL ) +igt_assert (param.value ==0 ); + +return param.value; +} +static void perf_stream_capture_workload_samples (struct drm_i915_perf_open_param *param,uint8_t *perf_reports, -int num_reports,int report_size) +int num_reports,int report_size, +uint64_t *hw_ctx_id) {drm_intel_bufmgr *bufmgr;drm_intel_context *context0;@@ -676,6 +694,9 @@ retry:igt_assert_eq (ret,0 );igt_assert_neq (ctx_id,0xffffffff ); +if (hw_ctx_id) + *hw_ctx_id =context_get_hw_ctx_id (drm_fd, ctx_id); +igt_debug ("opening i915-perf stream\n" ); stream_fd =__perf_open (drm_fd, param);@@ -776,7 +797,8 @@ test_oa_source(void)igt_assert (perf_reports);perf_stream_capture_workload_samples (¶m, perf_reports, - num_reports, report_size); + num_reports, report_size, +NULL );verify_source (perf_reports, num_reports, report_size);free (perf_reports); }@@ -784,6 +806,79 @@ test_oa_source(void)igt_waitchildren (); } +struct oa_ctxid_sample { +uint64_t ctx_id; +uint8_t oa_report[]; +}; + +static void +verify_ctxid (uint8_t *perf_reports,int num_reports,size_t report_size, +uint64_t hw_ctx_id) +{ +struct oa_ctxid_sample *sample; +uint32_t *oa_report; + +for (int i =0 ; i < num_reports; i++) { +size_t offset = i * report_size; + + sample = (struct oa_ctxid_sample *) (perf_reports + offset); + oa_report = (uint32_t *) sample->oa_report; + +igt_debug ("read report: ctx_id= %lu, reason = %x, " +"timestamp = %x\n" , + sample->ctx_id, oa_report[0 ], oa_report[1 ]); + +if (!oa_report[0 ]) +igt_assert (sample->ctx_id == hw_ctx_id); + } +} + +static void +test_perf_ctxid (void ) +{ +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 , test_metric_set_id, +DRM_I915_PERF_PROP_OA_FORMAT , test_oa_format, +DRM_I915_PERF_PROP_OA_EXPONENT , oa_exp_1_millisec, + +/* CS parameters */ + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_RENDER ,
tests/intel_perf_dapc.c test_oa_source(void) · line 859
Quoted 10 lines
tests/intel_perf_dapc.c +10
-0+ local_DRM_I915_PERF_PROP_SAMPLE_CTX_ID, true, + }; +struct drm_i915_perf_open_param param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC , + .num_properties =sizeof (properties) /16 , + .properties_ptr =to_user_pointer (properties), + }; + +/* should be default, but just to be sure... */ +write_u64_file ("/proc/sys/dev/i915/perf_stream_paranoid" ,1 );
This function is used to write parameter to only one file so path could be defined inside function
Quoted 37 lines
tests/intel_perf_dapc.c +25
-0+ + igt_fork(child, 1) { +int prop_size =ARRAY_SIZE (properties); +int num_reports =10 ; +int report_size =get_perf_report_size (properties, prop_size, + test_oa_format); +int total_size = num_reports * report_size; +uint8_t *perf_reports =malloc (total_size); +uint64_t hw_ctx_id; + +igt_assert (perf_reports); + +perf_stream_capture_workload_samples (¶m, perf_reports, + num_reports, report_size, + &hw_ctx_id); +verify_ctxid (perf_reports, num_reports, report_size, hw_ctx_id); +free (perf_reports); + } + +igt_waitchildren (); +} + igt_main {igt_skip_on_simulation ();@@ -805,6 +900,9 @@ igt_main igt_subtest("oa-source")test_oa_source (); + igt_subtest("perf-ctxid") +test_perf_ctxid (); + igt_fixture {close (drm_fd); }Signature · 1 line
1.9.1
--
Cheers,
Ewelina
Quoted 5 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/9 tests/perf: Add testcase to verify pid
In reply to Sagar Arun Kamblev2: Updated property enum names.
--- tests/intel_perf_dapc.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+)
tests/intel_perf_dapc.c +76 -0
@@ -879,6 +879,79 @@ test_perf_ctxid(void)igt_waitchildren (); } +struct oa_pid_sample { +uint64_t pid; +uint8_t oa_report[]; +}; + +static void +verify_pid (uint8_t *perf_reports,int num_reports,size_t report_size, +uint64_t pid) +{ +struct oa_pid_sample *sample; +uint32_t *oa_report; + +for (int i =0 ; i < num_reports; i++) { +size_t offset = i * report_size; + + sample = (struct oa_pid_sample *) (perf_reports + offset); + oa_report = (uint32_t *) sample->oa_report; + +igt_debug ("read report: pid= %lu, reason = %x, " +"timestamp = %x\n" , + sample->pid, oa_report[0 ], oa_report[1 ]); + +if (!oa_report[0 ]) +igt_assert (sample->pid == pid); + } +} + +static void +test_perf_pid (void ) +{ +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 , test_metric_set_id, +DRM_I915_PERF_PROP_OA_FORMAT , test_oa_format, +DRM_I915_PERF_PROP_OA_EXPONENT , oa_exp_1_millisec, + +/* CS parameters */ + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_RENDER , + local_DRM_I915_PERF_PROP_SAMPLE_PID, true, + }; +struct drm_i915_perf_open_param param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC , + .num_properties =sizeof (properties) /16 , + .properties_ptr =to_user_pointer (properties), + }; + +/* should be default, but just to be sure... */ +write_u64_file ("/proc/sys/dev/i915/perf_stream_paranoid" ,1 ); + + igt_fork(child, 1) { +int prop_size =ARRAY_SIZE (properties); +int num_reports =10 ; +int report_size =get_perf_report_size (properties, prop_size, + test_oa_format); +int total_size = num_reports * report_size; +uint8_t *perf_reports =malloc (total_size); +uint64_t pid =getpid (); + +igt_assert (perf_reports); + +perf_stream_capture_workload_samples (¶m, perf_reports, + num_reports, report_size, +NULL ); +verify_pid (perf_reports, num_reports, report_size, pid); +free (perf_reports); + } + +igt_waitchildren (); +} + igt_main {igt_skip_on_simulation ();
@@ -903,6 +976,9 @@ igt_main igt_subtest("perf-ctxid")test_perf_ctxid (); + igt_subtest("perf-pid") +test_perf_pid (); + igt_fixture {close (drm_fd); }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/9 tests/perf: Add testcase to verify tag
In reply to Sagar Arun Kamblev2: Updated property enum names. Defined TAG_MASK, set_tag and get_tag for local use.
--- tests/intel_perf_dapc.c | 142 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+)
tests/intel_perf_dapc.c +142 -0
@@ -138,6 +138,14 @@ enum {local_DRM_I915_PERF_PROP_MAX /* non-ABI */ }; +/* upper 32 bits of rsvd1 field contain tag */ +#define local_I915_EXEC_TAG_MASK (0xffffffff00000000UL) +#define local_i915_execbuffer2_set_tag (eb2, tag) \ + (eb2).rsvd1 = ((eb2).rsvd1 & ~local_I915_EXEC_TAG_MASK) |\ + ((tag << 32) & local_I915_EXEC_TAG_MASK) +#define local_i915_execbuffer2_get_tag (eb2) \ + (((eb2).rsvd1 & local_I915_EXEC_TAG_MASK) >> 32) + static struct { const char *name; size_t size;
@@ -532,6 +540,16 @@ get_perf_report_size(uint64_t *properties, int prop_size, int format_id)return sample_size; } +static size_t +get_perf_report_size_nonoa (uint64_t *properties,int prop_size) +{ +size_t sample_size =0 ; + + sample_size +=get_oa_report_offset (properties, prop_size); + +return sample_size; +} + static bool read_perf_reports(int stream_fd, uint8_t *perf_reports,
@@ -952,6 +970,127 @@ test_perf_pid(void)igt_waitchildren (); } +struct ts_tag_sample { +uint64_t tag; +uint64_t ts; +}; + +static void +verify_tag (uint8_t *perf_reports,int num_reports,size_t report_size, +uint64_t tag,int match_index) +{ +struct ts_tag_sample *sample; + +for (int i =0 ; i < num_reports; i++) { +size_t offset = i * report_size; + + sample = (struct ts_tag_sample *) (perf_reports + offset); + +igt_debug ("read report: tag= %lu, timestamp = %lu\n" , + sample->tag, sample->ts); + +if (i < match_index) +igt_assert (sample->tag != tag); +else +igt_assert (sample->tag == tag); + } +} + +#define LOCAL_I915_EXEC_NO_RELOC (1<<11) +#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12) + +static void +test_perf_tag (void ) +{ +uint64_t properties[] = { +/* CS parameters */ + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_RENDER , + local_DRM_I915_PERF_PROP_SAMPLE_TAG, true, + local_DRM_I915_PERF_PROP_SAMPLE_TS, true, + }; +struct drm_i915_perf_open_param param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC , + .num_properties =sizeof (properties) /16 , + .properties_ptr =to_user_pointer (properties), + }; + +/* should be default, but just to be sure... */ +write_u64_file ("/proc/sys/dev/i915/perf_stream_paranoid" ,1 ); + + igt_fork(child, 1) { +const int gen =intel_gen (intel_get_drm_devid (drm_fd)); +int prop_size =ARRAY_SIZE (properties); +int report_size =get_perf_report_size_nonoa (properties, + prop_size); +int num_reports =4 ; +int total_size = num_reports * report_size; +int stream_fd; +bool valid_data = false; +uint64_t test_tag =0xFEED0001 ; +uint8_t *perf_reports =NULL ; +const uint32_t bbe =MI_BATCH_BUFFER_END ; +struct drm_i915_gem_exec_object2 object[1 ]; +struct drm_i915_gem_execbuffer2 execbuf; +drm_intel_bufmgr *bufmgr; +drm_intel_context *context0; +uint32_t ctx_id =0xffffffff ;/* invalid id */ +int ret; + +memset (&execbuf,0 ,sizeof (execbuf)); + execbuf.buffers_ptr =to_user_pointer (object); + execbuf.flags =I915_EXEC_RENDER ; + execbuf.flags |=LOCAL_I915_EXEC_NO_RELOC ; + execbuf.flags |=LOCAL_I915_EXEC_HANDLE_LUT ; +if (gen <6 ) + execbuf.flags |=I915_EXEC_SECURE ; + +memset (object,0 ,sizeof (object)); + object[0 ].handle =gem_create (drm_fd,4096 ); +gem_write (drm_fd, object[0 ].handle,0 , &bbe,sizeof (bbe)); + + bufmgr =drm_intel_bufmgr_gem_init (drm_fd,4096 ); +drm_intel_bufmgr_gem_enable_reuse (bufmgr); + + context0 =drm_intel_gem_context_create (bufmgr); +igt_assert (context0); + + ret =drm_intel_gem_context_get_id (context0, &ctx_id); +igt_assert_eq (ret,0 ); +igt_assert_neq (ctx_id,0xffffffff ); + + perf_reports =malloc (total_size); +igt_assert (perf_reports); + +igt_debug ("opening render i915-perf stream\n" ); + stream_fd =__perf_open (drm_fd, ¶m); + + execbuf.buffer_count =1 ; +/* Do a submission with default tag */ +gem_execbuf (drm_fd, &execbuf); + +local_i915_execbuffer2_set_tag (execbuf, (uint64_t )test_tag); +/* Now submit with user tag */ +gem_execbuf (drm_fd, &execbuf); + +gem_close (drm_fd, object[0 ].handle); + +drm_intel_gem_context_destroy (context0); +drm_intel_bufmgr_destroy (bufmgr); + + valid_data =read_perf_reports (stream_fd, perf_reports, + num_reports, report_size, + false); +igt_assert (valid_data); +close (stream_fd); + +igt_debug ("Verify tag: %lu\n" , test_tag); +verify_tag (perf_reports, num_reports, report_size, + test_tag,2 ); +free (perf_reports); + } +igt_waitchildren (); +} + igt_main {igt_skip_on_simulation ();
@@ -979,6 +1118,9 @@ igt_main igt_subtest("perf-pid")test_perf_pid (); + igt_subtest("perf-tag") +test_perf_tag (); + igt_fixture {close (drm_fd); }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/9 tests/perf: Add testcase to verify timestamps
In reply to Sagar Arun Kamblev2: Updated property enum names.
--- tests/intel_perf_dapc.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+)
tests/intel_perf_dapc.c +75 -0
@@ -1091,6 +1091,78 @@ test_perf_tag(void)igt_waitchildren (); } +struct oa_ts_sample { +uint64_t ts; +uint8_t oa_report[]; +}; + +static void +verify_ts (uint8_t *perf_reports,int num_reports,size_t report_size) +{ +struct oa_ts_sample *sample; +uint32_t *oa_report; +uint64_t prev_ts =0 ; + +for (int i =0 ; i < num_reports; i++) { +size_t offset = i * report_size; + + sample = (struct oa_ts_sample *) (perf_reports + offset); + oa_report = (uint32_t *) sample->oa_report; + +igt_debug ("read report: ts= %lu, reason = %x, " +"timestamp = %x\n" , + sample->ts, oa_report[0 ], oa_report[1 ]); + +igt_assert (sample->ts > prev_ts); + prev_ts = sample->ts; + } +} + +static void +test_perf_ts (void ) +{ +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 , test_metric_set_id, +DRM_I915_PERF_PROP_OA_FORMAT , test_oa_format, +DRM_I915_PERF_PROP_OA_EXPONENT , oa_exp_1_millisec, + +/* CS parameters */ + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_RENDER , + local_DRM_I915_PERF_PROP_SAMPLE_TS, true, + }; +struct drm_i915_perf_open_param param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC , + .num_properties =sizeof (properties) /16 , + .properties_ptr =to_user_pointer (properties), + }; + +/* should be default, but just to be sure... */ +write_u64_file ("/proc/sys/dev/i915/perf_stream_paranoid" ,1 ); + + igt_fork(child, 1) { +int prop_size =ARRAY_SIZE (properties); +int num_reports =10 ; +int report_size =get_perf_report_size (properties, prop_size, + test_oa_format); +int total_size = num_reports * report_size; +uint8_t *perf_reports =malloc (total_size); + +igt_assert (perf_reports); + +perf_stream_capture_workload_samples (¶m, perf_reports, + num_reports, report_size, +NULL ); +verify_ts (perf_reports, num_reports, report_size); +free (perf_reports); + } + +igt_waitchildren (); +} + igt_main {igt_skip_on_simulation ();
@@ -1121,6 +1193,9 @@ igt_main igt_subtest("perf-tag")test_perf_tag (); + igt_subtest("perf-ts") +test_perf_ts (); + igt_fixture {close (drm_fd); }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/9 tests/perf: Add testcase to verify mmio
In reply to Sagar Arun Kamblev2: Updated the check for RC6 register value.
Updated property enum names. Defined local_I915_PERF_MMIO_NUM_MAX and local_drm_i915_perf_mmio_list for local use.
--- tests/intel_perf_dapc.c | 266 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 266 insertions(+)
tests/intel_perf_dapc.c +266 -0
@@ -127,6 +127,12 @@ enum {local_I915_PERF_SAMPLE_OA_SOURCE_MAX /* non-ABI */ }; +#define local_I915_PERF_MMIO_NUM_MAX 8 +struct local_drm_i915_perf_mmio_list { +__u32 num_mmio; +__u32 mmio_list[local_I915_PERF_MMIO_NUM_MAX]; +}; +enum { local_DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE =DRM_I915_PERF_PROP_OA_EXPONENT +1 , local_DRM_I915_PERF_PROP_ENGINE =DRM_I915_PERF_PROP_OA_EXPONENT +2 ,
@@ -1163,6 +1169,260 @@ test_perf_ts(void)igt_waitchildren (); } +static char * +read_debugfs_record (int device,const char *file,const char *key) +{ +FILE *fp; +int fd; +char *line =NULL ; +size_t line_buf_size =0 ; +int len =0 ; +int key_len =strlen (key); +char *value =NULL ; + + fd =igt_debugfs_open (device, file,O_RDONLY ); + fp =fdopen (fd,"r" ); +igt_require (fp); + +while ((len =getline (&line, &line_buf_size, fp)) >0 ) { + +if (line[len -1 ] =='\n' ) + line[len -1 ] ='\0' ; + +if (strncmp (key, line, key_len) ==0 && + line[key_len] ==':' && + line[key_len +1 ] ==' ' ) { + value =strdup (line + key_len +2 ); + goto done; + } + } + +igt_assert (!"reached" ); +done: +free (line); +fclose (fp); +close (fd); +return value; +} + +static uint64_t +read_debugfs_u64_record (int fd,const char *file,const char *key) +{ +char *str_val =read_debugfs_record (fd, file, key); +uint64_t val; + +igt_require (str_val); + + val =strtoull (str_val,NULL ,0 ); +free (str_val); + +return val; +} + +struct oa_mmio_sample { +uint32_t mmio[2 ]; +uint8_t oa_report[]; +}; + +static void +verify_oa_mmio (uint8_t *perf_reports,int num_reports,size_t report_size, +uint64_t *pre_mmio_residency,uint64_t *post_mmio_residency) +{ +struct oa_mmio_sample *sample; +uint32_t *oa_report; + +igt_debug ("pre rc6 residency = %lu, rc6p residency = %lu, " +"post rc6 residency = %lu, rc6p residency = %lu\n" , + pre_mmio_residency[0 ], pre_mmio_residency[1 ], + post_mmio_residency[0 ], post_mmio_residency[1 ]); + +for (int i =0 ; i < num_reports; i++) { +size_t offset = i * report_size; + + sample = (struct oa_mmio_sample *) (perf_reports + offset); + oa_report = (uint32_t *) sample->oa_report; + +igt_debug ("read mmio: rc6 = %u, rc6p = %u\n" , + sample->mmio[0 ], sample->mmio[1 ]); + +igt_debug ("read report: reason = %x, timestamp = %x\n" , + oa_report[0 ], oa_report[1 ]); + +if (!oa_report[0 ]) { +igt_assert (sample->mmio[0 ] >= pre_mmio_residency[0 ]); +igt_assert (sample->mmio[1 ] >= pre_mmio_residency[1 ]); +igt_assert (sample->mmio[0 ] <= post_mmio_residency[0 ]); +igt_assert (sample->mmio[1 ] <= post_mmio_residency[1 ]); + } + } +} + +static void +test_perf_oa_mmio (void ) +{ +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 , test_metric_set_id, +DRM_I915_PERF_PROP_OA_FORMAT , test_oa_format, +DRM_I915_PERF_PROP_OA_EXPONENT , oa_exp_1_millisec, + +/* CS parameters */ + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_RENDER , + local_DRM_I915_PERF_PROP_SAMPLE_MMIO,0 , + }; +struct drm_i915_perf_open_param param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC , + .num_properties =sizeof (properties) /16 , + .properties_ptr =to_user_pointer (properties), + }; +struct local_drm_i915_perf_mmio_list mmio; + +memset (&mmio,0 ,sizeof (mmio)); + +#define GEN6_GT_GFX_RC6 0x138108 +#define GEN6_GT_GFX_RC6p 0x13810C + mmio.mmio_list[0 ] =GEN6_GT_GFX_RC6 ; + mmio.mmio_list[1 ] = GEN6_GT_GFX_RC6p; + mmio.num_mmio =2 ; + + properties[ARRAY_SIZE (properties) -1 ] = (uint64_t )&mmio; + +/* should be default, but just to be sure... */ +write_u64_file ("/proc/sys/dev/i915/perf_stream_paranoid" ,1 ); + + igt_fork(child, 1) { +int prop_size =ARRAY_SIZE (properties); +int num_reports =10 ; +int report_size =get_perf_report_size (properties, prop_size, + test_oa_format); +int total_size = num_reports * report_size; +uint8_t *perf_reports =malloc (total_size); +uint64_t pre_mmio_residency[2 ], post_mmio_residency[2 ]; + +igt_assert (perf_reports); + + pre_mmio_residency[0 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6 residency since boot" ); + pre_mmio_residency[1 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6+ residency since boot" ); +perf_stream_capture_workload_samples (¶m, perf_reports, + num_reports, report_size, +NULL ); + post_mmio_residency[0 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6 residency since boot" ); + post_mmio_residency[1 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6+ residency since boot" ); +verify_oa_mmio (perf_reports, num_reports, report_size, + pre_mmio_residency, post_mmio_residency); +free (perf_reports); + } + +igt_waitchildren (); +} + +struct ts_mmio_sample { +uint64_t ts; +uint32_t mmio[2 ]; +}; + +static void +verify_ts_mmio (uint8_t *perf_reports,int num_reports,size_t report_size, +uint64_t *pre_mmio_residency,uint64_t *post_mmio_residency) +{ +struct ts_mmio_sample *sample; + +igt_debug ("pre rc6 residency = %lu, rc6p residency = %lu, " +"post rc6 residency = %lu, rc6p residency = %lu\n" , + pre_mmio_residency[0 ], pre_mmio_residency[1 ], + post_mmio_residency[0 ], post_mmio_residency[1 ]); + +for (int i =0 ; i < num_reports; i++) { +size_t offset = i * report_size; + + sample = (struct ts_mmio_sample *) (perf_reports + offset); + +igt_debug ("read mmio: rc6 = %u, rc6p = %u\n" , + sample->mmio[0 ], sample->mmio[1 ]); + +igt_debug ("read report: timestamp = %lu\n" , sample->ts); + +igt_assert (sample->mmio[0 ] >= pre_mmio_residency[0 ]); +igt_assert (sample->mmio[1 ] >= pre_mmio_residency[1 ]); +igt_assert (sample->mmio[0 ] <= post_mmio_residency[0 ]); +igt_assert (sample->mmio[1 ] <= post_mmio_residency[1 ]); + } +} + +static void +test_perf_ts_mmio (void ) +{ +uint64_t properties[] = { +/* CS parameters */ + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_RENDER , + local_DRM_I915_PERF_PROP_SAMPLE_TS, true, + local_DRM_I915_PERF_PROP_SAMPLE_MMIO,0 , + }; +struct drm_i915_perf_open_param param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC , + .num_properties =sizeof (properties) /16 , + .properties_ptr =to_user_pointer (properties), + }; +struct local_drm_i915_perf_mmio_list mmio; + +memset (&mmio,0 ,sizeof (mmio)); + +#define GEN6_GT_GFX_RC6 0x138108 +#define GEN6_GT_GFX_RC6p 0x13810C + mmio.mmio_list[0 ] =GEN6_GT_GFX_RC6 ; + mmio.mmio_list[1 ] = GEN6_GT_GFX_RC6p; + mmio.num_mmio =2 ; + + properties[ARRAY_SIZE (properties) -1 ] = (uint64_t )&mmio; + +/* should be default, but just to be sure... */ +write_u64_file ("/proc/sys/dev/i915/perf_stream_paranoid" ,1 ); + + igt_fork(child, 1) { +int prop_size =ARRAY_SIZE (properties); +int num_reports =2 ; +int report_size =get_perf_report_size_nonoa (properties, + prop_size); +int total_size = num_reports * report_size; +uint8_t *perf_reports =malloc (total_size); +uint64_t pre_mmio_residency[2 ], post_mmio_residency[2 ]; + +igt_assert (perf_reports); + + pre_mmio_residency[0 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6 residency since boot" ); + pre_mmio_residency[1 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6+ residency since boot" ); +perf_stream_capture_workload_samples (¶m, perf_reports, + num_reports, report_size, +NULL ); + post_mmio_residency[0 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6 residency since boot" ); + post_mmio_residency[1 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6+ residency since boot" ); +verify_ts_mmio (perf_reports, num_reports, report_size, + pre_mmio_residency, post_mmio_residency); +free (perf_reports); + } + +igt_waitchildren (); +} + igt_main {igt_skip_on_simulation ();
@@ -1196,6 +1456,12 @@ igt_main igt_subtest("perf-ts")test_perf_ts (); + igt_subtest("perf-mmio") { +igt_require (intel_get_device_info (devid)->gen >=9 ); +test_perf_ts_mmio (); +test_perf_oa_mmio (); + } + igt_fixture {close (drm_fd); }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 7/9] tests/perf: Add testcase to verify mmio
Quoted 27 lines · Sagar Arun Kamble
v2: Updated the check for RC6 register value.
Updated property enum names. Definedlocal_I915_PERF_MMIO_NUM_MAXandlocal_drm_i915_perf_mmio_listfor local use.Signed-off-by Sagar Arun Kamble <[email protected]>--- tests/intel_perf_dapc.c | 266 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 266 insertions(+)tests/intel_perf_dapc.c +6
-0@@ -127,6 +127,12 @@ enum {local_I915_PERF_SAMPLE_OA_SOURCE_MAX /* non-ABI */ }; +#define local_I915_PERF_MMIO_NUM_MAX 8 +struct local_drm_i915_perf_mmio_list { +__u32 num_mmio; +__u32 mmio_list[local_I915_PERF_MMIO_NUM_MAX]; +}; +enum { local_DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE =DRM_I915_PERF_PROP_OA_EXPONENT +1 , local_DRM_I915_PERF_PROP_ENGINE =DRM_I915_PERF_PROP_OA_EXPONENT +2 ,
tests/intel_perf_dapc.c test_perf_ts(void) · line 1173
Quoted 5 lines
tests/intel_perf_dapc.c +2
-0@@ -1163,6 +1169,260 @@ test_perf_ts(void)igt_waitchildren (); } +static char * +read_debugfs_record (int device,const char *file,const char *key)
In igt_debugfs.c we have some functions which could be used instead I think. If not those could be added there as a another helpers.
Quoted 26 lines
tests/intel_perf_dapc.c +26
-0+{ +FILE *fp; +int fd; +char *line =NULL ; +size_t line_buf_size =0 ; +int len =0 ; +int key_len =strlen (key); +char *value =NULL ; + + fd =igt_debugfs_open (device, file,O_RDONLY ); + fp =fdopen (fd,"r" ); +igt_require (fp); + +while ((len =getline (&line, &line_buf_size, fp)) >0 ) { + +if (line[len -1 ] =='\n' ) + line[len -1 ] ='\0' ; + +if (strncmp (key, line, key_len) ==0 && + line[key_len] ==':' && + line[key_len +1 ] ==' ' ) { + value =strdup (line + key_len +2 ); + goto done; + } + } +
tests/intel_perf_dapc.c test_perf_ts(void) · line 1209
Quoted 10 lines
tests/intel_perf_dapc.c +10
-0+igt_assert (!"reached" ); +done: +free (line); +fclose (fp); +close (fd); +return value; +} + +static uint64_t +read_debugfs_u64_record (int fd,const char *file,const char *key)
The same as above
Quoted 90 lines
tests/intel_perf_dapc.c +90
-0+{ +char *str_val =read_debugfs_record (fd, file, key); +uint64_t val; + +igt_require (str_val); + + val =strtoull (str_val,NULL ,0 ); +free (str_val); + +return val; +} + +struct oa_mmio_sample { +uint32_t mmio[2 ]; +uint8_t oa_report[]; +}; + +static void +verify_oa_mmio (uint8_t *perf_reports,int num_reports,size_t report_size, +uint64_t *pre_mmio_residency,uint64_t *post_mmio_residency) +{ +struct oa_mmio_sample *sample; +uint32_t *oa_report; + +igt_debug ("pre rc6 residency = %lu, rc6p residency = %lu, " +"post rc6 residency = %lu, rc6p residency = %lu\n" , + pre_mmio_residency[0 ], pre_mmio_residency[1 ], + post_mmio_residency[0 ], post_mmio_residency[1 ]); + +for (int i =0 ; i < num_reports; i++) { +size_t offset = i * report_size; + + sample = (struct oa_mmio_sample *) (perf_reports + offset); + oa_report = (uint32_t *) sample->oa_report; + +igt_debug ("read mmio: rc6 = %u, rc6p = %u\n" , + sample->mmio[0 ], sample->mmio[1 ]); + +igt_debug ("read report: reason = %x, timestamp = %x\n" , + oa_report[0 ], oa_report[1 ]); + +if (!oa_report[0 ]) { +igt_assert (sample->mmio[0 ] >= pre_mmio_residency[0 ]); +igt_assert (sample->mmio[1 ] >= pre_mmio_residency[1 ]); +igt_assert (sample->mmio[0 ] <= post_mmio_residency[0 ]); +igt_assert (sample->mmio[1 ] <= post_mmio_residency[1 ]); + } + } +} + +static void +test_perf_oa_mmio (void ) +{ +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 , test_metric_set_id, +DRM_I915_PERF_PROP_OA_FORMAT , test_oa_format, +DRM_I915_PERF_PROP_OA_EXPONENT , oa_exp_1_millisec, + +/* CS parameters */ + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_RENDER , + local_DRM_I915_PERF_PROP_SAMPLE_MMIO,0 , + }; +struct drm_i915_perf_open_param param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC , + .num_properties =sizeof (properties) /16 , + .properties_ptr =to_user_pointer (properties), + }; +struct local_drm_i915_perf_mmio_list mmio; + +memset (&mmio,0 ,sizeof (mmio)); + +#define GEN6_GT_GFX_RC6 0x138108 +#define GEN6_GT_GFX_RC6p 0x13810C + mmio.mmio_list[0 ] =GEN6_GT_GFX_RC6 ; + mmio.mmio_list[1 ] = GEN6_GT_GFX_RC6p; + mmio.num_mmio =2 ; + + properties[ARRAY_SIZE (properties) -1 ] = (uint64_t )&mmio; + +/* should be default, but just to be sure... */ +write_u64_file ("/proc/sys/dev/i915/perf_stream_paranoid" ,1 ); + + igt_fork(child, 1) { +int prop_size =ARRAY_SIZE (properties); +int num_reports =10 ; + int report_size = get_perf_report_size(properties, prop_size,
tests/intel_perf_dapc.c test_perf_ts(void) · line 1309
Quoted 10 lines
tests/intel_perf_dapc.c +10
-0+ test_oa_format); +int total_size = num_reports * report_size; +uint8_t *perf_reports =malloc (total_size); +uint64_t pre_mmio_residency[2 ], post_mmio_residency[2 ]; + +igt_assert (perf_reports); + + pre_mmio_residency[0 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6 residency since boot" );
Reading residency from sysfs is safer:/sys/class/drm/card0/power/rc6_residency_ms
--
Cheers,
Ewelina
Quoted 139 lines
tests/intel_perf_dapc.c +122
-0+ pre_mmio_residency[1 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6+ residency since boot" ); +perf_stream_capture_workload_samples (¶m, perf_reports, + num_reports, report_size, +NULL ); + post_mmio_residency[0 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6 residency since boot" ); + post_mmio_residency[1 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6+ residency since boot" ); +verify_oa_mmio (perf_reports, num_reports, report_size, + pre_mmio_residency, post_mmio_residency); +free (perf_reports); + } + +igt_waitchildren (); +} + +struct ts_mmio_sample { +uint64_t ts; +uint32_t mmio[2 ]; +}; + +static void +verify_ts_mmio (uint8_t *perf_reports,int num_reports,size_t report_size, +uint64_t *pre_mmio_residency,uint64_t *post_mmio_residency) +{ +struct ts_mmio_sample *sample; + +igt_debug ("pre rc6 residency = %lu, rc6p residency = %lu, " +"post rc6 residency = %lu, rc6p residency = %lu\n" , + pre_mmio_residency[0 ], pre_mmio_residency[1 ], + post_mmio_residency[0 ], post_mmio_residency[1 ]); + +for (int i =0 ; i < num_reports; i++) { +size_t offset = i * report_size; + + sample = (struct ts_mmio_sample *) (perf_reports + offset); + +igt_debug ("read mmio: rc6 = %u, rc6p = %u\n" , + sample->mmio[0 ], sample->mmio[1 ]); + +igt_debug ("read report: timestamp = %lu\n" , sample->ts); + +igt_assert (sample->mmio[0 ] >= pre_mmio_residency[0 ]); +igt_assert (sample->mmio[1 ] >= pre_mmio_residency[1 ]); +igt_assert (sample->mmio[0 ] <= post_mmio_residency[0 ]); +igt_assert (sample->mmio[1 ] <= post_mmio_residency[1 ]); + } +} + +static void +test_perf_ts_mmio (void ) +{ +uint64_t properties[] = { +/* CS parameters */ + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_RENDER , + local_DRM_I915_PERF_PROP_SAMPLE_TS, true, + local_DRM_I915_PERF_PROP_SAMPLE_MMIO,0 , + }; +struct drm_i915_perf_open_param param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC , + .num_properties =sizeof (properties) /16 , + .properties_ptr =to_user_pointer (properties), + }; +struct local_drm_i915_perf_mmio_list mmio; + +memset (&mmio,0 ,sizeof (mmio)); + +#define GEN6_GT_GFX_RC6 0x138108 +#define GEN6_GT_GFX_RC6p 0x13810C + mmio.mmio_list[0 ] =GEN6_GT_GFX_RC6 ; + mmio.mmio_list[1 ] = GEN6_GT_GFX_RC6p; + mmio.num_mmio =2 ; + + properties[ARRAY_SIZE (properties) -1 ] = (uint64_t )&mmio; + +/* should be default, but just to be sure... */ +write_u64_file ("/proc/sys/dev/i915/perf_stream_paranoid" ,1 ); + + igt_fork(child, 1) { +int prop_size =ARRAY_SIZE (properties); +int num_reports =2 ; +int report_size =get_perf_report_size_nonoa (properties, + prop_size); +int total_size = num_reports * report_size; +uint8_t *perf_reports =malloc (total_size); +uint64_t pre_mmio_residency[2 ], post_mmio_residency[2 ]; + +igt_assert (perf_reports); + + pre_mmio_residency[0 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6 residency since boot" ); + pre_mmio_residency[1 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6+ residency since boot" ); +perf_stream_capture_workload_samples (¶m, perf_reports, + num_reports, report_size, +NULL ); + post_mmio_residency[0 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6 residency since boot" ); + post_mmio_residency[1 ] =read_debugfs_u64_record (drm_fd, +"i915_drpc_info" , +"RC6+ residency since boot" ); +verify_ts_mmio (perf_reports, num_reports, report_size, + pre_mmio_residency, post_mmio_residency); +free (perf_reports); + } + +igt_waitchildren (); +} + igt_main {igt_skip_on_simulation ();@@ -1196,6 +1456,12 @@ igt_main igt_subtest("perf-ts")test_perf_ts (); + igt_subtest("perf-mmio") { +igt_require (intel_get_device_info (devid)->gen >=9 ); +test_perf_ts_mmio (); +test_perf_oa_mmio (); + } + igt_fixture {close (drm_fd); }Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/9 tests/perf: Add testcase to verify concurrent streams
In reply to Sagar Arun Kamblev2: Updated property enum names.
--- tests/intel_perf_dapc.c | 211 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+)
tests/intel_perf_dapc.c +211 -0
@@ -1423,6 +1423,214 @@ test_perf_ts_mmio(void)igt_waitchildren (); } +struct ts_ctxid_sample { +uint64_t ctx_id; +uint64_t ts; +}; + +static void +verify_ctxid_nonoa (uint8_t *perf_reports,int num_reports,size_t report_size, +uint64_t hw_ctx_id,int match_index) +{ +struct ts_ctxid_sample *sample; + +for (int i =0 ; i < num_reports; i++) { +size_t offset = i * report_size; + + sample = (struct ts_ctxid_sample *) (perf_reports + offset); + +igt_debug ("read report: ctx_id= %lu, timestamp = %lu\n" , + sample->ctx_id, sample->ts); + +if (i < match_index) +igt_assert (sample->ctx_id != hw_ctx_id); +else +igt_assert (sample->ctx_id == hw_ctx_id); + } +} + +#define LOCAL_I915_EXEC_NO_RELOC (1<<11) +#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12) + +/* Logic taken from store_ring in gem_sync */ +static void +test_concurrent_streams (void ) +{ +const int gen =intel_gen (intel_get_drm_devid (drm_fd)); +unsigned int engines[16 ]; +int num_children =1 ; +int timeout =5 ; +int num_engines =0 ; +const struct intel_execution_engine *e; +uint64_t render_hw_ctx_id; +uint64_t blt_hw_ctx_id; +uint64_t render_properties[] = { +/* CS parameters */ + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_RENDER , + local_DRM_I915_PERF_PROP_SAMPLE_CTX_ID, true, + local_DRM_I915_PERF_PROP_SAMPLE_TS, true, + }; +struct drm_i915_perf_open_param render_param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC , + .num_properties =sizeof (render_properties) /16 , + .properties_ptr =to_user_pointer (render_properties), + }; +uint64_t blt_properties[] = { +/* CS parameters */ + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_BLT , + local_DRM_I915_PERF_PROP_SAMPLE_CTX_ID, true, + local_DRM_I915_PERF_PROP_SAMPLE_TS, true, + }; +struct drm_i915_perf_open_param blt_param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC , + .num_properties =sizeof (blt_properties) /16 , + .properties_ptr =to_user_pointer (blt_properties), + }; +int num_reports =4 ; +int render_prop_size =ARRAY_SIZE (render_properties); +int render_report_size =get_perf_report_size_nonoa (render_properties, + render_prop_size); +int render_total_size = num_reports * render_report_size; +int render_stream_fd; +int blt_prop_size =ARRAY_SIZE (blt_properties); +int blt_report_size =get_perf_report_size_nonoa (blt_properties, + blt_prop_size); +int blt_total_size = num_reports * blt_report_size; +int blt_stream_fd; +bool valid_data = false; + +for (e = intel_execution_engines; e->name; e++) { +if (e->exec_id ==0 ) +continue ; + +if (!gem_has_ring (drm_fd, e->exec_id | e->flags)) +continue ; + +if (e->exec_id ==I915_EXEC_BSD ) { +int is_bsd2 = e->flags !=0 ; + +if (gem_has_bsd2 (drm_fd) != is_bsd2) +continue ; + } + + engines[num_engines++] = e->exec_id | e->flags; +if (num_engines ==ARRAY_SIZE (engines)) +break ; + } + +/* should be default, but just to be sure... */ +write_u64_file ("/proc/sys/dev/i915/perf_stream_paranoid" ,1 ); + + num_children *= num_engines; + +intel_detect_and_clear_missed_interrupts (drm_fd); + igt_fork(child, num_children) { +uint8_t *render_perf_reports =NULL ; +uint8_t *blt_perf_reports =NULL ; +const uint32_t bbe =MI_BATCH_BUFFER_END ; +struct drm_i915_gem_exec_object2 object[1 ]; +struct drm_i915_gem_execbuffer2 execbuf; +drm_intel_bufmgr *bufmgr; +drm_intel_context *context0; +uint32_t ctx_id =0xffffffff ;/* invalid id */ +int ret; + +memset (&execbuf,0 ,sizeof (execbuf)); + execbuf.buffers_ptr =to_user_pointer (object); + execbuf.flags = engines[child % num_engines]; + execbuf.flags |=LOCAL_I915_EXEC_NO_RELOC ; + execbuf.flags |=LOCAL_I915_EXEC_HANDLE_LUT ; +if (gen <6 ) + execbuf.flags |=I915_EXEC_SECURE ; + +memset (object,0 ,sizeof (object)); + object[0 ].handle =gem_create (drm_fd,4096 ); +gem_write (drm_fd, object[0 ].handle,0 , &bbe,sizeof (bbe)); + + bufmgr =drm_intel_bufmgr_gem_init (drm_fd,4096 ); +drm_intel_bufmgr_gem_enable_reuse (bufmgr); + + context0 =drm_intel_gem_context_create (bufmgr); +igt_assert (context0); + + ret =drm_intel_gem_context_get_id (context0, &ctx_id); +igt_assert_eq (ret,0 ); +igt_assert_neq (ctx_id,0xffffffff ); + +if ((execbuf.flags &I915_EXEC_RING_MASK ) ==I915_EXEC_RENDER ) { + render_hw_ctx_id =context_get_hw_ctx_id (drm_fd, + ctx_id); +igt_debug ("render user_handle = %u hw_id = %lu\n" , + ctx_id, render_hw_ctx_id); + + render_perf_reports =malloc (render_total_size); +igt_assert (render_perf_reports); + +igt_debug ("opening render i915-perf stream\n" ); + render_stream_fd =__perf_open (drm_fd, &render_param); + } + +if ((execbuf.flags &I915_EXEC_RING_MASK ) ==I915_EXEC_BLT ) { + blt_hw_ctx_id =context_get_hw_ctx_id (drm_fd, ctx_id); +igt_debug ("blt user_handle = %u hw_id = %lu\n" , + ctx_id, blt_hw_ctx_id); + + blt_perf_reports =malloc (blt_total_size); +igt_assert (blt_perf_reports); + +igt_debug ("opening blt i915-perf stream\n" ); + blt_stream_fd =__perf_open (drm_fd, &blt_param); + } + + execbuf.buffer_count =1 ; +/* Do a submission with default context */ +gem_execbuf (drm_fd, &execbuf); + +i915_execbuffer2_set_context_id (execbuf, ctx_id); +/* Now submit with user created context */ +gem_execbuf (drm_fd, &execbuf); + +gem_close (drm_fd, object[0 ].handle); + +drm_intel_gem_context_destroy (context0); +drm_intel_bufmgr_destroy (bufmgr); + +if ((execbuf.flags &I915_EXEC_RING_MASK ) ==I915_EXEC_RENDER ) { + valid_data =read_perf_reports (render_stream_fd, + render_perf_reports, + num_reports, + render_report_size, + false); +igt_assert (valid_data); +close (render_stream_fd); + +igt_debug ("Verify render ctx id: %lu\n" , + render_hw_ctx_id); +verify_ctxid_nonoa (render_perf_reports, num_reports, + render_report_size, render_hw_ctx_id, +2 ); +free (render_perf_reports); + } + +if ((execbuf.flags &I915_EXEC_RING_MASK ) ==I915_EXEC_BLT ) { + valid_data =read_perf_reports (blt_stream_fd, + blt_perf_reports, + num_reports, + blt_report_size, + false); +igt_assert (valid_data); +close (blt_stream_fd); + +igt_debug ("Verify blt ctx id: %lu\n" , blt_hw_ctx_id); +verify_ctxid_nonoa (blt_perf_reports, num_reports, + blt_report_size, blt_hw_ctx_id,2 ); +free (blt_perf_reports); + } + } +igt_waitchildren_timeout (timeout+10 ,NULL ); +igt_assert_eq (intel_detect_and_clear_missed_interrupts (drm_fd),0 ); +} + igt_main {igt_skip_on_simulation ();
@@ -1462,6 +1670,9 @@ igt_maintest_perf_oa_mmio (); } + igt_subtest("concurrent-streams") +test_concurrent_streams (); + igt_fixture {close (drm_fd); }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/9 tests/perf: Add testcase to verify association of OABUFFER reports with CS properties
In reply to Sagar Arun Kamble--- tests/intel_perf_dapc.c | 152 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 143 insertions(+), 9 deletions(-)
tests/intel_perf_dapc.c +143 -9
@@ -686,10 +686,10 @@ context_get_hw_ctx_id(int fd, unsigned int ctx) }static void -perf_stream_capture_workload_samples (struct drm_i915_perf_open_param *param, -uint8_t *perf_reports, -int num_reports,int report_size, -uint64_t *hw_ctx_id) +__perf_stream_capture_workload_samples (struct drm_i915_perf_open_param *param, +uint8_t *perf_reports, +int num_reports,int report_size, +uint64_t *hw_ctx_id,int num_batches) {drm_intel_bufmgr *bufmgr;drm_intel_context *context0;
@@ -701,8 +701,10 @@ perf_stream_capture_workload_samples(struct drm_i915_perf_open_param *param,int stream_fd;int ret;bool valid_data = false; +int batches; retry: + batches = num_batches; bufmgr =drm_intel_bufmgr_gem_init (drm_fd,4096 );drm_intel_bufmgr_gem_enable_reuse (bufmgr);
@@ -724,12 +726,15 @@ retry:igt_debug ("opening i915-perf stream\n" ); stream_fd =__perf_open (drm_fd, param); -render_copy (batch, - context0, - &src,0 ,0 , width, height, - &dst,0 ,0 ); +while (batches--) { +render_copy (batch, + context0, + &src,0 ,0 , width, height, + &dst,0 ,0 ); +usleep (1000 ); -intel_batchbuffer_flush_with_context (batch, context0); +intel_batchbuffer_flush_with_context (batch, context0); + }drm_intel_bo_unreference (src.bo);drm_intel_bo_unreference (dst.bo);
@@ -747,6 +752,16 @@ retry: } } +static void +perf_stream_capture_workload_samples (struct drm_i915_perf_open_param *param, +uint8_t *perf_reports, +int num_reports,int report_size, +uint64_t *hw_ctx_id) +{ +__perf_stream_capture_workload_samples (param, perf_reports, num_reports, + report_size, hw_ctx_id,1 ); +} +struct oa_source_sample {uint64_t source;uint64_t ctx_id;
@@ -1631,6 +1646,122 @@ test_concurrent_streams(void)igt_assert_eq (intel_detect_and_clear_missed_interrupts (drm_fd),0 ); } +struct oa_ctxid_pid_sample { +uint64_t source; +uint64_t ctx_id; +uint64_t pid; +uint8_t oa_report[]; +}; + +#define INVALID_CTX_ID 0xffffffff +#define INVALID_PID 0xffffffff + +static void +verify_oa_association (uint8_t *perf_reports,int num_reports,size_t report_size) +{ +struct oa_ctxid_pid_sample *sample; +uint32_t *oa_report; +uint64_t last_ctx_id =INVALID_CTX_ID ; +uint64_t last_pid =INVALID_PID ; +uint32_t last_ts =0 ; +bool in_batch = false; + +for (int i =0 ; i < num_reports; i++) { +size_t offset = i * report_size; + + sample = (struct oa_ctxid_pid_sample *) (perf_reports + offset); + oa_report = (uint32_t *) sample->oa_report; + +igt_debug ("read report: source= %s, reason = %x, " +"timestamp = %x\n" , +SOURCE (sample->source), oa_report[0 ], oa_report[1 ]); + +igt_assert (last_ts <= oa_report[1 ]); + last_ts = oa_report[1 ]; + +igt_assert ((sample->source == + local_I915_PERF_SAMPLE_OA_SOURCE_OABUFFER) || + (sample->source == + local_I915_PERF_SAMPLE_OA_SOURCE_CS)); + +if (sample->source == local_I915_PERF_SAMPLE_OA_SOURCE_CS) { +igt_assert (!oa_report[0 ]); +if (!in_batch) { + last_ctx_id = sample->ctx_id; + last_pid = sample->pid; + in_batch = true; + }else { + last_ctx_id =INVALID_CTX_ID ; + last_pid =INVALID_PID ; + in_batch = false; + } + }else { +igt_debug ("in_batch: %s ctx_id = %lu, pid = %lu, " +"sample ctx_id = %lu, sample pid = %lu\n" , + in_batch ?"yes" :"no" , last_ctx_id, + last_pid, sample->ctx_id, sample->pid); + +if (in_batch) +igt_assert (sample->ctx_id == last_ctx_id); +igt_assert (sample->pid == last_pid); + } + } +} + +static void +test_oa_data_association (void ) +{ +uint64_t oa_exp_1_msec =max_oa_exponent_for_period_lte (1000000 ); + +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 , test_metric_set_id, +DRM_I915_PERF_PROP_OA_FORMAT , test_oa_format, +DRM_I915_PERF_PROP_OA_EXPONENT , oa_exp_1_msec, + +/* CS parameters */ + local_DRM_I915_PERF_PROP_ENGINE,I915_EXEC_RENDER , + local_DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE, true, + local_DRM_I915_PERF_PROP_SAMPLE_CTX_ID, true, + local_DRM_I915_PERF_PROP_SAMPLE_PID, true, + }; +struct drm_i915_perf_open_param param = { + .flags =I915_PERF_FLAG_FD_CLOEXEC , + .num_properties =sizeof (properties) /16 , + .properties_ptr =to_user_pointer (properties), + }; + +/* should be default, but just to be sure... */ +write_u64_file ("/proc/sys/dev/i915/perf_stream_paranoid" ,1 ); + + igt_fork(child, 1) { +int prop_size =ARRAY_SIZE (properties); +int num_reports =100 ; +int report_size =get_perf_report_size (properties, prop_size, + test_oa_format); +int total_size = num_reports * report_size; +uint8_t *perf_reports =malloc (total_size); + +igt_assert (perf_reports); + +/* +* TODO: in some runs, OABUFFER periodic reports are not triggered +* during execution of workload, hence increasing the execbuf +* duration might be needed. +*/ +__perf_stream_capture_workload_samples (¶m, perf_reports, + num_reports, report_size, +NULL ,10 ); +verify_oa_association (perf_reports, num_reports, report_size); +free (perf_reports); + } + +igt_waitchildren (); +} + igt_main {igt_skip_on_simulation ();
@@ -1673,6 +1804,9 @@ igt_main igt_subtest("concurrent-streams")test_concurrent_streams (); + igt_subtest("oa-data-association") +test_oa_data_association (); + igt_fixture {close (drm_fd); }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for IGT Testcases for i915 DAPC feature (rev2)
In reply to Sagar Arun Kamble== Series Details ==
== Series Details ==
Series: IGT Testcases for i915 DAPC feature (rev2)
URL : https://patchwork.freedesktop.org/series/29940/
State : success
== Summary ==
IGT patchset tested on top of latest successful buildc718ba805208e55d675defe9b2a66852e2ae038c lib/igt_kmod: Allow specifying libkmod config via environment variables
with latest DRM-Tip kernel build CI_DRM_308476f9b11f445f drm-tip: 2017y-09m-13d-12h-28m-54s UTC integration manifest
Test kms_cursor_legacy:
Subgroup basic-busy-flip-before-cursor-atomic:
pass -> FAIL (fi-snb-2600) fdo#100215 +1
Subgroup basic-flip-before-cursor-atomic:
incomplete -> PASS (fi-bxt-j4205) fdo#102705fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215
fdo#102705 https://bugs.freedesktop.org/show_bug.cgi?id=102705
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:453s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:455s fi-blb-e6850 total:289 pass:224 dwarn:1 dfail:0 fail:0 skip:64 time:383s fi-bsw-n3050 total:289 pass:243 dwarn:0 dfail:0 fail:0 skip:46 time:529s fi-bwr-2160 total:289 pass:184 dwarn:0 dfail:0 fail:0 skip:105 time:267s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:510s fi-byt-j1900 total:289 pass:254 dwarn:1 dfail:0 fail:0 skip:34 time:509s fi-byt-n2820 total:289 pass:250 dwarn:1 dfail:0 fail:0 skip:38 time:503s fi-cfl-s total:289 pass:223 dwarn:34 dfail:0 fail:0 skip:32 time:558s fi-elk-e7500 total:289 pass:230 dwarn:0 dfail:0 fail:0 skip:59 time:458s fi-glk-2a total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:593s fi-hsw-4770 total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:432s fi-hsw-4770r total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:409s fi-ilk-650 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:447s fi-ivb-3520m total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:491s fi-ivb-3770 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:468s fi-kbl-7500u total:289 pass:264 dwarn:1 dfail:0 fail:0 skip:24 time:492s fi-kbl-7560u total:289 pass:270 dwarn:0 dfail:0 fail:0 skip:19 time:579s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:587s fi-pnv-d510 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:555s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:462s fi-skl-6700k total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:528s fi-skl-6770hq total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:501s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:458s fi-skl-x1585l total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:481s fi-snb-2600 total:289 pass:248 dwarn:0 dfail:0 fail:2 skip:39 time:428s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_184/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for IGT Testcases for i915 DAPC feature (rev2)
In reply to Sagar Arun Kamble== Series Details ==
== Series Details ==
Series: IGT Testcases for i915 DAPC feature (rev2)
URL : https://patchwork.freedesktop.org/series/29940/
State : success
== Summary ==
Test kms_setmode:
Subgroup basic:
pass -> FAIL (shard-hsw) fdo#99912fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
shard-hsw total:2322 pass:1245 dwarn:0 dfail:0 fail:22 skip:1055 time:9491s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_184/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx