From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Subject: Re: [PATCH 2/4] drm/dp/i2c: send bare addresses to properly reset i2c connections (v3) Date: Mon, 7 Apr 2014 15:58:06 +0200 Message-ID: <20140407135804.GA25832@ulmo> References: <1396641519-18529-1-git-send-email-alexander.deucher@amd.com> <1396641519-18529-3-git-send-email-alexander.deucher@amd.com> <20140407074907.GA25718@ulmo> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2056957484==" Return-path: Received: from mail-bk0-f44.google.com (mail-bk0-f44.google.com [209.85.214.44]) by gabe.freedesktop.org (Postfix) with ESMTP id 685516E675 for ; Mon, 7 Apr 2014 06:58:59 -0700 (PDT) Received: by mail-bk0-f44.google.com with SMTP id mz13so690627bkb.3 for ; Mon, 07 Apr 2014 06:58:58 -0700 (PDT) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Alex Deucher Cc: Jani Nikula , Maling list - DRI developers , Alex Deucher , treding@nvidia.com List-Id: dri-devel@lists.freedesktop.org --===============2056957484== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="huq684BweRXVnRxX" Content-Disposition: inline --huq684BweRXVnRxX Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 07, 2014 at 09:44:06AM -0400, Alex Deucher wrote: > On Mon, Apr 7, 2014 at 3:49 AM, Thierry Reding = wrote: > > On Fri, Apr 04, 2014 at 03:58:37PM -0400, Alex Deucher wrote: > >> We need bare address packets at the start and end of > >> each i2c over aux transaction to properly reset the connection > >> between transactions. This mirrors what the existing dp i2c > >> over aux algo currently does. > >> > >> This fixes EDID fetches on certain monitors especially with > >> dp bridges. > >> > >> v2: update as per Ville's comments > >> - Set buffer to NULL for zero sized packets > >> - abort the entre transaction if one of the messages fails > >> v3: drop leftover debugging code > >> > >> Signed-off-by: Alex Deucher > >> Cc: Ville Syrj=C3=A4l=C3=A4 > >> Cc: Jani Nikula > >> Cc: Thierry Reding > >> Reviewed-by: Ville Syrj=C3=A4l=C3=A4 > >> --- > >> drivers/gpu/drm/drm_dp_helper.c | 52 +++++++++++++++++++++++---------= --------- > >> 1 file changed, 29 insertions(+), 23 deletions(-) > > > > Can we please document that zero-sized messages specify address-only > > transactions? Perhaps it would also be useful to mention that these can > > only happen for I2C-over-AUX messages. >=20 > Can do. I don't know of any uses for bare address packets with > regular aux off hand, but there may be cases I'm not familiar with. > Does anyone know of any use for a bare address packet with regular > aux? >=20 > > > >> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_= helper.c > >> index 74724aa..dfe4cf4 100644 > >> --- a/drivers/gpu/drm/drm_dp_helper.c > >> +++ b/drivers/gpu/drm/drm_dp_helper.c > >> @@ -664,12 +664,23 @@ static int drm_dp_i2c_xfer(struct i2c_adapter *a= dapter, struct i2c_msg *msgs, > >> int num) > >> { > >> struct drm_dp_aux *aux =3D adapter->algo_data; > >> - unsigned int i, j; > >> + unsigned int m, b; > > > > I don't see why these would need to be changed. i and j are perfectly > > fine loop variable names. >=20 > It was easier for me to follow the code since the variables matched > the objects they were iterating, but I can change them back if you'd > prefer. I think there's enough context in the surrounding code to make it obvious what they are used for. I also think that keeping the names makes the diff easier to follow. But if you feel really strongly about keeping m and b I can live with it. > >> - for (i =3D 0; i < num; i++) { > >> - struct drm_dp_aux_msg msg; > >> - int err; > >> + memset(&msg, 0, sizeof(msg)); > >> > >> + for (m =3D 0; m < num; m++) { > >> + msg.address =3D msgs[m].addr; > >> + msg.request =3D (msgs[m].flags & I2C_M_RD) ? > >> + DP_AUX_I2C_READ : > >> + DP_AUX_I2C_WRITE; > >> + msg.request |=3D DP_AUX_I2C_MOT; > >> + msg.buffer =3D NULL; > >> + msg.size =3D 0; > >> + err =3D drm_dp_i2c_do_msg(aux, &msg); > >> + if (err < 0) > >> + break; > > > > This seems somewhat brittle to me. Even though I notice that patch 3/4 > > updates a comment that documents these assumptions, I don't see a reason > > for these assumptions in the first place. >=20 > We already assume that in drm_dp_i2c_do_msg() for the retry loop. Ugh... you're right. > > I'd prefer if we simply provided the complete message rather than rely > > on drivers not to touch anything but the reply field. >=20 > Are you suggesting we re-write drm_dp_i2c_do_msg() or move the retry > logic into drm_dp_i2c_xfer()? Do you mind if we do that in a follow > up patch so we can keep it separate from the addition of the bare > address packets? No, looking at the code again, I don't see how we can do much better without sacrificing much of the clarity of the code. But perhaps this could be documented somewhere else than the I2C helpers. Perhaps the struct drm_dp_aux comment should be updated, which would cause the DRM docbook to automatically pick up that change as well. Thierry --huq684BweRXVnRxX Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJTQq7sAAoJEN0jrNd/PrOh+wwP/jwh1MN6IDAy0xCfAn3TpdwF dREdPGH1U963uWnYxaAwJmv0z//ZWCgAEZ2fR20PEAeBVA+WIfNkLZxhSCWrwkEb Kxs+etiHRUYjKJlGKZbQfMbs8/64poYaXRMrefsfGYVUQZVbCagJjLKDrjlRdWzM aop4PclRy1Wrp8qjx84feYCqaDx/A8VSFMmhS/Dzp6qKH48xxn4PoiAs+jOri2dm iZnFdwBZW1UH71cgxtxibRi/kxOb3GQJh3cGwb0O/Q0a14JKzjgLBVq2RrdHt9jg L2Ie96JzopixH+x+EF2RWWoOCCbrZWFWNqPvEc8JH9IFdmGABQovXsEQUFk40wmm yo45uyO0MSlKAHtUF734fk7P/P3gbUNdYtM4KxX3NIP/Ry3jrX7g45x6p6RMTuZW AgpsOz+7ONL5T9Qr/MjY24rLO2PZH7kUgRXiUcNeeWXtXiLCqbvUj1Wcm3f5xX2E ZpQjvTWqCw4K8dimPDxDLBPj6OsQWKc22DHcBLquiT8I5tFd6n2YlJliXsQ49tmp S/svP8xKJn3yU75UjFZiF3E+8Aau10VtjRV3FNs7OA9d+Q5EKuBfH7Lnth17RXO8 um62shl6HlBiwKo5u2NdJ9KEs3KkzKKV7ZWuUcZBYAf9ZhXoOtxTscNkuKt2Vjjm 9U/EcNmmn0V+c1qlH2DL =AGUi -----END PGP SIGNATURE----- --huq684BweRXVnRxX-- --===============2056957484== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel --===============2056957484==--