From patchwork Wed Oct 30 19:24:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lipski, Mikita" X-Patchwork-Id: 11219999 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 1C2FB14DB for ; Wed, 30 Oct 2019 19:25:21 +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 005EC204FD for ; Wed, 30 Oct 2019 19:25:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 005EC204FD 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 33A906ED24; Wed, 30 Oct 2019 19:25:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730053.outbound.protection.outlook.com [40.107.73.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7474C6ED34; Wed, 30 Oct 2019 19:24:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NgRI9DFgcFLnsqWSSZ/sKeGe9sScBxrzcDCAdo9qlLCSOOa6WVIvCj7+DEusB+H+oFj19+1NCEuoqxqfQTgzfGa0wi7x9Hjw1YV/HWf87ZUEVnxiyCqmsgzMJwQvnSF3+ZR7CRreq3wDpBfw/YODRDdbE20RNTQ2vnjKIlMtJHiVSmp5LeX3dSHif4oGsTPfSsYk6ldqwh1PaR6kt7ZJ2HXzGMMjuyGgHbLNilviFz+zCF+UpIcSPVpunLNXawmueqku6DSrPbM+t9jd/DLsmSKXoCztWbr6y91ZXXvJnQkNFW80oQ9q6e3x/t557TorVD2sOXix31TixfM1IPtRoA== 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=2enPJsa5bWYxzHlgOZrxUh9Lh4IthigZTOGTHcx0uMg=; b=HvRQwl+P36hfQLePtXtct2YJ1Pz4ICyxa/RIkFfRBkvmzvpUEqZOgG4UYZhxYeDs2oHOfdilN1D4fiWL9VOh3lhC6qBmU2l/bI0NZiz9oRvdbifPZuNL4FAa7mquM2TgagWs57yi5ZYSNqYgqvP5VQbCJAkmtii/AJeQeAL4JywFFCFtEZbyuSan0UpVUi+iH298PMXOCiM2A3mH2v26vh1rrpaKt7jg6ZdPSVIiUWPi5PUDrYMqltWYyDz/yeCjND08vHCP2tIiLJFrct2hZcBOeBVYAnTF+t1YBKSWtipzExQZ0drw/H9HI3efZc4FiA+CuvREi7cQzQO+jvRWtQ== 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 CY4PR1201CA0010.namprd12.prod.outlook.com (2603:10b6:910:16::20) by DM6PR12MB3898.namprd12.prod.outlook.com (2603:10b6:5:1c9::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2387.24; Wed, 30 Oct 2019 19:24:46 +0000 Received: from CO1NAM03FT026.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::208) by CY4PR1201CA0010.outlook.office365.com (2603:10b6:910:16::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2408.20 via Frontend Transport; Wed, 30 Oct 2019 19:24:46 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXMB01.amd.com (165.204.84.17) by CO1NAM03FT026.mail.protection.outlook.com (10.152.80.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2387.20 via Frontend Transport; Wed, 30 Oct 2019 19:24:46 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB01.amd.com (10.181.40.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 30 Oct 2019 14:24:45 -0500 Received: from SATLEXMB02.amd.com (10.181.40.143) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 30 Oct 2019 14:24:45 -0500 Received: from mlipski-pc.amd.com (10.180.168.240) by SATLEXMB02.amd.com (10.181.40.143) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Wed, 30 Oct 2019 14:24:44 -0500 From: To: Subject: [PATCH 12/13] drm/dp_mst: Add DSC enablement helpers to DRM Date: Wed, 30 Oct 2019 15:24:30 -0400 Message-ID: <20191030192431.5798-13-mikita.lipski@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191030192431.5798-1-mikita.lipski@amd.com> References: <20191030192431.5798-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)(396003)(39860400002)(376002)(346002)(136003)(428003)(189003)(199004)(6666004)(14444005)(316002)(7696005)(356004)(4326008)(6916009)(8936002)(2906002)(8676002)(51416003)(305945005)(26005)(54906003)(48376002)(81156014)(81166006)(76176011)(50226002)(50466002)(2351001)(1076003)(86362001)(336012)(426003)(5660300002)(478600001)(2876002)(486006)(476003)(2616005)(16586007)(36756003)(11346002)(446003)(70586007)(53416004)(186003)(126002)(70206006)(47776003)(16060500001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR12MB3898; H:SATLEXMB01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 20ed03f8-803d-4112-a5ad-08d75d6ed30a X-MS-TrafficTypeDiagnostic: DM6PR12MB3898: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-Forefront-PRVS: 02065A9E77 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T4xTAFbNgRrMKuYdcE2rZ/GhVqSt7nyp72b4JyIE+1NlUvdIfHoaFNSdSRZ8fa78eCNTP6bI87PJvCq6lkBIQPMUqDVwrr6GQKt452MVPzrCAAeEEM6bOC8nF335NbhMZqsCpQnlSILLm+bNq2KF6fQBupgcYY2kTYx/3AhOx/4JW5pmlcRkpjwhyB+A8QOEJaYZ6Zun6R++KIdBLRy8zdGBXpy7qolyGvn2tuXPK9xWAwNh76qhuqYgDYRfSIRT5DTxWXSzHXWfaohlpwFGUw7guiATXiUGjP/kULdd6pFvWbfZGVIVBTRC7TwMOr3NWMRNMTNj752I5sLjwmIR9lfaSCnppH0lBuP5uL/UJT/kmbWWV6WdrFTMp1DGb9LPuxlQm57IIhV4t8gVJKcP1dchg/RvnCPAT/lDrFCL6+3xMAd4Kpcsc5WPl++42PEi X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2019 19:24:46.3079 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20ed03f8-803d-4112-a5ad-08d75d6ed30a 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=[SATLEXMB01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3898 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=2enPJsa5bWYxzHlgOZrxUh9Lh4IthigZTOGTHcx0uMg=; b=PqJKzAPpi7jDEuwL0mwgOPvGI3jSXNW+EkpsvSG/OJ8DRojlmrSLHRskhdpztFKFxk7yTq1ZH+EljFGbElMUucrSibGCi38t5M6DI2u4d15YtLozX++mrUt/eVMnq0ZLJ9cSaa2D7UcdzVQNcq7ZHoK2G+VMdt514aNgWLFlwbc= 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: Mikita Lipski , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Mikita Lipski Adding the following elements to add MST DSC support to DRM: - dsc_enable boolean flag to drm_dp_vcpi_allocation structure to signal, which port got DSC enabled - function drm_dp_helper_update_vcpi_slots_for_dsc allows reallocation of newly recalculated VCPI slots and raises dsc_enable flag on the port. - function drm_dp_mst_update_dsc_crtcs is called in drm_dp_mst_atomic_check, its purpose is to iterate through all the ports in the topology and set mode_changed flag on crtc if DSC has been enabled. Cc: Harry Wentland Cc: Lyude Paul Signed-off-by: Mikita Lipski --- drivers/gpu/drm/drm_dp_mst_topology.c | 103 +++++++++++++++++++++++++- include/drm/drm_dp_mst_helper.h | 4 + 2 files changed, 106 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index d5df02315e14..4f2f09fe32f8 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -73,6 +73,7 @@ static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr, static int drm_dp_mst_register_i2c_bus(struct drm_dp_aux *aux); static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_aux *aux); static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr); +static void drm_dp_mst_update_dsc_crtcs(struct drm_dp_mst_topology_state *mst_state); #define DP_STR(x) [DP_ ## x] = #x @@ -3293,6 +3294,65 @@ int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state, } EXPORT_SYMBOL(drm_dp_atomic_find_vcpi_slots); +/** + * drm_dp_helper_update_vcpi_slots_for_dsc() - Update VCPI slots with new on the state + * + * @state: global atomic state + * @port: port to find vcpi slots + * @pbn: updated bandwidth required for the mode in PBN + * + * Function reallocates VCPI slots to the @port by calling + * drm_dp_atomic_find_vcpi_slots. The assumption is that VCPI slots + * have already been allocated and this is second call overwritting + * initial values. After the VCPI is allocated dsc_enable flag is set to + * true for atomic check. + * + * It is driver's responsibility to call this function after it decides + * to enable DSC. + * + * See also: + * drm_dp_mst_update_dsc_crtcs() + * + * Returns: + * Total slots in the atomic state assigned for this port, or a negative error + * code if the port no longer exists or vcpi slots haven't been assigned. + */ +int drm_dp_helper_update_vcpi_slots_for_dsc(struct drm_atomic_state *state, + struct drm_dp_mst_port *port, + int pbn) +{ + struct drm_dp_mst_topology_state *topology_state; + struct drm_dp_vcpi_allocation *pos; + bool found = false; + int vcpi = 0; + + topology_state = drm_atomic_get_mst_topology_state(state, port->mgr); + + if (IS_ERR(topology_state)) + return PTR_ERR(topology_state); + + list_for_each_entry(pos, &topology_state->vcpis, next) { + if (pos->port == port) { + found = true; + break; + } + } + + if (!found || !pos->vcpi) + return -EINVAL; + + vcpi = drm_dp_atomic_find_vcpi_slots(state, port->mgr, + port, pbn); + + if (vcpi < 0) + return -EINVAL; + + pos->dsc_enable = true; + + return vcpi; +} + +EXPORT_SYMBOL(drm_dp_helper_update_vcpi_slots_for_dsc); /** * drm_dp_atomic_release_vcpi_slots() - Release allocated vcpi slots * @state: global atomic state @@ -3871,6 +3931,46 @@ drm_dp_mst_atomic_check_topology_state(struct drm_dp_mst_topology_mgr *mgr, return 0; } +/** + * drm_dp_mst_update_dsc_crtcs - Set mode change flag on CRTCs which + * just got DSC enabled + * @state: Pointer to the new &struct drm_dp_mst_topology_state + * + * Itearate through all the ports in MST topology to check if DSC + * has been enabled on any of them. Set mode_changed to true on + * crtc state that just got DSC enabled. + * + * See also: + * drm_dp_helper_update_vcpi_slots_for_dsc() + */ +static void +drm_dp_mst_update_dsc_crtcs(struct drm_dp_mst_topology_state *mst_state) +{ + struct drm_dp_vcpi_allocation *pos; + struct drm_dp_mst_port *port; + struct drm_connector_state *conn_state; + struct drm_crtc *crtc; + struct drm_crtc_state *crtc_state; + + list_for_each_entry(pos, &mst_state->vcpis, next) { + + port = pos->port; + conn_state = drm_atomic_get_connector_state(mst_state->base.state, + port->connector); + crtc = conn_state->crtc; + if (!crtc) + continue; + + crtc_state = drm_atomic_get_crtc_state(mst_state->base.state, crtc); + if (port->vcpi.vcpi == pos->vcpi) + continue; + + if (pos->dsc_enable) { + crtc_state->mode_changed = true; + pos->dsc_enable = false; + } + } +} /** * drm_dp_mst_atomic_check - Check that the new state of an MST topology in an * atomic update is valid @@ -3887,9 +3987,9 @@ drm_dp_mst_atomic_check_topology_state(struct drm_dp_mst_topology_mgr *mgr, * See also: * drm_dp_atomic_find_vcpi_slots() * drm_dp_atomic_release_vcpi_slots() - * * Returns: * + * * 0 if the new state is valid, negative error code otherwise. */ int drm_dp_mst_atomic_check(struct drm_atomic_state *state) @@ -3902,6 +4002,7 @@ int drm_dp_mst_atomic_check(struct drm_atomic_state *state) ret = drm_dp_mst_atomic_check_topology_state(mgr, mst_state); if (ret) break; + drm_dp_mst_update_dsc_crtcs(mst_state); } return ret; diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h index 4cf738545dfb..185e29895f5f 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -431,6 +431,7 @@ struct drm_dp_payload { struct drm_dp_vcpi_allocation { struct drm_dp_mst_port *port; int vcpi; + bool dsc_enable; struct list_head next; }; @@ -662,6 +663,9 @@ int __must_check drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state, struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, int pbn); +int drm_dp_helper_update_vcpi_slots_for_dsc(struct drm_atomic_state *state, + struct drm_dp_mst_port *port, + int pbn); int __must_check drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state, struct drm_dp_mst_topology_mgr *mgr,