cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

i915_selftest.h (4516B)


      1/*
      2 * Copyright © 2016 Intel Corporation
      3 *
      4 * Permission is hereby granted, free of charge, to any person obtaining a
      5 * copy of this software and associated documentation files (the "Software"),
      6 * to deal in the Software without restriction, including without limitation
      7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      8 * and/or sell copies of the Software, and to permit persons to whom the
      9 * Software is furnished to do so, subject to the following conditions:
     10 *
     11 * The above copyright notice and this permission notice (including the next
     12 * paragraph) shall be included in all copies or substantial portions of the
     13 * Software.
     14 *
     15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
     21 * IN THE SOFTWARE.
     22 */
     23
     24#ifndef __I915_SELFTEST_H__
     25#define __I915_SELFTEST_H__
     26
     27#include <linux/types.h>
     28
     29struct pci_dev;
     30struct drm_i915_private;
     31
     32struct i915_selftest {
     33	unsigned long timeout_jiffies;
     34	unsigned int timeout_ms;
     35	unsigned int random_seed;
     36	char *filter;
     37	int mock;
     38	int live;
     39	int perf;
     40};
     41
     42#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
     43#include <linux/fault-inject.h>
     44
     45extern struct i915_selftest i915_selftest;
     46
     47int i915_mock_selftests(void);
     48int i915_live_selftests(struct pci_dev *pdev);
     49int i915_perf_selftests(struct pci_dev *pdev);
     50
     51/* We extract the function declarations from i915_mock_selftests.h and
     52 * i915_live_selftests.h Add your unit test declarations there!
     53 *
     54 * Mock unit tests are run very early upon module load, before the driver
     55 * is probed. All hardware interactions, as well as other subsystems, must
     56 * be "mocked".
     57 *
     58 * Live unit tests are run after the driver is loaded - all hardware
     59 * interactions are real.
     60 */
     61#define selftest(name, func) int func(void);
     62#include "selftests/i915_mock_selftests.h"
     63#undef selftest
     64#define selftest(name, func) int func(struct drm_i915_private *i915);
     65#include "selftests/i915_live_selftests.h"
     66#include "selftests/i915_perf_selftests.h"
     67#undef selftest
     68
     69struct i915_subtest {
     70	int (*func)(void *data);
     71	const char *name;
     72};
     73
     74int __i915_nop_setup(void *data);
     75int __i915_nop_teardown(int err, void *data);
     76
     77int __i915_live_setup(void *data);
     78int __i915_live_teardown(int err, void *data);
     79
     80int __intel_gt_live_setup(void *data);
     81int __intel_gt_live_teardown(int err, void *data);
     82
     83int __i915_subtests(const char *caller,
     84		    int (*setup)(void *data),
     85		    int (*teardown)(int err, void *data),
     86		    const struct i915_subtest *st,
     87		    unsigned int count,
     88		    void *data);
     89#define i915_subtests(T, data) \
     90	__i915_subtests(__func__, \
     91			__i915_nop_setup, __i915_nop_teardown, \
     92			T, ARRAY_SIZE(T), data)
     93#define i915_live_subtests(T, data) ({ \
     94	typecheck(struct drm_i915_private *, data); \
     95	__i915_subtests(__func__, \
     96			__i915_live_setup, __i915_live_teardown, \
     97			T, ARRAY_SIZE(T), data); \
     98})
     99#define intel_gt_live_subtests(T, data) ({ \
    100	typecheck(struct intel_gt *, data); \
    101	__i915_subtests(__func__, \
    102			__intel_gt_live_setup, __intel_gt_live_teardown, \
    103			T, ARRAY_SIZE(T), data); \
    104})
    105
    106#define SUBTEST(x) { x, #x }
    107
    108#define I915_SELFTEST_DECLARE(x) x
    109#define I915_SELFTEST_ONLY(x) unlikely(x)
    110#define I915_SELFTEST_EXPORT
    111
    112#else /* !IS_ENABLED(CONFIG_DRM_I915_SELFTEST) */
    113
    114static inline int i915_mock_selftests(void) { return 0; }
    115static inline int i915_live_selftests(struct pci_dev *pdev) { return 0; }
    116static inline int i915_perf_selftests(struct pci_dev *pdev) { return 0; }
    117
    118#define I915_SELFTEST_DECLARE(x)
    119#define I915_SELFTEST_ONLY(x) 0
    120#define I915_SELFTEST_EXPORT static
    121
    122#endif
    123
    124/* Using the i915_selftest_ prefix becomes a little unwieldy with the helpers.
    125 * Instead we use the igt_ shorthand, in reference to the intel-gpu-tools
    126 * suite of uabi test cases (which includes a test runner for our selftests).
    127 */
    128
    129#define IGT_TIMEOUT(name__) \
    130	unsigned long name__ = jiffies + i915_selftest.timeout_jiffies
    131
    132__printf(2, 3)
    133bool __igt_timeout(unsigned long timeout, const char *fmt, ...);
    134
    135#define igt_timeout(t, fmt, ...) \
    136	__igt_timeout((t), KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
    137
    138void igt_hexdump(const void *buf, size_t len);
    139
    140#endif /* !__I915_SELFTEST_H__ */