From patchwork Tue Dec 3 14:35:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lipski, Mikita" X-Patchwork-Id: 11271429 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 74343186E for ; Tue, 3 Dec 2019 14:36:20 +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 5CC1D20659 for ; Tue, 3 Dec 2019 14:36:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CC1D20659 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 C722E6E7DD; Tue, 3 Dec 2019 14:35:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-eopbgr740041.outbound.protection.outlook.com [40.107.74.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id AD1556E7A2; Tue, 3 Dec 2019 14:35:52 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Be0AE+OpCijkl6GTn//ZTiw2DQ3tQa7DfBXUSXhCHy4kRxjf6PR9RB5jyfxsR8uciNenJmHAF6fu/bvecuJuMkxwFO6bSfnrm95Er10Siu2ducSdaCWNLG+rkXvN5JSf8xVQJ1hnCSfRT1bvDZriKYSYao8lIsvUEhyG/u8CUgK7uM6d0rOBzP0UwVOtxhe4g7bN5K3HkRyNVV/8Ahq6U4sPfXryyFc5lQzplmOOk4WBmQg7wOGFdADhjCzWn7KFq852civNZwaMqzGtUIwvjCnJay53gwcRp/6fMfsVCaoYJ/uqL0Tq+wWDimP8+pTAlnY+ATqkFtpPBoZdtTF7yA== 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=YNQXdpFoxmV9VP2lzwPvBu5kKQX/8AIogTx2kbKxPro=; b=QU81L8/dXSg8QxkTZpQE3rhZVlN1RB3k7hAPTCymFRvhmyceS9HZJGIAq+1i7uzar2MgM/NUPrJtHys8i5BoYWFPl/OFe+miv44wSuOy+eeMGambWq6sdSYOuR/HHjWpvWui+KQY8nd0hgAmG6vAQO86N49eWmctZ5sRJJqrDSaxqEdU9Y6v3K1dCD3aY6oMkIN3XYhgQWVbESogh+fU6Hz/nWfaHR9vN7xFavUpkHtOERKQhLrbC5grOIfE5q1j3NBhEjPJA8aqZCMlkbkkocEGyZBa1sIj1oToo/volVKH4YXXIuNV5Djb7thx396EkFc50gVm+o6hkR/ZaT6L/w== 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 DM6PR12CA0022.namprd12.prod.outlook.com (2603:10b6:5:1c0::35) by DM6PR12MB3691.namprd12.prod.outlook.com (2603:10b6:5:1c5::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2495.17; Tue, 3 Dec 2019 14:35:50 +0000 Received: from DM6NAM11FT054.eop-nam11.prod.protection.outlook.com (2a01:111:f400:7eaa::205) by DM6PR12CA0022.outlook.office365.com (2603:10b6:5:1c0::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2495.18 via Frontend Transport; Tue, 3 Dec 2019 14:35:50 +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 DM6NAM11FT054.mail.protection.outlook.com (10.13.173.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2451.23 via Frontend Transport; Tue, 3 Dec 2019 14:35:50 +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; Tue, 3 Dec 2019 08:35:47 -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; Tue, 3 Dec 2019 08:35:47 -0600 From: To: Subject: [PATCH v8 15/17] drm/amd/display: Recalculate VCPI slots for new DSC connectors Date: Tue, 3 Dec 2019 09:35:28 -0500 Message-ID: <20191203143530.27262-16-mikita.lipski@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203143530.27262-1-mikita.lipski@amd.com> References: <20191203143530.27262-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)(136003)(346002)(396003)(39860400002)(376002)(428003)(189003)(199004)(5660300002)(1076003)(16586007)(316002)(2351001)(50466002)(70206006)(70586007)(86362001)(14444005)(478600001)(36756003)(54906003)(48376002)(53416004)(336012)(305945005)(356004)(186003)(26005)(6666004)(2906002)(8676002)(81166006)(6916009)(81156014)(426003)(8936002)(11346002)(2616005)(446003)(51416003)(2876002)(76176011)(4326008)(7696005)(50226002)(16060500001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB3691; 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: 9d310c71-b7ba-4255-97c8-08d777fe1848 X-MS-TrafficTypeDiagnostic: DM6PR12MB3691: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 02408926C4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mN5xsPSAAa98wESi3Q/j41gyHgASbEk/SVB7TH+hKBZWjES54jqeROPpGIWV69z7VcV7a3P4SHN0cwHDdXVbF9dRpvkn6+rl1B1+458OczeQPacvFlIeWcFc32rTHh6mV3xQPgX23FTKZysLrkKgAl1aeQAO7uNOGAVE/rt9Ue8WCZ6UKB1A7z6Qb0/u+e9mpTPfxYYQMQmitHrR9YK4yfBi0CYO1JyxRC1sWzFThK0lIrHq37Qh/y3d1zbe43aMO0m6XDG5rjRs+g3QeCns2GMbaBKJH7O2maU2AgN9NgW1ivxXbxtCTxXXP86VTEc4vcEV64MpPvkRqs6/7MO5izhfR9L9rG/phxuOKYbfSLKm/Osihkrnnqd/hlSkCvxt65bn69A9GfETUK6kcHNCqBSh1fCvGu/l5D6y3m9PmTPF5H4I0QvOqCOh/+UjcDlS7cWHBGCdbsAOuC8Dr6v6VXRutPOkouW00Vss51jD4ijcF58gLW26mOo3SfPehMDS X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2019 14:35:50.8153 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d310c71-b7ba-4255-97c8-08d777fe1848 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: DM6PR12MB3691 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=YNQXdpFoxmV9VP2lzwPvBu5kKQX/8AIogTx2kbKxPro=; b=jWbk5cQnEp0O9B7rakQGphmQtDE4QZYKAYmPHc8eaduwGDN6Mv+R+2hhr2QWnTV2cIxUBDPNfFKxP2UAcKmH1pMTf4NAxYRAaY021swbFMclk3RkoWwncX45pMtjZriiuPOvXuoJjPogzBDlz7MDPATBtgGqnM1GFIeKbcynKSA= 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: dri-devel@lists.freedesktop.org, Manasi Navare , Jerry Zuo , Mikita Lipski 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 Cc: Manasi Navare Signed-off-by: Mikita Lipski Reviewed-by: Lyude Paul --- .../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 93a230d956ee..2ac3a2f0b452 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; @@ -8022,11 +8085,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 @@ -8098,6 +8156,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; @@ -8126,6 +8188,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) {