lib/drmtest: Avoid calling exit handlers multiple times

- reset the count when forking
- don't add the same handler multiple times
- don't restore the exit signal handlers in the forked helper
  process
- reset the exit handler count once called to make sure we don't call
  it multiple times when dying
- don't wait for the signal helper if it's gone already

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: fixup for the prefault rework

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: create helpers for forking helper threads

The upshot is that we can share the logic to make sure the helpers
are all properly stoved again in a 2nd step.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
tests/gem_reloc_vs_gpu: use igt_fork_helper

Now we do a waitpid instead of a simple wait which could eat
the "wrong" child ...

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: consolidate the helper process killing in one exit handler

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: double-check that we clean up helper processes

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: Use ARRAY_SIZE

Less fragile ...

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: skip when prefault control isn't available

Instead of crashing with an igt_assert. Fixes the only crashing test
when running igt on non-intel systems.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: Fix igt_stop_signal_helper for subtest listing

We need to bail out early for otherwise we'll hit the
!signal_helper->running assert.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: Reject igt_fork from within igt_fork earlier

We reject it in igt_waitchildren already, but earlier is better.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: handle SIGBUS in the exit handlers

Our kernel likes to occasionally kill process with a SIGBUS when this
shouldn't ever happen. Hence also handle this signal in the exit
handler infrastructure.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
tests/gem_reloc_vs_gpu: some fixes

- Clear the igt_helper_process struct to avoid hitting asserts.
- Fix up the logic for enumerating forked processes.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
tests/gem_persisten_relocs: Update like gem_reloc_vs_pug

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: clean up children in an exit handler

Also be a bit more careful with killing them in general.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: don't frob signals in __igt_fork_helper

We shut up the exit handlers already by clearing the array.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: Restore default sighandlers

Forked tests ended up restoring the sighandlers already inherited
from the parent, resulting in endless signal loops through our
atexit handler.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: drop unused oldsig variabel

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: skip suspend tests in simulation

The simulator doesn't like this nor really support it :(

v2: We've tried to a more gentle resume testing using the pm_test
infrastructure, but that alos failed. So add a FIXME comment that we
need to improve things a bit here.

Cc: Ben Widawsky <benjamin.widawsky@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
man: Fixes typo in intel_lid.man

Signed-off-by: Eero Tamminen <eero.t.tamminen@intel.com>
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
overlay: Fix stale mention to x11-position.c

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>