Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp921614rdb; Fri, 1 Dec 2023 02:07:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IGX8wKL8OKS0+740EpZaNQoi4VH7838SmsemOIO9JbxwsZr4S7wtKJTCJGz0hjRp3oZ1yvj X-Received: by 2002:a05:6a20:72a5:b0:18c:1d42:4e13 with SMTP id o37-20020a056a2072a500b0018c1d424e13mr26237507pzk.25.1701425228725; Fri, 01 Dec 2023 02:07:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701425228; cv=none; d=google.com; s=arc-20160816; b=kOt9tO58kryYNMhrxS3irDh0+RkPwbiSMnr9XSDmqDRsnuHR1IUOHK/H3OaKVOxlp9 XaUXeMnHlg/cu+PBFwzfX49Eiv2F6w5F6SNOkFAvlNAj4UsIBwy0rfaWixUQ7wpBPP7n YKmDYxbJ2NPGFzaynW/4ND4jyb6QEac8cMS/nkzFOt9dif5FSkXMLXJSZ7au1s+rdmJ1 pKgSFXuZGcWMveYOUjLtJ+tPoMpk90Mx8Pbd1jk7h95SY4hPSAUbTUifx0naK6zT0bDb Voc9FlClnl7LaJnIAWxIJZ2juCZldsM2c0JLvAzrZloTOJ2crc4t9pgy6ESgF5i77NBx y9rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=iouGbjYh7PQI/V9G3rEu49o2u8EynU+zRGVYHubGuzQ=; fh=QoSbISJOX9f5o4a7D6OB1rDhdA+HPhd+ru6mokQAanI=; b=CFZIXq5i8enIP9h0UOq3KCAMadrCeuCxz3e8o0fJx+bvhLqJk5hTIk+9yaejrIazyM DEdq+88SqgTrT8sqC1kyRRhXmzQJ9edq7BKk0PK8tLgJU9X7VD378Rxa44p4MW1XQMqq FAu12y0u7tiEI4rusiEKpl/22045H/vazdDI3lmTSQgEFGSh8S4S+31g4XlV604hncYY 25lI24J3vS3KnphrmlqgO7z70s9Jpbb/4f2JntkxrkNVR/HlxOB1A03Cgtc/SvJk79g9 8ZFPFzgjLOW7fgnVSSizLgE06J5SkqwvSYrjf5ssV5Tw7Dt5XROIIzEHy6KHJCjuVbA/ w1UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="eSqNbW/v"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id gt22-20020a17090af2d600b002851727a227si5411686pjb.32.2023.12.01.02.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 02:07:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="eSqNbW/v"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 3DF5480FDDCF; Fri, 1 Dec 2023 02:07:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378151AbjLAKGw (ORCPT + 99 others); Fri, 1 Dec 2023 05:06:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377899AbjLAKGs (ORCPT ); Fri, 1 Dec 2023 05:06:48 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FB1BCF; Fri, 1 Dec 2023 02:06:54 -0800 (PST) Received: from eldfell (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pq) by madras.collabora.co.uk (Postfix) with ESMTPSA id A9EC966003B9; Fri, 1 Dec 2023 10:06:51 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1701425212; bh=6WWOVpafYoUXOtbV/gIxloanlnjCVTDsutvvOB5R06k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=eSqNbW/vcMm8gefKx26+RTZNe45vOqDDJId4LeIpzjizuRblOupMr56FPiyAO8cJI HoP3M/JHDlWCJtUXAkO9E+3pvapouu4f9kzZrZS1ByBVvLObKNuVz/EjsXdJng/Iqe pEUMP+ukzHGOoiK0MjyHaQPqmBtkuSxYys47iZKWV2sZn9ubB1OX7Ybr3kZeFM7mxC E552xNCRvIvEqR/05QqkYVsmNBAOC+kh6K2dK2fvoI0mpUjx/8FCZXN+RtkOFLYkhM l03l4l3YoAD317l4jwxcmhJYkwDd07Qh6HBrBn5h/pKyIWilKC/9DL/UTzK6ioqOhQ OP98HRBqNdR1A== Date: Fri, 1 Dec 2023 12:06:48 +0200 From: Pekka Paalanen To: Maxime Ripard Cc: =?UTF-8?B?QW5kcsOp?= Almeida , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-dev@igalia.com, alexander.deucher@amd.com, christian.koenig@amd.com, Simon Ser , Rob Clark , daniel@ffwll.ch, Daniel Stone , 'Marek =?UTF-8?B?T2zFocOhayc=?= , Dave Airlie , Michel =?UTF-8?B?RMOkbnplcg==?= , Randy Dunlap , Jonathan Corbet , linux-doc@vger.kernel.org, Thomas Zimmermann , Maarten Lankhorst Subject: Re: [PATCH] drm/doc: Define KMS atomic state set Message-ID: <20231201120648.2ba706e1.pekka.paalanen@collabora.com> In-Reply-To: References: <20231130200740.53454-1-andrealmeid@igalia.com> <20231201110616.30ad1468.pekka.paalanen@collabora.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/=bSmbDZcOhdjv3iZ1XwQta1"; protocol="application/pgp-signature"; micalg=pgp-sha256 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,T_SCC_BODY_TEXT_LINE 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]); Fri, 01 Dec 2023 02:07:07 -0800 (PST) --Sig_/=bSmbDZcOhdjv3iZ1XwQta1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, 1 Dec 2023 10:25:09 +0100 Maxime Ripard wrote: > On Fri, Dec 01, 2023 at 11:06:16AM +0200, Pekka Paalanen wrote: > > On Fri, 1 Dec 2023 09:29:05 +0100 > > Maxime Ripard wrote: > > =20 > > > Hi, > > >=20 > > > On Thu, Nov 30, 2023 at 05:07:40PM -0300, Andr=C3=A9 Almeida wrote: = =20 > > > > From: Pekka Paalanen > > > >=20 > > > > Specify how the atomic state is maintained between userspace and > > > > kernel, plus the special case for async flips. > > > >=20 > > > > Signed-off-by: Pekka Paalanen > > > > Signed-off-by: Andr=C3=A9 Almeida > > > > --- > > > >=20 > > > > This is a standalone patch from the following serie, the other patc= hes are > > > > already merged: > > > > https://lore.kernel.org/lkml/20231122161941.320564-1-andrealmeid@ig= alia.com/ > > > >=20 > > > > Documentation/gpu/drm-uapi.rst | 47 ++++++++++++++++++++++++++++++= ++++ > > > > 1 file changed, 47 insertions(+) > > > >=20 > > > > diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm= -uapi.rst > > > > index 370d820be248..d0693f902a5c 100644 > > > > --- a/Documentation/gpu/drm-uapi.rst > > > > +++ b/Documentation/gpu/drm-uapi.rst > > > > @@ -570,3 +570,50 @@ dma-buf interoperability > > > > =20 > > > > Please see Documentation/userspace-api/dma-buf-alloc-exchange.rst = for > > > > information on how dma-buf is integrated and exposed within DRM. > > > > + > > > > +KMS atomic state > > > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > + > > > > +An atomic commit can change multiple KMS properties in an atomic f= ashion, > > > > +without ever applying intermediate or partial state changes. Eith= er 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-atomi= c API which is > > > > +referred to as the "legacy API". Applying intermediate state coul= d unexpectedly > > > > +fail, cause visible glitches, or delay reaching the final state. > > > > + > > > > +An atomic commit can be flagged with DRM_MODE_ATOMIC_TEST_ONLY, wh= ich means the > > > > +complete state change is validated but not applied. Userspace sho= uld use this > > > > +flag to validate any state change before asking to apply it. If va= lidation 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 t= o avoid =20 > > >=20 > > > That part is pretty confusing to me. > > >=20 > > > What are you calling the current and old KMS state? =20 > >=20 > > Current =3D old, if you read that "current" is the KMS state before > > considering the atomic commit at hand. > > =20 > > > What's confusing to me is that, yes, what you're saying is true for a > > > given object: if it was part of the commit, the new state is the old > > > state + whatever the new state changed. > > >=20 > > > However, if that object wasn't part of the commit at all, then it's > > > completely out of the old or new global KMS state. =20 > >=20 > > This is not talking about kernel data structures at all. This is > > talking about how KMS looks from the userspace point of view. =20 >=20 > I mean, that's also true from the userspace point of view. You can very > well commit only a single property on a single object, and only that > object will be part of the "global KMS state". What is "global KMS state"? As a userspace developer, the global KMS state is the complete, total, hardware and driver instance state. It's not any kind of data structure, but it is all the condition and all the programming of the whole device (hardware + driver instance) at any specific time instant. It is not related to any atomic commit or UAPI call, it is how the hardware is currently programmed. How can we make that clear? Should "KMS state" be replaced with "complete device state" or something similar? > > All objects are always part of the device KMS state as referred to > > in this doc, whether they were mentioned in the atomic commit state set > > or not. That's the whole point: all state that was not explicitly > > modified remains as it was, and is actively used state by the driver > > and hardware. The practical end result state is the same as if all > > objects were (redundantly) mentioned. > >=20 > > For example, if you change properties of CRTC 31, it has no effect on > > the behaviour of CRTC 54. If CRTC 54 was active, it remains active. If > > CRTC 54 had certain property values, it continues to have those > > property values. =20 >=20 > I'm not quite sure I followed your previous paragraph, sorry, but we > agree here and it's kind of my point really: CRTC-54 would not be part > of the new KMS state, so claiming that it is complete is confusing. >=20 > It's not complete to me precisely because it doesn't contain the state > of all objects. Did my explanation of what "KMS state" means from userspace perspective above help? > > This is opposed to something else; the UAPI could have > > been designed to e.g. reset all unmentioned objects to defaults/off by > > the atomic commit. Obviously that's not how it works today, so we need > > to mention how things do work. =20 >=20 > Sure, I'm not claiming we should change anything but the wording of that > doc. >=20 > > >=20 > > > So yeah, individual object KMS state are indeed complete, but > > > drm_atomic_state definitely isn't. And it's the whole point of functi= ons > > > like drm_atomic_get_crtc_state() vs drm_atomic_get_old/new_crtc_state: > > > the old/new variants only return a state if it was part of > > > drm_atomic_state to begin with. drm_atomic_get_crtc_state() brings the > > > crtc state into drm_atomic_state if it wasn't part of it. =20 > >=20 > > At no point the text is referring to drm_atomic_state or any other > > kernel data structure. =20 >=20 > Then it's even more confusing, because the sentence I was quoting was > "The changes recorded in an atomic commit apply on top the current KMS > state *in the kernel*", which is ambiguous then. It's perhaps a misguided attempt to say that the kernel maintains the complete device state, and that the complete device state is modified in the kernel. If it helps, the "in the kernel" can be dropped. Thanks, pq --Sig_/=bSmbDZcOhdjv3iZ1XwQta1 Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEJQjwWQChkWOYOIONI1/ltBGqqqcFAmVpsDgACgkQI1/ltBGq qqeTfQ//Tx1aj3ET5ljpFzO8+v0bqwcdE10/JnjR54V/GWhcVEFfyL40b7MLpX4K AcPjb2BWg3F6DiGMIIM+yl2QAPudYPCXn6pyGFWugEyu+H5MeMSQe3TpwyXKrvse lq5mBtN8gxjPz/4hq1U13g4Qrr3ogeuSchDdL8GkvaDadsRBaveQ/vjxHh/XRoVx wDdZQQ/ukV1xzstILk64XxSJIXUWFqzwFIAxMNHNjdBhc3h1g/6ccvRbsTLG9k9w tumPW0TENqBzTUcKdyknpPrs6pM5GILrNLOBrByrpIL1EOMH8M5tMB4qmqNVsuTg TLJ1uANUjgBPvSKJhHrgllY/5KVMWfzR37uDLfXZTAGLgWekTLqvtEkWSb+8dANW 8LDkNu8kEWYimCk1EoC4lTYoxa/Gv238wzd/QKWAqLqqGyTyzOf1AFnpk2it6Xce iIQFTI+g3PYxeQIxHI9tc+523pVqwtVLEXh73Cr8l7fO6NTgOpog/uR7KO2TEVIc 75G/ho7GxIpyJjnVLeijU/5bL46C5kXNAqE1Nvm4S5BKOt4I7NGSWGSRHlABrMyC HLx/0/U3Is5x0JlrR9VUN4BB3/RVKyKyVdfvbRROKYPdHRb4WSaBxMPG2TwtGYNH 29o1yD9N5yiVM0+7a6/7h/pGM2G4lBppk/KZ9133JgtvOUi71kM= =u5wp -----END PGP SIGNATURE----- --Sig_/=bSmbDZcOhdjv3iZ1XwQta1--