Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2243631rda; Tue, 24 Oct 2023 17:53:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvobBz9Y4JefYZp1phPL+iHe2vUGgIOy0JX4ugoSTRvsFCbeu4sYT+J3yYk+nfLzCMBIow X-Received: by 2002:a17:902:c183:b0:1c6:636:e40a with SMTP id d3-20020a170902c18300b001c60636e40amr13029943pld.14.1698195237757; Tue, 24 Oct 2023 17:53:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698195237; cv=none; d=google.com; s=arc-20160816; b=Nxyb2oG+VkHx7PhneClzJIrUNVY3Z5JYnn3zm0wKVIl3Zu0dT2qIwMCmga94m4Wu4n SRJlOtOpfrKS6XxqbyI06SUcnvOR4eSdgCRLilcDuzFVXoGzUd7HrIrQ8dYydjYDfbOB Ejr1yXlb2atm9QGdtBNjT20siUa0whepponOaepjL+e7FipJhJxZPySd/6qdmdF/nzJG tf5v7eJdVnkbbYUdoUdX9F6LNp6wIwG+3M1zwtaKcdeRxRnIMxEd8BlqDI23JiuqDQjo sQRBUCLxo9VBiadY5nqkVQmQ5fT47cacY4zHBZuAhjidE6AgsKIcRWRum5aT5J/PFnSO hSCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M0OhnC9PF7mmN9DYZd8NiL3IgQoyU0UGHjNLFnu9l9M=; fh=oozRrKarZZG8EJ8TWYFtLglEZVoKmF8bWYorcz/JMDw=; b=qBxy9yvKjA9a48Hc+LoqzUwFZMe+DD+HrcSIAIu6YyteDQufLArE7XxH3YRaKdGe9X A/Mnp8Hs34/R0PjZ1qDErqOcUz4bowKUwRc42kCjMXoPEOc/Tlf0Il0q1Zij+dagMBMO 6PKZqWYMPopMVHZM6eCqWiJRILlbmFmGXcePzqzodNnR2len84orXhJkY6J0INAB2uYP egyVDM0O3FldW0dyuMwdsC6fyvWLjBTYNei3sMt9GDa0usAt+Y/1PQxQDlciEy4B5RvV 8fH4VvMMqe3n0vk1F6ouSXHHp9yML+ALUyVKNH8VRu1j0nSRBvWOjtXcCrq9idYGlAlo +f5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=bWMqqSbK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id c9-20020a170902c1c900b001bbaa5e95fdsi8833780plc.102.2023.10.24.17.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 17:53:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=bWMqqSbK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CF6CC80267EF; Tue, 24 Oct 2023 17:53:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbjJYAxr (ORCPT + 99 others); Tue, 24 Oct 2023 20:53:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjJYAxn (ORCPT ); Tue, 24 Oct 2023 20:53:43 -0400 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0A2C128 for ; Tue, 24 Oct 2023 17:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=M0OhnC9PF7mmN9DYZd8NiL3IgQoyU0UGHjNLFnu9l9M=; b=bWMqqSbK+vJm9pFO3CNK/K8Xz7 oXt5jMp7dAb6q4y1jqDVjSmFeWuxfzFsbbugVjqAMaQRxTjD3wf/dncG99zjH8sC2p7mSz6Vv6Do5 aMQfMvVekoSud/iVE2jTocu0xK+CKSIr3LelQDjp6NDD4TQJgJerZCYbBCldAidXM7Fe70bVLE29A qjFvqpe1mqVgUbw1B39aZxsSgNlSk+xAOQHXE4TxKrp6PbhKqXNbS7l+qPlMXeb8yPQzZIcwZkUo7 CrmZGjFFD9vfQp14Vqwq/9Sl19wDbni1ubH03tPH3GJbb4qiHoN1x4EjHGKgWnroTelKL4TCGjThH JZfMeesg==; Received: from [191.193.179.125] (helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1qvS9M-006qog-Lm; Wed, 25 Oct 2023 02:53:33 +0200 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: kernel-dev@igalia.com, alexander.deucher@amd.com, christian.koenig@amd.com, pierre-eric.pelloux-prayer@amd.com, Simon Ser , Rob Clark , Pekka Paalanen , Daniel Vetter , Daniel Stone , =?UTF-8?q?=27Marek=20Ol=C5=A1=C3=A1k=27?= , Dave Airlie , =?UTF-8?q?Michel=20D=C3=A4nzer?= , Randy Dunlap , =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH v8 1/6] drm: allow DRM_MODE_PAGE_FLIP_ASYNC for atomic commits Date: Tue, 24 Oct 2023 21:53:13 -0300 Message-ID: <20231025005318.293690-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231025005318.293690-1-andrealmeid@igalia.com> References: <20231025005318.293690-1-andrealmeid@igalia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 24 Oct 2023 17:53:57 -0700 (PDT) From: Simon Ser If the driver supports it, allow user-space to supply the DRM_MODE_PAGE_FLIP_ASYNC flag to request an async page-flip. Set drm_crtc_state.async_flip accordingly. Document that drivers will reject atomic commits if an async flip isn't possible. This allows user-space to fall back to something else. For instance, Xorg falls back to a blit. Another option is to wait as close to the next vblank as possible before performing the page-flip to reduce latency. Signed-off-by: Simon Ser Reviewed-by: Alex Deucher Co-developed-by: André Almeida Signed-off-by: André Almeida --- drivers/gpu/drm/drm_atomic_uapi.c | 28 +++++++++++++++++++++++++--- include/uapi/drm/drm_mode.h | 9 +++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 98d3b10c08ae..a15121e75a0a 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -1323,6 +1323,18 @@ static void complete_signaling(struct drm_device *dev, kfree(fence_state); } +static void +set_async_flip(struct drm_atomic_state *state) +{ + struct drm_crtc *crtc; + struct drm_crtc_state *crtc_state; + int i; + + for_each_new_crtc_in_state(state, crtc, crtc_state, i) { + crtc_state->async_flip = true; + } +} + int drm_mode_atomic_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { @@ -1363,9 +1375,16 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, } if (arg->flags & DRM_MODE_PAGE_FLIP_ASYNC) { - drm_dbg_atomic(dev, - "commit failed: invalid flag DRM_MODE_PAGE_FLIP_ASYNC\n"); - return -EINVAL; + if (!dev->mode_config.async_page_flip) { + drm_dbg_atomic(dev, + "commit failed: DRM_MODE_PAGE_FLIP_ASYNC not supported\n"); + return -EINVAL; + } + if (dev->mode_config.atomic_async_page_flip_not_supported) { + drm_dbg_atomic(dev, + "commit failed: DRM_MODE_PAGE_FLIP_ASYNC not supported with atomic\n"); + return -EINVAL; + } } /* can't test and expect an event at the same time. */ @@ -1468,6 +1487,9 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, if (ret) goto out; + if (arg->flags & DRM_MODE_PAGE_FLIP_ASYNC) + set_async_flip(state); + if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) { ret = drm_atomic_check_only(state); } else if (arg->flags & DRM_MODE_ATOMIC_NONBLOCK) { diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index ea1b639bcb28..04e6a3caa675 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -957,6 +957,15 @@ struct hdr_output_metadata { * Request that the page-flip is performed as soon as possible, ie. with no * delay due to waiting for vblank. This may cause tearing to be visible on * the screen. + * + * When used with atomic uAPI, the driver will return an error if the hardware + * doesn't support performing an asynchronous page-flip for this update. + * User-space should handle this, e.g. by falling back to a regular page-flip. + * + * Note, some hardware might need to perform one last synchronous page-flip + * before being able to switch to asynchronous page-flips. As an exception, + * the driver will return success even though that first page-flip is not + * asynchronous. */ #define DRM_MODE_PAGE_FLIP_ASYNC 0x02 #define DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE 0x4 -- 2.42.0