From patchwork Fri Jan 22 22:07:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 8093671 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2928B9F744 for ; Fri, 22 Jan 2016 22:08:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B8D5205BD for ; Fri, 22 Jan 2016 22:08:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4FAC1205BB for ; Fri, 22 Jan 2016 22:08:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B64C872154; Fri, 22 Jan 2016 14:08:20 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0078.outbound.protection.outlook.com [157.56.110.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 162F672154 for ; Fri, 22 Jan 2016 14:08:19 -0800 (PST) Received: from CY1PR12CA0024.namprd12.prod.outlook.com (10.160.137.34) by SN1PR12MB0718.namprd12.prod.outlook.com (10.163.209.20) with Microsoft SMTP Server (TLS) id 15.1.365.19; Fri, 22 Jan 2016 22:08:16 +0000 Received: from BY2NAM03FT026.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::209) by CY1PR12CA0024.outlook.office365.com (2a01:111:e400:4c1f::34) with Microsoft SMTP Server (TLS) id 15.1.390.13 via Frontend Transport; Fri, 22 Jan 2016 22:08:16 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.221) 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; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp01.amd.com (165.204.84.221) by BY2NAM03FT026.mail.protection.outlook.com (10.152.84.210) with Microsoft SMTP Server id 15.1.390.12 via Frontend Transport; Fri, 22 Jan 2016 22:08:16 +0000 X-WSS-ID: 0O1DK5R-07-DM1-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 247CF12C12C1 for ; Fri, 22 Jan 2016 17:08:15 -0500 (EST) Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 22 Jan 2016 16:08:20 -0600 Received: from STOREXDAG02.amd.com (10.1.13.11) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 22 Jan 2016 17:08:14 -0500 Received: from cnhwentlanub.amd.com (172.29.225.36) by storexdag02.amd.com (10.1.13.11) with Microsoft SMTP Server id 14.3.266.1; Fri, 22 Jan 2016 17:08:14 -0500 From: Harry Wentland To: Subject: [PATCH 2/5] drm/dp/mst: Calculate MST PBN with 31.32 fixed point Date: Fri, 22 Jan 2016 17:07:26 -0500 Message-ID: <1453500449-9224-3-git-send-email-harry.wentland@amd.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453500449-9224-1-git-send-email-harry.wentland@amd.com> References: <1453500449-9224-1-git-send-email-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(450100001)(48376002)(189998001)(4326007)(19580405001)(92566002)(77096005)(2906002)(87936001)(33646002)(50466002)(2950100001)(110136002)(1220700001)(5008740100001)(1096002)(19580395003)(86362001)(76176999)(50986999)(229853001)(105586002)(53416004)(47776003)(11100500001)(106466001)(97736004)(5003940100001)(36756003)(586003)(101416001)(50226001)(5003600100002)(2351001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0718; H:atltwp01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0718; 2:sLuqgJT1+91jHjv9SjA6+qf0j+dTWyj7suLPL62yfeYZRktKW4xc3jAo+8iFijhksjXu92Wng8a4sKWB95go+Ijtsah1Ys38ZbPXvXMJClJlAE+3nY3S+LqfFXn4c2T0C97ZLGLBl9UWODohIBfWMQ==; 3:hlCIgEZ7HxDI2JYE+yGzbM+tQnpSJfNun9onytPhgRKzwZrCakJwBu38SOW9IMf3LNIU4MF92KF8z0G8KlUctQiD4BnOVLb10LuwN3A2xLfmgdGPgOGu6FBEFo0hdS6jNhQGM5jbfx7z1948wvZam15EUc0vtYdD56hs5PFttE6EhKKZua+2FVvUZKr/vg6QHW5pP9vqZL8q4kz9Sdn5ZT0EPshd3c7dh1CyCp1hMcw=; 25:eH8WsXn4PK5b900FRALxGPYkjZE/6Lw6hqL2CGRskaOYHv7FuuN7wUm4DiMX9mRgmBBxFVcWVVTbINcL9G1Q9j54UO1cjhQ3ZMphdWUGUv4AGR8BjsSEmnH1B8p3NzCHCom9SjfAkkQvGACt/JUM8hle4p2PZo11giaB7wPY0z7yzYlCTFUqVvciKT4vant5xzXeJjUKxpW9HX4FwDTvFnpk3s96NwxmvFfz8laQMf5dd6N9uS8M5x6nfl9+/CjT X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0718; X-MS-Office365-Filtering-Correlation-Id: 5091c4f0-3e38-46fb-db6b-08d32378875b X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0718; 20:TVDVMGlxT8zLKqXeXADkcG3r+gwrl9RNvT9jbZdwwH75Kru21mKJZCQUcN2Htf0NOKMTrJKFNUK555PXOYIoIn3LUU6I9Fl5tRbrmd9jJR+Yl5oJ7ds3oU3Y2k46DwYnm7B78CBep3uaRfzun16NWMKBkvpbqjxbECUvOEAhr3CpEBy4WNWiiCK+ljgsuUoMTBiu2evbjx8oQFz30RdjOQpi6JIDO/3uesBR8kJfzDNR9wUCWOUT0tpJZIsiZHKvaE1ELSH2mscNtXvyj5ybMYIIjiLdpkRj+CM4Nfllag8/963HTSkxk/ERZ9w8MYajg0kbI6hK026BA+aBiQWQXUR/va/U4o1L3umWF5jPTCX2gSz+LlyDKCOZ8gvHqDhjRLyjSvCsKsNWXriyVCsH8Z9kdbonCy72Jb9dN1YxtaM2jop3xefFkkgEO4dMd0GhzpCDvur6POx1Yf1+EQjSnsKfyEKrh1sMBHg6kmbl4AwFMqiwVSvgPC1oCUjaUTPo X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(8121501046)(5005006)(13017025)(13015025)(13024025)(520078)(13023025)(3002001)(10201501046); SRVR:SN1PR12MB0718; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0718; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0718; 4:zxOs3PPmMxRxpJgzhSER7Z1bChZ0TbJe0zbHFkNP37e0emGxmSIxOM3EX5y0Or6XW3gKWks3KYH3Y1I06M+okPmdPvsDqLKraHAciG55bf/PpWWFLyDrLJ7mtIvNx9dKnIGsD8tARZ2WTUj5Shk09muiKQ+LidEh6YSSJN+MXwsh8xXnerb0nrb+Jfkr+6+0m9677athIIVFrHcjb1YWojcfIU56+pGZvzLJdds4A8V0NYpne/dxH6Zzpo5D5UjXR2OjnjMsU6LRjX5sSMkpaIhbsNiDdA4YVr+uQEFhLLrk49DvVdsKmnhr7J2P9j5t4m56rqlS8XJrruO2yG8bxWxYia0OK4mIjbGRFUPG9C36MTAOVs0awhmQdwz9XC7YDVt7FemshswcGjz5dwlvtSSurO/3mtChhgUm8dQny4mP/NNEJ1meWMb8W71noR6LcoyLuUvdip/GZ3qMwA17tYVDlYr/A3669dh/7KfnYX9OSbKO2AbeiErhOmilBTOjq3T+iCrOdSe67KYJDTuu1A== X-Forefront-PRVS: 08296C9B35 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0718; 23:SbBsa+r4rbdkBbKgorqjiv+m1mDh/3cGWmNC11UnL?= =?us-ascii?Q?uS9mHkIf6byn+z+xhd5Wr3SiBUmMjkPGxUic71bJE5E/ABJnLJm3YIoWkZLY?= =?us-ascii?Q?MsGAnkqiDwkYnb+crgQNgd4YXkpZuP+lvIJu91oPgK3k6vp1l6XCKev2sN8T?= =?us-ascii?Q?BpYNjW44S1J13HvRQ9gxOHPRQE5jeWy9VbhOjn1q9Z7dNJVY4m55EG0Tbv5i?= =?us-ascii?Q?2Wo+4vKggT3cq9QHIHe1TkA5MiPAqfI/ucSY9nvbz9FV7fG1WDzNMR02OtDR?= =?us-ascii?Q?VBoylBAyT/dcPF9N7YkXODBZ1mZFlgnUwC1HVFCNMXUqQhbUhbLQtqXJjolU?= =?us-ascii?Q?Gn2jHC1DY1+46EBS0Py9C+n2rhZjOKFeNJGCtr12/9ooPL36ksOe5KYUH4IX?= =?us-ascii?Q?jtACvIh5HDBeVD5vmorPgobjTvZlLu8wO+OmwWkWJ/znRUo4G6E4H6xDJ6OF?= =?us-ascii?Q?uauZj6RMk/JKg1/LQM3eUDSlXl0x++fCy5nmSi3alJa/LFgiPyi0msO4nK/r?= =?us-ascii?Q?TbyKaniayF+4IQDTkC1XQgwJ7rqvDj/1CG28OwPP7EuakDuxAFS1Hs63EAwg?= =?us-ascii?Q?j62HujxPz30J3Yftjp0CHlGPlo98Q834Onc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AVKUTTZBbUN1j8Dc+JaGMLq+HxhnpuHeW/YBZwPG6U+hqKKpLX2 SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2016 22:08:16.1332 (UTC) 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.221]; Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0718 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Our PBN value overflows the 20 bits integer part of the 20.12 fixed point. We need to use 31.32 fixed point to avoid this. This happens with display clocks larger than 293122 (at 24 bpp), which we see with the Sharp (and similar) 4k tiled displays. Signed-off-by: Harry Wentland Reviewed-by: Alex Deucher --- drivers/gpu/drm/drm_dp_mst_topology.c | 67 ++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 6ed90a2437e5..041597b7a7c6 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -2605,32 +2605,31 @@ EXPORT_SYMBOL(drm_dp_check_act_status); */ int drm_dp_calc_pbn_mode(int clock, int bpp) { - fixed20_12 pix_bw; - fixed20_12 fbpp; - fixed20_12 result; - fixed20_12 margin, tmp; - u32 res; - - pix_bw.full = dfixed_const(clock); - fbpp.full = dfixed_const(bpp); - tmp.full = dfixed_const(8); - fbpp.full = dfixed_div(fbpp, tmp); - - result.full = dfixed_mul(pix_bw, fbpp); - margin.full = dfixed_const(54); - tmp.full = dfixed_const(64); - margin.full = dfixed_div(margin, tmp); - result.full = dfixed_div(result, margin); - - margin.full = dfixed_const(1006); - tmp.full = dfixed_const(1000); - margin.full = dfixed_div(margin, tmp); - result.full = dfixed_mul(result, margin); - - result.full = dfixed_div(result, tmp); - result.full = dfixed_ceil(result); - res = dfixed_trunc(result); - return res; + u64 kbps; + s64 peak_kbps; + u32 numerator; + u32 denominator; + + kbps = clock * 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 *= (1006/1000) + * peak_kbps *= (64/54) + * peak_kbps *= 8 convert to bytes + */ + + numerator = 64 * 1006; + 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); @@ -2638,11 +2637,23 @@ static int test_calc_pbn_mode(void) { int ret; ret = drm_dp_calc_pbn_mode(154000, 30); - if (ret != 689) + if (ret != 689) { + DRM_ERROR("PBN calculation test failed - clock %d, bpp %d, expected PBN %d, actual PBN %d.\n", + 154000, 30, 689, ret); return -EINVAL; + } ret = drm_dp_calc_pbn_mode(234000, 30); - if (ret != 1047) + if (ret != 1047) { + DRM_ERROR("PBN calculation test failed - clock %d, bpp %d, expected PBN %d, actual PBN %d.\n", + 234000, 30, 1047, ret); return -EINVAL; + } + ret = drm_dp_calc_pbn_mode(297000, 24); + if (ret != 1063) { + DRM_ERROR("PBN calculation test failed - clock %d, bpp %d, expected PBN %d, actual PBN %d.\n", + 297000, 24, 1063, ret); + return -EINVAL; + } return 0; }