Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3242121imu; Sat, 24 Nov 2018 00:54:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/WbYtBgApLls1QNziOX/pU8MW7yzWZqTWaKtBqZPrPTT+gmBWTPzb+54zLSWrfJ2o2FWt0x X-Received: by 2002:a63:da14:: with SMTP id c20mr16574695pgh.233.1543049655474; Sat, 24 Nov 2018 00:54:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543049655; cv=none; d=google.com; s=arc-20160816; b=Zbu7ST61L4wwx2ItXlPDBV0lxhdHxuFNexW1c6nTQMQiTRwPfqULCXp7OdfG9e7NjS PEDDVerGxb6aE6PjxwJ/pf7iEyCPRD42Q9T//MILaB0Ojrz3flEIJ84lqm5p/3uvju+B arAzYHcLWAEdIWo1jfj78m21pb9WEKKs0YQNUrxt7RGhLHIAZN688hs1EK2B7zQedWJl LTWl+9VyePKkJcVPbEpFZD9mPrSP2v3kFsiNkBS9KnBjgHqx2oec3T6ykpVbc0FzI8eQ HEWMV0eWIrq5Vz/+XYLsYg1e70xVI2HCf4gDJg9e4ksPQitdYKX5cYx+2LeGoRDE0JsC ylDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=VH0XMGjyjYxFL7gVPzUONeNcfyJyW/q1Eba+Ndx7MRI=; b=jz6qvrUVAFUUDBdwBl5+skvHoRnloXDh1XEVR+kiuWB+H7xWEemJ9bGW4ubqifOcWj V3ZOATJLGfTgAHFPPJBTHIGwHu0mSkSNEOxJjUqt6VRg091fe7DyBPfxf9eLjLMaVm4O 3LVIGB13SdhImidPyk0To5xadsORD/nlqaIIUZ2PZmiO5QWoesKd/mHlWLfEZQachq/Q KzNXrfB6ujLqNiSrJ9ATFKuePAvYqiHw3m17IUcXvZmPDOotzj3DFa4bjfyj0sWUmTtm gX/lQ/m0P5BajMBHJPDjwKIe177J2IGG47UqjBKL1uKSlRX6pnt0ytdhz1Pz1TOOoAGf blyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e184si25161397pfg.185.2018.11.24.00.54.01; Sat, 24 Nov 2018 00:54:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727141AbeKXIkG (ORCPT + 99 others); Sat, 24 Nov 2018 03:40:06 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:33426 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726979AbeKXIkG (ORCPT ); Sat, 24 Nov 2018 03:40:06 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: koike) with ESMTPSA id D15FD263AE1 From: Helen Koike To: David Airlie Cc: dnicoara@chromium.org, alexandros.frantzis@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Gustavo Padovan , tomasz Figa , Sean Paul , kernel@collabora.com, =?UTF-8?q?St=C3=A9phane=20Marchesin?= Subject: [PATCH v2] drm/atomic: add ATOMIC_AMEND flag to the Atomic IOCTL. Date: Fri, 23 Nov 2018 19:53:54 -0200 Message-Id: <20181123215354.14540-1-helen.koike@collabora.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 [updated for upstream] Signed-off-by: Helen Koike --- Hi, This is the second 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 was created by Alexandros and modified by Enric to test the capability flag [2]. To test, just build the program and use the --atomic flag to use the cursor plane with the ATOMIC_AMEND flag. E.g. drm_cursor --atomic The test worked on a rockchip Ficus v1.1 board on top of mainline plus the patch to update cursors asynchronously through atomic for the drm/rockchip driver plus the DRM_CAP_ASYNC_UPDATE patch. Alexandros also did a proof-of-concept to use this flag and draw cursors using atomic if possible on ozone [1]. Thanks Helen [1] https://chromium-review.googlesource.com/c/chromium/src/+/1092711 [2] https://gitlab.collabora.com/eballetbo/drm-cursor/commits/async-capability Changes in v2: - rebase tree - do not fall back to a non-async update if if there isn't any pending commit to amend Changes in v1: - https://patchwork.freedesktop.org/patch/243088/ - 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_helper.c | 6 +++++- drivers/gpu/drm/drm_atomic_uapi.c | 6 ++++++ include/uapi/drm/drm_mode.h | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 269f1a74de38..333190c6a0a4 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -934,7 +934,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; @@ -1602,6 +1602,10 @@ 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 is an outstanding commit modifying * the plane. This prevents our async update's changes from getting diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index d5b7f315098c..d5d26fe85ecf 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -1275,6 +1276,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); @@ -1283,6 +1288,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: copied_objs = 0; diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index d3e0fe31efc5..0adb28d27e9e 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -733,13 +733,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; -- 2.19.1