Re: [Intel-gfx] [PATCH] tests: Add drv_workarounds
On Fri, Aug 01, 2014 at 08:46:25PM +0300, Mika Kuoppala wrote: To check that static workarounds are set and stay after init, hang and suspend/restore. Checks are currently provided for ivb and bdw only. Signed-off-by: Mika Kuoppala mika.kuopp...@intel.com --- lib/intel_chipset.h |4 + lib/intel_workaround.h | 142 +++ tests/Makefile.sources |1 + tests/drv_workarounds.c | 244 +++ 4 files changed, 391 insertions(+) create mode 100644 lib/intel_workaround.h create mode 100644 tests/drv_workarounds.c diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h index 404c632..5a03f2b 100644 --- a/lib/intel_chipset.h +++ b/lib/intel_chipset.h @@ -263,6 +263,10 @@ void intel_check_pch(void); (devid) == PCI_CHIP_IVYBRIDGE_S || \ (devid) == PCI_CHIP_IVYBRIDGE_S_GT2) +#define IS_IVB_GT1(devid)((devid) == PCI_CHIP_IVYBRIDGE_GT1 || \ + (devid) == PCI_CHIP_IVYBRIDGE_M_GT1 || \ + (devid) == PCI_CHIP_IVYBRIDGE_S) + #define IS_VALLEYVIEW(devid) ((devid) == PCI_CHIP_VALLEYVIEW_PO || \ (devid) == PCI_CHIP_VALLEYVIEW_1 || \ (devid) == PCI_CHIP_VALLEYVIEW_2 || \ diff --git a/lib/intel_workaround.h b/lib/intel_workaround.h new file mode 100644 index 000..87e3a44 --- /dev/null +++ b/lib/intel_workaround.h @@ -0,0 +1,142 @@ +/* + * Copyright © 2013,2014 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. + * + * Authors: + *Mika Kuoppala mika.kuopp...@intel.com + * + */ + +#ifndef INTEL_WORKAROUNDS +#define INTEL_WORKAROUNDS + +#include intel_chipset.h +#include intel_io.h +#include igt_core.h + +static int __wa_devid = 0; + +struct wa { + const char * const name; + int (*f)(const int devid); +}; + +static void wa_init(const int devid) +{ + __wa_devid = devid; + intel_register_access_init(intel_get_pci_device(), 0); +} + +static void wa_fini(void) +{ + __wa_devid = 0; + intel_register_access_fini(); +} + +static int wa_check(const struct wa *wa) +{ + igt_assert(__wa_devid); + igt_assert(wa-name); + igt_assert(wa-f); + return wa-f(__wa_devid); +} + +#define WA(_name) /* _name */ static int _name##_fun(const int devid); \ + static const struct wa _name = \ + { #_name, _name##_fun };\ + static int _name##_fun(const int devid) + +#define wa_assert_m(reg, val, mask) { \ + unsigned int x; \ + igt_assert(mask); \ + x = intel_register_read(reg); \ + if (((x) (mask)) != (val)) { \ + igt_warn(a:0x%08x r:0x%08x m:0%08x v:0%08x\n, reg, x, mask, val); \ + return 1; \ + } \ + } + +#define wa_assert(reg, val) wa_assert_m(reg, val, 0x) +#define wa_assert_bit_set(reg, bit) wa_assert_m(reg, (1 bit), (1 bit)) +#define wa_assert_bit_clr(reg, bit) wa_assert_m(reg, 0, (1 bit)) + +#define WA_MASK(_name, reg, val, mask) \ + WA(_name) { \ + wa_assert_m(reg, val, mask);\ + return 0; \ + } + +#define WA_BIT_SET(_name, reg, bit) WA_MASK(_name, reg, (1 bit), (1 bit)) +#define WA_BIT_CLR(_name, reg, bit) WA_MASK(_name, reg, 0, (1 bit)) + + +/*
[Intel-gfx] [PATCH] tests: Add drv_workarounds
To check that static workarounds are set and stay after init, hang and suspend/restore. Checks are currently provided for ivb and bdw only. Signed-off-by: Mika Kuoppala mika.kuopp...@intel.com --- lib/intel_chipset.h |4 + lib/intel_workaround.h | 142 +++ tests/Makefile.sources |1 + tests/drv_workarounds.c | 244 +++ 4 files changed, 391 insertions(+) create mode 100644 lib/intel_workaround.h create mode 100644 tests/drv_workarounds.c diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h index 404c632..5a03f2b 100644 --- a/lib/intel_chipset.h +++ b/lib/intel_chipset.h @@ -263,6 +263,10 @@ void intel_check_pch(void); (devid) == PCI_CHIP_IVYBRIDGE_S || \ (devid) == PCI_CHIP_IVYBRIDGE_S_GT2) +#define IS_IVB_GT1(devid) ((devid) == PCI_CHIP_IVYBRIDGE_GT1 || \ +(devid) == PCI_CHIP_IVYBRIDGE_M_GT1 || \ +(devid) == PCI_CHIP_IVYBRIDGE_S) + #define IS_VALLEYVIEW(devid) ((devid) == PCI_CHIP_VALLEYVIEW_PO || \ (devid) == PCI_CHIP_VALLEYVIEW_1 || \ (devid) == PCI_CHIP_VALLEYVIEW_2 || \ diff --git a/lib/intel_workaround.h b/lib/intel_workaround.h new file mode 100644 index 000..87e3a44 --- /dev/null +++ b/lib/intel_workaround.h @@ -0,0 +1,142 @@ +/* + * Copyright © 2013,2014 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. + * + * Authors: + *Mika Kuoppala mika.kuopp...@intel.com + * + */ + +#ifndef INTEL_WORKAROUNDS +#define INTEL_WORKAROUNDS + +#include intel_chipset.h +#include intel_io.h +#include igt_core.h + +static int __wa_devid = 0; + +struct wa { + const char * const name; + int (*f)(const int devid); +}; + +static void wa_init(const int devid) +{ + __wa_devid = devid; + intel_register_access_init(intel_get_pci_device(), 0); +} + +static void wa_fini(void) +{ + __wa_devid = 0; + intel_register_access_fini(); +} + +static int wa_check(const struct wa *wa) +{ + igt_assert(__wa_devid); + igt_assert(wa-name); + igt_assert(wa-f); + return wa-f(__wa_devid); +} + +#define WA(_name) /* _name */ static int _name##_fun(const int devid); \ + static const struct wa _name = \ + { #_name, _name##_fun };\ + static int _name##_fun(const int devid) + +#define wa_assert_m(reg, val, mask) { \ + unsigned int x; \ + igt_assert(mask); \ + x = intel_register_read(reg); \ + if (((x) (mask)) != (val)) { \ + igt_warn(a:0x%08x r:0x%08x m:0%08x v:0%08x\n, reg, x, mask, val); \ + return 1; \ + } \ + } + +#define wa_assert(reg, val) wa_assert_m(reg, val, 0x) +#define wa_assert_bit_set(reg, bit) wa_assert_m(reg, (1 bit), (1 bit)) +#define wa_assert_bit_clr(reg, bit) wa_assert_m(reg, 0, (1 bit)) + +#define WA_MASK(_name, reg, val, mask) \ + WA(_name) { \ + wa_assert_m(reg, val, mask);\ + return 0; \ + } + +#define WA_BIT_SET(_name, reg, bit) WA_MASK(_name, reg, (1 bit), (1 bit)) +#define WA_BIT_CLR(_name, reg, bit) WA_MASK(_name, reg, 0, (1 bit)) + + +/* *** ivb workarounds ***/ +WA(WaDisablePSDDualDispatchEnable) { + if (IS_IVB_GT1(devid)) +