From: Daniel Vetter Subject: Re: [PATCH 4/4] drm/i915: Intel-specific primary plane handling (v6) Date: Thu, 15 May 2014 23:20:39 +0200 Message-ID: <20140515212039.GB8790@phenom.ffwll.local> References: <1398877623-16930-1-git-send-email-matthew.d.roper@intel.com> <1398877623-16930-5-git-send-email-matthew.d.roper@intel.com> <20140515155228.GF27580@intel.com> <20140515163755.GD23405@intel.com> <20140515170048.GG27580@intel.com> <20140515193517.GE23405@intel.com> <20140515204952.GW8790@phenom.ffwll.local> <20140515205939.GF23405@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) by gabe.freedesktop.org (Postfix) with ESMTP id B83BF6E1CA for ; Thu, 15 May 2014 14:20:43 -0700 (PDT) Received: by mail-ee0-f49.google.com with SMTP id e53so1002170eek.8 for ; Thu, 15 May 2014 14:20:42 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20140515205939.GF23405@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Matt Roper Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Thu, May 15, 2014 at 01:59:39PM -0700, Matt Roper wrote: > On Thu, May 15, 2014 at 10:49:52PM +0200, Daniel Vetter wrote: > > On Thu, May 15, 2014 at 12:35:17PM -0700, Matt Roper wrote: > > > On Thu, May 15, 2014 at 08:00:48PM +0300, Ville Syrj=E4l=E4 wrote: > > > > On Thu, May 15, 2014 at 09:37:55AM -0700, Matt Roper wrote: > > > > > On Thu, May 15, 2014 at 06:52:28PM +0300, Ville Syrj=E4l=E4 wrote: > > > > > ... > > > > > > = > > > > > > > + }; > > > > > > > + bool visible; > > > > > > > + int ret; > > > > > > > + > > > > > > > + ret =3D drm_primary_helper_check_update(plane, crtc, fb, > > > > > > > + &src, &dest, &clip, > > > > > > > + DRM_PLANE_HELPER_NO_SCALING, > > > > > > > + DRM_PLANE_HELPER_NO_SCALING, > > > > > > > + false, true, &visible); > > > > > > > + if (ret) > > > > > > > + return ret; > > > > > > > + > > > > > > > + if (!visible) > > > > > > > + return intel_primary_plane_disable(plane); > > > > > > = > > > > > > Here we unpin the old fb... > > > > > > = > > > > > > > + > > > > > > > + /* > > > > > > > + * If the CRTC isn't enabled, we're just pinning the frameb= uffer, > > > > > > > + * updating the fb pointer, and returning without touching = the > > > > > > > + * hardware. This allows us to later do a drmModeSetCrtc w= ith fb=3D-1 to > > > > > > > + * turn on the display with all planes setup as desired. > > > > > > > + */ > > > > > > > + if (!crtc->enabled) > > > > > > > + /* Pin and return without programming hardware */ > > > > > > > + return intel_pin_and_fence_fb_obj(dev, > > > > > > > + to_intel_framebuffer(fb)->obj, > > > > > > > + NULL); > > > > > > = > > > > > > ...but here we just pin the new fb and leave the old also pinne= d? > > > > > > = > > > > > > Something's a bit fishy here. Also a non-enabled crtc but visib= le primary > > > > > > plane doesn't seem to make sense. We also need to remember that= set_base > > > > > > will always unpin the old_fb. So if something can result in set= _base > > > > > > being called w/ old_fb!=3DNULL when it's not pinned, we'll be i= n deep > > > > > > doodoo. > > > > > = > > > > > Right, I guess we need to unpin the old fb, if any, here as well = in case > > > > > they perform several setplane() calls while the crtc is disabled. > > > > > = > > > > > Eventually the crtc will get reenabled by a drmModeSetCrtc call. = If we > > > > > do setcrtc(fb =3D -1), then it should keep whatever fb we've alre= ady > > > > > pinned via the setplane. If they provide a new fb, then the pinn= ing > > > > > we're doing here will get unpinned by the set_base that gets call= ed. > > > > > = > > > > > I don't see a way that you can hit set_base with an unpinned > > > > > old_fb!=3DNULL (since the disable plane case farther up also clea= rs > > > > > primary->fb). > > > > = > > > > But it doesn't. > > > > = > > > = > > > Ah, you're right. I was conflating explicit disables (fb=3D0) with > > > implicit disables (clipped to invisible). I think the v7 I just sent > > > should handle this properly...for the implicit disable case we leave = the > > > fb pinned and pointed to by primary->fb. So when we switch to another > > > fb (or explicitly disable with fb=3D0), we should unpin it properly. > > = > > Do we have proper coverage for this fun in our primary plane helper tes= ts? > > This is the kind of complexity that freaks me out ;-) > > -Daniel > = > Was 'helper' in your question above a typo? The i-g-t tests I've > written have been intended for use with this patch (i.e., i915-specific > primary plane support), so I don't really have any tests that only test > the lesser, helper-provided functionality (and drivers using the helpers > shouldn't run into the things Ville is pointing out here because they > can't disable the primary plane independent of the crtc). > = > But assuming you meant the general i-g-t tests, yeah, I also posted a > slightly updated version so that it now tries to set multiple fb's while > the crtc is off. Since crtc=3Doff causes the primary plane to be fully > clipped and implicitly disabled, it should exercise these cases and > catch the pin/unpin mistakes that Ville's review caught. Yeah, s/helper// ;-) For the tests, do you also have some that use the implicit fb (i.e. fb =3D -1) with setcrtc? Just kinda for completeness. -Daniel -- = Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch