Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/bridge: tc358767: cleanup LT result check

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>
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190528082747.3631-16-tomi.valkeinen@ti.com

authored by

Tomi Valkeinen and committed by
Andrzej Hajda
0bf25146 0776a269

+34 -26
+34 -26
drivers/gpu/drm/bridge/tc358767.c
··· 980 980 if (ret < 0) 981 981 goto err_dpcd_write; 982 982 983 - /* Wait */ 984 - timeout = 100; 985 - do { 986 - udelay(1); 987 - /* Read DPCD 0x202-0x207 */ 988 - ret = drm_dp_dpcd_read_link_status(aux, tmp + 2); 989 - if (ret < 0) 990 - goto err_dpcd_read; 991 - } while ((--timeout) && 992 - !(drm_dp_channel_eq_ok(tmp + 2, tc->link.base.num_lanes))); 983 + /* Check link status */ 984 + ret = drm_dp_dpcd_read_link_status(aux, tmp); 985 + if (ret < 0) 986 + goto err_dpcd_read; 993 987 994 - if (timeout == 0) { 995 - /* Read DPCD 0x200-0x201 */ 996 - ret = drm_dp_dpcd_read(aux, DP_SINK_COUNT, tmp, 2); 997 - if (ret < 0) 998 - goto err_dpcd_read; 999 - dev_err(dev, "channel(s) EQ not ok\n"); 1000 - dev_info(dev, "0x0200 SINK_COUNT: 0x%02x\n", tmp[0]); 1001 - dev_info(dev, "0x0201 DEVICE_SERVICE_IRQ_VECTOR: 0x%02x\n", 1002 - tmp[1]); 1003 - dev_info(dev, "0x0202 LANE0_1_STATUS: 0x%02x\n", tmp[2]); 1004 - dev_info(dev, "0x0204 LANE_ALIGN_STATUS_UPDATED: 0x%02x\n", 1005 - tmp[4]); 1006 - dev_info(dev, "0x0205 SINK_STATUS: 0x%02x\n", tmp[5]); 1007 - dev_info(dev, "0x0206 ADJUST_REQUEST_LANE0_1: 0x%02x\n", 1008 - tmp[6]); 988 + ret = 0; 1009 989 1010 - return -EAGAIN; 990 + value = tmp[0] & DP_CHANNEL_EQ_BITS; 991 + 992 + if (value != DP_CHANNEL_EQ_BITS) { 993 + dev_err(tc->dev, "Lane 0 failed: %x\n", value); 994 + ret = -ENODEV; 995 + } 996 + 997 + if (tc->link.base.num_lanes == 2) { 998 + value = (tmp[0] >> 4) & DP_CHANNEL_EQ_BITS; 999 + 1000 + if (value != DP_CHANNEL_EQ_BITS) { 1001 + dev_err(tc->dev, "Lane 1 failed: %x\n", value); 1002 + ret = -ENODEV; 1003 + } 1004 + 1005 + if (!(tmp[2] & DP_INTERLANE_ALIGN_DONE)) { 1006 + dev_err(tc->dev, "Interlane align failed\n"); 1007 + ret = -ENODEV; 1008 + } 1009 + } 1010 + 1011 + if (ret) { 1012 + dev_err(dev, "0x0202 LANE0_1_STATUS: 0x%02x\n", tmp[0]); 1013 + dev_err(dev, "0x0203 LANE2_3_STATUS 0x%02x\n", tmp[1]); 1014 + dev_err(dev, "0x0204 LANE_ALIGN_STATUS_UPDATED: 0x%02x\n", tmp[2]); 1015 + dev_err(dev, "0x0205 SINK_STATUS: 0x%02x\n", tmp[3]); 1016 + dev_err(dev, "0x0206 ADJUST_REQUEST_LANE0_1: 0x%02x\n", tmp[4]); 1017 + dev_err(dev, "0x0207 ADJUST_REQUEST_LANE2_3: 0x%02x\n", tmp[5]); 1018 + goto err; 1011 1019 } 1012 1020 1013 1021 return 0;