[Intel-gfx] [PATCH i-g-t] tests/drm_hw_lock: Tests for hw_lock fixes.
Chris Wilson
chris at chris-wilson.co.uk
Mon Apr 27 08:33:52 PDT 2015
On Mon, Apr 27, 2015 at 04:24:37PM +0100, Thomas Wood wrote:
> On 23 April 2015 at 15:07, Peter Antoine <peter.antoine at intel.com> wrote:
> > There are several issues with the hardware locks functions that stretch
> > from kernel crashes to priority escalations. This new test will test the
> > the fixes for these features.
> >
> > This test will cause a driver/kernel crash on un-patched kernels, the
> > following patches should be applied to stop the crashes:
> >
> > drm: Kernel Crash in drm_unlock
> > drm: Fixes unsafe deference in locks.
> >
> > Issue: VIZ-5485
> > Signed-off-by: Peter Antoine <peter.antoine at intel.com>
> > ---
> > lib/ioctl_wrappers.c | 19 +++++
> > lib/ioctl_wrappers.h | 1 +
> > tests/Makefile.sources | 1 +
> > tests/drm_hw_lock.c | 207 +++++++++++++++++++++++++++++++++++++++++++++++++
> > 4 files changed, 228 insertions(+)
> > create mode 100644 tests/drm_hw_lock.c
> >
> > diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> > index 000d394..ad8b3d3 100644
> > --- a/lib/ioctl_wrappers.c
> > +++ b/lib/ioctl_wrappers.c
> > @@ -964,6 +964,25 @@ bool gem_has_bsd2(int fd)
> > {
> > return gem_has_enable_ring(fd,LOCAL_I915_PARAM_HAS_BSD2);
> > }
> > +#define I915_PARAM_HAS_LEGACY_CONTEXT 35
>
>
> Please add some API documentation for this new function here.
>
> > +bool drm_has_legacy_context(int fd)
> > +{
> > + int tmp = 0;
> > + drm_i915_getparam_t gp;
> > +
> > + memset(&gp, 0, sizeof(gp));
> > + gp.value = &tmp;
> > + gp.param = I915_PARAM_HAS_LEGACY_CONTEXT;
> > +
> > + /*
> > + * if legacy context param is not supported, then it's old and we
> > + * can assume that the HW_LOCKS are supported.
> > + */
> > + if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp) != 0)
> > + return true;
Would not a simpler test be to try and legally acquire a hwlock?
If it fails, hwlocks are not supported. No need for a PARAM.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list