Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp451817pxb; Thu, 9 Sep 2021 04:55:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDQugTOu8O6IIV9Lw+ytbGkaW98wlu6bSOUEK1bzAPUtSEBjSgqlI3iF1/j74hgOCYaUQy X-Received: by 2002:a17:906:369a:: with SMTP id a26mr3003574ejc.539.1631188553781; Thu, 09 Sep 2021 04:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188553; cv=none; d=google.com; s=arc-20160816; b=dU8MljW95dVUzWoLYOR3SpagbjKBLjD8dHr4hTgSge/r4EnDb5NFBKJPjacTMHSF5F PpqGCB9k/KGVfVqX4RbnhMmZzPARb72FfD8mwOhWim8vWbY0Cp0hWbmYCchT58fyujai JcQigLTGwAZVkhlnQTZnjKlBsUUsggx+bvJ49T9huGkT+8AELTtg/F3hrIqMIdm6yqLI NySQUTShvuIjkigpwRxpWx0VdabJxQQk2VkfnZLT7KrOPrB+iOQxUl6bdFKdhElczrB6 OL7aJb6EcfeaSUkx53zYn5rsKc67+F3gaCBIRkjRI9/5+kwUvxDNY6IXVR6IpiQI5J0s i1Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=COabdq1zs1YtL3ggor2S15jInqiBYgiL8GqSxugwBc8=; b=WGDSoQZqcSKXN2gPQN33wqGWy72YcE9hrL2mIlPbZa8LWbSvgM76O1QnBmqgqfPLVW +OH6bBCuGGJuNxj5LhKufbbnchAUc82WtPC6lN9JO1LGz7xUXw5NFbHypaObwFU9y7yi ulT2inTyYhXrv5clL5cNLE0oxk4ygRBy5TFMeeGkBxED+WrGSrsiTFmzezyEbNvhE5wl cQ/dLdzPkMsZlYmXe/I3LeLJjRooOZJ3jBpmTvikc86pxS+nEK++z5GLw6fVPXFCuIpa 7znWmUpaRc7WDBF7XX9bxSwMutmvwHsYx/+eG+MildB6MYjefXwQwFJstESA4AVcRpjI MxfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kuOpgUP2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zp1si1237297ejb.666.2021.09.09.04.55.29; Thu, 09 Sep 2021 04:55:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kuOpgUP2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244243AbhIILyb (ORCPT + 99 others); Thu, 9 Sep 2021 07:54:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:54526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238800AbhIILwA (ORCPT ); Thu, 9 Sep 2021 07:52:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2C2F561288; Thu, 9 Sep 2021 11:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187856; bh=0bo7ow20Vjjagu611zzbdx4DpyRacN4U9snfytX4aUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kuOpgUP2sAbxb6Zpe01vzmgWpkRpI1lAikCNlW5RFmCgKsavnYCAEQHPxoYb7PeUc W0NxXOqtVZwH9kPFeqYGTDfCTzgpu0WdLGBFCcTBqSlq0ZVkkunSnSbmvxutT3S2v9 XJyLwZVyQeCoDk0OlGrzyP4U9nrEZ8X01PIrilO/fmbj5zirg6F2GFjDoDsXeN16BU gqvKfye116fZesSuMtDoLhRFAr7rYtchzgd5R6baSdF3+Ry0oToc3lm/+YwXWNkXUm GY88KGH5CjqnU4Cu6lG0VXnw2FNTDjuFVaCALai2GcDYYt2ODyrBa7TFTQAO52dQC7 E3WS8oc5gRV8w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kuogee Hsieh , Stephen Boyd , Rob Clark , Sasha Levin , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.14 145/252] drm/msm/dp: do not end dp link training until video is ready Date: Thu, 9 Sep 2021 07:39:19 -0400 Message-Id: <20210909114106.141462-145-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kuogee Hsieh [ Upstream commit 2e0adc765d884cc080baa501e250bfad97035b09 ] Initialize both pre-emphasis and voltage swing level to 0 before start link training and do not end link training until video is ready to reduce the period between end of link training and video start to meet Link Layer CTS requirement. Some dongle main link symbol may become unlocked again if host did not end link training soon enough after completion of link training 2. Host have to re train main link if loss of symbol locked detected before end link training so that the coming video stream can be transmitted to sink properly. This fixes Link Layer CTS cases 4.3.2.1, 4.3.2.2, 4.3.2.3 and 4.3.2.4. Changes in v3: -- merge retrain link if loss of symbol locked happen into this patch -- replace dp_ctrl_loss_symbol_lock() with dp_ctrl_channel_eq_ok() Signed-off-by: Kuogee Hsieh Reviewed-by: Stephen Boyd Link: https://lore.kernel.org/r/1628196295-7382-7-git-send-email-khsieh@codeaurora.org Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/dp/dp_ctrl.c | 56 +++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c index 30d20e3beb29..6f5e45d54b26 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.c +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c @@ -1480,6 +1480,9 @@ static int dp_ctrl_link_maintenance(struct dp_ctrl_private *ctrl) dp_ctrl_push_idle(&ctrl->dp_ctrl); + ctrl->link->phy_params.p_level = 0; + ctrl->link->phy_params.v_level = 0; + ctrl->dp_ctrl.pixel_rate = ctrl->panel->dp_mode.drm_mode.clock; ret = dp_ctrl_setup_main_link(ctrl, &training_step); @@ -1632,6 +1635,16 @@ static bool dp_ctrl_clock_recovery_any_ok( return drm_dp_clock_recovery_ok(link_status, reduced_cnt); } +static bool dp_ctrl_channel_eq_ok(struct dp_ctrl_private *ctrl) +{ + u8 link_status[DP_LINK_STATUS_SIZE]; + int num_lanes = ctrl->link->link_params.num_lanes; + + dp_ctrl_read_link_status(ctrl, link_status); + + return drm_dp_channel_eq_ok(link_status, num_lanes); +} + int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl) { int rc = 0; @@ -1666,6 +1679,9 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl) ctrl->link->link_params.rate, ctrl->link->link_params.num_lanes, ctrl->dp_ctrl.pixel_rate); + ctrl->link->phy_params.p_level = 0; + ctrl->link->phy_params.v_level = 0; + rc = dp_ctrl_enable_mainlink_clocks(ctrl); if (rc) return rc; @@ -1731,17 +1747,19 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl) if (ctrl->link->sink_request & DP_TEST_LINK_PHY_TEST_PATTERN) return rc; - /* stop txing train pattern */ - dp_ctrl_clear_training_pattern(ctrl); + if (rc == 0) { /* link train successfully */ + /* + * do not stop train pattern here + * stop link training at on_stream + * to pass compliance test + */ + } else { + /* + * link training failed + * end txing train pattern here + */ + dp_ctrl_clear_training_pattern(ctrl); - /* - * keep transmitting idle pattern until video ready - * to avoid main link from loss of sync - */ - if (rc == 0) /* link train successfully */ - dp_ctrl_push_idle(dp_ctrl); - else { - /* link training failed */ dp_ctrl_deinitialize_mainlink(ctrl); rc = -ECONNRESET; } @@ -1749,9 +1767,15 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl) return rc; } +static int dp_ctrl_link_retrain(struct dp_ctrl_private *ctrl) +{ + int training_step = DP_TRAINING_NONE; + + return dp_ctrl_setup_main_link(ctrl, &training_step); +} + int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl) { - u32 rate = 0; int ret = 0; bool mainlink_ready = false; struct dp_ctrl_private *ctrl; @@ -1761,10 +1785,6 @@ int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl) ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); - rate = ctrl->panel->link_info.rate; - - ctrl->link->link_params.rate = rate; - ctrl->link->link_params.num_lanes = ctrl->panel->link_info.num_lanes; ctrl->dp_ctrl.pixel_rate = ctrl->panel->dp_mode.drm_mode.clock; DRM_DEBUG_DP("rate=%d, num_lanes=%d, pixel_rate=%d\n", @@ -1779,6 +1799,12 @@ int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl) } } + if (!dp_ctrl_channel_eq_ok(ctrl)) + dp_ctrl_link_retrain(ctrl); + + /* stop txing train pattern to end link training */ + dp_ctrl_clear_training_pattern(ctrl); + ret = dp_ctrl_enable_stream_clocks(ctrl); if (ret) { DRM_ERROR("Failed to start pixel clocks. ret=%d\n", ret); -- 2.30.2