igt/gem_workarounds: Test all types of workarounds
PATCH v5 1/1 igt/gem_workarounds: Test all types of workarounds
Apart from context based workarounds, we can now also test for global MMIO and whitelisting ones.
Do take into account that this test does not guarantee that all known WAs for a given platform are applied. It only checks that the WAs the kernel does know about are correctly applied (e.g. they didn't get lost on a GPU reset or a suspend/resume).
v2:
- Do not wait for the GPU unnecessarily (Chris)
- Make a comment that this tests only looks for regressions (Chris)
v3:
- GT instead of MMIO (Chris, Mika)
- Limit register access to just the mmio tests (Chris)
- Add the possibility to read the WAs from a local file (Chris)
- Display workarounds (Ville)
v4:
- Keep backward compatibility with older kernels (Petri)
- Unify the result checker and pretty print the result (Chris)
v5:
- Avoid error with even older kernels
- Missing mem free
--- tests/gem_workarounds.c | 260 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 197 insertions(+), 63 deletions(-)
tests/gem_workarounds.c +197 -63
@@ -28,6 +28,7 @@#include "igt.h" #include <fcntl.h> +#include <ctype.h> #define PAGE_SIZE 4096#define PAGE_ALIGN (x) ALIGN(x, PAGE_SIZE)
@@ -62,27 +63,53 @@ static struct write_only_list {*/ }; -static struct intel_wa_reg *wa_regs; -static int num_wa_regs; +static struct intel_wa_reg *ctx_wa_regs; +static int num_ctx_wa_regs; + +static struct intel_wa_reg *gt_wa_regs; +static int num_gt_wa_regs; + +static struct intel_wa_reg *display_wa_regs; +static int num_display_wa_regs; + +static struct intel_wa_reg *whitelist_wa_regs; +static int num_whitelist_wa_regs;static bool write_only (const uint32_t addr) {int i; -for (i =0 ; i <ARRAY_SIZE (wo_list); i++) { -if (gen == wo_list[i].gen && - addr == wo_list[i].addr) { -igt_info ("Skipping check for 0x%x due to write only\n" , addr); +for (i =0 ; i <ARRAY_SIZE (wo_list); i++) +if (gen == wo_list[i].gen && addr == wo_list[i].addr)return true; - } - }return false; } +static int check_result (struct intel_wa_reg *wa_reg, +uint32_t out,const char *type) +{ +const bool ok = (wa_reg->value & wa_reg->mask) == (out & wa_reg->mask); +char buf[80 ]; + +snprintf (buf,sizeof (buf),"0x%05X\t0x%08X\t0x%08X\t0x%08X\t(%s)" , + wa_reg->addr, wa_reg->value, wa_reg->mask, out, type); + +if (ok) { +igt_debug ("%s\tOK\n" , buf); + }else if (write_only (wa_reg->addr)) { +igt_debug ("%s\tIGNORED (w/o)\n" , buf); + }else { +igt_warn ("%s\tFAIL\n" , buf); +return 1 ; + } + +return 0 ; +} +#define MI_STORE_REGISTER_MEM (0x24 << 23) -static int workaround_fail_count (int fd,uint32_t ctx) +static int ctx_workarounds_fail_count (int fd,uint32_t ctx) {struct drm_i915_gem_exec_object2 obj[2 ];struct drm_i915_gem_relocation_entry *reloc;
@@ -91,13 +118,16 @@ static int workaround_fail_count(int fd, uint32_t ctx)uint32_t *base, *out;int fail_count =0 ; - reloc =calloc (num_wa_regs,sizeof (*reloc)); +if (!num_ctx_wa_regs) +return 0 ; + + reloc =calloc (num_ctx_wa_regs,sizeof (*reloc));igt_assert (reloc); - result_sz =4 * num_wa_regs; + result_sz =4 * num_ctx_wa_regs; result_sz =PAGE_ALIGN (result_sz); - batch_sz =16 * num_wa_regs +4 ; + batch_sz =16 * num_ctx_wa_regs +4 ; batch_sz =PAGE_ALIGN (batch_sz);memset (obj,0 ,sizeof (obj));
@@ -105,12 +135,12 @@ static int workaround_fail_count(int fd, uint32_t ctx)gem_set_caching (fd, obj[0 ].handle,I915_CACHING_CACHED ); obj[1 ].handle =gem_create (fd, batch_sz); obj[1 ].relocs_ptr =to_user_pointer (reloc); - obj[1 ].relocation_count = num_wa_regs; + obj[1 ].relocation_count = num_ctx_wa_regs; out = base =gem_mmap__cpu (fd, obj[1 ].handle,0 , batch_sz,PROT_WRITE ); -for (int i =0 ; i < num_wa_regs; i++) { +for (int i =0 ; i < num_ctx_wa_regs; i++) { *out++ =MI_STORE_REGISTER_MEM | ((gen >=8 ?4 :2 ) -2 ); - *out++ = wa_regs[i].addr; + *out++ = ctx_wa_regs[i].addr; reloc[i].target_handle = obj[0 ].handle; reloc[i].offset = (out - base) *sizeof (*out); reloc[i].delta = i *sizeof (uint32_t );
@@ -131,29 +161,9 @@ static int workaround_fail_count(int fd, uint32_t ctx)gem_set_domain (fd, obj[0 ].handle,I915_GEM_DOMAIN_CPU ,0 ); -igt_debug ("Address\tval\t\tmask\t\tread\t\tresult\n" ); - out =gem_mmap__cpu (fd, obj[0 ].handle,0 , result_sz,PROT_READ ); -for (int i =0 ; i < num_wa_regs; i++) { -const bool ok = - (wa_regs[i].value & wa_regs[i].mask) == - (out[i] & wa_regs[i].mask); -char buf[80 ]; - -snprintf (buf,sizeof (buf), -"0x%05X\t0x%08X\t0x%08X\t0x%08X" , - wa_regs[i].addr, wa_regs[i].value, wa_regs[i].mask, - out[i]); - -if (ok) { -igt_debug ("%s\tOK\n" , buf); - }else if (write_only (wa_regs[i].addr)) { -igt_debug ("%s\tIGNORED (w/o)\n" , buf); - }else { -igt_warn ("%s\tFAIL\n" , buf); - fail_count++; - } - } +for (int i =0 ; i < num_ctx_wa_regs; i++) + fail_count +=check_result (&ctx_wa_regs[i], out[i],"ctx" );munmap (out, result_sz);gem_close (fd, obj[1 ].handle);
@@ -163,6 +173,44 @@ static int workaround_fail_count(int fd, uint32_t ctx)return fail_count; } +static int mmio_workarounds_fail_count (struct intel_wa_reg *wa_regs, +int num_wa_regs,const char *type) +{ +int i, fail_count =0 ; + +for (i =0 ; i < num_wa_regs; i++) { +const uint32_t val =intel_register_read (wa_regs[i].addr); + fail_count +=check_result (&wa_regs[i], val, type); + } + +return fail_count; +} + +static int workarounds_fail_count (int fd,uint32_t ctx) +{ +int fail_count =0 ; + +igt_debug ("Address\tval\t\tmask\t\tread\t\ttype\tresult\n" ); + + fail_count +=ctx_workarounds_fail_count (fd, ctx); + +intel_register_access_init (intel_get_pci_device (),0 , fd); + + fail_count +=mmio_workarounds_fail_count (gt_wa_regs, + num_gt_wa_regs, +"gt" ); + fail_count +=mmio_workarounds_fail_count (display_wa_regs, + num_display_wa_regs, +"disp" ); + fail_count +=mmio_workarounds_fail_count (whitelist_wa_regs, + num_whitelist_wa_regs, +"wlist" ); + +intel_register_access_fini (); + +return fail_count; +} +static int reopen (int fd) {char path[256 ];
@@ -185,7 +233,7 @@ static void check_workarounds(int fd, enum operation op, unsigned int flags)if (flags &CONTEXT ) ctx =gem_context_create (fd); -igt_assert_eq (workaround_fail_count (fd, ctx),0 ); +igt_assert_eq (workarounds_fail_count (fd, ctx),0 );switch (op) {case GPU_RESET :
@@ -209,7 +257,7 @@ static void check_workarounds(int fd, enum operation op, unsigned int flags)igt_assert (0 ); } -igt_assert_eq (workaround_fail_count (fd, ctx),0 ); +igt_assert_eq (workarounds_fail_count (fd, ctx),0 );if (flags &CONTEXT )gem_context_destroy (fd, ctx);
@@ -217,6 +265,74 @@ static void check_workarounds(int fd, enum operation op, unsigned int flags)close (fd); } +static bool is_empty (const char *s) +{ +while (*s !='\0' ) { +if (!isspace (*s)) +return false; + s++; + } + +return true; +} + +static char *skip_preamble (char *s,const char *preamble) +{ +int i =strlen (preamble); + +while (*s == *preamble) { + s++; + preamble++; + i--; + } + +return (i ==0 ) ? s :NULL ; +} + +static void read_workarounds (FILE *file,const char *preamble, +struct intel_wa_reg **regs,int *num) +{ +char *header, *line =NULL ; +size_t line_size; +struct intel_wa_reg *wa_regs =NULL ; +int num_wa_regs =0 ; +int i =0 ; + +if (getline (&line, &line_size, file) <=0 ) + goto out; + + header =skip_preamble (line, preamble); +if (!header) + goto out; + +igt_debug ("i915_wa_registers: %s" , line); + +sscanf (header," applied: %d" , &num_wa_regs); +if (!num_wa_regs) + goto out; + + wa_regs =malloc (num_wa_regs *sizeof (*wa_regs)); + +while (getline (&line, &line_size, file) >0 ) { +if (is_empty (line)) +break ; + +if (sscanf (line,"0x%X: 0x%08X, mask: 0x%08X" , + &wa_regs[i].addr, + &wa_regs[i].value, + &wa_regs[i].mask) ==3 ) + i++; + } + +igt_assert_lte (i, num_wa_regs); + +out: + *regs = wa_regs; + *num = num_wa_regs; + +free (line); +} + igt_main {int device =-1 ;
@@ -242,38 +358,49 @@ igt_main igt_fixture {FILE *file; -char *line =NULL ; -size_t line_size; -int i, fd; +int fd; device =drm_open_driver (DRIVER_INTEL );igt_require_gem (device); gen =intel_gen (intel_get_drm_devid (device)); - fd =igt_debugfs_open (device,"i915_wa_registers" ,O_RDONLY ); - file =fdopen (fd,"r" ); -igt_assert (getline (&line, &line_size, file) >0 ); -igt_debug ("i915_wa_registers: %s" , line); -sscanf (line,"Workarounds applied: %d" , &num_wa_regs); -igt_require (num_wa_regs >0 ); - - wa_regs =malloc (num_wa_regs *sizeof (*wa_regs)); -igt_assert (wa_regs); - - i =0 ; -while (getline (&line, &line_size, file) >0 ) { -igt_debug ("%s" , line); -if (sscanf (line,"0x%X: 0x%08X, mask: 0x%08X" , - &wa_regs[i].addr, - &wa_regs[i].value, - &wa_regs[i].mask) ==3 ) - i++; +if ((file =fopen ("wa_registers.txt" ,"r" ))) { +igt_info ("Using a local workarounds file\n" ); + }else { + fd =igt_debugfs_open (device,"i915_wa_registers" ,O_RDONLY ); + file =fdopen (fd,"r" ); } +igt_assert (file); + +/* +* This test relies on the list of workarounds the kernel says +* have been applied and it only checks that those are (indeed) +* correctly applied. It does not report whether the system has +* applied all known workarounds for a fiven platform. +*/ +read_workarounds (file,"Workarounds" , + &ctx_wa_regs, &num_ctx_wa_regs); + +if (num_ctx_wa_regs ==0 ) { +/* Newish kernel, with support for more WA types */ +rewind (file); + +read_workarounds (file,"Context workarounds" , + &ctx_wa_regs, &num_ctx_wa_regs); +read_workarounds (file,"GT workarounds" , + >_wa_regs, &num_gt_wa_regs); +read_workarounds (file,"Display workarounds" , + &display_wa_regs, + &num_display_wa_regs); +read_workarounds (file,"Whitelist workarounds" , + &whitelist_wa_regs, + &num_whitelist_wa_regs); + } +igt_require (num_ctx_wa_regs + + num_gt_wa_regs + + num_whitelist_wa_regs >0 ); -igt_assert_lte (i, num_wa_regs); - -free (line);fclose (file);close (fd); }
@@ -284,4 +411,11 @@ igt_maincheck_workarounds (device, op->op, m->flags); } } + + igt_fixture { +free (ctx_wa_regs); +free (gt_wa_regs); +free (display_wa_regs); +free (whitelist_wa_regs); + } }
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/gem_workarounds: Test all types of workarounds (rev4)
== Series Details ==
== Series Details ==
Series: igt/gem_workarounds: Test all types of workarounds (rev4)
URL : https://patchwork.freedesktop.org/series/31612/
State : success
== Summary ==
IGT patchset tested on top of latest successful build 7aac0e88606ce453b111ce80419dc58519db05ad assembler: Fix bashism in run-test.sh
with latest DRM-Tip kernel build CI_DRM_3296e069b70ce83d drm-tip: 2017y-10m-30d-21h-18m-56s UTC integration manifest
No testlist changes.
Test kms_cursor_legacy:
Subgroup basic-busy-flip-before-cursor-legacy:
pass -> FAIL (fi-gdg-551) fdo#102618fdo#102618 https://bugs.freedesktop.org/show_bug.cgi?id=102618
fi-bdw-5557u total:289 pass:266 dwarn:0 dfail:0 fail:2 skip:21 time:465s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:453s fi-blb-e6850 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:372s fi-bsw-n3050 total:289 pass:241 dwarn:0 dfail:0 fail:2 skip:46 time:537s fi-bwr-2160 total:289 pass:183 dwarn:0 dfail:0 fail:0 skip:106 time:270s fi-bxt-dsi total:289 pass:257 dwarn:0 dfail:0 fail:2 skip:30 time:518s fi-bxt-j4205 total:289 pass:258 dwarn:0 dfail:0 fail:2 skip:29 time:514s fi-byt-j1900 total:289 pass:251 dwarn:1 dfail:0 fail:2 skip:35 time:518s fi-byt-n2820 total:289 pass:247 dwarn:1 dfail:0 fail:2 skip:39 time:509s fi-cfl-s total:289 pass:251 dwarn:4 dfail:0 fail:2 skip:32 time:565s fi-cnl-y total:289 pass:260 dwarn:0 dfail:0 fail:2 skip:27 time:597s fi-elk-e7500 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:429s fi-gdg-551 total:289 pass:177 dwarn:1 dfail:0 fail:2 skip:109 time:259s fi-glk-1 total:289 pass:259 dwarn:0 dfail:0 fail:2 skip:28 time:596s fi-hsw-4770 total:289 pass:260 dwarn:0 dfail:0 fail:2 skip:27 time:446s fi-hsw-4770r total:289 pass:260 dwarn:0 dfail:0 fail:2 skip:27 time:444s fi-ilk-650 total:289 pass:228 dwarn:0 dfail:0 fail:0 skip:61 time:426s fi-ivb-3520m total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:489s fi-ivb-3770 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:467s fi-kbl-7500u total:289 pass:262 dwarn:1 dfail:0 fail:2 skip:24 time:512s fi-kbl-7560u total:289 pass:268 dwarn:0 dfail:0 fail:2 skip:19 time:580s fi-kbl-7567u total:289 pass:267 dwarn:0 dfail:0 fail:2 skip:20 time:498s fi-kbl-r total:289 pass:260 dwarn:0 dfail:0 fail:2 skip:27 time:596s fi-skl-6260u total:289 pass:267 dwarn:0 dfail:0 fail:2 skip:20 time:470s fi-skl-6600u total:289 pass:260 dwarn:0 dfail:0 fail:2 skip:27 time:600s fi-skl-6700hq total:289 pass:261 dwarn:0 dfail:0 fail:2 skip:26 time:659s fi-skl-6700k total:289 pass:263 dwarn:0 dfail:0 fail:2 skip:24 time:542s fi-skl-6770hq total:289 pass:267 dwarn:0 dfail:0 fail:2 skip:20 time:518s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:457s fi-snb-2520m total:289 pass:250 dwarn:0 dfail:0 fail:0 skip:39 time:571s fi-snb-2600 total:289 pass:249 dwarn:0 dfail:0 fail:0 skip:40 time:421s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_448/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for igt/gem_workarounds: Test all types of workarounds (rev4)
In reply to Oscar Mateo== Series Details ==
== Series Details ==
Series: igt/gem_workarounds: Test all types of workarounds (rev4)
URL : https://patchwork.freedesktop.org/series/31612/
State : success
== Summary ==
Test drv_module_reload:
Subgroup basic-reload-inject:
pass -> DMESG-WARN (shard-hsw) fdo#102707 +1
Test kms_setmode:
Subgroup basic:
pass -> FAIL (shard-hsw) fdo#99912
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-primscrn-cur-indfb-move:
skip -> PASS (shard-hsw)
Test kms_cursor_crc:
Subgroup cursor-64x64-onscreen:
skip -> PASS (shard-hsw)
Test drv_suspend:
Subgroup forcewake:
skip -> PASS (shard-hsw)
Test kms_flip:
Subgroup plain-flip-fb-recreate:
pass -> FAIL (shard-hsw) fdo#100368
Test kms_plane:
Subgroup plane-panning-top-left-pipe-A-planes:
skip -> PASS (shard-hsw)
Test perf:
Subgroup oa-exponents:
fail -> PASS (shard-hsw) fdo#102254
Test kms_atomic:
Subgroup atomic_invalid_params:
skip -> PASS (shard-hsw)fdo#102707 https://bugs.freedesktop.org/show_bug.cgi?id=102707
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#102254 https://bugs.freedesktop.org/show_bug.cgi?id=102254
shard-hsw total:2539 pass:1392 dwarn:1 dfail:0 fail:53 skip:1093 time:9346s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_448/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx