[Intel-gfx] [PATCH v2] drm/i915/selftests: Test i915_sw_fence/dma_fence interop

Chris Wilson chris at chris-wilson.co.uk
Tue Jan 16 10:05:55 UTC 2018


Quoting Tvrtko Ursulin (2018-01-16 09:48:48)
> 
> On 15/01/2018 20:43, Chris Wilson wrote:
> > +static struct dma_fence *alloc_dma_fence(void)
> > +{
> > +     struct dma_fence *dma;
> > +
> > +     dma = kmalloc(sizeof(*dma), GFP_KERNEL);
> > +     if (dma)
> > +             dma_fence_init(dma, &mock_fence_ops, &mock_fence_lock, 0, 0);
> > +
> > +     return dma;
> > +}
> > +
> > +static struct i915_sw_fence *
> > +wrap_dma_fence(struct dma_fence *dma, unsigned long delay)
> 
> await_dma_fence?

Hmm, but no, I think I prefer having the distinction that this is
creating a i915_sw_fence rather than attaching it to an existing fence,
which is what the await routines do.

[snip]

> > +skip:
> > +     dma_fence_signal(dma);
> > +
> > +     if (!i915_sw_fence_done(timeout) || !i915_sw_fence_done(not)) {
> > +             pr_err("Fences unsignaled\n");
> > +             goto err;
> > +     }
> > +
> > +     free_fence(fetch_and_zero(&not));
> > +     free_fence(fetch_and_zero(&timeout));
> 
> A bit of an overkill with fetch_and_zero.

'Twas forgotten leftovers.
 
> > +     dma_fence_put(dma);
> > +
> > +     return 0;
> > +
> > +err:
> > +     dma_fence_signal(dma);
> > +     if (!IS_ERR_OR_NULL(timeout))
> > +             free_fence(timeout);
> > +     if (!IS_ERR_OR_NULL(not))
> > +             free_fence(not);
> > +     dma_fence_put(dma);
> > +     return err;
> > +}
> > +
> >   int i915_sw_fence_mock_selftests(void)
> >   {
> >       static const struct i915_subtest tests[] = {
> > @@ -618,6 +754,7 @@ int i915_sw_fence_mock_selftests(void)
> >               SUBTEST(test_chain),
> >               SUBTEST(test_ipc),
> >               SUBTEST(test_timer),
> > +             SUBTEST(test_dma_fence),
> >       };
> >   
> >       return i915_subtests(tests, NULL);
> > 
> 
> Looks OK anyway.
> 
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Ta,
-Chris


More information about the Intel-gfx mailing list