From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84358C4360F for ; Tue, 12 Mar 2019 12:49:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 47CA4214D8 for ; Tue, 12 Mar 2019 12:49:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gpKx8OYB"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amdcloud.onmicrosoft.com header.i=@amdcloud.onmicrosoft.com header.b="jRjyR0MG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47CA4214D8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=o+aSN6W6XD9vDWqhIn/lsqQtDamURqwwGwlkn5jbrYU=; b=gpKx8OYBJ8RCaB emWjs6OSQvsup7hDWDXKjrtABOhuh/eLH6gJhdlhJcCHqUwRKEZ6zzTgyvnDwbC8EZpoG/9qzHc00 FtTPQgfuriT/Itp61TpISUrt+Iv/oprhmtn/8Vy1OnSlBnocIlPWFvUVr3Yf3/V2slQUDOTPsp+1t 3ZO3y+zEmIBpS7x7UFhbzP8ju32AU4O00Vsad36YvNa7SfSwrEFMOBEjRyiHf4sf1bCT8+LdXqzUy 2mJwJhZ6y6o+mWMK4OUZzRW5thOmE2mHC+IV5TtADH7VeX+OisdwnN5fGM+ai+IzrsrrIJ2YF9UYu l1+n+1wz0FJtG5ZBQNuA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3gqj-0003zr-EI; Tue, 12 Mar 2019 12:49:41 +0000 Received: from mail-eopbgr680087.outbound.protection.outlook.com ([40.107.68.87] helo=NAM04-BN3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3gqg-0003z6-G5; Tue, 12 Mar 2019 12:49:40 +0000 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:X-MS-Exchange-SenderADCheck; bh=uHENzublx1G6GI1+b2ZWAxn/4Sedj5ZoadEYOhir4T8=; b=jRjyR0MGcyrKUdt6Md35tomrqTDSIOQcHHqsoZVgh4kLLZ9l+bFy+4h2aB6HfeZLyAfY6sHj9MLuV64PiH6Mb+5E91NGJ91BdEE0LKgaprRDMZ4gC04ICzWTP9UolvjzyaE/EjlYqjrWkzKtOTYAhvM9p4ty1E+xqqy1b3nibaI= Received: from BYAPR12MB3560.namprd12.prod.outlook.com (20.178.197.10) by BYAPR12MB2662.namprd12.prod.outlook.com (20.176.255.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.21; Tue, 12 Mar 2019 12:49:31 +0000 Received: from BYAPR12MB3560.namprd12.prod.outlook.com ([fe80::8df:1157:dba2:30cb]) by BYAPR12MB3560.namprd12.prod.outlook.com ([fe80::8df:1157:dba2:30cb%2]) with mapi id 15.20.1686.021; Tue, 12 Mar 2019 12:49:31 +0000 From: "Kazlauskas, Nicholas" To: Boris Brezillon , Helen Koike Subject: Re: [PATCH v2 5/5] drm: don't block fb changes for async plane updates Thread-Topic: [PATCH v2 5/5] drm: don't block fb changes for async plane updates Thread-Index: AQHU2Hr15b9d+jEuq021Ol7jk+IimKYHjQmAgABmDoA= Date: Tue, 12 Mar 2019 12:49:31 +0000 Message-ID: <8ad63c91-1158-4f52-84db-3f8b9429ebad@amd.com> References: <20190312022204.2775-1-helen.koike@collabora.com> <20190312022204.2775-6-helen.koike@collabora.com> <20190312074411.59174024@collabora.com> In-Reply-To: <20190312074411.59174024@collabora.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: YTOPR0101CA0067.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b00:14::44) To BYAPR12MB3560.namprd12.prod.outlook.com (2603:10b6:a03:ae::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Nicholas.Kazlauskas@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.55.250] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a2a2bbb3-9826-461a-e1a9-08d6a6e92be3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:BYAPR12MB2662; x-ms-traffictypediagnostic: BYAPR12MB2662: x-microsoft-exchange-diagnostics: 1; BYAPR12MB2662; 20:myE/43e71+8xOAmLIKvtx32BOD3+jVRihokLBrloxpbocRnlbMPavM9r6MYVHQwmJ2BIKGCi0iqHmErft1dTFF8LwU3BSvcQxDOsvyOoHS84EFlVvY6q3Rh8NDYE6SlDSVDAKl2DUSO9RGkLcOhOffOYn/+dW7gMRlolcm2WLfeQ6NSdnF9jTd58f9SFKzuuOvDp1x3r6St4jBfa7CK4JDaLfJfAcbO1bVZVO8G4uQ57HX4K/ahonWdcWizJAqIk x-microsoft-antispam-prvs: x-forefront-prvs: 09749A275C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(39860400002)(376002)(346002)(366004)(136003)(396003)(189003)(199004)(2906002)(68736007)(53546011)(15650500001)(71190400001)(105586002)(6436002)(106356001)(4326008)(66066001)(305945005)(71200400001)(5660300002)(54906003)(6486002)(81156014)(81166006)(8676002)(316002)(110136005)(7736002)(11346002)(52116002)(31696002)(76176011)(86362001)(99286004)(6116002)(7416002)(25786009)(53936002)(446003)(486006)(386003)(8936002)(2616005)(186003)(476003)(6512007)(26005)(31686004)(36756003)(256004)(14444005)(102836004)(229853002)(6506007)(14454004)(72206003)(3846002)(478600001)(97736004)(6246003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR12MB2662; H:BYAPR12MB3560.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ZNgern2soWR/gDGKNRZYGMWby5mWEM/79NnVWQBGwby3Ii4Pcu0FWysTVT9ks+wsbP1lw5m35ttPhBeM2qCznufEhsAs0qwvcpZdmKMo5GGA6EhDOCQ8OEBW6fwA/dk2YVILrpQ68dsJJ0xCe4RwXDg/izvUPV0vNy4QE7nTwBUqOh7D80Iwj4J/e456w83BpgErnDm4b442rU0r7Zx1YKpNOEwPi3eJlAMApB0unYSVWUREPOX1neSoZIHOFuBxlhVmZYx5fMF2S19VWb77dvU+TpcVPclj722ehJPIfDlQ5Pcx5I0rMrXRJeyYTeH085ntVVQo1hlWbzNMVFSWu6244ZNJFY7wNwHWK7Cd2CE/JE1DQrUjKNQSyrW1gV0TmpSgfV+euDhXe5QCwWX1/bxSm4H7Ok6QlG3czTAyfi8= Content-ID: <60DC841580B7654BADF12E8C3D193D1B@namprd12.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a2a2bbb3-9826-461a-e1a9-08d6a6e92be3 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Mar 2019 12:49:31.8122 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2662 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190312_054938_595430_358CC7E6 X-CRM114-Status: GOOD ( 24.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?B?SGVpa28gU3TDvGJuZXI=?= , Sean Paul , David Airlie , "daniel.vetter@ffwll.ch" , "dri-devel@lists.freedesktop.org" , Sandy Huang , "eric@anholt.net" , "kernel@collabora.com" , Maxime Ripard , "amd-gfx@lists.freedesktop.org" , "linux-rockchip@lists.infradead.org" , "Wentland, Harry" , "Grodzovsky, Andrey" , "linux-arm-msm@vger.kernel.org" , Maarten Lankhorst , Sean Paul , "linux-arm-kernel@lists.infradead.org" , =?utf-8?B?U3TDqXBoYW5lIE1hcmNoZXNpbg==?= , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , Tomasz Figa , "robdclark@gmail.com" , Daniel Vetter , "freedreno@lists.freedesktop.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 3/12/19 2:44 AM, Boris Brezillon wrote: > On Mon, 11 Mar 2019 23:22:03 -0300 > Helen Koike wrote: > >> In the case of a normal sync update, the preparation of framebuffers (be >> it calling drm_atomic_helper_prepare_planes() or doing setups with >> drm_framebuffer_get()) are performed in the new_state and the respective >> cleanups are performed in the old_state. >> >> In the case of async updates, the preparation is also done in the >> new_state but the cleanups are done in the new_state (because updates >> are performed in place, i.e. in the current state). >> >> The current code blocks async udpates when the fb is changed, turning >> async updates into sync updates, slowing down cursor updates and >> introducing regressions in igt tests with errors of type: >> >> "CRITICAL: completed 97 cursor updated in a period of 30 flips, we >> expect to complete approximately 15360 updates, with the threshold set >> at 7680" >> >> Fb changes in async updates were prevented to avoid the following scenario: >> >> - Async update, oldfb = NULL, newfb = fb1, prepare fb1, cleanup fb1 >> - Async update, oldfb = fb1, newfb = fb2, prepare fb2, cleanup fb2 >> - Non-async commit, oldfb = fb2, newfb = fb1, prepare fb1, cleanup fb2 (wrong) >> Where we have a single call to prepare fb2 but double cleanup call to fb2. >> >> To solve the above problems, instead of blocking async fb changes, we >> place the old framebuffer in the new_state object, so when the code >> performs cleanups in the new_state it will cleanup the old_fb and we >> will have the following scenario instead: >> >> - Async update, oldfb = NULL, newfb = fb1, prepare fb1, no cleanup >> - Async update, oldfb = fb1, newfb = fb2, prepare fb2, cleanup fb1 >> - Non-async commit, oldfb = fb2, newfb = fb1, prepare fb1, cleanup fb2 >> >> Where calls to prepare/cleanup are balanced. >> >> Cc: # v4.14+ >> Fixes: 25dc194b34dd ("drm: Block fb changes for async plane updates") >> Suggested-by: Boris Brezillon >> Signed-off-by: Helen Koike > > Reviewed-by: Boris Brezillon Reviewed-by: Nicholas Kazlauskas I was thinking that the comment could go in async_commit or async_check, but I guess it works there too. Maybe it needs a FIXME or a TODO for a full state swap, but these are just nitpicks. Nicholas Kazlauskas > >> >> --- >> Hello, >> >> As mentioned in the cover letter, I tested in almost all platforms with >> igt plane_cursor_legacy and kms_cursor_legacy and I didn't see any >> regressions. But I couldn't test on MSM and AMD because I don't have >> the hardware I would appreciate if anyone could help me testing those. >> >> Thanks! >> Helen >> >> Changes in v2: >> - Change the order of the patch in the series, add this as the last one. >> - Add documentation >> - s/ballanced/balanced >> >> drivers/gpu/drm/drm_atomic_helper.c | 20 ++++++++++---------- >> include/drm/drm_modeset_helper_vtables.h | 5 +++++ >> 2 files changed, 15 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c >> index 540a77a2ade9..e7eb96f1efc2 100644 >> --- a/drivers/gpu/drm/drm_atomic_helper.c >> +++ b/drivers/gpu/drm/drm_atomic_helper.c >> @@ -1608,15 +1608,6 @@ int drm_atomic_helper_async_check(struct drm_device *dev, >> old_plane_state->crtc != new_plane_state->crtc) >> return -EINVAL; >> >> - /* >> - * FIXME: Since prepare_fb and cleanup_fb are always called on >> - * the new_plane_state for async updates we need to block framebuffer >> - * changes. This prevents use of a fb that's been cleaned up and >> - * double cleanups from occuring. >> - */ >> - if (old_plane_state->fb != new_plane_state->fb) >> - return -EINVAL; >> - >> funcs = plane->helper_private; >> if (!funcs->atomic_async_update) >> return -EINVAL; >> @@ -1657,6 +1648,9 @@ void drm_atomic_helper_async_commit(struct drm_device *dev, >> int i; >> >> for_each_new_plane_in_state(state, plane, plane_state, i) { >> + struct drm_framebuffer *new_fb = plane_state->fb; >> + struct drm_framebuffer *old_fb = plane->state->fb; >> + >> funcs = plane->helper_private; >> funcs->atomic_async_update(plane, plane_state); >> >> @@ -1665,11 +1659,17 @@ void drm_atomic_helper_async_commit(struct drm_device *dev, >> * plane->state in-place, make sure at least common >> * properties have been properly updated. >> */ >> - WARN_ON_ONCE(plane->state->fb != plane_state->fb); >> + WARN_ON_ONCE(plane->state->fb != new_fb); >> WARN_ON_ONCE(plane->state->crtc_x != plane_state->crtc_x); >> WARN_ON_ONCE(plane->state->crtc_y != plane_state->crtc_y); >> WARN_ON_ONCE(plane->state->src_x != plane_state->src_x); >> WARN_ON_ONCE(plane->state->src_y != plane_state->src_y); >> + >> + /* >> + * Make sure the FBs have been swapped so that cleanups in the >> + * new_state performs a cleanup in the old FB. >> + */ >> + WARN_ON_ONCE(plane_state->fb != old_fb); >> } >> } >> EXPORT_SYMBOL(drm_atomic_helper_async_commit); >> diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h >> index cfb7be40bed7..ce582e8e8f2f 100644 >> --- a/include/drm/drm_modeset_helper_vtables.h >> +++ b/include/drm/drm_modeset_helper_vtables.h >> @@ -1174,6 +1174,11 @@ struct drm_plane_helper_funcs { >> * current one with the new plane configurations in the new >> * plane_state. >> * >> + * Drivers should also swap the framebuffers between plane state >> + * and new_state. This is required because prepare and cleanup calls >> + * are performed on the new_state object, then to cleanup the old >> + * framebuffer, it needs to be placed inside the new_state object. >> + * >> * FIXME: >> * - It only works for single plane updates >> * - Async Pageflips are not supported yet > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel