From patchwork Tue Aug 15 18:57:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 135711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:3f2:4152:657d with SMTP id x8csp824856vqo; Tue, 15 Aug 2023 19:27:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQKJqjFTRIQxbNNVrCumHK0rHOJMjGcls/uQYKLNmgCKfcEll4yFhhsk/R9PO1hAjCoCZH X-Received: by 2002:a05:620a:1107:b0:76c:b527:1e38 with SMTP id o7-20020a05620a110700b0076cb5271e38mr577541qkk.46.1692152865199; Tue, 15 Aug 2023 19:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692152865; cv=none; d=google.com; s=arc-20160816; b=UKAmZyawTiAvzttAmhJsE6ZZtIYAuehEAI+WEV2H6Za3SKGstNWQjcDKL4kIFQ7Grl JCbYqRRmqpUXfE2X9rj+l+TonKBcPPhkWDmXT0kMJhEYWm/UTPUdyZ5LFyS5mJ5DUPkW r+kFtmzLv3ly0hG2DFv45W9/73XuBcmFh62IwWobaGfCYU4pzcuHE7bWOQgiYiJDWqVm 4IPrlKuJTOtj6AK2IKc45G6tqkCYX1OAAO5vIHRSg8ROFQTpVVMMeAm+nzi06mahdlqe XaFWe3jR3tdpjkNAwSTCDsct6JeUe0ExCMLGQX0RpDh3Ydl2ga4eAdCY+yqIJkFOAWT9 +xkA== 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=TVMdAoDdkx9jLjKJOYRYZPm8RW3qIM+jfzlkYz40wQ8=; fh=qbfaDyBg+GqerSAvcu3kFTx3mMThVk/CBXk9qNOf42k=; b=GLQcD6joAVL6V8X80iw3wR94zJREpxrrCUkudNiJUGJE9//UF3h5dSlDshDpkaUsV4 /PRG3W92sNQjqyPHvdIIWDe2hBFq6myyGTwvbGuRKptaKPCKwnwcMwFalXo/zqt1Wg+O w3Lh2OJIsHZ3jUnS7oUm4HHTLU7zANMkz4odlWP7Omf6ngF4Rut72yMF+RJHGRXbonhR CDGJwOpjOeFEmRIBJIiNdKqcca76dftagHZz/sQrvYBRd8fswkmnz+8frYYAb1cXQOMO HI2K/8DPkAlREmF22ASxM3KDwFSd+udCSu0Q78w/z0FmHpseFDqLJOekveeNouOOJjgT G2LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=QXaH3Hsu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r27-20020a63fc5b000000b0055adfd70273si10456511pgk.538.2023.08.15.19.27.32; Tue, 15 Aug 2023 19:27:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=QXaH3Hsu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239562AbjHOS6c (ORCPT + 99 others); Tue, 15 Aug 2023 14:58:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239516AbjHOS56 (ORCPT ); Tue, 15 Aug 2023 14:57:58 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 808BA210A for ; Tue, 15 Aug 2023 11:57:35 -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=TVMdAoDdkx9jLjKJOYRYZPm8RW3qIM+jfzlkYz40wQ8=; b=QXaH3HsuFEQMcEH7GwbLvUlIeA jJ0j5AKmwUd1XurOLY6yuEvOSakJrm0CjrwJzb+64pKDrA+Sq+yXcubkzP32SMWUPWPjCSFkupSiy +3gHY3qRyZHPKbITVtk+FRM9d/PR9R9nkF197oA8cIOQ4BdMgTm0NKorAalH1RCtRpps78Ld629Cw Bq90dEtNKgWVPMW9RRZdQuOg1zasQ4WNOD88bxfOBJKpHb3378LaRRjeemWuADci/+CUUHw+oPvMH TG6l7tZgqdaavl3RdrwRJIpDskql9COE7Pfxi4sjT5fmN+LDnXPDLeEIBk/lbimFYB4AipO8fge3b JZ1jQpPQ==; Received: from [191.193.179.209] (helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1qVzES-001Ca3-7o; Tue, 15 Aug 2023 20:57:32 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, wayland-devel@lists.freedesktop.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?b?J01hcmVrIE9sxaHDoWsn?= , Dave Airlie , =?utf-8?q?Michel_D=C3=A4nzer?= , Randy Dunlap , hwentlan@amd.com, joshua@froggi.es, ville.syrjala@linux.intel.com, =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v6 1/6] drm: allow DRM_MODE_PAGE_FLIP_ASYNC for atomic commits Date: Tue, 15 Aug 2023 15:57:05 -0300 Message-ID: <20230815185710.159779-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815185710.159779-1-andrealmeid@igalia.com> References: <20230815185710.159779-1-andrealmeid@igalia.com> MIME-Version: 1.0 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,URIBL_BLOCKED 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774350882839788449 X-GMAIL-MSGID: 1774350882839788449 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 --- v5: no changes v4: no changes --- 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 From patchwork Tue Aug 15 18:57:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 135734 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:3f2:4152:657d with SMTP id x8csp948612vqo; Wed, 16 Aug 2023 01:06:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZHbHLI/hFUh25WDVLMgHt+YIm+I8Cu+wQDg1XUc6J1PVy2KX3H5PoErnwfVPEdOET1uBH X-Received: by 2002:a17:906:8a48:b0:99b:6687:6107 with SMTP id gx8-20020a1709068a4800b0099b66876107mr813190ejc.5.1692173212572; Wed, 16 Aug 2023 01:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692173212; cv=none; d=google.com; s=arc-20160816; b=mMzAh/zVBnEwVWaP6+1MEAxBBh8c7+dqv4jmC0JVV/rPQ6gDVEs4ZuZHJQyf2hyipH tkht5XhhKXhyifxF8g68f+fNvSL0hPGqaDJDs3bF91le3+0YywlPJ2bz5bpUn9rhHDEA C+w500ERQWL7ColRER+G5VoW4/dMuzi+IPcni2TdIs7p3C3KsN3aa/VJ3I21n2jwDrWy q00c+sxHnjmB7zSoybNjqJ2k22f6XdbSCJTiCwYLMJh3bLDHcSfk7pUpLXf1Q/PT0jRb hw3LtPYATIoaeGP9+UB85YcYL8YHvpnGIyp+nfnWxhSLxw4jUXM3OQqnVf4mVnPVInTc UrSw== 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=12D9YB4XL5iWqebcq+TLGzYuVPhU8QWpBYqiCegu2nk=; fh=qbfaDyBg+GqerSAvcu3kFTx3mMThVk/CBXk9qNOf42k=; b=k5HDkJFq+UY2AqwY22OuXCdrpkZkOYwhpphA6wHOxPzy/Yj74iuK3pLyt8PNd7H16m wzF+o1NJcljO3y7/qxohg2YXZkMtyDrfUtXTFQPxx+d+F9hTh/DzZpDnXYczBHh0Bed4 xaJghAxbgyOF4QiZs3ajxDKPkCnsbz556cWs/1dhzSLFBBSnfqqxGeauGTsmCS+Zst+k crzu7iMcp10+NoFQyU2h7cJnOkOPa2IOqd3KxBjQxilvQOkk7FgbsKYFrGwkxYvkDnAX kymk3L9UGWKqCr1wvedqkcPlxyuaJz/18rDGwBkL0ya2PZPWQN5+lupWdw9TxlyZl84o dA3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=WghJqxe8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lm18-20020a170906981200b0099364d9f0e4si10529540ejb.278.2023.08.16.01.06.28; Wed, 16 Aug 2023 01:06:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=WghJqxe8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239585AbjHOS6i (ORCPT + 99 others); Tue, 15 Aug 2023 14:58:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239569AbjHOS6B (ORCPT ); Tue, 15 Aug 2023 14:58:01 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 313F2211C for ; Tue, 15 Aug 2023 11:57:40 -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=12D9YB4XL5iWqebcq+TLGzYuVPhU8QWpBYqiCegu2nk=; b=WghJqxe8TxHFnK1XYxxq+A7WLQ e62VanIPpX+mcWyG9UiL5FjfzQ4ltV8q/dVjqeNFd0IQf5r7gF1Oqe1vLSmzo3dNgrQMhVzolFTW3 5d8ap0btaEfqv/oQP6XJso9ueDHqOmWTD17IbtfLmQbym2ij+FBQ8Iq3n011Abylf9Z0tNq/IK3VP Ovp7m9CqI3yERWtwWUmeY4ohBkemIZS0gtg0+DVIxBGw7uMprLh+8ShSp776k9nsSvJkuD89uumZF 31T2YnWrWx23mz9VFa/SaZ49C0VMRY3i4yqJG3sAl8Gly8HcCorK++rGGH9HfIH8x5wkhAUydMjr9 JMEPCVnw==; Received: from [191.193.179.209] (helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1qVzEX-001Ca3-7J; Tue, 15 Aug 2023 20:57:37 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, wayland-devel@lists.freedesktop.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?b?J01hcmVrIE9sxaHDoWsn?= , Dave Airlie , =?utf-8?q?Michel_D=C3=A4nzer?= , Randy Dunlap , hwentlan@amd.com, joshua@froggi.es, ville.syrjala@linux.intel.com, =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v6 2/6] drm: introduce DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP Date: Tue, 15 Aug 2023 15:57:06 -0300 Message-ID: <20230815185710.159779-3-andrealmeid@igalia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815185710.159779-1-andrealmeid@igalia.com> References: <20230815185710.159779-1-andrealmeid@igalia.com> MIME-Version: 1.0 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,URIBL_BLOCKED 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774372218482983558 X-GMAIL-MSGID: 1774372218482983558 From: Simon Ser This new kernel capability indicates whether async page-flips are supported via the atomic uAPI. DRM clients can use it to check for support before feeding DRM_MODE_PAGE_FLIP_ASYNC to the kernel. Make it clear that DRM_CAP_ASYNC_PAGE_FLIP is for legacy uAPI only. Signed-off-by: Simon Ser Reviewed-by: André Almeida Reviewed-by: Alex Deucher Signed-off-by: André Almeida --- v5: no changes v4: no changes --- drivers/gpu/drm/drm_ioctl.c | 5 +++++ include/uapi/drm/drm.h | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index f03ffbacfe9b..3562b717b74f 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -301,6 +301,11 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_ case DRM_CAP_CRTC_IN_VBLANK_EVENT: req->value = 1; break; + case DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP: + req->value = drm_core_check_feature(dev, DRIVER_ATOMIC) && + dev->mode_config.async_page_flip && + !dev->mode_config.atomic_async_page_flip_not_supported; + break; default: return -EINVAL; } diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 794c1d857677..58baefe32c23 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -713,7 +713,8 @@ struct drm_gem_open { /** * DRM_CAP_ASYNC_PAGE_FLIP * - * If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC. + * If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC for legacy + * page-flips. */ #define DRM_CAP_ASYNC_PAGE_FLIP 0x7 /** @@ -773,6 +774,13 @@ struct drm_gem_open { * :ref:`drm_sync_objects`. */ #define DRM_CAP_SYNCOBJ_TIMELINE 0x14 +/** + * DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP + * + * If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC for atomic + * commits. + */ +#define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP 0x15 /* DRM_IOCTL_GET_CAP ioctl argument type */ struct drm_get_cap { From patchwork Tue Aug 15 18:57:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 135747 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:3f2:4152:657d with SMTP id x8csp1049974vqo; Wed, 16 Aug 2023 04:50:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFlsoKS9T8bWKjJPd0XHMOskd8M1HR4sAniCIwmO2zdgPaaEGxjcrPyLTv3XUYeEcTU0Knv X-Received: by 2002:a17:907:75db:b0:99b:f645:224 with SMTP id jl27-20020a17090775db00b0099bf6450224mr1239612ejc.9.1692186652412; Wed, 16 Aug 2023 04:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692186652; cv=none; d=google.com; s=arc-20160816; b=SkitRUrfYuyntkaRcHlhYddnbKMShU4jnyZNkQLOnkRSKqRQnSh6UmmWAfIOHxzGOx z0PxPI+AXDyuhYEV9Idm/ISxiV/DlE78czHNvRkyj9XR3pQ90VEcpjpXQ6Q/iEkF5TPm 5cONL8/h/vgdrrKylrhJzbPI6X5mFsL+SJgXajVcsOz6ivgqmfACYjwRbElvny5EXjo+ 2wpWsl4z1RJDF9jnYpxNoUv6oOWVsaTJ/VTIJTh3qo4fk5Gb2ee2Hv2suY2Jkutn3jF1 ljzSYC7IQsehi28JEHelTA6uOsPkd9an2O9/kIwFQqqEsXlRU75AvXa+6sLoflgxt4qy w1OA== 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=++dv1YcZtTUgwkcqesMhrWgRGVjCmLDErvcE127Lp4k=; fh=qbfaDyBg+GqerSAvcu3kFTx3mMThVk/CBXk9qNOf42k=; b=V0ttAnVo53RpyLPOVMVf52+PNJQw5XTtPj5scO+kEdxLq001XJ4sB8+RgJHrhSHfwT UR+bAJs2yiKOJZvfswdq5aVCohwsOXruaucAbfwV7Jt1/2rW7IwrqD+NyMxh2O1nJ+Gd mEwjCkfQsyhSXmeBfugrQfBqqlb8JlmsqygrV0YNXiySh3Tqfh2aufUVVxBjnJISbkWw mm3gvP88nPGiKKKhXhG9kac8ZHxzy5l+7Y8wvNRTMJVmbKnToEid2EKZ6PwYgF2ZI6bJ ljNmeM5+9nBpa5TF7E48CsWZxJr8dzIM989T1MQaXJ/hnLFWi58vBJRdLJELjEcpLewd quug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=MN1VQgdN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r24-20020a1709067fd800b0099caf73097esi10523200ejs.226.2023.08.16.04.50.26; Wed, 16 Aug 2023 04:50:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=MN1VQgdN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239615AbjHOS6o (ORCPT + 99 others); Tue, 15 Aug 2023 14:58:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239587AbjHOS6C (ORCPT ); Tue, 15 Aug 2023 14:58:02 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 280801FD6 for ; Tue, 15 Aug 2023 11:57:50 -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=++dv1YcZtTUgwkcqesMhrWgRGVjCmLDErvcE127Lp4k=; b=MN1VQgdNk+1D8fu7wLlBepRrRB aCCVMsFhnQDaC+5HulasVarDOXq1JfDOKuKpdFvSxaieGhfGSLR8K7Dl0Cl4IOhuSvMWTA5K9c2kS meaXoweiHuatFmcmzMHvVAskQz00BoBt7zXwQcQyaT3YcuQOrtrIZh2qaB+7ju6BwgQBMD7yMDJ9Y kVIK0xCAslGPixRhDZNX6fChAX5uxj7GJWYzRYLgLUmFkH88FQUPwvIGLnz1TbHwiABezkfSZiC4e b/aOMJonS+x4zP+o50CiF+04939vh77T/li2buDWI97L5txZ5pIIb00SZgFr95ZZp9HtTDQ/9dsVp b1hpRKXw==; Received: from [191.193.179.209] (helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1qVzEh-001Ca3-4Q; Tue, 15 Aug 2023 20:57:47 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, wayland-devel@lists.freedesktop.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?b?J01hcmVrIE9sxaHDoWsn?= , Dave Airlie , =?utf-8?q?Michel_D=C3=A4nzer?= , Randy Dunlap , hwentlan@amd.com, joshua@froggi.es, ville.syrjala@linux.intel.com, =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v6 4/6] amd/display: indicate support for atomic async page-flips on DC Date: Tue, 15 Aug 2023 15:57:08 -0300 Message-ID: <20230815185710.159779-5-andrealmeid@igalia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815185710.159779-1-andrealmeid@igalia.com> References: <20230815185710.159779-1-andrealmeid@igalia.com> MIME-Version: 1.0 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,URIBL_BLOCKED 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774386311132663435 X-GMAIL-MSGID: 1774386311132663435 From: Simon Ser amdgpu_dm_commit_planes() already sets the flip_immediate flag for async page-flips. This flag is used to set the UNP_FLIP_CONTROL register. Thus, no additional change is required to handle async page-flips with the atomic uAPI. Signed-off-by: Simon Ser Reviewed-by: André Almeida Reviewed-by: Alex Deucher Signed-off-by: André Almeida --- v5: no changes v4: no changes --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 4b433793f5a0..4d3d6009838c 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -3924,7 +3924,6 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev) adev_to_drm(adev)->mode_config.prefer_shadow = 1; /* indicates support for immediate flip */ adev_to_drm(adev)->mode_config.async_page_flip = true; - adev_to_drm(adev)->mode_config.atomic_async_page_flip_not_supported = true; state = kzalloc(sizeof(*state), GFP_KERNEL); if (!state) From patchwork Tue Aug 15 18:57:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 135727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:3f2:4152:657d with SMTP id x8csp914987vqo; Tue, 15 Aug 2023 23:43:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRVUsvZlQ1bPwxmxB7DRtdA8jqNH0SWtJQkmndKHnXhMidpZHbXwJRAMWsUWvgjslclHR3 X-Received: by 2002:aa7:d852:0:b0:523:1e0a:e12e with SMTP id f18-20020aa7d852000000b005231e0ae12emr831654eds.23.1692168188625; Tue, 15 Aug 2023 23:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692168188; cv=none; d=google.com; s=arc-20160816; b=z0aF6+D2srNjCYWQQnMzlP0PWAQ0UQs7iCnWCwu5bQX0ZxBtv51rkBmx2dT/SfqknP dfAD7Dlg1MiMZSVq7urXwsPzjgwpfXdF7bYqusQIM1o+swInGT8+zPZIs4Z1WfbYWYi6 87TQJ7waE623+lVqStprC7ZSoXoGdXD1bGnyhWz76PxVY5QIDjBskeDEuaqKh/dku/pZ Ic+ulTqydVQzp9I42A14DhfeCZ43yq6MEr8Gjqqca1Bl6+V4o/at3P9xBtWLFVbZmpb8 sytkrjLLYAO3JkbW73oHIXsiTfvauSNgM0qn3DMHn7MaKum02/88wtlvzljfxA/pCWw6 I/dg== 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=CUu6cUqsLaQ5HGGvMpkPKfD424cCdPwZUqRPltbOhvo=; fh=qbfaDyBg+GqerSAvcu3kFTx3mMThVk/CBXk9qNOf42k=; b=HlnwaTeh+3sva5WllN6xEV5mYcshcZu4y4jRHJq4sexwNfn6N3TzZbrXYqBJHwNZvI SUiT4Elst54qNKn8GoxZh7yChm660VYLgkJZzHLYTUpTaesMjcvUhnM/lBq8AFuA8MVT 7vTWhhjos1mQnD6Pa4SToMhpMqr5zSiE4pIPuvty/L026gOH9Tij16cCVsgh9C+EN2nn BlnqTHSAfMf6HoKUB9jp4mo3Qbjg8Dx9CnuQ/is4mdjYVu0xn5xS/OFg0TlgqZFP4X+7 E3h574mLotR3Yi+PX4Y806+n6TzOxLe3O+1J44/usiyWOaH5isNXQqYNoVqr9ikWoPnn 32Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=U1xAdWRf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d25-20020aa7d5d9000000b005232273f880si10502191eds.443.2023.08.15.23.42.42; Tue, 15 Aug 2023 23:43:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=U1xAdWRf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239633AbjHOS6p (ORCPT + 99 others); Tue, 15 Aug 2023 14:58:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239610AbjHOS6E (ORCPT ); Tue, 15 Aug 2023 14:58:04 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8EDD1FEE for ; Tue, 15 Aug 2023 11:57:54 -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=CUu6cUqsLaQ5HGGvMpkPKfD424cCdPwZUqRPltbOhvo=; b=U1xAdWRfkC43Ht88i8qhNko242 V2BQ+owfjQg+NE7sV/18F4Rz3/PTgzevnf9FUiAGJdnG2dFy+1uc2Om2ODp+sRbNmwAZciN8J6vxc 6t+uThFwTrzR7LYZVcaR44p9HAPIqH/nvBDBElWg0GuoQSwlrRCfgxfWW1RpOAg/HDOQN98hWFwFp UaNZvyaiaR+Ow7Uggx2Q3KXQr1LSiz3JEA0XD3TS18dl0TSGQ+ZxkBvbt5iAKlX9bJCjKhYvJVivI uGODB3M2aj/5+/sIxTbKoD2wf17ZY3fWynol4ezf0LKXK8V/dcrUqMo2S3KI9ZDx8N0KwkqvlJgI8 0KPY6XhQ==; Received: from [191.193.179.209] (helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1qVzEm-001Ca3-59; Tue, 15 Aug 2023 20:57:52 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, wayland-devel@lists.freedesktop.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?b?J01hcmVrIE9sxaHDoWsn?= , Dave Airlie , =?utf-8?q?Michel_D=C3=A4nzer?= , Randy Dunlap , hwentlan@amd.com, joshua@froggi.es, ville.syrjala@linux.intel.com, =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v6 5/6] drm: Refuse to async flip with atomic prop changes Date: Tue, 15 Aug 2023 15:57:09 -0300 Message-ID: <20230815185710.159779-6-andrealmeid@igalia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815185710.159779-1-andrealmeid@igalia.com> References: <20230815185710.159779-1-andrealmeid@igalia.com> MIME-Version: 1.0 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,URIBL_BLOCKED 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774366950655849780 X-GMAIL-MSGID: 1774366950655849780 Given that prop changes may lead to modesetting, which would defeat the fast path of the async flip, refuse any atomic prop change for async flips in atomic API. The only exceptions are the framebuffer ID to flip to and the mode ID, that could be referring to an identical mode. Signed-off-by: André Almeida --- v5: no changes v4: new patch --- drivers/gpu/drm/drm_atomic_helper.c | 5 +++ drivers/gpu/drm/drm_atomic_uapi.c | 52 +++++++++++++++++++++++++++-- drivers/gpu/drm/drm_crtc_internal.h | 2 +- drivers/gpu/drm/drm_mode_object.c | 2 +- 4 files changed, 56 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 292e38eb6218..b34e3104afd1 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -629,6 +629,11 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, WARN_ON(!drm_modeset_is_locked(&crtc->mutex)); if (!drm_mode_equal(&old_crtc_state->mode, &new_crtc_state->mode)) { + if (new_crtc_state->async_flip) { + drm_dbg_atomic(dev, "[CRTC:%d:%s] no mode changes allowed during async flip\n", + crtc->base.id, crtc->name); + return -EINVAL; + } drm_dbg_atomic(dev, "[CRTC:%d:%s] mode changed\n", crtc->base.id, crtc->name); new_crtc_state->mode_changed = true; diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index a15121e75a0a..6c423a7e8c7b 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -1006,13 +1006,28 @@ int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state, return ret; } +static int drm_atomic_check_prop_changes(int ret, uint64_t old_val, uint64_t prop_value, + struct drm_property *prop) +{ + if (ret != 0 || old_val != prop_value) { + drm_dbg_atomic(prop->dev, + "[PROP:%d:%s] No prop can be changed during async flip\n", + prop->base.id, prop->name); + return -EINVAL; + } + + return 0; +} + int drm_atomic_set_property(struct drm_atomic_state *state, struct drm_file *file_priv, struct drm_mode_object *obj, struct drm_property *prop, - uint64_t prop_value) + uint64_t prop_value, + bool async_flip) { struct drm_mode_object *ref; + uint64_t old_val; int ret; if (!drm_property_change_valid_get(prop, prop_value, &ref)) @@ -1029,6 +1044,13 @@ int drm_atomic_set_property(struct drm_atomic_state *state, break; } + if (async_flip) { + ret = drm_atomic_connector_get_property(connector, connector_state, + prop, &old_val); + ret = drm_atomic_check_prop_changes(ret, old_val, prop_value, prop); + break; + } + ret = drm_atomic_connector_set_property(connector, connector_state, file_priv, prop, prop_value); @@ -1037,6 +1059,7 @@ int drm_atomic_set_property(struct drm_atomic_state *state, case DRM_MODE_OBJECT_CRTC: { struct drm_crtc *crtc = obj_to_crtc(obj); struct drm_crtc_state *crtc_state; + struct drm_mode_config *config = &crtc->dev->mode_config; crtc_state = drm_atomic_get_crtc_state(state, crtc); if (IS_ERR(crtc_state)) { @@ -1044,6 +1067,18 @@ int drm_atomic_set_property(struct drm_atomic_state *state, break; } + /* + * We allow mode_id changes here for async flips, because we + * check later on drm_atomic_helper_check_modeset() callers if + * there are modeset changes or they are equal + */ + if (async_flip && prop != config->prop_mode_id) { + ret = drm_atomic_crtc_get_property(crtc, crtc_state, + prop, &old_val); + ret = drm_atomic_check_prop_changes(ret, old_val, prop_value, prop); + break; + } + ret = drm_atomic_crtc_set_property(crtc, crtc_state, prop, prop_value); break; @@ -1051,6 +1086,7 @@ int drm_atomic_set_property(struct drm_atomic_state *state, case DRM_MODE_OBJECT_PLANE: { struct drm_plane *plane = obj_to_plane(obj); struct drm_plane_state *plane_state; + struct drm_mode_config *config = &plane->dev->mode_config; plane_state = drm_atomic_get_plane_state(state, plane); if (IS_ERR(plane_state)) { @@ -1058,6 +1094,13 @@ int drm_atomic_set_property(struct drm_atomic_state *state, break; } + if (async_flip && prop != config->prop_fb_id) { + ret = drm_atomic_plane_get_property(plane, plane_state, + prop, &old_val); + ret = drm_atomic_check_prop_changes(ret, old_val, prop_value, prop); + break; + } + ret = drm_atomic_plane_set_property(plane, plane_state, file_priv, prop, prop_value); @@ -1349,6 +1392,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, struct drm_out_fence_state *fence_state; int ret = 0; unsigned int i, j, num_fences; + bool async_flip = false; /* disallow for drivers not supporting atomic: */ if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) @@ -1385,6 +1429,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, "commit failed: DRM_MODE_PAGE_FLIP_ASYNC not supported with atomic\n"); return -EINVAL; } + + async_flip = true; } /* can't test and expect an event at the same time. */ @@ -1469,8 +1515,8 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, goto out; } - ret = drm_atomic_set_property(state, file_priv, - obj, prop, prop_value); + ret = drm_atomic_set_property(state, file_priv, obj, + prop, prop_value, async_flip); if (ret) { drm_mode_object_put(obj); goto out; diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h index 501a10edd0e1..381130cebe81 100644 --- a/drivers/gpu/drm/drm_crtc_internal.h +++ b/drivers/gpu/drm/drm_crtc_internal.h @@ -251,7 +251,7 @@ int drm_atomic_set_property(struct drm_atomic_state *state, struct drm_file *file_priv, struct drm_mode_object *obj, struct drm_property *prop, - uint64_t prop_value); + uint64_t prop_value, bool async_flip); int drm_atomic_get_property(struct drm_mode_object *obj, struct drm_property *property, uint64_t *val); diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c index ac0d2ce3f870..0e8355063eee 100644 --- a/drivers/gpu/drm/drm_mode_object.c +++ b/drivers/gpu/drm/drm_mode_object.c @@ -538,7 +538,7 @@ static int set_property_atomic(struct drm_mode_object *obj, obj_to_connector(obj), prop_value); } else { - ret = drm_atomic_set_property(state, file_priv, obj, prop, prop_value); + ret = drm_atomic_set_property(state, file_priv, obj, prop, prop_value, false); if (ret) goto out; ret = drm_atomic_commit(state); From patchwork Tue Aug 15 18:57:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 136162 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2085353vqi; Sat, 19 Aug 2023 08:47:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNfrxJ+tQ9ddu8BXkj/mSusLnURNMlhr8CyHhEFgJwCXwrtmz97uTeDPYsVUjky/XyL230 X-Received: by 2002:a17:902:da81:b0:1b8:7e53:704 with SMTP id j1-20020a170902da8100b001b87e530704mr3315609plx.27.1692460049869; Sat, 19 Aug 2023 08:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692460049; cv=none; d=google.com; s=arc-20160816; b=LGAXbSpdjj2Iz3/rzJFk+Zsa/yJqCPHVhnPuFxZAdjty7pAtYiYF191m2iM0HIQAmU BmjpUXEvNW356Yjnto0Jp1iBviZAC+a437C8Ap+1p5cLU5QZDrFWAfgOri5Pg46ZkUYV vz/yZ/zzKXROyyFrMruX5ueL+OqvprHaxBNGW6YDFiBX4WqYeiveyogVLy9wPD/PrIcB YNGexLSOKR3Br4zxeQ0AgPptFGeMihDkFm64dA79DBIR5vDGtY1lT4jWRwajK8/ObQL6 VnmyxNUSqM9mKiNCEG1tDxAlcTH52QJ/gLkikYBepOLloMmsr1d8FsAHvo3iaEPwm5SP Ks+g== 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=lYbxQgfILVH8fA/tTFGSpqiJIGXYZvMVa/QdVn3ynTY=; fh=LjT+njuVizWTSzr6iuglUnPxawOqQbLOR7Ym8u+3GU0=; b=fMw07iF7tZatGqRfYe4gMnfUAbGMUalCPQa1QUTzCjjUYpL9wC0fxUwc2OmG/PSf1q navgSJaJDwXt08KoQKDk2b8xB6ED/6DPo/L2Q4BCmOUKc9nuYFbquNCGN12qPyqhl4cb wLrW9GIHyLM/Ko8XqR1eJbH84WIceCUuMmJW6MYbk4D02QW0a93EobN8PDhREXM5bnly 92l+BW1B0Gi0TiMarsjrANAYvxT00yAHcQwOJEq35hIFcOLVVm06RQ4C0NxmJBkWiqzc 8a3KWaK3otGNeqkrU/VtAfqLNZRaIgc8oC34WndDdZzkOfciOoIkR/eRF9zir8OIkr70 IV3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=MbS0ON8N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l11-20020a170903120b00b001bba8a9e29dsi3893383plh.100.2023.08.19.08.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 08:47:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=MbS0ON8N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3DE79F2990; Sat, 19 Aug 2023 01:48:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239703AbjHOS6t (ORCPT + 99 others); Tue, 15 Aug 2023 14:58:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239631AbjHOS6H (ORCPT ); Tue, 15 Aug 2023 14:58:07 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C56B01FF7 for ; Tue, 15 Aug 2023 11:58:00 -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=lYbxQgfILVH8fA/tTFGSpqiJIGXYZvMVa/QdVn3ynTY=; b=MbS0ON8NVvJUCKFcJY9Pu7irDu pNSLG1yYzPcgi/N+p6PEWW2toQNFlmh9EYo4AfASgK8bdeYJi3tpyBBdJyPPgFbCeRfFnfNxu22Ok C/g3zzS/CROc/NbYC+z0k5+ORIae9Xu3hytcIj79OgyUAma7D4bZvCXwTVBD6SLKbllvmkC4bAZ3G CYBK7CTcbXecZsnwVra+s8Z9hWJCyV0Fknm7VNlvmFiVlH0FIDC3Hn2kLsRVdJueseU+qYeepxPzM OcbUWxg/YE0o5u/eagalUYp1gxAJiacmy5NQd2rxn5DdQ+sgHkZI3hySUGKgQaj+Vo9hHY3QZsU9t HJ9VvmFQ==; Received: from [191.193.179.209] (helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1qVzEr-001Ca3-By; Tue, 15 Aug 2023 20:57:57 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, wayland-devel@lists.freedesktop.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?b?J01hcmVrIE9sxaHDoWsn?= , Dave Airlie , =?utf-8?q?Michel_D=C3=A4nzer?= , Randy Dunlap , hwentlan@amd.com, joshua@froggi.es, ville.syrjala@linux.intel.com, Pekka Paalanen , =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v6 6/6] drm/doc: Define KMS atomic state set Date: Tue, 15 Aug 2023 15:57:10 -0300 Message-ID: <20230815185710.159779-7-andrealmeid@igalia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815185710.159779-1-andrealmeid@igalia.com> References: <20230815185710.159779-1-andrealmeid@igalia.com> MIME-Version: 1.0 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,URIBL_BLOCKED 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774672988792122828 X-GMAIL-MSGID: 1774672988792122828 From: Pekka Paalanen Specify how the atomic state is maintained between userspace and kernel, plus the special case for async flips. Signed-off-by: Pekka Paalanen Signed-off-by: André Almeida --- v5: Add note that not every redundant attribute will result in no-op v4: total rework by Pekka --- Documentation/gpu/drm-uapi.rst | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst index 65fb3036a580..b91ccaddeeb9 100644 --- a/Documentation/gpu/drm-uapi.rst +++ b/Documentation/gpu/drm-uapi.rst @@ -486,3 +486,47 @@ and the CRTC index is its position in this array. .. kernel-doc:: include/uapi/drm/drm_mode.h :internal: + +KMS atomic state +================ + +An atomic commit can change multiple KMS properties in an atomic fashion, +without ever applying intermediate or partial state changes. Either the whole +commit succeeds or fails, and it will never be applied partially. This is the +fundamental improvement of the atomic API over the older non-atomic API which is +referred to as the "legacy API". Applying intermediate state could unexpectedly +fail, cause visible glitches, or delay reaching the final state. + +An atomic commit can be flagged with DRM_MODE_ATOMIC_TEST_ONLY, which means the +complete state change is validated but not applied. Userspace should use this +flag to validate any state change before asking to apply it. If validation fails +for any reason, userspace should attempt to fall back to another, perhaps +simpler, final state. This allows userspace to probe for various configurations +without causing visible glitches on screen and without the need to undo a +probing change. + +The changes recorded in an atomic commit apply on top the current KMS state in +the kernel. Hence, the complete new KMS state is the complete old KMS state with +the committed property settings done on top. The kernel will try to avoid +no-operation changes, so it is safe for userspace to send redundant property +settings. However, not every situation allows for no-op changes, due to the +need to acquire locks for some attributes. Userspace needs to be aware that some +redundant information might result in oversynchronization issues. No-operation +changes do not count towards actually needed changes, e.g. setting MODE_ID to a +different blob with identical contents as the current KMS state shall not be a +modeset on its own. + +A "modeset" is a change in KMS state that might enable, disable, or temporarily +disrupt the emitted video signal, possibly causing visible glitches on screen. A +modeset may also take considerably more time to complete than other kinds of +changes, and the video sink might also need time to adapt to the new signal +properties. Therefore a modeset must be explicitly allowed with the flag +DRM_MODE_ATOMIC_ALLOW_MODESET. This in combination with +DRM_MODE_ATOMIC_TEST_ONLY allows userspace to determine if a state change is +likely to cause visible disruption on screen and avoid such changes when end +users do not expect them. + +An atomic commit with the flag DRM_MODE_PAGE_FLIP_ASYNC is allowed to +effectively change only the FB_ID property on any planes. No-operation changes +are ignored as always. Changing any other property will cause the commit to be +rejected.