[Intel-gfx] [PATCH] drm/i915: Dumb down the semaphore logic

Ben Widawsky ben at bwidawsk.net
Fri Sep 2 16:02:54 CEST 2011


On Fri, Sep 02, 2011 at 09:54:32AM +0100, Chris Wilson wrote:
> On Thu,  1 Sep 2011 20:55:35 -0700, Ben Widawsky <ben at bwidawsk.net> wrote:
> > While I think the previous code is correct, it was hard to follow and
> > hard to debug. Since we already have a ring abstraction, might as well
> > use it to handle the semaphore updates and compares.
> > 
> > I don't expect this code to make semaphores better or worse, but you
> > never know...
> 
> So "dumbing it down" means using macros instead of small functions and
> putting magic values into the ring structure. I'm not sure if that's an
> improvement to readability at all.
> -Chris

The previous code for doing an update was non obvious to me. Obviously I
will be biased in thinking my code is easier to follow, but for the
existing code I had to map out exactly what it's doing every single time
I went through it to convince myself it is correct.

Using pointer arithmetic and then RING_SYNC_0 with math did not seem the
correct way to do it. As for the magic values, they started out as
non-magic, but got changed at some point during developing the patch. At
the end I went back to magic to reduce the LOC.  You'll notice the
comments there make them slightly less magic.

And although a lame argument... if a new ring comes along the previous code was
not very well equiped to handle it.

Ben



More information about the Intel-gfx mailing list