From patchwork Sat Nov 16 22:01:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lipski, Mikita" X-Patchwork-Id: 11247773 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 271E413B2 for ; Sat, 16 Nov 2019 22:02:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0EB492071E for ; Sat, 16 Nov 2019 22:02:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0EB492071E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC0636E243; Sat, 16 Nov 2019 22:01:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-eopbgr820075.outbound.protection.outlook.com [40.107.82.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5AEA06E054; Sat, 16 Nov 2019 22:01:48 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZPnfzhjIKq0nGgDhvRU7rvaBxV7tC3QzYbN6o6RRsppFbV0Pmm+cse8A00124Xt9a7sKix6ibdb7I+agMqzjg17k8KBE9zG9p7ix4Jg1XQOlNZEHt4cQ7zOaOw8Cibu/3++e623Bc71Qr1LHvhN0NRGdmijsAkF/tvIWS72qjm44eE19R4SI4zGh3zytqI5TcBhymgaNVzwJO01TJz9booCwTuFN/idhK9+L1aKtSKEzy6c0nb2HYd5zjYCpyxgBZHLoGMmV4OY1vFmishgOzX4NyhZ/Ea8c2HYS1TEeZt0HF8YTB+0hRMeKBXSxO7+MIc/2VEOZrYgyB/CYwNyU0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=92XcHgcBCZHYmmGQ7bNK4TAWpclLn+1qX91J9OSj9Bw=; b=RVP2bM06lqJy+W9Cq2rfZ86R0YuF4SA0I5H3365nqqbTicrBxvROhPdcxE4qNGDQd/G9TOxy2rC5GFm3/34iJZ5ud8WZ+j9SiY5jrlYtI/Q6D1IBgngkcz2/B4PT6B1WSJziidBEOwFuFnSgJevNEKEw/qCZxImruQhddVvIWjm1vPE1Lu0ok6QDSHUzxVGgbdAKBA11kBiWuAYonktLekyYkBLU29PivmwD/SefkbnJlo+2dJjBx+ANLibNE/dVfzx2qbHnbx0Xn2DmV4cE4Fz7Lx2Ie+yOf6E47NtAQb87fotGlE0d+MDCL71tWFMI87PvqkFjwljZUzL1wrqO3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=permerror action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from CY4PR1201CA0017.namprd12.prod.outlook.com (2603:10b6:910:16::27) by BN6PR12MB1443.namprd12.prod.outlook.com (2603:10b6:405:e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.27; Sat, 16 Nov 2019 22:01:44 +0000 Received: from CO1NAM11FT025.eop-nam11.prod.protection.outlook.com (2a01:111:f400:7eab::200) by CY4PR1201CA0017.outlook.office365.com (2603:10b6:910:16::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.23 via Frontend Transport; Sat, 16 Nov 2019 22:01:44 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB02.amd.com (165.204.84.17) by CO1NAM11FT025.mail.protection.outlook.com (10.13.175.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2451.23 via Frontend Transport; Sat, 16 Nov 2019 22:01:43 +0000 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sat, 16 Nov 2019 16:01:40 -0600 Received: from mlipski-pc.amd.com (10.180.168.240) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Sat, 16 Nov 2019 16:01:39 -0600 From: To: Subject: [PATCH v7 16/17] drm/amd/display: Recalculate VCPI slots for new DSC connectors Date: Sat, 16 Nov 2019 17:01:27 -0500 Message-ID: <20191116220128.16598-17-mikita.lipski@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191116220128.16598-1-mikita.lipski@amd.com> References: <20191116220128.16598-1-mikita.lipski@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(396003)(39860400002)(136003)(428003)(189003)(199004)(4326008)(6916009)(426003)(14444005)(47776003)(2351001)(50226002)(8936002)(1076003)(53416004)(81156014)(51416003)(7696005)(76176011)(81166006)(8676002)(86362001)(5660300002)(26005)(476003)(126002)(356004)(186003)(2876002)(316002)(336012)(446003)(11346002)(54906003)(50466002)(70586007)(70206006)(478600001)(48376002)(16586007)(2616005)(2906002)(36756003)(486006)(305945005)(6666004)(16060500001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1443; H:SATLEXMB02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75598559-d6d8-4e7e-fd67-08d76ae09164 X-MS-TrafficTypeDiagnostic: BN6PR12MB1443: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 02234DBFF6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WYNfAimuWKGFuR9EbVNkX8u/bi72UttFB/KModJtMyldvUvVwDmYL78JrAXciLx+MOy+Fa0MsLidey1G5B+o7NTbvbRqNvRcebj7+bPANO2BiTLc3AuSOeTp2kGMFmaJ7U+GiaW+CByNCGsbE8KkeljyHs5SD9RDV6tka3cAQSMVz4aSM6gIHkfY7r/JY/yS18hZmgA8ZDAMSsN/sgM6Q68MLJaqHxAfeZi1IqLc9oYfudR6ud0mqeA3ZwGtQhJr9O+nJdnqSqqx7gwzEcuEewXsyS1zloqx3Z1+7qdpjNROtEiCVbi+bT2GJTol80JVZiFh8jzDAPEkMHyqNFn60jVV0CJFsHCBHoFKEqYpA+NBghabIGlXXZi2KqUq9MaeEiQBl+jGSnP9aQczAgRS2VzTUDFL44iQiAhpbARJEqGLD4QBP04k5t+CmuXGlM5V X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2019 22:01:43.9156 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75598559-d6d8-4e7e-fd67-08d76ae09164 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1443 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=92XcHgcBCZHYmmGQ7bNK4TAWpclLn+1qX91J9OSj9Bw=; b=eaf0RCgoV1rREbc8BIMgxY55zLnmJZGWuXI/Hs3f1Km8YQmmUowLDlThDPOiDs/UgmX6bbXFs1ysdazr5roXgUIBFzkTj9BoNtRfzHKFt7P6Q88UCRTI7YTnAnv9MgFvRrHLBm8/xhZUst+g52zFkcBTxZ7oVazhhIY0108qx1I= X-Mailman-Original-Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jerry Zuo , Mikita Lipski , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Mikita Lipski [why] Since for DSC MST connector's PBN is claculated differently due to compression, we have to recalculate both PBN and VCPI slots for that connector. [how] The function iterates through all the active streams to find, which have DSC enabled, then recalculates PBN for it and calls drm_dp_helper_update_vcpi_slots_for_dsc to update connector's VCPI slots. v2: - use drm_dp_mst_atomic_enable_dsc per port to enable/disable DSC v3: - Iterate through connector states from the state passed - On each connector state get stream from dc_state, instead CRTC state Cc: Jerry Zuo Cc: Harry Wentland Cc: Lyude Paul Signed-off-by: Mikita Lipski --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 76 +++++++++++++++++-- 1 file changed, 71 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 7d8e244e5210..4be6621088d2 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -4986,6 +4986,69 @@ const struct drm_encoder_helper_funcs amdgpu_dm_encoder_helper_funcs = { .atomic_check = dm_encoder_helper_atomic_check }; +static int dm_update_mst_vcpi_slots_for_dsc(struct drm_atomic_state *state, + struct dc_state *dc_state) +{ + struct dc_stream_state *stream = NULL; + struct drm_connector *connector; + struct drm_connector_state *new_con_state, *old_con_state; + struct amdgpu_dm_connector *aconnector; + struct dm_connector_state *dm_conn_state; + int i, j, clock, bpp; + int vcpi, pbn_div, pbn = 0; + + for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) { + + aconnector = to_amdgpu_dm_connector(connector); + + if (!aconnector->port) + continue; + + if (!new_con_state || !new_con_state->crtc) + continue; + + dm_conn_state = to_dm_connector_state(new_con_state); + + for (j = 0; j < dc_state->stream_count; j++) { + stream = dc_state->streams[j]; + if (!stream) + continue; + + if ((struct amdgpu_dm_connector*)stream->dm_stream_context == aconnector) + break; + + stream = NULL; + } + + if (!stream) + continue; + + if (stream->timing.flags.DSC != 1) { + drm_dp_mst_atomic_enable_dsc(state, + aconnector->port, + dm_conn_state->pbn, + 0, + false); + continue; + } + + pbn_div = dm_mst_get_pbn_divider(stream->link); + bpp = stream->timing.dsc_cfg.bits_per_pixel; + clock = stream->timing.pix_clk_100hz / 10; + pbn = drm_dp_calc_pbn_mode(clock, bpp, true); + vcpi = drm_dp_mst_atomic_enable_dsc(state, + aconnector->port, + pbn, pbn_div, + true); + if (vcpi < 0) + return vcpi; + + dm_conn_state->pbn = pbn; + dm_conn_state->vcpi_slots = vcpi; + } + return 0; +} + static void dm_drm_plane_reset(struct drm_plane *plane) { struct dm_plane_state *amdgpu_state = NULL; @@ -8017,11 +8080,6 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, if (ret) goto fail; - /* Perform validation of MST topology in the state*/ - ret = drm_dp_mst_atomic_check(state); - if (ret) - goto fail; - if (state->legacy_cursor_update) { /* * This is a fast cursor update coming from the plane update @@ -8093,6 +8151,10 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, if (!compute_mst_dsc_configs_for_state(state, dm_state->context)) goto fail; + ret = dm_update_mst_vcpi_slots_for_dsc(state, dm_state->context); + if (ret) + goto fail; + if (dc_validate_global_state(dc, dm_state->context, false) != DC_OK) { ret = -EINVAL; goto fail; @@ -8121,6 +8183,10 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, dc_retain_state(old_dm_state->context); } } + /* Perform validation of MST topology in the state*/ + ret = drm_dp_mst_atomic_check(state); + if (ret) + goto fail; /* Store the overall update type for use later in atomic check. */ for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) {