From: Daniel Vetter Subject: Re: [PATCH 2/2] drm/i915: Make use of intel_fb_obj() Date: Tue, 8 Jul 2014 13:14:12 +0200 Message-ID: <20140708111412.GY17271@phenom.ffwll.local> References: <1404782508-9007-1-git-send-email-matthew.d.roper@intel.com> <1404782508-9007-2-git-send-email-matthew.d.roper@intel.com> <20140708064713.GC26405@nuc-i3427.alporthouse.com> <20140708095118.GT17271@phenom.ffwll.local> <20140708100649.GK26405@nuc-i3427.alporthouse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-wg0-f49.google.com (mail-wg0-f49.google.com [74.125.82.49]) by gabe.freedesktop.org (Postfix) with ESMTP id EFE766E534 for ; Tue, 8 Jul 2014 04:14:01 -0700 (PDT) Received: by mail-wg0-f49.google.com with SMTP id a1so2411455wgh.32 for ; Tue, 08 Jul 2014 04:14:01 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20140708100649.GK26405@nuc-i3427.alporthouse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Chris Wilson , Daniel Vetter , Matt Roper , intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Tue, Jul 08, 2014 at 11:06:49AM +0100, Chris Wilson wrote: > On Tue, Jul 08, 2014 at 11:51:18AM +0200, Daniel Vetter wrote: > > On Tue, Jul 08, 2014 at 07:47:13AM +0100, Chris Wilson wrote: > > > On Mon, Jul 07, 2014 at 06:21:48PM -0700, Matt Roper wrote: > > > > This should hopefully simplify the display code slightly and also > > > > solves at least one mistake in intel_pipe_set_base() where > > > > to_intel_framebuffer(fb)->obj is referenced during local variable > > > > initialization, before 'if (!fb)' gets checked. > > > > > > > > Potential uses of this macro were identified via the following > > > > Coccinelle patch: > > > > > > > > @@ > > > > expression E; > > > > @@ > > > > * to_intel_framebuffer(E)->obj > > > > > > > > @@ > > > > expression E; > > > > identifier I; > > > > @@ > > > > I = to_intel_framebuffer(E); > > > > ... > > > > * I->obj > > > > > > > > Signed-off-by: Matt Roper > > > > > > The only drawback is that I am suddenly nervous of potential NULL > > > objs... > > > > I concur with Chris here, I think intel_fb_obj should be a static inline > > and first check for fb == NULL. To catch abuse we could do an > > > > if (WARN_ON(!fb)) > > return NULL; > > > > return to_intel_framebuffer(fb)->obj; > > > > The most likely abuse is that we call intel_fb_obj before checking fb for > > NULL, so the WARN is better than a BUG_ON. With that I don't think we need > > to change the checks as Chris suggested here. > > This came about because of one path where we should have expected fb to > be NULL. Having a WARN followed by a GPF isn't any better than the GPF, > in which case this patch is superfluous and you would rather just fix > the single callsite where the bug occurred. Ok, I've missed the context then. Anyway I like the idea of intel_fb_obj and that it'll make the code more robust against misorderings of fb == NULL checks. Please ignore me and proceed ;-) -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch