From patchwork Tue Dec 3 14:35: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: 11271417 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 16294138D for ; Tue, 3 Dec 2019 14:36:07 +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 F2BB620659 for ; Tue, 3 Dec 2019 14:36:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2BB620659 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 23A046E79E; Tue, 3 Dec 2019 14:35:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM04-CO1-obe.outbound.protection.outlook.com (mail-eopbgr690079.outbound.protection.outlook.com [40.107.69.79]) by gabe.freedesktop.org (Postfix) with ESMTPS id A66276E7A3; Tue, 3 Dec 2019 14:35:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gyc9fefcgWTLZgKnrvTKJwbY8bIlFkLUAKE7jzmDkYgexjeyVaAA3VcHJ9MDbl8c06ooL/MUOsOREnoXh+itp43cnxNdrZ57pTsNXrS4HBvPSQL8k5iFCc3RMSBNxasdIESSQrQh2LED8kxxMeemsPbyH40ERQ6/EFW+QBvdYeHEbyDl4M0aGiT6Bzs13Ia1T3v2POFMF8PoBrB8NYB3asSdqlEQbHkiI4deS5sYldWlAw3Cn3ApW9FVXK5Y/Jr0I9Tep++XT5sHEPPubkwyXSQV6qeLyTeT28CzSWPamOEQIH7bprACSNk1wtR+/efVoVYiUlUnQV/e+3gtvdu1Cw== 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=2UrE4Ew41tPsdhTMVp07HCIU5E5wsypTL/QnWHiCPHk=; b=Ms1J0LGNhtLQbzhOORl0BXQXwN5KatOUTjLlvI7mCfH05/Q0/feyZUY3S3TdMWUNUiAS0W+whzqPsZR1xEpwfW8JJGCOzFP/tMmjjP7BuBl0f4eYVucDI9lnguJhanhbo9R17jW3jD+MYRwjjW706F2IsfdMW/HnRpej8Eb4bEMTFGaxPKjy5Ug+TlyfxVYq8Tef4ZKZvzKh6sSEbgy243USBhSXTtLEK3VXVKgpU43yUblwKg5dZLz1baE0KoQes4oAPoe3wRO36AnngSDB5VdsX6bI7LCjuvWLXe0xBD5LkecmTgcekrsvR/yCv3xg0iW2DX8Xh4lHHI5Eq+nEeg== 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 CY4PR12MB1479.namprd12.prod.outlook.com (2603:10b6:910:d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2495.21; Tue, 3 Dec 2019 14:35:48 +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:48 +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:48 +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:45 -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:45 -0600 From: To: Subject: [PATCH v8 11/17] drm/dp_mst: Add DSC enablement helpers to DRM Date: Tue, 3 Dec 2019 09:35:24 -0500 Message-ID: <20191203143530.27262-12-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)(396003)(346002)(376002)(136003)(39860400002)(428003)(199004)(189003)(51416003)(7696005)(81156014)(81166006)(8676002)(50226002)(8936002)(86362001)(356004)(2616005)(478600001)(1076003)(16586007)(5660300002)(446003)(316002)(336012)(11346002)(426003)(54906003)(53416004)(2876002)(2906002)(70586007)(186003)(36756003)(6666004)(6916009)(26005)(70206006)(76176011)(50466002)(305945005)(4326008)(2351001)(14444005)(48376002)(16060500001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1479; H:SATLEXMB02.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5d5cf5f-9441-4400-cb6b-08d777fe16a8 X-MS-TrafficTypeDiagnostic: CY4PR12MB1479: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-Forefront-PRVS: 02408926C4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4qJIyZjFAXI596WPqygfxY7+EiHHFlVgOirTyONS7UboUYHz578/KP1mgEDePjSPclwAJGT+k6aTbEsDHKoaGqSUSaNB0AGOeDYaQoRqdPYgDJsxZODqFMX+oQb9t/piCcZaQJzGO8qgTt33yQ/Q4eUOBJhekNNKHKnmAmtNul0cidbI0cWhH3tp5qZznbkm8vWcp9G0AqSpMLsAm72wnBy8S4f668j8S/TrjT2ZY5/ak6wwQWocf6aGjIuGUIqdOMGrZknBVzhVRedJqDqOFhrH1rM8QG8Tx+T2GUxzr0qT/GALTyr/yvgBBleE9GKebKWBoNuZzyP8l45i9RaJKuq6NOc/jZK4nRR3ilM0Bl+jQXHe7yWc9tmLBQBJ9OwUbrmuZSG0pglZLjI3LqwcTQZpbFbTwdW+3aDlK675XnQAtHnlU7cdZb7eQ8cpdxT6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2019 14:35:48.0913 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5d5cf5f-9441-4400-cb6b-08d777fe16a8 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: CY4PR12MB1479 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=2UrE4Ew41tPsdhTMVp07HCIU5E5wsypTL/QnWHiCPHk=; b=PE7v/YYFNqfS314BajUwaBe8/PA/lkIHl4/a1Vuvfh9X5VvUl4HS8WPGewQ4pxS4Xc9P8WBsTc9SmpNGR8ZkMy2F92Y0K5+zpMdCVvWJCOVzHxKPZprpb/pYO8kSZSRQgfUvvZzcUnUJZNAx0K7vsSZ2lm3W3X4AqfHY0c7/aww= 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 a helper function to be called by drivers outside of DRM to enable DSC on the MST ports. Function is called to recalculate VCPI allocation if DSC is enabled and raise the DSC flag to enable. In case of disabling DSC the flag is set to false and recalculation of VCPI slots is expected to be done in encoder's atomic_check. v2: squash separate functions into one and call it per port Cc: Harry Wentland Cc: Lyude Paul Signed-off-by: Mikita Lipski Reported-by: kbuild test robot Reviewed-by: Lyude Paul --- drivers/gpu/drm/drm_dp_mst_topology.c | 61 +++++++++++++++++++++++++++ include/drm/drm_dp_mst_helper.h | 5 +++ 2 files changed, 66 insertions(+) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index f1d883960831..5e549f48ffb8 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -4742,6 +4742,67 @@ drm_dp_mst_atomic_check_topology_state(struct drm_dp_mst_topology_mgr *mgr, return 0; } +/** + * drm_dp_mst_atomic_enable_dsc - Set DSC Enable Flag to On/Off + * @state: Pointer to the new drm_atomic_state + * @pointer: Pointer to the affected MST Port + * @pbn: Newly recalculated bw required for link with DSC enabled + * @pbn_div: Divider to calculate correct number of pbn per slot + * @enable: Boolean flag enabling or disabling DSC on the port + * + * This function enables DSC on the given Port + * by recalculating its vcpi from pbn provided + * and sets dsc_enable flag to keep track of which + * ports have DSC enabled + * + */ +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) +{ + struct drm_dp_mst_topology_state *mst_state; + struct drm_dp_vcpi_allocation *pos; + bool found = false; + int vcpi = 0; + + mst_state = drm_atomic_get_mst_topology_state(state, port->mgr); + + if (IS_ERR(mst_state)) + return PTR_ERR(mst_state); + + list_for_each_entry(pos, &mst_state->vcpis, next) { + if (pos->port == port) { + found = true; + break; + } + } + + if (!found) { + DRM_DEBUG_ATOMIC("[MST PORT:%p] Couldn't find VCPI allocation in mst state %p\n", + port, mst_state); + return -EINVAL; + } + + if (pos->dsc_enabled == enable) { + DRM_DEBUG_ATOMIC("[MST PORT:%p] DSC flag is already set to %d, returning %d VCPI slots\n", + port, enable, pos->vcpi); + vcpi = pos->vcpi; + } + + if (enable) { + vcpi = drm_dp_atomic_find_vcpi_slots(state, port->mgr, port, pbn, pbn_div); + DRM_DEBUG_ATOMIC("[MST PORT:%p] Enabling DSC flag, reallocating %d VCPI slots on the port\n", + port, vcpi); + if (vcpi < 0) + return -EINVAL; + } + + pos->dsc_enabled = enable; + + return vcpi; +} +EXPORT_SYMBOL(drm_dp_mst_atomic_enable_dsc); /** * drm_dp_mst_atomic_check - Check that the new state of an MST topology in an * atomic update is valid diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h index 0f813d6346aa..830c94b7f45d 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -502,6 +502,7 @@ struct drm_dp_payload { struct drm_dp_vcpi_allocation { struct drm_dp_mst_port *port; int vcpi; + bool dsc_enabled; struct list_head next; }; @@ -773,6 +774,10 @@ 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 pbn_div); +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 __must_check drm_dp_atomic_release_vcpi_slots(struct drm_atomic_state *state, struct drm_dp_mst_topology_mgr *mgr,