From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 02/38] drm/i915: Provide a hook for selftests
Date: Wed, 25 Jan 2017 13:50:01 +0200 [thread overview]
Message-ID: <1485345001.5030.18.camel@linux.intel.com> (raw)
In-Reply-To: <20170119114158.17941-3-chris@chris-wilson.co.uk>
On to, 2017-01-19 at 11:41 +0000, Chris Wilson wrote:
> Some pieces of code are independent of hardware but are very tricky to
> exercise through the normal userspace ABI or via debugfs hooks. Being
> able to create mock unit tests and execute them through CI is vital.
> Start by adding a central point where we can execute unit tests and
> a parameter to enable them. This is disabled by default as the
> expectation is that these tests will occasionally explode.
>
> To facilitate integration with igt, any parameter beginning with
> i915.igt__ is interpreted as a subtest executable independently via
> igt/drv_selftest.
>
> Two classes of selftests are recognised: mock unit tests and integration
> tests. Mock unit tests are run as soon as the module is loaded, before
> the device is probed. At that point there is no driver instantiated and
> all hw interactions must be "mocked". This is very useful for writing
> universal tests to exercise code not typically run on a broad range of
> architectures. Alternatively, you can hook into the live selftests and
> run when the device has been instantiated - hw interactions are real.
>
> v2: Add a macro for compiling conditional code for mock objects inside
> real objects.
> v3: Differentiate between mock unit tests and late integration test.
> v4: List the tests in natural order, use igt to sort after modparam.
> v5: s/late/live/
> v6: s/unsigned long/unsigned int/
> v7: Use igt_ prefixes for long helpers.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> #v1
<SNIP>
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -3,6 +3,7 @@
> # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>
> subdir-ccflags-$(CONFIG_DRM_I915_WERROR) := -Werror
> +subdir-ccflags-$(CONFIG_DRM_I915_SELFTEST) += -I$(src) -I$(src)/selftests
Similar to drm, add selftests/Makefile, to get rid of this.
> @@ -116,6 +117,9 @@ i915-y += dvo_ch7017.o \
>
> # Post-mortem debug and GPU hang state capture
> i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o
> +i915-$(CONFIG_DRM_I915_SELFTEST) += \
> + selftests/i915_random.o \
> + selftests/i915_selftest.o
>
Ditto.
> @@ -499,7 +501,17 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> if (vga_switcheroo_client_probe_defer(pdev))
> return -EPROBE_DEFER;
>
> - return i915_driver_load(pdev, ent);
> + err = i915_driver_load(pdev, ent);
> + if (err)
> + return err;
> +
> + err = i915_live_selftests(pdev);
> + if (err) {
> + i915_driver_unload(pci_get_drvdata(pdev));
> + return err > 0 ? -ENOTTY : err;
What's up with this?
> static void i915_pci_remove(struct pci_dev *pdev)
> @@ -521,6 +533,11 @@ static struct pci_driver i915_pci_driver = {
> static int __init i915_init(void)
> {
> bool use_kms = true;
> + int err;
> +
> + err = i915_mock_selftests();
> + if (err)
> + return err > 0 ? 0 : err;
Especially this, is this for skipping the device init completely?
> +int i915_subtests(const char *caller,
> + const struct i915_subtest *st,
> + unsigned int count,
> + void *data);
> +#define i915_subtests(T, data) \
> + (i915_subtests)(__func__, T, ARRAY_SIZE(T), data)
Argh, why not __i915_subtests like good people do?
> +/* Using the i915_selftest_ prefix becomes a little unwieldy with the helpers.
> + * Instead we use the igt_ shorthand, in reference to the intel-gpu-tools
> + * suite of uabi test cases (which includes a test runner for our selftests).
> + */
I'd ask for an ack from Daniel/Jani on this.
> +static inline u32 i915_prandom_u32_max_state(u32 ep_ro, struct rnd_state *state)
> +{
> > + return upper_32_bits((u64)prandom_u32_state(state) * ep_ro);
> +}
Upstream material. Also I remember this stuff is in DRM too, so I
assume you cleanly copy pasted, and skip this randomization code.
> +++ b/drivers/gpu/drm/i915/selftests/i915_selftest.c
<SNIP>
> +/* Embed the line number into the parameter name so that we can order tests */
> +#define selftest(n, func) selftest_0(n, func, param(n))
> +#define param(n) __PASTE(igt__, __PASTE(__PASTE(__LINE__, __), mock_##n))
Hmm, you could reduce one __PASTE by making the ending __mock_##n?
> +static int run_selftests(const char *name,
> + struct selftest *st,
> + unsigned int count,
> + void *data)
> +{
> + int err = 0;
> +
> + while (!i915_selftest.random_seed)
> + i915_selftest.random_seed = get_random_int();
You know that in theory this might take an eternity. I'm not sure why
zero is not OK after this point?
> +
> + i915_selftest.timeout_jiffies =
> + i915_selftest.timeout_ms ?
> + msecs_to_jiffies_timeout(i915_selftest.timeout_ms) :
> + MAX_SCHEDULE_TIMEOUT;
You had a default value for the variable too, I guess that's not needed
now, and gets some bytes off .data.
> +
> + set_default_test_all(st, count);
> +
> + pr_info("i915: Performing %s selftests with st_random_seed=0x%x st_timeout=%u\n",
> + name, i915_selftest.random_seed, i915_selftest.timeout_ms);
> +
> + /* Tests are listed in order in i915_*_selftests.h */
> + for (; count--; st++) {
> + if (!st->enabled)
> + continue;
> +
> + cond_resched();
> + if (signal_pending(current))
> + return -EINTR;
> +
> + pr_debug("i915: Running %s\n", st->name);
I guess we shouldn't be hardcoding "i915" in strings.
> + if (data)
> + err = st->live(data);
> + else
> + err = st->mock();
I'd newline here.
> + if (err == -EINTR && !signal_pending(current))
> + err = 0;
> + if (err)
> + break;
> + }
> +
> + if (WARN(err > 0 || err == -ENOTTY,
> + "%s returned %d, conflicting with selftest's magic values!\n",
> + st->name, err))
> + err = -1;
> +
> + rcu_barrier();
Our tests themselves use no RCU, so at least drop a comment here,
internal driver implementation seems to bleed here.
> + return err;
> +}
> +
> +#define run_selftests(x, data) \
> + (run_selftests)(#x, x##_selftests, ARRAY_SIZE(x##_selftests), data)
Nooooo....
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-01-25 11:50 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-19 11:41 More selftests Chris Wilson
2017-01-19 11:41 ` [PATCH v2 01/38] drm: Provide a driver hook for drm_dev_release() Chris Wilson
2017-01-25 11:12 ` Joonas Lahtinen
2017-01-25 11:16 ` Chris Wilson
2017-01-19 11:41 ` [PATCH v2 02/38] drm/i915: Provide a hook for selftests Chris Wilson
2017-01-25 11:50 ` Joonas Lahtinen [this message]
2017-02-01 13:57 ` Chris Wilson
2017-01-19 11:41 ` [PATCH v2 03/38] drm/i915: Add some selftests for sg_table manipulation Chris Wilson
2017-02-01 11:17 ` Tvrtko Ursulin
2017-02-01 11:34 ` Chris Wilson
2017-02-02 12:41 ` Tvrtko Ursulin
2017-02-02 13:38 ` Chris Wilson
2017-01-19 11:41 ` [PATCH v2 04/38] drm/i915: Add unit tests for the breadcrumb rbtree, insert/remove Chris Wilson
2017-01-19 11:41 ` [PATCH v2 05/38] drm/i915: Add unit tests for the breadcrumb rbtree, completion Chris Wilson
2017-01-19 11:41 ` [PATCH v2 06/38] drm/i915: Add unit tests for the breadcrumb rbtree, wakeups Chris Wilson
2017-02-01 11:27 ` Tvrtko Ursulin
2017-02-01 11:43 ` Chris Wilson
2017-02-01 13:19 ` [PATCH v3] " Chris Wilson
2017-02-01 16:57 ` Tvrtko Ursulin
2017-02-01 17:08 ` Chris Wilson
2017-01-19 11:41 ` [PATCH v2 07/38] drm/i915: Mock the GEM device for self-testing Chris Wilson
2017-01-19 11:41 ` [PATCH v2 08/38] drm/i915: Mock a GGTT " Chris Wilson
2017-01-19 11:41 ` [PATCH v2 09/38] drm/i915: Mock infrastructure for request emission Chris Wilson
2017-01-19 11:41 ` [PATCH v2 10/38] drm/i915: Create a fake object for testing huge allocations Chris Wilson
2017-01-19 13:09 ` Matthew Auld
2017-01-19 11:41 ` [PATCH v2 11/38] drm/i915: Add selftests for i915_gem_request Chris Wilson
2017-01-19 11:41 ` [PATCH v2 12/38] drm/i915: Add a simple request selftest for waiting Chris Wilson
2017-01-19 11:41 ` [PATCH v2 13/38] drm/i915: Add a simple fence selftest to i915_gem_request Chris Wilson
2017-01-19 11:41 ` [PATCH v2 14/38] drm/i915: Simple selftest to exercise live requests Chris Wilson
2017-02-01 8:14 ` Joonas Lahtinen
2017-02-01 10:31 ` Chris Wilson
2017-01-19 11:41 ` [PATCH v2 15/38] drm/i915: Test simultaneously submitting requests to all engines Chris Wilson
2017-02-01 8:03 ` Joonas Lahtinen
2017-02-01 10:15 ` Chris Wilson
2017-01-19 11:41 ` [PATCH v2 16/38] drm/i915: Add selftests for object allocation, phys Chris Wilson
2017-01-19 11:41 ` [PATCH v2 17/38] drm/i915: Add a live seftest for GEM objects Chris Wilson
2017-01-19 11:41 ` [PATCH v2 18/38] drm/i915: Test partial mappings Chris Wilson
2017-01-19 11:41 ` [PATCH v2 19/38] drm/i915: Test exhaustion of the mmap space Chris Wilson
2017-01-19 11:41 ` [PATCH v2 20/38] drm/i915: Test coherency of and barriers between cache domains Chris Wilson
2017-01-19 13:01 ` Matthew Auld
2017-01-19 11:41 ` [PATCH v2 21/38] drm/i915: Move uncore selfchecks to live selftest infrastructure Chris Wilson
2017-01-19 11:41 ` [PATCH v2 22/38] drm/i915: Test all fw tables during mock selftests Chris Wilson
2017-01-19 11:41 ` [PATCH v2 23/38] drm/i915: Sanity check all registers for matching fw domains Chris Wilson
2017-01-19 11:41 ` [PATCH v2 24/38] drm/i915: Add some mock tests for dmabuf interop Chris Wilson
2017-01-19 11:41 ` [PATCH v2 25/38] drm/i915: Add initial selftests for i915_gem_gtt Chris Wilson
2017-01-19 11:41 ` [PATCH v2 26/38] drm/i915: Exercise filling the top/bottom portions of the ppgtt Chris Wilson
2017-01-31 12:32 ` Joonas Lahtinen
2017-01-19 11:41 ` [PATCH v2 27/38] drm/i915: Exercise filling the top/bottom portions of the global GTT Chris Wilson
2017-01-19 11:41 ` [PATCH v2 28/38] drm/i915: Fill different pages of the GTT Chris Wilson
2017-01-19 11:41 ` [PATCH v2 29/38] drm/i915: Exercise filling and removing random ranges from the live GTT Chris Wilson
2017-01-20 10:39 ` Matthew Auld
2017-01-19 11:41 ` [PATCH v2 30/38] drm/i915: Test creation of VMA Chris Wilson
2017-01-31 10:50 ` Joonas Lahtinen
2017-02-01 14:07 ` Chris Wilson
2017-01-19 11:41 ` [PATCH v2 31/38] drm/i915: Exercise i915_vma_pin/i915_vma_insert Chris Wilson
2017-01-19 11:41 ` [PATCH v2 32/38] drm/i915: Verify page layout for rotated VMA Chris Wilson
2017-02-01 13:26 ` Matthew Auld
2017-02-01 14:33 ` Tvrtko Ursulin
2017-02-01 14:55 ` Chris Wilson
2017-02-01 15:44 ` Tvrtko Ursulin
2017-01-19 11:41 ` [PATCH v2 33/38] drm/i915: Test creation of partial VMA Chris Wilson
2017-01-31 12:03 ` Joonas Lahtinen
2017-01-19 11:41 ` [PATCH v2 34/38] drm/i915: Live testing for context execution Chris Wilson
2017-01-25 14:51 ` Joonas Lahtinen
2017-01-19 11:41 ` [PATCH v2 35/38] drm/i915: Initial selftests for exercising eviction Chris Wilson
2017-01-19 11:41 ` [PATCH v2 36/38] drm/i915: Add mock exercise for i915_gem_gtt_reserve Chris Wilson
2017-01-25 13:30 ` Joonas Lahtinen
2017-01-19 11:41 ` [PATCH v2 37/38] drm/i915: Add mock exercise for i915_gem_gtt_insert Chris Wilson
2017-01-25 13:31 ` Joonas Lahtinen
2017-01-19 11:41 ` [PATCH v2 38/38] drm/i915: Add initial selftests for hang detection and resets Chris Wilson
2017-02-01 11:43 ` Mika Kuoppala
2017-02-01 13:31 ` Chris Wilson
2017-01-19 13:54 ` ✗ Fi.CI.BAT: failure for series starting with [v2,01/38] drm: Provide a driver hook for drm_dev_release() Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1485345001.5030.18.camel@linux.intel.com \
--to=joonas.lahtinen@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.