From patchwork Mon Aug 6 16:01:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enric Balletbo i Serra X-Patchwork-Id: 10558689 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 082DB14E5 for ; Tue, 7 Aug 2018 13:08:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA206296EB for ; Tue, 7 Aug 2018 13:08:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDB852970A; Tue, 7 Aug 2018 13:08:11 +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,UNPARSEABLE_RELAY 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 CC7B9296EB for ; Tue, 7 Aug 2018 13:08:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1597189B7D; Tue, 7 Aug 2018 13:08:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id E7B0E6E30D for ; Mon, 6 Aug 2018 16:01:13 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id E7DB2260C4A From: Enric Balletbo i Serra To: David Airlie Subject: [PATCH] drm/atomic: add ATOMIC_AMEND flag to the Atomic IOCTL. Date: Mon, 6 Aug 2018 18:01:02 +0200 Message-Id: <20180806160102.11877-1-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 07 Aug 2018 13:08:02 +0000 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: dnicoara@chromium.org, =?utf-8?q?St=C3=A9phane_Marchesin?= , Sean Paul , alexandros.frantzis@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, tomasz Figa , Gustavo Padovan , kernel@collabora.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gustavo Padovan This flag tells core to jump ahead the queued update if the conditions in drm_atomic_async_check() are met. That means we are only able to do an async update if no modeset is pending and update for the same plane is not queued. It uses the already in place infrastructure for async updates. It is useful for cursor updates and async PageFlips over the atomic ioctl, otherwise in some cases updates may be delayed to the point the user will notice it. Note that for now it's only enabled for cursor planes. DRM_MODE_ATOMIC_AMEND should be passed to the Atomic IOCTL to use this feature. Signed-off-by: Gustavo Padovan Signed-off-by: Enric Balletbo i Serra --- Hi, This is an attempt to introduce the new ATOMIC_AMEND flag for atomic operations, see the commit message for a more detailed description. This was tested using a small program that exercises the uAPI for easy sanity testing. The program created by Alexandros can be found here [2]. To test, just build the program and use the --atomic flag to use the cursor plane in normal (blocking mode), and --atomic-async to use the cursor plane with the ATOMIC_AMEND flag. E.g. drm_cursor --atomic or drm_cursor --atomic-async The test worked on a Samsung Chromebook Plus on top of mainline plus the patch to update cursors asynchronously through atomic for the drm/rockchip driver. Alexandros also did a proof-of-concept to use this flag and draw cursors using atomic if possible on ozone [1]. Best regards, Enric [1] https://chromium-review.googlesource.com/c/chromium/src/+/1092711 [2] https://gitlab.collabora.com/alf/drm-cursor Changes in v1: - Only enable it if userspace requests it. - Only allow async update for cursor type planes. - Rename ASYNC_UPDATE for ATOMIC_AMEND. drivers/gpu/drm/drm_atomic.c | 5 +++++ drivers/gpu/drm/drm_atomic_helper.c | 10 +++++++++- include/uapi/drm/drm_mode.h | 4 +++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 895741e9cd7d..7b3e4aa2874d 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -2338,6 +2338,10 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, (arg->flags & DRM_MODE_PAGE_FLIP_EVENT)) return -EINVAL; + if ((arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET) && + (arg->flags & DRM_MODE_ATOMIC_AMEND)) + return -EINVAL; + drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE); state = drm_atomic_state_alloc(dev); @@ -2346,6 +2350,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, state->acquire_ctx = &ctx; state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET); + state->async_update = !!(arg->flags & DRM_MODE_ATOMIC_AMEND); retry: plane_mask = 0; diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 81e32199d3ef..59495f61c583 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -902,7 +902,7 @@ int drm_atomic_helper_check(struct drm_device *dev, if (ret) return ret; - if (state->legacy_cursor_update) + if (state->async_update || state->legacy_cursor_update) state->async_update = !drm_atomic_helper_async_check(dev, state); return ret; @@ -1539,6 +1539,14 @@ int drm_atomic_helper_async_check(struct drm_device *dev, if (new_plane_state->fence) return -EINVAL; + /* Only allow async update for cursor type planes. */ + if (plane->type != DRM_PLANE_TYPE_CURSOR) + return -EINVAL; + + /* Don't do an async update if there isn't a pending commit. */ + if (!old_plane_state->commit) + return -EINVAL; + /* * Don't do an async update if there is an outstanding commit modifying * the plane. This prevents our async update's changes from getting diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 4b3a1bb58e68..6dae18428123 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -724,13 +724,15 @@ struct drm_mode_destroy_dumb { #define DRM_MODE_ATOMIC_TEST_ONLY 0x0100 #define DRM_MODE_ATOMIC_NONBLOCK 0x0200 #define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400 +#define DRM_MODE_ATOMIC_AMEND 0x0800 #define DRM_MODE_ATOMIC_FLAGS (\ DRM_MODE_PAGE_FLIP_EVENT |\ DRM_MODE_PAGE_FLIP_ASYNC |\ DRM_MODE_ATOMIC_TEST_ONLY |\ DRM_MODE_ATOMIC_NONBLOCK |\ - DRM_MODE_ATOMIC_ALLOW_MODESET) + DRM_MODE_ATOMIC_ALLOW_MODESET |\ + DRM_MODE_ATOMIC_AMEND) struct drm_mode_atomic { __u32 flags;