From patchwork Sat Nov 16 22:01:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lipski, Mikita" X-Patchwork-Id: 11247771 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 0FD3C913 for ; Sat, 16 Nov 2019 22:02:33 +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 E6EF22071E for ; Sat, 16 Nov 2019 22:02:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6EF22071E 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 940336E270; Sat, 16 Nov 2019 22:01:51 +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-eopbgr740054.outbound.protection.outlook.com [40.107.74.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id A78E16E1ED; Sat, 16 Nov 2019 22:01:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=igBG8F8yZKSBvWyZbmE3Cm5l1Wro5LqE5lJJygMv0+4wfyd8JWuyyfPnDL9NCJyHz9vTdJfgYSKaelGZ/erEDRP3dqd9zU7XAV/ob0CcWNer5LnjRJZxXDMiWUSlF8L8PBLACPo/S+aYu+CpPU+VMIKEEos2LscC4+h1iIZNgo3OMcbEND8Xl6z0w2crAB/CPerFTsFjJ5F38W39VTAsPwpzEmeGBiiaWP1FUn0caLg6/f9fGG5LVMdhzTPNEWjl0MxbLrUbLsv2XE3C7PP8zyHgSXVXcWk7UF1g/6E9iXD5H3QLEF6oNue2nyFThhOnP5G3opyU+Eg6593TvpLoVQ== 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=M7tRPK+iip7jp7gTIgzLFG4hMyHc/UqLL3TzNXoaJjk=; b=e5AO+vD/YIUhZvl4bYKOPRznrKqbTQJvW/CPwMfi74AtuSGAVVzZnqLExVak748wXPNkycU4AmVUWpAzL/MNXUsnisIdbju21XZipMBqrmj23AsDHvn/tt0ul55pDNePLw/aNti0rqhXS9ZCXs5OZB48U7HUihIqPnxKvQlcRc2fiMovzUzXjZbueS0GqQxmwUMNUmlSs8jgx2G+D53SK0lqDVcExOf6ViNfjrbioUoYa1DThvQ0vGZSx6KU45fiN812HOPlKnXAgjHVV1KM0eKnPbLUACoF22QjEooRzfngRL48DT3U4r0iapgbr1FyI85K6MhVXndVGmXivC6Jbw== 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 DM5PR1201MB0010.namprd12.prod.outlook.com (2603:10b6:3:e3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.29; Sat, 16 Nov 2019 22:01:39 +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:38 +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:37 -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:37 -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:37 -0600 From: To: Subject: [PATCH v7 11/17] drm/dp_mst: Add DSC enablement helpers to DRM Date: Sat, 16 Nov 2019 17:01:22 -0500 Message-ID: <20191116220128.16598-12-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)(39860400002)(376002)(396003)(346002)(136003)(428003)(199004)(189003)(8936002)(426003)(70586007)(478600001)(2876002)(476003)(14444005)(70206006)(47776003)(2616005)(305945005)(186003)(53416004)(11346002)(446003)(486006)(356004)(6666004)(7696005)(76176011)(126002)(26005)(51416003)(336012)(2906002)(5660300002)(6916009)(50226002)(36756003)(50466002)(2351001)(4326008)(1076003)(48376002)(81166006)(316002)(8676002)(16586007)(81156014)(86362001)(54906003)(16060500001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR1201MB0010; H:SATLEXMB01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 209276d0-7475-4898-9d28-08d76ae08e6c X-MS-TrafficTypeDiagnostic: DM5PR1201MB0010: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-Forefront-PRVS: 02234DBFF6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 74ywBDhqbYv3bXuUPV/rNFwHkGQRskrhzaotpeqFdSnhH5ptDsbMG3sRwAaDQPCa9x6dMkFhRThZIIOWTP0Vzg2qGL8CXHqGc+9Ec2krctgW+9fvu1hOiXHoXcG6dJ2lexlxzDFUuRjrP8uhFxX3FtfRiWJmKKjQ5NRY3MYCPM2PJyfJZ7c4NoS+9JkjyS1FUFeijQ1S3MZHtTK1Z+MCl5dDZc4bdLR3ENSgvM7LgPzXme8C2y+9wCXs7n6R/YC6+1P33LuayEJIZvOa5Sp9zJ57hHrq8/ow7vUPpEJ2lmyP81LlbZbtsXFIcJB06hEsoeMc0vjdq8v0DMM8wy8vhKiF+QOqlrwTslNOcGWjnffDDGmPp8qpc51dCBeMQboc2nlR/6bKrx7ZB0evhIvB9wEWojnDyYQLxQywbcqm/ulfxz9KBpbkoLur8S+MspCw X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2019 22:01:38.9314 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 209276d0-7475-4898-9d28-08d76ae08e6c 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: DM5PR1201MB0010 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=M7tRPK+iip7jp7gTIgzLFG4hMyHc/UqLL3TzNXoaJjk=; b=ADt++C13jygK1RAh+KicCzhXiBq9oJwBdjFC6/O4yO/T8EFpzFAet4aqWkMW647VcIAQGeCe+CAsidGrG/FLUtFWQSS5X/gqWMQVjWDkHSWVAIDa6PwRteCA4AEilwsOYJ+CWZDTEV2VQi1kTqJeFTCuGyP1B6qxLjmhkPkZ0u8= 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 --- 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 94bb259ab73e..98cc93d5ddd7 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -3876,6 +3876,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 fc19094b06c3..b1b00de3083b 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_enabled; struct list_head next; }; @@ -663,6 +664,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,