From patchwork Tue Aug 20 19:11:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Francis X-Patchwork-Id: 11104535 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 9CB8813B1 for ; Tue, 20 Aug 2019 19:12:42 +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 84D4D2082F for ; Tue, 20 Aug 2019 19:12:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84D4D2082F 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 27F006E86C; Tue, 20 Aug 2019 19:12:30 +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-eopbgr730066.outbound.protection.outlook.com [40.107.73.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id 623D66E866; Tue, 20 Aug 2019 19:12:28 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mvviOYw3LHouMQv6rQ/Mmy8HRl4fw5O3LQf8Sti0cO912jILdxy3B5w/0/gOsqcCBQzNd3BuapnT8ZpyxloVJcW6bHc5n6g4R1/KpUuzHS7er4edlW4dRoksvnIh464dFeJsQEagb5UYdKsT5UmReBWBEa2ADILtZ1Ruf9UNE8j8oD4I4r5woVkl+Kj+Ej5TkRBWtqu+lAXDo8GnLzUGCHONvo8lE+qHeNos+tCvEuwBSTLrWtDwPgOOYtB3Xutx+X1KQkpCCJU8AMcuT4zXQ+nE+ZH6LmE5JY+U3g5Z3+w0iDrX772VIIgGJ1BmRl5b/97FzI63LwaRJX8aq9O9nQ== 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=xWxSdJDCh0chskGh5wL8fWwLYc0o9AVKu+WfRH16CCo=; b=mviivZ+uw0lWzdkFWnpOsWpKMb9IjJ/QuZiJa7kibtJqPI4T2DPgBaYdYaS71/kOXWkh81zLbiTTlCFsmpQTxbjF2ORGuXMpqXpjsvG0aE60+iU0gQaDq1jjwOTsW0QSm2EOham5gqEfEizBdA1nGecp9ZSUg9BgWotcpt/C5jFAMhmdAcwjJSRWGEp0hi6fm4BjrB+7mRO5/ajdkEIxNDE4mgv2IL86MEoFx5lcZww16nlXr9rdv2SYRcMhIvuSQRjY51pq1Wr5ME01LsxtfQ6Bht5rIaIAmVZ+L5SX920UEafq0yLGRryqrWhToBIU7JMtgNfitY+ENRW5A1qfsw== 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 MWHPR1201CA0010.namprd12.prod.outlook.com (2603:10b6:301:4a::20) by CY4PR12MB1271.namprd12.prod.outlook.com (2603:10b6:903:3d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Tue, 20 Aug 2019 19:12:25 +0000 Received: from BY2NAM03FT012.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::205) by MWHPR1201CA0010.outlook.office365.com (2603:10b6:301:4a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2178.16 via Frontend Transport; Tue, 20 Aug 2019 19:12:25 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by BY2NAM03FT012.mail.protection.outlook.com (10.152.84.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2178.16 via Frontend Transport; Tue, 20 Aug 2019 19:12:24 +0000 Received: from localhost.localdomain (10.180.168.240) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Tue, 20 Aug 2019 14:12:21 -0500 From: David Francis To: , Subject: [PATCH v2 06/14] drm/dp-mst: Use dc and drm helpers to compute timeslots Date: Tue, 20 Aug 2019 15:11:55 -0400 Message-ID: <20190820191203.25807-7-David.Francis@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820191203.25807-1-David.Francis@amd.com> References: <20190820191203.25807-1-David.Francis@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)(346002)(39860400002)(396003)(376002)(136003)(2980300002)(428003)(189003)(199004)(81166006)(81156014)(5660300002)(478600001)(8676002)(8936002)(70586007)(50226002)(70206006)(86362001)(50466002)(305945005)(48376002)(51416003)(49486002)(76176011)(476003)(126002)(450100002)(14444005)(53936002)(54906003)(110136005)(16586007)(446003)(426003)(11346002)(336012)(2616005)(186003)(26005)(36756003)(486006)(1076003)(316002)(6666004)(356004)(2906002)(4326008)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1271; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 031af769-cfa6-4556-a2de-08d725a255cb X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328); SRVR:CY4PR12MB1271; X-MS-TrafficTypeDiagnostic: CY4PR12MB1271: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-Forefront-PRVS: 013568035E X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 4aWc5pAZ4zgmax19dZ/L5cTMHG4AUW2UVvxxbQKUmeGVIaIWi/kZG8pmS9bnU9jzYGLNyuxxTB4bNwJco/BOOr9Hb0EusuXSyLtwHDuFrIfzy6L5RKIL1xFLEuF1OomPPdDIAmJwHaMe4vtXl/POtA6VGi6RCYW7+5MZ9rInRtliS3zC12qSeQ9y2rKs6mDpP4Mjt+Gz2Rurit1lDLwDfXgkYxk+SLNNbAYOBMyo58/qfe0IOZrAq7cd6p2pQ33joJwSnHsgB0GYvCEKQLrGigHBPsVietDqXBV7RCXMeiuJ3RB1jdt7BMAURgBrzBVsTFqxhXFChL0XU1vB9rENK3azaY74sT3rslGLcQBEc4hK9exwDdAYDiX4B4xXniOlPuauiGjEZz/tdgU7WACA1n9MVfENNLbc9c6ZOC7kYQA= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2019 19:12:24.8921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 031af769-cfa6-4556-a2de-08d725a255cb 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=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1271 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=xWxSdJDCh0chskGh5wL8fWwLYc0o9AVKu+WfRH16CCo=; b=i7i3tJFrv5jC1m5Bys9MWUJ1OGuint9cblCMA56lCbCqyvawMYFB2mBlPlLCQ9oZgP/FJDDNS7Lw+mMhJiFoS3zwu2XqhmhzJkx7+wQc5eIksuo7BppcEi/0Cx9o5OezyDBazKBtecttqqKEQiky5xAOI0EfGctxn/R/IQyA3WQ= 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: David Francis , Jerry Zuo , Nicholas Kazlauskas Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We were using drm helpers to convert a timing into its bandwidth, its bandwidth into pbn, and its pbn into timeslots These helpers -Did not take DSC timings into account -Used the link rate and lane count of the link's aux device, which are not the same as the link's current cap -Did not take FEC into account (FEC reduces the PBN per timeslot) For converting timing into PBN, add a new function drm_dp_calc_pbn_mode_dsc that handles the DSC case For converting PBN into time slots, amdgpu doesn't use the 'correct' atomic method (drm_dp_atomic_find_vcpi_slots), so don't add a new helper to cover our approach. Use the same means of calculating pbn per time slot as the DSC code. v2: Add drm helper for clock to pbn conversion Cc: Jerry Zuo Cc: Nicholas Kazlauskas Signed-off-by: David Francis --- .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 18 +++++--- drivers/gpu/drm/drm_dp_mst_topology.c | 41 +++++++++++++++++++ include/drm/drm_dp_mst_helper.h | 2 +- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index 5f2c315b18ba..dfa99e0d6e64 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c @@ -189,8 +189,8 @@ bool dm_helpers_dp_mst_write_payload_allocation_table( int slots = 0; bool ret; int clock; - int bpp = 0; int pbn = 0; + int pbn_per_timeslot, bpp = 0; aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context; @@ -208,7 +208,6 @@ bool dm_helpers_dp_mst_write_payload_allocation_table( clock = stream->timing.pix_clk_100hz / 10; switch (stream->timing.display_color_depth) { - case COLOR_DEPTH_666: bpp = 6; break; @@ -234,11 +233,18 @@ bool dm_helpers_dp_mst_write_payload_allocation_table( bpp = bpp * 3; - /* TODO need to know link rate */ - - pbn = drm_dp_calc_pbn_mode(clock, bpp); +#ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT + if (stream->timing.flags.DSC) + pbn = drm_dp_calc_pbn_mode_dsc(clock, + stream->timing.dsc_cfg.bits_per_pixel); + else +#endif + pbn = drm_dp_calc_pbn_mode(clock, bpp); - slots = drm_dp_find_vcpi_slots(mst_mgr, pbn); + /* Convert kilobits per second / 64 (for 64 timeslots) to pbn (54/64 megabytes per second) */ + pbn_per_timeslot = dc_link_bandwidth_kbps( + stream->link, dc_link_get_link_cap(stream->link)) / (8 * 1000 * 54); + slots = DIV_ROUND_UP(pbn, pbn_per_timeslot); ret = drm_dp_mst_allocate_vcpi(mst_mgr, mst_port, pbn, slots); if (!ret) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 398e7314ea8b..d789b7af7dbf 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -3588,6 +3588,47 @@ static int test_calc_pbn_mode(void) return 0; } +/** + * drm_dp_calc_pbn_mode_dsc() - Calculate the PBN for a mode with DSC enabled. + * @clock: dot clock for the mode + * @dsc_bpp: dsc bits per pixel x16 (e.g. dsc_bpp = 136 is 8.5 bpp) + * + * This uses the formula in the spec to calculate the PBN value for a mode, + * given that the mode is using DSC + */ +int drm_dp_calc_pbn_mode_dsc(int clock, int dsc_bpp) +{ + u64 kbps; + s64 peak_kbps; + u32 numerator; + u32 denominator; + + kbps = clock * dsc_bpp; + + /* + * margin 5300ppm + 300ppm ~ 0.6% as per spec, factor is 1.006 + * The unit of 54/64Mbytes/sec is an arbitrary unit chosen based on + * common multiplier to render an integer PBN for all link rate/lane + * counts combinations + * calculate + * peak_kbps *= (1/16) bppx16 to bpp + * peak_kbps *= (1006/1000) + * peak_kbps *= (64/54) + * peak_kbps *= 8 convert to bytes + * + * Divide numerator and denominator by 16 to avoid overflow + */ + + numerator = 64 * 1006 / 16; + denominator = 54 * 8 * 1000 * 1000; + + kbps *= numerator; + peak_kbps = drm_fixp_from_fraction(kbps, denominator); + + return drm_fixp2int_ceil(peak_kbps); +} +EXPORT_SYMBOL(drm_dp_calc_pbn_mode_dsc); + /* we want to kick the TX after we've ack the up/down IRQs. */ static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr) { diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h index 2ba6253ea6d3..ddb518f2157a 100644 --- a/include/drm/drm_dp_mst_helper.h +++ b/include/drm/drm_dp_mst_helper.h @@ -611,7 +611,7 @@ struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_ int drm_dp_calc_pbn_mode(int clock, int bpp); - +int drm_dp_calc_pbn_mode_dsc(int clock, int dsc_bpp); bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, int pbn, int slots);