From patchwork Mon Nov 22 18:33:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Aaltonen X-Patchwork-Id: 1558222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HybZ41yZ6z9sRN for ; Tue, 23 Nov 2021 05:35:56 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mpEAJ-0001O9-9F; Mon, 22 Nov 2021 18:35:43 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mpE91-0007QD-9l for kernel-team@lists.ubuntu.com; Mon, 22 Nov 2021 18:34:23 +0000 Received: from leon.. (mobile-user-c1d2e5-215.dhcp.inet.fi [193.210.229.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 04D0140079 for ; Mon, 22 Nov 2021 18:34:22 +0000 (UTC) From: Timo Aaltonen To: kernel-team@lists.ubuntu.com Subject: [PATCH 11/30] drm/amd/display: Implement DPIA link configuration Date: Mon, 22 Nov 2021 20:33:59 +0200 Message-Id: <20211122183418.73674-12-tjaalton@ubuntu.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211122183418.73674-1-tjaalton@ubuntu.com> References: <20211122183418.73674-1-tjaalton@ubuntu.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jimmy Kizito BugLink: https://bugs.launchpad.net/bugs/1951868 [Why] Training settings need to be applied to DPIA link at start of each training loop. Note: FEC readiness should be configured before link training while FEC enablement should be configured once training is complete. [How] - Implement DPIA link configuration function. - Account for dynamically assigned link encoders during link configuration. Reviewed-by: Jun Lei Acked-by: Wayne Lin Acked-by: Nicholas Kazlauskas Acked-by: Harry Wentland Signed-off-by: Jimmy Kizito Signed-off-by: Alex Deucher (backported from commit 187c236aacc0c157204a23c2b9fc174e3612efee - added the new enum) Signed-off-by: Timo Aaltonen --- .../drm/amd/display/dc/core/dc_link_dpia.c | 49 ++++++++++++++++--- .../display/dc/dcn31/dcn31_dio_link_encoder.c | 2 + .../gpu/drm/amd/display/dc/inc/dc_link_dp.h | 4 ++ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dpia.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dpia.c index afb18cba3efa..1184ff84b767 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dpia.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dpia.c @@ -30,6 +30,9 @@ #include "dc_link.h" #include "dc_link_dp.h" +#define DC_LOGGER \ + link->ctx->logger + enum dc_status dpcd_get_tunneling_device_data(struct dc_link *link) { /** @todo Read corresponding DPCD region and update link caps. */ @@ -38,17 +41,51 @@ enum dc_status dpcd_get_tunneling_device_data(struct dc_link *link) /* Configure link as prescribed in link_setting; set LTTPR mode; and * Initialize link training settings. + * Abort link training if sink unplug detected. + * + * @param link DPIA link being trained. + * @param[in] link_setting Lane count, link rate and downspread control. + * @param[out] lt_settings Link settings and drive settings (voltage swing and pre-emphasis). */ static enum link_training_result dpia_configure_link(struct dc_link *link, const struct dc_link_settings *link_setting, struct link_training_settings *lt_settings) { - enum link_training_result result; - - /** @todo Fail until implemented. */ - result = LINK_TRAINING_ABORT; - - return result; + enum dc_status status; + bool fec_enable; + + DC_LOG_HW_LINK_TRAINING("%s\n DPIA(%d) configuring\n - LTTPR mode(%d)\n", + __func__, + link->link_id.enum_id - ENUM_ID_1, + link->lttpr_mode); + + dp_decide_training_settings(link, + link_setting, + lt_settings); + + status = dpcd_configure_channel_coding(link, lt_settings); + if (status != DC_OK && !link->hpd_status) + return LINK_TRAINING_ABORT; + + /* Configure lttpr mode */ + status = dpcd_configure_lttpr_mode(link, lt_settings); + if (status != DC_OK && !link->hpd_status) + return LINK_TRAINING_ABORT; + + /* Set link rate, lane count and spread. */ + status = dpcd_set_link_settings(link, lt_settings); + if (status != DC_OK && !link->hpd_status) + return LINK_TRAINING_ABORT; + + if (link->preferred_training_settings.fec_enable) + fec_enable = *link->preferred_training_settings.fec_enable; + else + fec_enable = true; + status = dp_set_fec_ready(link, fec_enable); + if (status != DC_OK && !link->hpd_status) + return LINK_TRAINING_ABORT; + + return LINK_TRAINING_SUCCESS; } /* Execute clock recovery phase of link training for specified hop in display diff --git a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_dio_link_encoder.c b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_dio_link_encoder.c index b87691d34ede..fd0ae6ade9c4 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_dio_link_encoder.c +++ b/drivers/gpu/drm/amd/display/dc/dcn31/dcn31_dio_link_encoder.c @@ -424,6 +424,7 @@ void dcn31_link_encoder_enable_dp_output( if (link) { dpia_control.dpia_id = link->ddc_hw_inst; + dpia_control.fec_rdy = link->fec_state == dc_link_fec_ready ? 1 : 0; } else { DC_LOG_ERROR("%s: Failed to execute DPIA enable DMUB command.\n", __func__); BREAK_TO_DEBUGGER(); @@ -465,6 +466,7 @@ void dcn31_link_encoder_enable_dp_mst_output( if (link) { dpia_control.dpia_id = link->ddc_hw_inst; + dpia_control.fec_rdy = link->fec_state == dc_link_fec_ready ? 1 : 0; } else { DC_LOG_ERROR("%s: Failed to execute DPIA enable DMUB command.\n", __func__); BREAK_TO_DEBUGGER(); diff --git a/drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h b/drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h index 01c3a31be191..b0b90f867099 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h +++ b/drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h @@ -188,6 +188,10 @@ enum dc_status dpcd_configure_lttpr_mode( struct dc_link *link, struct link_training_settings *lt_settings); +enum dc_status dpcd_configure_channel_coding( + struct dc_link *link, + struct link_training_settings *lt_settings); + enum dp_link_encoding dp_get_link_encoding_format(const struct dc_link_settings *link_settings); bool dp_retrieve_lttpr_cap(struct dc_link *link); #endif /* __DC_LINK_DP_H__ */