From patchwork Tue Jan 3 15:06:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 9495015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 58F08606A7 for ; Tue, 3 Jan 2017 15:07:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E1BC27569 for ; Tue, 3 Jan 2017 15:07:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FD7C276D6; Tue, 3 Jan 2017 15:07:19 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 9795D27569 for ; Tue, 3 Jan 2017 15:07:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A0736E598; Tue, 3 Jan 2017 15:07:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 163948 seconds by postgrey-1.35 at gabe; Tue, 03 Jan 2017 15:06:59 UTC Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0060.outbound.protection.outlook.com [104.47.41.60]) by gabe.freedesktop.org (Postfix) with ESMTPS id 29AFF6E598 for ; Tue, 3 Jan 2017 15:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=tZrI4YVgmfiVtqMIJuWPnVJeexbchqm9gn0Tm+dm/oA=; b=azQpTXYWSBX2nb+NdAHkNiT2GPkvqGcBOdN7cKcEORMeRT1wVLDG5Ou96Nusrv7iC8ns/njFdtkqIpWPF7jXVqP1YUuESw488vBiMa6uFprsjCjuwNyowcBXT0eyvpPET6p90M+N9GBq5w1LzW31zxZcV+Bf8NKeLWzCrBqq8IQ= Received: from DM3PR12CA0009.namprd12.prod.outlook.com (10.164.12.147) by BY2PR12MB0039.namprd12.prod.outlook.com (10.160.66.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.817.10; Tue, 3 Jan 2017 15:06:56 +0000 Received: from DM3NAM03FT054.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::206) by DM3PR12CA0009.outlook.office365.com (2a01:111:e400:599f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.817.10 via Frontend Transport; Tue, 3 Jan 2017 15:06:56 +0000 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; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by DM3NAM03FT054.mail.protection.outlook.com (10.152.83.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.803.8 via Frontend Transport; Tue, 3 Jan 2017 15:06:56 +0000 Received: from SCYBEXDAG01.amd.com (10.34.11.11) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 3 Jan 2017 09:06:56 -0600 Received: from agrodzovsky-All-Series.amd.com (172.29.227.109) by SCYBEXDAG01.amd.com (10.34.11.11) with Microsoft SMTP Server id 14.3.319.2; Tue, 3 Jan 2017 23:06:52 +0800 From: Andrey Grodzovsky To: Subject: [PATCH] drm/atomic: Add target_vblank support in atomic helpers. Date: Tue, 3 Jan 2017 10:06:38 -0500 Message-ID: <1483455998-26914-1-git-send-email-Andrey.Grodzovsky@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: 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)(6009001)(7916002)(39410400002)(39850400002)(39860400002)(39840400002)(39450400003)(2980300002)(428002)(199003)(189002)(2906002)(110136003)(106466001)(6916009)(105586002)(76176999)(4326007)(101416001)(189998001)(53416004)(6666003)(8936002)(305945005)(50226002)(626004)(86362001)(38730400001)(2950100002)(50466002)(50986999)(48376002)(77096006)(356003)(36756003)(97736004)(47776003)(54906002)(8676002)(5003940100001)(92566002)(68736007)(5660300001)(2351001)(81156014)(81166006); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0039; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT054; 1:DbpQWgOYqaR9V7Ijy0Vodc15vpzD8AWWFjFN0d6r/j5lRjh9nbJUhEJCTrsxEhS/ZaYYYx+Gs4/mhuvlEnFHdFLAlH/mx3Sn7XW2PBkNaHBixr88uyfTKm+YaWFoR5DUCVVf6OOYT/Wb0xcumgClEqOXfRnxxygMBYR7ona4bB5kPdzZ+ave4qN/7S13J4kjqOjb3Oh2wDvAENT3rX/IDJxCTWcmVqKA+hSyurdZSYgAfiHdgS1q6CIF3QRHseHF48ahVUpwNynu1bu2WiXowY9ZAYPXizt9M5C7BUsvIdJJJiFa47dWYiyytD2pFZXvmZbhjiS7frI2UuZUGwUOhkt8uwF+GAJ+R5OgQRy4TxC+il8+QFgdkoUzO7aw18UO24myNdZsGgDqyS2oR3O8WnLs/dbYoGzwu58IoG0c/wiAClX9OpqfYkznC2zp+MP0R4KNoUc/FwaGGGqOzbhuHGsE2hgHi8oZHB0kMC1eFNHxGx3Cx1sOmsaIfiuV0ngy X-MS-Office365-Filtering-Correlation-Id: 0c32ca97-63df-436d-6c7a-08d433ea28ef X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BY2PR12MB0039; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0039; 3:jqUd7XrIfB/8vjvPS93vZ2A6DJIH7xLGp229d490ZEN8GE9OrGjOAQ2h/vWXIHKZq8yBENnMI3/8VFuX/4qztsrU85HZnQO2BhIkT2/eVNPRTTVwpxmO9orMqOA+xEJ8U+uQfPys+/Bt3oLA2enSsh1fYSQRJHYOV8f7bWlisjnfstuvts3ExoqvoHRBiATNNsLahjtNrrU8uTwijVUbJFTpk6TGp7uj5Ji0Qc96sFtFDQCGlsaP8lnXsbIXXOoBAj4p9Bu2RKFaA2cSFxjVDxS+NcBEH3mQisZJqVc3djSG118zErdq0X0qpGqYzD7HLgZ0Duu0ruv+tyfqrFN0aWDXDFHan47nZjhxNu5g8zaIuxuIEK6i7MWdBROQb0lO; 25:+j4SbUiknHnfrVcltOssmqCLadskrUG6l1/vXNOXCOOhhy/WPhvzCqUFj9VCJznuPznFUxu78mEKOzO/2hB0FZ4uSBe6pZNscFH4F0fWOkflCPPzJnVx/nlImVhvc+9h+UkNaPxXfZv6Le7BK8KsDexduGVepDl87hOtVcnNioV3J6eMaaA0FR7VOFLfjAqPHrn7JAPXBJu+PmnaLF2nwuTIDNEL713EsbxeCA/3NrVQCY2Pp866S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-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13016025)(13018025)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123560025)(20161123558021)(20161123564025)(20161123562025)(6072148); SRVR:BY2PR12MB0039; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0039; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0039; 4:pX6qVcopAADC902ovr5bbbwzG7i02WzpEaRSaBO2QqxqklVTOp0dkBbf3r76JS67akS48XF6wsiM6LDF7Mj7cjF4nkCK+WgyHamL/BNixcMvJISN4MjnayGqd5fPsitskPG9q1dhhqX1Bf6osomE6sdp7xWqdyc+wTfuqyaG/nOG2kAhfp/P41H3IRiymxr44hVRh68VmRKsASoywKT6tNT5hsyNUmCb2m39hCyzB8t47Re6yE7ggABreY26yDsOrlke15GuS5muIq7Wzj/h9D0+rkfceJq141PMLJQV5mn1ooh2uBwfhOlI7LkpYgZXE9mbegSYIOyMDsL0a86Al4EURqEnFisDuJxiJAdVvG1x8PxAFNKTH4BhWy5O4ozNkssm9TL73Pv3vgFiPrt1Cwg1Y3pyayUKvmhKyZq9jboDgiFNaoeab4O9BbDSw95o4jqq4FrjDLoRc8/L+gDI3YsGud/3dDYmbvN8KP639dYs6RnZCDUBTKMD0dBjGQRXOLARjNmKFJXdnKvznQTqK5umBufExsBnpbT4yKrutAiILbRsQStW1TCFTThSDhOISxpjKPTI4mRYH20pBN/APqgPzY6RziqBhklcS/taV9FPLTLiS2dTtH6+lgIElVIsg/bsfio2cl0Z1i4+ZP3+d5iUyI2AD0pjq8Gti1ulgFBh5pfcVXUhPR5kewS7+CorE5yhgXHHhmyeH7LDDqgmJw== X-Forefront-PRVS: 01762B0D64 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR12MB0039; 23:8LBCaDBPIQ+MbvpZ0Jy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UBXR582zUwbFcQsq39IVCA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0039; 7:Y1D1ytkiYeD1E5VKUrCRt8U7kCq2AYdKTY/r3umEfRxXRjS2O1gj6oFNANTtW39XN/PGnpXn9pXcz1Vkt2iPZhFpjbiw0viyDqM5/+o7+0qRCnmKkE/TvyyzPx3TvoUh2rQA56f6/JU2WDGOqrxM2bZRPyiNKMuXKdGAT8OfrfDReyRmVpvptMHySukoMAbBXJ6cpjP30t3jj6BL151Vz677L77HdMchQfVBymx5U5s6gxchq4MfpSpbsQX4//mM0O/iKY/5KQdHO+kpOSX1PGnIuoTq6wZHkDJ2oJT6YTMm6rfXP6K37my22IdFRVMsEIjUCV0zDAKMyECpjmEeEeQY1eph3yFNCEczAA65Bf2Tu4kPrTCmPJBDHAFIO+9j6eV9QssOm4IBFvaXcldtiuJmh5+b7s3XZBl2dQn7Bgbfdz5MbrPuKx8ow7IeTVGG2oHDz+RuC5YBxHFBLQCANA==; 20:VaZYc9ysREE+AhQgr070BvZkvgx/q7Fv4bxmySCcP/ZGOtVMMicS8Xpb3rVR83VUKwNLXzC3QcP2pP9GGz1nRo5zFCQKOoXoePA4pcljQfSEuB0tpNH1D2Zdo1e9oNjjLcgB0uTdHAASxjAItDgkRNvsJhIkr8B/L53rDrbVxkjD53aOu+2pdFTdVKKwJO0Y5WLgdzaTmHREy6OFHQFGA4ndpLGee3XBfSbrhvK8tAnRSh/U+nhUawhctKg0Vj5J X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2017 15:06:56.6819 (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.17]; Helo=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0039 Cc: Alexander.Deucher@amd.com, daniel.vetter@ffwll.ch, Michel.Daenzer@amd.com, Andrey Grodzovsky 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-Virus-Scanned: ClamAV using ClamSMTP Allows usage of the new page_flip_target hook for drivers implementing the atomic path. Provides default atomic helper for the new hook. Signed-off-by: Andrey Grodzovsky --- drivers/gpu/drm/drm_atomic_helper.c | 146 ++++++++++++++++++++++++++++-------- include/drm/drm_atomic_helper.h | 6 ++ include/drm/drm_crtc.h | 3 + 3 files changed, 125 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 583f47f..5e76f90 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -2733,6 +2733,59 @@ int drm_atomic_helper_resume(struct drm_device *dev, } EXPORT_SYMBOL(drm_atomic_helper_connector_set_property); +static int drm_atomic_helper_page_flip_create_state( + struct drm_atomic_state *state, + struct drm_crtc *crtc, + struct drm_framebuffer *fb, + struct drm_pending_vblank_event *event) +{ + struct drm_plane *plane = crtc->primary; + struct drm_plane_state *plane_state; + struct drm_crtc_state *crtc_state; + int ret = 0; + + crtc_state = drm_atomic_get_crtc_state(state, crtc); + if (IS_ERR(crtc_state)) + return PTR_ERR(crtc_state); + + crtc_state->event = event; + + plane_state = drm_atomic_get_plane_state(state, plane); + if (IS_ERR(plane_state)) + return PTR_ERR(plane_state); + + + ret = drm_atomic_set_crtc_for_plane(plane_state, crtc); + if (ret != 0) + return ret; + drm_atomic_set_fb_for_plane(plane_state, fb); + + /* Make sure we don't accidentally do a full modeset. */ + state->allow_modeset = false; + if (!crtc_state->active) { + DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy flip\n", + crtc->base.id); + return -EINVAL; + } + + return ret; +} + +static void drm_atomic_helper_page_flip_prepare_retry( + struct drm_atomic_state *state, + struct drm_plane *plane) +{ + drm_atomic_state_clear(state); + drm_atomic_legacy_backoff(state); + + /* + * Someone might have exchanged the framebuffer while we dropped locks + * in the backoff code. We need to fix up the fb refcount tracking the + * core does for us. + */ + plane->old_fb = plane->fb; +} + /** * drm_atomic_helper_page_flip - execute a legacy page flip * @crtc: DRM crtc @@ -2756,8 +2809,6 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc, { struct drm_plane *plane = crtc->primary; struct drm_atomic_state *state; - struct drm_plane_state *plane_state; - struct drm_crtc_state *crtc_state; int ret = 0; if (flags & DRM_MODE_PAGE_FLIP_ASYNC) @@ -2768,35 +2819,79 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc, return -ENOMEM; state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc); + retry: - crtc_state = drm_atomic_get_crtc_state(state, crtc); - if (IS_ERR(crtc_state)) { - ret = PTR_ERR(crtc_state); + ret = drm_atomic_helper_page_flip_create_state(state, crtc, fb, event); + if (ret != 0) goto fail; - } - crtc_state->event = event; - plane_state = drm_atomic_get_plane_state(state, plane); - if (IS_ERR(plane_state)) { - ret = PTR_ERR(plane_state); - goto fail; - } + ret = drm_atomic_nonblocking_commit(state); - ret = drm_atomic_set_crtc_for_plane(plane_state, crtc); +fail: + if (ret == -EDEADLK) + goto backoff; + + drm_atomic_state_put(state); + return ret; + +backoff: + drm_atomic_helper_page_flip_prepare_retry(state, plane); + goto retry; +} +EXPORT_SYMBOL(drm_atomic_helper_page_flip); + +/** + * drm_atomic_helper_page_flip - execute a legacy page flip + * @crtc: DRM crtc + * @fb: DRM framebuffer + * @event: optional DRM event to signal upon completion + * @flags: flip flags for non-vblank sync'ed updates + * + * Provides a default page flip on specific vblank implementation using + * the atomic driver interface. + * + * Note that for now so called async page flips (i.e. updates which are not + * synchronized to vblank) are not supported, since the atomic interfaces have + * no provisions for this yet. + * + * Returns: + * Returns 0 on success, negative errno numbers on failure. + */ +int drm_atomic_helper_page_flip_on_target_vblank( + struct drm_crtc *crtc, + struct drm_framebuffer *fb, + struct drm_pending_vblank_event *event, + uint32_t flags, + uint32_t target) +{ + struct drm_plane *plane = crtc->primary; + struct drm_atomic_state *state; + struct drm_crtc_state *crtc_state; + int ret = 0; + + if (flags & DRM_MODE_PAGE_FLIP_ASYNC) + return -EINVAL; + + state = drm_atomic_state_alloc(plane->dev); + if (!state) + return -ENOMEM; + + state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc); + +retry: + ret = drm_atomic_helper_page_flip_create_state(state, crtc, fb, event); if (ret != 0) goto fail; - drm_atomic_set_fb_for_plane(plane_state, fb); - /* Make sure we don't accidentally do a full modeset. */ - state->allow_modeset = false; - if (!crtc_state->active) { - DRM_DEBUG_ATOMIC("[CRTC:%d] disabled, rejecting legacy flip\n", - crtc->base.id); + crtc_state = drm_atomic_get_existing_crtc_state(state, crtc); + if (WARN_ON(!crtc_state)) { ret = -EINVAL; goto fail; } + crtc_state->target_vblank = target; ret = drm_atomic_nonblocking_commit(state); + fail: if (ret == -EDEADLK) goto backoff; @@ -2805,19 +2900,10 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc, return ret; backoff: - drm_atomic_state_clear(state); - drm_atomic_legacy_backoff(state); - - /* - * Someone might have exchanged the framebuffer while we dropped locks - * in the backoff code. We need to fix up the fb refcount tracking the - * core does for us. - */ - plane->old_fb = plane->fb; - + drm_atomic_helper_page_flip_prepare_retry(state, plane); goto retry; } -EXPORT_SYMBOL(drm_atomic_helper_page_flip); +EXPORT_SYMBOL(drm_atomic_helper_page_flip_on_target_vblank); /** * drm_atomic_helper_connector_dpms() - connector dpms helper implementation diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h index 7ff92b0..e8cb6b7 100644 --- a/include/drm/drm_atomic_helper.h +++ b/include/drm/drm_atomic_helper.h @@ -124,6 +124,12 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb, struct drm_pending_vblank_event *event, uint32_t flags); +int drm_atomic_helper_page_flip_on_target_vblank( + struct drm_crtc *crtc, + struct drm_framebuffer *fb, + struct drm_pending_vblank_event *event, + uint32_t flags, + uint32_t target); int drm_atomic_helper_connector_dpms(struct drm_connector *connector, int mode); struct drm_encoder * diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 946672f..cc926dc 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -103,6 +103,7 @@ static inline uint64_t I642U64(int64_t val) * @ctm: Transformation matrix * @gamma_lut: Lookup table for converting pixel data after the * conversion matrix + * @target_vblank: Target vblank count to flip * @state: backpointer to global drm_atomic_state * * Note that the distinction between @enable and @active is rather subtile: @@ -156,6 +157,8 @@ struct drm_crtc_state { struct drm_property_blob *ctm; struct drm_property_blob *gamma_lut; + u32 target_vblank; + /** * @event: *