From patchwork Sat Nov 16 22:01:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lipski, Mikita" X-Patchwork-Id: 11247757 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 8767D913 for ; Sat, 16 Nov 2019 22:02:16 +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 6F2BD2071E for ; Sat, 16 Nov 2019 22:02:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F2BD2071E 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 6CF8A6E202; Sat, 16 Nov 2019 22:01:48 +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-eopbgr730078.outbound.protection.outlook.com [40.107.73.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id D98236E1F2; Sat, 16 Nov 2019 22:01:44 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oFaq8fAlPFhS+Klrj0Tw4Fsc/kDzLU6rLgftKJPTlxNxUSIhI+5FHynhszDAIg3VGIIcGjD88bVlWuf0zxiNTs54ffW06hoYI35w6iMs56HRjqimJc7wBqoC/EQPUIhOcL3dKweIn3IJKmiUQ2AC2tMs8imf8fKLgVk/4cmL0D17curC2ujlBlPubYUMSDD0qWA/ZrGY776K/TuYuvPPs4X+qNbAMv/BX5/R4NLkViE8MFgS+tQG0XmaPsKtz6eKrwqYZIgQra9OeiVAVrRFdwW0gJHVab2+X1T+hMd5UTG6oqMiUMCxiBfMMprKWwxkwysFL0HjRHEC7mYGdnZ5lw== 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=yV8WCJ89uh2tBErlC+5l8Y55UMZFMakdjbF9gOuW65I=; b=g+qY1ZzbustxYGTYZ0RnQpxZFrBgYm+7nLUI0g6cTH4CnFIqHtfsIXFEuW+5uTrqqdmmwvdm873AY2cCVzKBGDCssL7LrwyNWeWaltPfI2T51hu4Y9PcbsqqSpTSBEkWOt+oWTmDnfEHTiNvbGWUNn2vRFOUZtqLAKoxX4TezBm8fq6VTn2l7HyGquLJsFKWsT+3VN8Uo28Sfbf1C5A3jtW71pMZqzcQubZB+Xf8eimnqnycvSDppJwJR8Wfr0fLd0Lez3s+WBvKzhmyMU+m0DeJriQ6FcBwdF3Dnuw1088wx7gFUTeRLEF1GnVBhixvQ6cFdL91qD2q0Z/AT22kiQ== 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 CY4PR1201CA0008.namprd12.prod.outlook.com (2603:10b6:910:16::18) by BYAPR12MB3080.namprd12.prod.outlook.com (2603:10b6:a03:de::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.28; Sat, 16 Nov 2019 22:01:40 +0000 Received: from CO1NAM11FT010.eop-nam11.prod.protection.outlook.com (2a01:111:f400:7eab::209) by CY4PR1201CA0008.outlook.office365.com (2603:10b6:910:16::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2451.23 via Frontend Transport; Sat, 16 Nov 2019 22:01:39 +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 CO1NAM11FT010.mail.protection.outlook.com (10.13.175.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2451.23 via Frontend Transport; Sat, 16 Nov 2019 22:01:39 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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; Sat, 16 Nov 2019 16:01:38 -0600 Received: from SATLEXMB01.amd.com (10.181.40.142) by SATLEXMB05.amd.com (10.181.40.146) 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:38 -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:38 -0600 From: To: Subject: [PATCH v7 13/17] drm/dp_mst: Add helper to trigger modeset on affected DSC MST CRTCs Date: Sat, 16 Nov 2019 17:01:24 -0500 Message-ID: <20191116220128.16598-14-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)(39860400002)(346002)(136003)(396003)(428003)(189003)(199004)(5660300002)(2906002)(4326008)(476003)(126002)(336012)(36756003)(48376002)(16586007)(14444005)(50466002)(5024004)(316002)(53416004)(6666004)(356004)(305945005)(54906003)(2876002)(2351001)(486006)(7696005)(51416003)(76176011)(81156014)(81166006)(8676002)(186003)(6916009)(26005)(8936002)(478600001)(426003)(86362001)(11346002)(446003)(2616005)(50226002)(70206006)(70586007)(1076003)(47776003)(17423001)(16060500001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR12MB3080; 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: 71fd366b-a9d6-4bea-2469-08d76ae08ed4 X-MS-TrafficTypeDiagnostic: BYAPR12MB3080: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 02234DBFF6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gci/fea+w5lmdlKOPLsY85gyiifad57R8b1PsgB5tylKLRW9TKhFP5hf8BAdnMGnOUlT2oW8NqY7fyF81qkuMFAd3O721CbG6e9sNLAJDo0bc8+74+c0lgFucP1kS3QvkOTXd6DhiRbOmK4LC9XkHYOCvY+X+vN7urK6OcOHGkrHML4L97KAu1r2ZZA2Eoqqsn1OTCEUbSXMsJ8FIDp1tnoBYwSh2teR/t9qIUS4sUtGeS5GB/NoG001ePSvA1OCbnkKIFkkwYhxfJ1sRtC8kngzVDunVs5H5x5vBbE/v0MrtB/w15z11hxnC4cGD2Qcz3xU4JM+jEdL+8jXkS5ODUadWYDIgZkN4rs2CMpPfyUcolkAJf97oDDQDwzCWIr0Zsi8PHifGANf4Y0ngsneX4gkwerBfNJ+J3kV3QqxZCx0jxoCtmvInswcjHjjyGp8 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2019 22:01:39.6099 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71fd366b-a9d6-4bea-2469-08d76ae08ed4 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: BYAPR12MB3080 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=yV8WCJ89uh2tBErlC+5l8Y55UMZFMakdjbF9gOuW65I=; b=ePImrXONA2obfCAYUULrlc+7KkWlUu+wH7pfQcSBhZag7Zs455aIVd77VzNa8ZYAsC0WaRUn1OaJcmoEYVVNxXZaaqWDOVY1Fb6yn7tT1HegsonNcaZcmE6fTjG6xniRzNBPqybxr+mnMmevwT+LMVS5gu/2mDca94fcAD7t8/E= 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 [why] Whenever a connector on an MST network is changed or undergoes a modeset, the DSC configs for each stream on that topology will be recalculated. This can change their required bandwidth, requiring a full reprogramming, as though a modeset was performed, even if that stream did not change timing. [how] Adding helper to trigger modesets on MST DSC connectors by setting mode_changed flag on CRTCs in the same topology as affected connector Signed-off-by: Mikita Lipski --- drivers/gpu/drm/drm_dp_mst_topology.c | 90 +++++++++++++++++++++++++++ include/drm/drm_dp_mst_helper.h | 2 + 2 files changed, 92 insertions(+) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 5072c1e3dcfe..4d9089fe84c1 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 bool drm_dp_mst_is_dsc_supported(struct drm_dp_mst_port *port); #define DP_STR(x) [DP_ ## x] = #x @@ -3936,6 +3937,66 @@ drm_dp_mst_atomic_check_topology_state(struct drm_dp_mst_topology_mgr *mgr, return 0; } +/** + * drm_dp_mst_add_affected_dsc_crtcs + * @state: Pointer to the new &struct drm_dp_mst_topology_state + * @port: Pointer tothe port of connector with new state + * + * Whenever there is a change in mst topology + * DSC configuration would have to be recalculated + * therefore we need to trigger modeset on all affected + * CRTCs in that topology + * + * See also: + * drm_dp_mst_atomic_enable_dsc() + */ +int drm_dp_mst_add_affected_dsc_crtcs(struct drm_atomic_state *state, struct drm_dp_mst_port *port) +{ + struct drm_dp_mst_topology_state *mst_state; + struct drm_dp_vcpi_allocation *pos; + struct drm_connector *connector; + struct drm_connector_state *conn_state; + struct drm_crtc *crtc; + struct drm_crtc_state *crtc_state; + + if (!port) + return -EINVAL; + + mst_state = drm_atomic_get_mst_topology_state(state, port->mgr); + + list_for_each_entry(pos, &mst_state->vcpis, next) { + + connector = pos->port->connector; + + if (!connector) + return -EINVAL; + + conn_state = drm_atomic_get_connector_state(state, connector); + + if (IS_ERR(conn_state)) + return PTR_ERR(conn_state); + + crtc = conn_state->crtc; + + if (!crtc) + return -EINVAL; + + if (!drm_dp_mst_is_dsc_supported(pos->port)) + continue; + + crtc_state = drm_atomic_get_crtc_state(mst_state->base.state, crtc); + + if (IS_ERR(crtc_state)) + return PTR_ERR(crtc_state); + + DRM_DEBUG_ATOMIC("[MST PORT:%p] Setting mode_changed flag on CRTC %p\n", port, crtc); + + crtc_state->mode_changed = true; + } + return 0; +} +EXPORT_SYMBOL(drm_dp_mst_add_affected_dsc_crtcs); + /** * drm_dp_mst_atomic_enable_dsc - Set DSC Enable Flag to On/Off * @state: Pointer to the new drm_atomic_state @@ -4433,3 +4494,32 @@ struct drm_dp_aux *drm_dp_mst_dsc_aux_for_port(struct drm_dp_mst_port *port) return NULL; } EXPORT_SYMBOL(drm_dp_mst_dsc_aux_for_port); + +/** + * drm_dp_mst_is_dsc_supported() - Verify DSC support on connector + * @port: The port to check. A leaf of the MST tree with an attached display. + * + * Acquiring correct aux from drm_dp_mst_dsc_aux_for_port + * and verifying DPCD flag that the aux is DSC capable + * + * Returns: + * True / False - if DSC is supported + */ +static bool drm_dp_mst_is_dsc_supported(struct drm_dp_mst_port *port) +{ + struct drm_dp_aux *dsc_aux; + u8 endpoint_dsc; + + dsc_aux = drm_dp_mst_dsc_aux_for_port(port); + + if (!dsc_aux) + return false; + + if (drm_dp_dpcd_read(&port->aux, DP_DSC_SUPPORT, &endpoint_dsc, 1) < 0) + return false; + + if (endpoint_dsc & DP_DSC_DECOMPRESSION_IS_SUPPORTED) + return true; + + return false; +} diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h index 5a119a40ed5a..7d1e5e42c9ac 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -669,6 +669,8 @@ int drm_dp_mst_atomic_enable_dsc(struct drm_atomic_state *state, struct drm_dp_mst_port *port, int pbn, int pbn_div, bool enable); +int drm_dp_mst_add_affected_dsc_crtcs(struct drm_atomic_state *state, + struct drm_dp_mst_port *port); int __must_check drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state, struct drm_dp_mst_topology_mgr *mgr,