From: Chris Wilson Subject: Re: [PATCH v2] drm: Only create a cmdline mode if no probed modes match Date: Fri, 22 May 2015 10:54:12 +0100 Message-ID: <20150522095412.GA25229@nuc-i3427.alporthouse.com> References: <5534F9D6.4080908@radekdostal.com> <1429536536-4107-1-git-send-email-chris@chris-wilson.co.uk> <20150522090327.GX18908@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Content-Disposition: inline In-Reply-To: <20150522090327.GX18908@intel.com> Sender: stable-owner@vger.kernel.org To: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Cc: dri-devel@lists.freedesktop.org, Radek =?iso-8859-1?Q?Dost=E1l?= , Jesse Barnes , Daniel Vetter , Julia Lemire , Dave Airlie , stable@vger.kernel.org List-Id: dri-devel@lists.freedesktop.org On Fri, May 22, 2015 at 12:03:27PM +0300, Ville Syrj=E4l=E4 wrote: > On Mon, Apr 20, 2015 at 02:28:56PM +0100, Chris Wilson wrote: > > The intention of using video=3D: is primarily to s= elect > > the user's preferred resolution at startup. Currently we always cre= ate a > > new mode irrespective of whether the monitor has a native mode at t= he > > desired resolution. This has the issue that we may then select the = fake > > mode rather the native mode during fb_helper->inital_config() and s= o > > if the fake mode is invalid we then end up with a loss of signal. O= ops. > > This invalid fake mode would also be exported to userspace, who > > potentially may make the same mistake. > >=20 > > To avoid this issue, we filter out the added command line mode if w= e > > detect the desired resolution (and clock if specified) amongst the > > probed modes. This fixes the immediate problem of adding a duplicat= e > > mode, but perhaps more generically we should avoid adding a GTF mod= e if > > the monitor has an EDID that is not GTF-compatible, or similarly fo= r > > CVT. > >=20 > > A second issue sneaked into this patch is to add the cmdline mode m= ode > > ahead of the absolute fallback 1024x768 mode. That is if the user h= as > > specified a mode that we create as a fallback, we do not need to ad= d a > > second unused fallback mode. > >=20 > > Fixes regression from > >=20 > > commit eaf99c749d43ae74ac7ffece5512f3c73f01dfd2 > > Author: Chris Wilson > > Date: Wed Aug 6 10:08:32 2014 +0200 > >=20 > > drm: Perform cmdline mode parsing during connector initialisati= on > >=20 > > that breaks HDMI output on BeagleBone Black with LG TV (model 19LS4= R-ZA). > >=20 > > v2: Explicitly delete our earlier cmdline mode > >=20 > > Reported-by: Radek Dost=E1l > > Signed-off-by: Chris Wilson > > Cc: Radek Dost=E1l > > Cc: Jesse Barnes > > Cc: Ville Syrj=E4l=E4 > > Cc: Daniel Vetter > > Cc: dri-devel@lists.freedesktop.org > > Cc: Julia Lemire > > Cc: Dave Airlie > > Cc: stable@vger.kernel.org > > --- > > drivers/gpu/drm/drm_modes.c | 2 +- > > drivers/gpu/drm/drm_probe_helper.c | 39 ++++++++++++++++++++++++++= +++++++++--- > > 2 files changed, 37 insertions(+), 4 deletions(-) > >=20 > > diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_mode= s.c > > index 213b11ea69b5..13293e009990 100644 > > --- a/drivers/gpu/drm/drm_modes.c > > +++ b/drivers/gpu/drm/drm_modes.c > > @@ -1400,7 +1400,7 @@ drm_mode_create_from_cmdline_mode(struct drm_= device *dev, > > if (!mode) > > return NULL; > > =20 > > - mode->type |=3D DRM_MODE_TYPE_USERDEF; > > + mode->type |=3D DRM_MODE_TYPE_USERDEF | DRM_MODE_TYPE_DRIVER; >=20 > Why do we need the DRIVER flag here? So we can differentiate it from an equivalent mode added by the user later on. > > + /* Remove the existing fake mode */ > > + list_for_each_entry(mode, &connector->modes, head) { > > + if ((mode->type & (DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_USERDEF= )) !=3D (DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_USERDEF)) > > + continue; >=20 > Doesn't drm_mode_connector_list_update() kill it from the list > eventually if there's no matching mode present on the > probed_modes list? Hmm, that's what I thought I tried at first. If I remember correctly we had to set mode->status in order to prune it since drm_mode_connector_list_update() itself doesn't do the deletion. Using the mode->status was problematic, and the simplest way to do delete the original cmdline mode was by explicitly removing it ourselves. > > @@ -179,9 +212,9 @@ static int drm_helper_probe_single_connector_mo= des_merge_bits(struct drm_connect > > count =3D (*connector_funcs->get_modes)(connector); > > } > > =20 > > + count +=3D drm_helper_probe_add_cmdline_mode(connector); > > if (count =3D=3D 0 && connector->status =3D=3D connector_status_c= onnected) > > count =3D drm_add_modes_noedid(connector, 1024, 768); > > - count +=3D drm_helper_probe_add_cmdline_mode(connector); >=20 > Hmm. This means drm_add_modes_noedid() will never be called if the > cmdline mode is present, and hence the mode list will only ever have > that single mode user specified mode. Not sure if that can be conside= red > a real problem or not. I consider it to a real problem as it goes against my expectations as a user, that is if I specify a mode to use, I expect that mode to be used= =2E Doesn't need to be in this patch though. -Chris --=20 Chris Wilson, Intel Open Source Technology Centre