From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Subject: Re: [PATCH v2.1 3/3] drm/edid: Switch DDC when reading the EDID Date: Mon, 17 Aug 2015 12:41:32 +0200 Message-ID: <20150817104130.GC8453@ulmo.nvidia.com> References: <7984d8eacbb0386ca52e3fdf2ad2554dc90ff1fe.1439739853.git.lukas@wunner.de> <3f927fb1a1df18bfdbb501b98a6b2dcd5c064f02.1439739853.git.lukas@wunner.de> <3d6de562c9dd7387318f90f2dc1578e56cb666c1.1439739853.git.lukas@wunner.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1486342302==" Return-path: Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id D04846E8D9 for ; Mon, 17 Aug 2015 03:42:38 -0700 (PDT) Received: by pawq9 with SMTP id q9so8416024paw.3 for ; Mon, 17 Aug 2015 03:42:38 -0700 (PDT) In-Reply-To: <3d6de562c9dd7387318f90f2dc1578e56cb666c1.1439739853.git.lukas@wunner.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Lukas Wunner Cc: Daniel Vetter , Seth Forshee , dri-devel@lists.freedesktop.org, Dave Airlie List-Id: dri-devel@lists.freedesktop.org --===============1486342302== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="DIOMP1UsTsWJauNi" Content-Disposition: inline --DIOMP1UsTsWJauNi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 14, 2015 at 06:28:35PM +0200, Lukas Wunner wrote: > Originally by Seth Forshee , 2012-10-04: > Some dual graphics machines support muxing the DDC separately from the > display, so make use of this functionality when reading the EDID on the > inactive GPU. Also serialize drm_get_edid() with a mutex to avoid races > on the DDC mux state. >=20 > Modified by Dave Airlie , 2012-12-22: > I can't figure out why I didn't like this, but I rewrote this [...] to > lock/unlock the ddc lines [...]. I think I'd prefer something like that > otherwise the interface got really ugly. >=20 > Modified by Lukas Wunner , 2015-03-27: > Unlock DDC lines if drm_probe_ddc() fails. >=20 > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=3D88861 > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=3D61115 > Tested-by: Pierre Moreau > [MBP 5,3 2009 nvidia 9400M + 9600M GT pre-retina] > Tested-by: Paul Hordiienko > [MBP 6,2 2010 intel ILK + nvidia GT216 pre-retina] > Tested-by: William Brown > [MBP 8,2 2011 intel SNB + amd turks pre-retina] > Tested-by: Lukas Wunner > [MBP 9,1 2012 intel IVB + nvidia GK107 pre-retina] > Tested-by: Bruno Bierbaumer > [MBP 11,3 2013 intel HSW + nvidia GK107 retina -- work in progress] >=20 > Cc: Seth Forshee > Cc: Dave Airlie > Signed-off-by: Lukas Wunner > --- > drivers/gpu/drm/drm_edid.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > index e6e05bb..cdb2fa1 100644 > --- a/drivers/gpu/drm/drm_edid.c > +++ b/drivers/gpu/drm/drm_edid.c > @@ -32,6 +32,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1377,13 +1378,21 @@ struct edid *drm_get_edid(struct drm_connector *c= onnector, > struct i2c_adapter *adapter) > { > struct edid *edid; > + struct pci_dev *pdev =3D connector->dev->pdev; > =20 > - if (!drm_probe_ddc(adapter)) > + vga_switcheroo_lock_ddc(pdev); > + > + if (!drm_probe_ddc(adapter)) { > + vga_switcheroo_unlock_ddc(pdev); > return NULL; > + } > =20 > edid =3D drm_do_get_edid(connector, drm_do_probe_ddc_edid, adapter); > if (edid) > drm_get_displayid(connector, edid); > + > + vga_switcheroo_unlock_ddc(pdev); > + > return edid; > } > EXPORT_SYMBOL(drm_get_edid); I think this is backwards and it'd be more explicit (though I suspect slightly more work for this patch) to add a separate helper that does the VGA switcheroo wrapping rather than have this in drm_get_edid() where essentially every driver will go through the motions even if it doesn't remotely support switcheroo. Thierry --DIOMP1UsTsWJauNi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJV0bpaAAoJEN0jrNd/PrOhWxQQAL6NILW+bkrGDbG/ayO808tX WXHHD3QiWPXEtTszCMx2ZZpwQ1/dJxmO06YunyQ2UB8eLF2p9TgMBUiOHSyfRuQY FyBmEjL/6hW9RHIzG8QjWV0zGUIL5qdO4/is+N1/p+vJGlHMlZDp4WtUSoqNSl1a 7KCVaxqBUtl04QSClXNBnV+OOb0YlNi+1EhMpQWTjoQrt3t86yIyJHq1rWX7+y8/ AtcgNLKrSNDHyesy5G/37OO+ZwvmOs2AKtFsvD2LZ/lK3EqsYCywm/cVYsQqR1NU f2zSQCVW5ZYXmEmDmIoMnI2b6ZDt3ZnqsRWQpl04X2zGeMigw398AjXdg3bnvgnG tmdFdKYtnaGIWFmsjfzQdVccfq/ljlBB+r5vht+iSdQBM8EqR2Y5MRLlEEK8Vb5X kndR7CKV3A+Cc7YqnibBB28HEXj525wSurzboX+lMWAXACN4z3UF/AZkIEZTJ9CD Fz5AdYsIeePJ/InHH3lU3r7xLcdjpPRmA6rftFHrVU9y5+lpuMRaJWay8gBINunA arK+732p3/P6OPj4S2+a+o3F5+/EzQkjvXpeHOwa8SyXEoV/xWHLs6Z5vnDa3N78 FGXRm+rbxAWRwyWRnn5gVLHkdr/rDZAJMnBKXl16az3I1YGoqcO81rNblIOHUd1n Q4mUTDtTNfqwqmQ9UZOL =uo2C -----END PGP SIGNATURE----- --DIOMP1UsTsWJauNi-- --===============1486342302== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHA6Ly9saXN0 cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9kcmktZGV2ZWwK --===============1486342302==--