From patchwork Tue Nov 6 20:24:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kazlauskas, Nicholas" X-Patchwork-Id: 10671367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E00BC13AD for ; Tue, 6 Nov 2018 20:25:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC78928E5D for ; Tue, 6 Nov 2018 20:25:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF3C929483; Tue, 6 Nov 2018 20:25:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 624692AA6E for ; Tue, 6 Nov 2018 20:25:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 957096E425; Tue, 6 Nov 2018 20:24:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0078.outbound.protection.outlook.com [104.47.40.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4E2496E41C; Tue, 6 Nov 2018 20:24:46 +0000 (UTC) Received: from CY4PR1201CA0007.namprd12.prod.outlook.com (2603:10b6:910:16::17) by BLUPR12MB0419.namprd12.prod.outlook.com (2a01:111:e400:516c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Tue, 6 Nov 2018 20:24:44 +0000 Received: from DM3NAM03FT037.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::208) by CY4PR1201CA0007.outlook.office365.com (2603:10b6:910:16::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1294.21 via Frontend Transport; Tue, 6 Nov 2018 20:24:44 +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 DM3NAM03FT037.mail.protection.outlook.com (10.152.83.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1294.14 via Frontend Transport; Tue, 6 Nov 2018 20:24:43 +0000 Received: from kazbox.amd.com (10.180.168.240) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Tue, 6 Nov 2018 14:24:41 -0600 From: Nicholas Kazlauskas To: , Subject: [PATCH v6 4/5] drm/amdgpu: Correct get_crtc_scanoutpos behavior when vpos >= vtotal Date: Tue, 6 Nov 2018 15:24:34 -0500 Message-ID: <20181106202435.23556-5-nicholas.kazlauskas@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181106202435.23556-1-nicholas.kazlauskas@amd.com> References: <20181106202435.23556-1-nicholas.kazlauskas@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)(136003)(39860400002)(346002)(376002)(396003)(2980300002)(428003)(189003)(199004)(11346002)(2616005)(81156014)(7696005)(53416004)(316002)(97736004)(81166006)(53936002)(23676004)(426003)(1076002)(68736007)(4326008)(14444005)(110136005)(50226002)(72206003)(26005)(77096007)(76176011)(486006)(36756003)(5820100001)(476003)(54906003)(2870700001)(106466001)(186003)(8936002)(478600001)(446003)(126002)(6666004)(104016004)(2906002)(66574009)(47776003)(44832011)(356004)(336012)(305945005)(8676002)(50466002)(105586002)(86362001)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR12MB0419; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT037; 1:+HXN2M33DqzlDzuCcHtYy7m5oJBLGwcfreTYtE6mx7Zd9hmQbnXmwE0uVIOz5pWw3ILVZOHB+71Tlqfh6xwFhsWaBBU6ZkQkyD/fjlbupLnEhS0yyp/VMCa5mNW7TNRb X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 054aa3ba-8564-4ef2-d0bb-08d64425e364 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060); SRVR:BLUPR12MB0419; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0419; 3:tFA3HxLvnvn6kyaxn1g+7FMjRjrb8yJOqGUJ+pWDlDtlBmJFqdf/hX7y4y8DbCALHGzutG04giw+TFvezwR5p3jDUzUra3yn0XFUwznR5I81ZNf7FDvFGgmvKva+LFoELVhjFfslA/tvPwO6L9pnhG7L9ozEMEx7omJUUFbOq4sUIbArRsJ8bXhb3Ok1mzHWBuYHSqhNrLdpKUmHQrYBLMayv4QOmSvXVQbOUU4+ab4IsVJktjYcyIditsqP4LgeFGyhlNY+p2ACnCG7oqIA9/EzvOJA1C/4xMzhjYHa/q9Xzk+dM0XHXFDkOv68B6vIXfe76oP7yTyQ/xtPA3tTcO5t9MsC0AxlMeSX0Van4XM=; 25:+27rMpSB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CIX6V0RR9teDtZwG5DZsMpmWUSDy5Zgml0E5zN4hc6Ak8gMTvOMBEzZ/VCvr/71x21/zDbnHRkeR7AWJH X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(17755550239193); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231382)(944501410)(52105095)(3002001)(10201501046)(93006095)(93003095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:BLUPR12MB0419; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0419; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0419; 4:vVTe5CzJo1+rLoVCvQcfn4Ksz45ugiGfSfYQFWnIFZ5sB+dcSYI8ACjm9TyNgrSiX+ew0AvMdbycPWGhguhRvVcTsV4bQ1hxUqIIq6SXAbMODceM5FtvnQ53HKnrKMhyPXe7qC5tuobQiD+YVsi6Bfop5clewFMUq3XvywHXkjMrJvuHfHxy7RGgYogvLPF7zJPA/yyYQPY3mT0qTyImXGMWVUMT4m2KZPoIw0N40mdpRP+9By7jOgtLTiq9ItWEME9Ytp4bJ6IfIJxGDgVL9BjP101bzihzrtpFqW1Wul7tffruCnk/OgXHiNLGVXBbmcasHmdsW6QeLW+3NoHkVw== X-Forefront-PRVS: 0848C1A6AA X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BBLUPR12MB0419=3B23=3AOcVHWM0?= =?utf-8?q?sopJT9R5OESr8zVRtH2DNn4dlK45wzn5X03BOk8K38z3LWU58OTTs4fw7HurpMho2?= =?utf-8?q?h0GBFnZKpBlF1rQIkoebLmjPbMIY5WWSXqHcrQ3RjZfYL3FRoAn7MGRl7GGWey0of?= =?utf-8?q?0Yf0nNqz9n9bfJPtKI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zIRRQ2TePBfm7oYsWm2N57OGnBKWmc/BU5Oz6CZ3XiLAFVzS19DxJ1YdetQ==; 5:0Vdmb4UFv1KrQ9MenQ0BrO13kFxNMphfzT7iHgroNWknoRv4XDjIhkxCRuduUAVqYe099xc3yA/MJVFDlLAIs4Cj4kJbQzPM9S5xSxGpJmdLsluOjpufDadM9Lgjtzqb5Ak2ryEl/9/hH74z8Z6oPPwieTyifttIjJrE9fPKbOU=; 7:Pp+aEtVkJ8oPQE8nOuwB1Drdu7Um3y3vXguifHfcEnu5kQfAHiIsfsSYplbflXfq1JSw4f35Mwe0VFund9qlAgo+TNA3TWHTa0ot3A4Puztj3t4TVfOZStaGWCkDHjeH8ZShTn7csWZvsBECZiBEUg== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0419; 20:Ie7+doP6PnhaatMlwvA/AeJYRPTFHWlHi8bTh+wmkSjRWqgZqqMyoPgQMtGhtm8g5Ox0kY/VhU/mLzlyzszPEZI+HbXqOADbGpufyX/3Exde3A9Wkf1w4f4vU1Xn3M7xRk/mWDGFMFnu6Mm1/p+1qR5NmXqPjkO9oGsCtxam+2eUV3AyimeWd8KAJY+1+AaJDtTpP9do2pUvzai+/hJbwqXMo9eMeQfqx++Ya/+qsi9jTmFkvJlHtk+j2lG4vNE2 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2018 20:24:43.7142 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 054aa3ba-8564-4ef2-d0bb-08d64425e364 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: BLUPR12MB0419 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: michel@daenzer.net, Nicholas Kazlauskas Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When variable refresh rate is active the hardware counter can return a position >= vtotal. This results in a vpos being returned from amdgpu_display_get_crtc_scanoutpos that's a positive value. The positive value indicates to the caller that the display is currently in scanout when the display is actually still in vblank. This is because the vfront porch duration is unknown with variable refresh active and will end when either a page flip occurs or the timeout specified by the driver/display is reached. The behavior of the amdgpu_display_get_crtc_scanoutpos remains the same when the position is below vtotal. When the position is above vtotal the function will return a value that is effectively -vbl_end, the size of the vback porch. The only caller affected by this change is the DRM helper for calculating vblank timestamps. This change corrects behavior for calculating the page flip timestap from being the previous timestamp to the calculation to the next timestamp when position >= vtotal. Signed-off-by: Nicholas Kazlauskas Cc: Michel Dänzer Cc: Harry Wentland Reviewed-by: Harry Wentland --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 6748cd7fc129..cb331319f225 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c @@ -850,7 +850,12 @@ int amdgpu_display_get_crtc_scanoutpos(struct drm_device *dev, /* Inside "upper part" of vblank area? Apply corrective offset if so: */ if (in_vbl && (*vpos >= vbl_start)) { vtotal = mode->crtc_vtotal; - *vpos = *vpos - vtotal; + + /* With variable refresh rate displays the vpos can exceed + * the vtotal value. Clamp to 0 to return -vbl_end instead + * of guessing the remaining number of lines until scanout. + */ + *vpos = (*vpos < vtotal) ? (*vpos - vtotal) : 0; } /* Correct for shifted end of vbl at vbl_end. */