All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Andrzej Hajda <a.hajda@samsung.com>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	dri-devel@lists.freedesktop.org,
	Lucas Stach <l.stach@pengutronix.de>,
	Andrey Gusakov <andrey.gusakov@cogentembedded.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Jyri Sarha <jsarha@ti.com>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	Benoit Parrot <bparrot@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [PATCH 14/21] drm/bridge: tc358767: cleanup LT result check
Date: Tue, 19 Mar 2019 12:41:07 +0200	[thread overview]
Message-ID: <20190319104114.12077-15-tomi.valkeinen@ti.com> (raw)
In-Reply-To: <20190319104114.12077-1-tomi.valkeinen@ti.com>

The driver has a loop after ending link training, where it reads the
DPCD link status and prints an error if that status is not ok.

The loop is unnecessary, as far as I can understand from DP specs, so
let's remove it. We can also print the more specific errors to help
debugging.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/bridge/tc358767.c | 62 +++++++++++++++++--------------
 1 file changed, 35 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
index 700e161015af..220408db82f7 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -968,34 +968,42 @@ static int tc_main_link_enable(struct tc_data *tc)
 	if (ret < 0)
 		goto err_dpcd_write;
 
-	/* Wait */
-	timeout = 100;
-	do {
-		udelay(1);
-		/* Read DPCD 0x202-0x207 */
-		ret = drm_dp_dpcd_read_link_status(aux, tmp + 2);
-		if (ret < 0)
-			goto err_dpcd_read;
-	} while ((--timeout) &&
-		 !(drm_dp_channel_eq_ok(tmp + 2,  tc->link.base.num_lanes)));
+	/* Check link status */
+	ret = drm_dp_dpcd_read_link_status(aux, tmp);
+	if (ret < 0)
+		goto err_dpcd_read;
 
-	if (timeout == 0) {
-		/* Read DPCD 0x200-0x201 */
-		ret = drm_dp_dpcd_read(aux, DP_SINK_COUNT, tmp, 2);
-		if (ret < 0)
-			goto err_dpcd_read;
-		dev_err(dev, "channel(s) EQ not ok\n");
-		dev_info(dev, "0x0200 SINK_COUNT: 0x%02x\n", tmp[0]);
-		dev_info(dev, "0x0201 DEVICE_SERVICE_IRQ_VECTOR: 0x%02x\n",
-			 tmp[1]);
-		dev_info(dev, "0x0202 LANE0_1_STATUS: 0x%02x\n", tmp[2]);
-		dev_info(dev, "0x0204 LANE_ALIGN_STATUS_UPDATED: 0x%02x\n",
-			 tmp[4]);
-		dev_info(dev, "0x0205 SINK_STATUS: 0x%02x\n", tmp[5]);
-		dev_info(dev, "0x0206 ADJUST_REQUEST_LANE0_1: 0x%02x\n",
-			 tmp[6]);
-
-		return -EAGAIN;
+	ret = 0;
+
+	value = tmp[0] & DP_CHANNEL_EQ_BITS;
+
+	if (value != DP_CHANNEL_EQ_BITS) {
+		dev_err(tc->dev, "Lane 0 failed: %x\n", value);
+		ret = -ENODEV;
+	}
+
+	if (tc->link.base.num_lanes == 2) {
+		value = (tmp[0] >> 4) & DP_CHANNEL_EQ_BITS;
+
+		if (value != DP_CHANNEL_EQ_BITS) {
+			dev_err(tc->dev, "Lane 1 failed: %x\n", value);
+			ret = -ENODEV;
+		}
+
+		if (!(tmp[2] & DP_INTERLANE_ALIGN_DONE)) {
+			dev_err(tc->dev, "Interlane align failed\n");
+			ret = -ENODEV;
+		}
+	}
+
+	if (ret) {
+		dev_err(dev, "0x0202 LANE0_1_STATUS:            0x%02x\n", tmp[0]);
+		dev_err(dev, "0x0203 LANE2_3_STATUS             0x%02x\n", tmp[1]);
+		dev_err(dev, "0x0204 LANE_ALIGN_STATUS_UPDATED: 0x%02x\n", tmp[2]);
+		dev_err(dev, "0x0205 SINK_STATUS:               0x%02x\n", tmp[3]);
+		dev_err(dev, "0x0206 ADJUST_REQUEST_LANE0_1:    0x%02x\n", tmp[4]);
+		dev_err(dev, "0x0207 ADJUST_REQUEST_LANE2_3:    0x%02x\n", tmp[5]);
+		goto err;
 	}
 
 	return 0;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-03-19 10:42 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 10:40 [PATCH 00/21] drm/bridge: tc358767: DP support Tomi Valkeinen
2019-03-19 10:40 ` [PATCH 01/21] drm/bridge: tc358767: fix tc_aux_get_status error handling Tomi Valkeinen
2019-03-19 10:40 ` [PATCH 02/21] drm/bridge: tc358767: reset voltage-swing & pre-emphasis Tomi Valkeinen
2019-03-19 10:40 ` [PATCH 03/21] drm/bridge: tc358767: fix ansi 8b10b use Tomi Valkeinen
2019-03-19 10:40 ` [PATCH 04/21] drm/bridge: tc358767: cleanup spread & scrambler_dis Tomi Valkeinen
2019-03-19 10:40 ` [PATCH 05/21] drm/bridge: tc358767: remove unused swing & preemp Tomi Valkeinen
2019-03-19 10:40 ` [PATCH 06/21] drm/bridge: tc358767: cleanup aux_link_setup Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 07/21] drm/bridge: tc358767: move video stream setup to tc_main_link_stream Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 08/21] drm/bridge: tc358767: split stream enable/disable Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 09/21] drm/bridge: tc358767: move PXL PLL enable/disable to " Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 10/21] drm/bridge: tc358767: add link disable function Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 11/21] drm/bridge: tc358767: ensure DP is disabled before LT Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 12/21] drm/bridge: tc358767: remove unnecessary msleep Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 13/21] drm/bridge: tc358767: use more reliable seq when finishing LT Tomi Valkeinen
2019-03-19 10:41 ` Tomi Valkeinen [this message]
2019-03-19 10:41 ` [PATCH 15/21] drm/bridge: tc358767: clean-up link training Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 16/21] drm/bridge: tc358767: remove check for video mode in link enable Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 17/21] drm/bridge: tc358767: use bridge mode_valid Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 18/21] drm/bridge: tc358767: remove tc_connector_best_encoder Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 19/21] drm/bridge: tc358767: copy the mode data, instead of storing the pointer Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 20/21] drm/bridge: tc358767: add GPIO & interrupt registers Tomi Valkeinen
2019-03-19 10:41 ` [PATCH 21/21] drm/bridge: tc358767: implement naive HPD handling Tomi Valkeinen
2019-03-19 18:18   ` [21/21] " Andrey Smirnov
2019-03-20  5:55     ` Andrey Smirnov
2019-03-20  7:06       ` Tomi Valkeinen
2019-03-20  6:57     ` Tomi Valkeinen
2019-03-20 13:03       ` Tomi Valkeinen
2019-03-20 22:58         ` Andrey Smirnov
2019-03-21 13:12           ` Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190319104114.12077-15-tomi.valkeinen@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=andrey.gusakov@cogentembedded.com \
    --cc=bparrot@ti.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jsarha@ti.com \
    --cc=l.stach@pengutronix.de \
    --cc=p.zabel@pengutronix.de \
    --cc=peter.ujfalusi@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.