From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Widawsky Subject: Re: [PATCH] drm/i915: Dumb down the semaphore logic Date: Fri, 2 Sep 2011 14:02:54 +0000 Message-ID: <20110902140254.GA30736@cloud01> References: <1314935735-5451-1-git-send-email-ben@bwidawsk.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from cloud01.chad-versace.us (184-106-247-128.static.cloud-ips.com [184.106.247.128]) by gabe.freedesktop.org (Postfix) with ESMTP id 8744AA15CC for ; Fri, 2 Sep 2011 06:59:51 -0700 (PDT) Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Chris Wilson Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Fri, Sep 02, 2011 at 09:54:32AM +0100, Chris Wilson wrote: > On Thu, 1 Sep 2011 20:55:35 -0700, Ben Widawsky 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