Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp929720rdb; Fri, 1 Dec 2023 02:25:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHEt6vmsuwafi6ciyKFIPE1LbX5ACPzs1LxOHJVj3fYYviIGS3pANE8XRvNPCSGxUmVmKaE X-Received: by 2002:a9d:7a55:0:b0:6d2:e1fc:f387 with SMTP id z21-20020a9d7a55000000b006d2e1fcf387mr2356140otm.4.1701426328935; Fri, 01 Dec 2023 02:25:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701426328; cv=none; d=google.com; s=arc-20160816; b=zFuYAk+PxLm6GXHEgt3M9JV2KfZlO9LCOiwOUQ+O5q1UU0/Qnp/JgRZ4Uo5Yg7pzi/ 7DkmU+tGvjh9CtAZHto0wYfDOijhEZT1BsgaEKlJ+OD9CqPxhujL89stZlLSyKrNrx3F 3p29Gr2sM+LJ4dpkNJGbNaHDvfa3VfGaCt5FQM/4Bd6WXCpfsYZ3X1fxooNBgzRuvV6J G3Jc2uShmr8JZlPitiWFeHOOEogANjDngaov7/sG3rsuz5NMkCx+5QkOUuKjQk3jfYVr rPMszQJ6aJCcny/ueGoOju0CxvdKKXcQJTlKh3PaEEtysb2rsjQKvZYrwl6i+7Q/cltc ArnA== 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 :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :date:dkim-signature; bh=bgyglF9ayxa/RKpdlocwZSsZ3zpKoAyjXW1dDPrXAGw=; fh=EfAPaZF/skNhLnySqR7Pslxgb3loVahf9D7hBZvMRfM=; b=CvKBrrznWgNlVJl8lmbTN/ClYX5XXjCjg0NgPK2N3ruI9O6+LbXaQJX6lMnpWJ+De5 l3tB5ryoirx7+HGNV7WguBAHJRX3giij9fmqR5IFvzpMy2nYY6da1U6APhTym6OVyCU8 Hbj+nSAUEUWgdvpFz0HWHJkjk+7gZao4ILMocOgY/6pX3kpnE+PBTAVobDZ55HGa62ff 2Y76V67BC3x73DcGYMChiMQ0/8gjnt6PG/UjQCD6CAjqyF/BngQq/lFofz/dpJEy/k7r 7xx4xe26Iy6yMUYuZ0bge/Sn+nJ64XbMKvlsnGWzBaXx2eLDglOb0fzAtrCrNrJjdNrc UiDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@emersion.fr header.s=protonmail2 header.b=bcHl5BOW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=emersion.fr Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id s26-20020a63525a000000b00578fe1bdfcasi3232515pgl.860.2023.12.01.02.25.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 02:25:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@emersion.fr header.s=protonmail2 header.b=bcHl5BOW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=emersion.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id DAA3C809C152; Fri, 1 Dec 2023 02:25:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378239AbjLAKZI (ORCPT + 99 others); Fri, 1 Dec 2023 05:25:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378226AbjLAKZG (ORCPT ); Fri, 1 Dec 2023 05:25:06 -0500 Received: from mail-40136.proton.ch (mail-40136.proton.ch [185.70.40.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB9494 for ; Fri, 1 Dec 2023 02:25:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail2; t=1701426309; x=1701685509; bh=bgyglF9ayxa/RKpdlocwZSsZ3zpKoAyjXW1dDPrXAGw=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=bcHl5BOWYJk0TNt+h0a9dSc7hrj5VR3v/kDHbFw4D6qQ43nZkZsUCZJZcDlef95K8 GrGLErUWOXrEp8Vne614IgeuIvN+x+S2s5Y5ItC1PQ9WgGl+oaCYuauaxRNckBO0Wq 130Q+aUQIMLyDdDnTQMgd/2YIlOKfZ7rFkaAOJyL/lrFKEuko+hGFW0sdSBsnQ2xWI GLQLeWNgrT9RLZeZxmJ/2RETDuDnXOg/D3UV9Sf9QCki5U48+LC9C7aOXh1AcAvDgl qQDWfQixyh9cvr8ALnbfagtkRR3Zy6xePdY76/MGM1z7XYbxYjaYP2wlrm8eSeYJbV qaPa7yxtL95Rg== Date: Fri, 01 Dec 2023 10:25:03 +0000 To: Pekka Paalanen From: Simon Ser Cc: =?utf-8?Q?Andr=C3=A9_Almeida?= , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-dev@igalia.com, alexander.deucher@amd.com, christian.koenig@amd.com, Rob Clark , daniel@ffwll.ch, Daniel Stone , =?utf-8?Q?=27Marek_Ol=C5=A1=C3=A1k=27?= , Dave Airlie , =?utf-8?Q?Michel_D=C3=A4nzer?= , Randy Dunlap , Jonathan Corbet , linux-doc@vger.kernel.org, Thomas Zimmermann , Maxime Ripard , Maarten Lankhorst Subject: Re: [PATCH] drm/doc: Define KMS atomic state set Message-ID: In-Reply-To: <20231201115709.61c0817e.pekka.paalanen@collabora.com> References: <20231130200740.53454-1-andrealmeid@igalia.com> <40gonZRoP7FjDn_ugL_LpXsqwoSCZtypIe7jiWg0t8lkTx94-gESc60Cuu5eWxivJoZCNg3i-cUG9kNpKQZeYdCJPawDpTSIXivJ_t_a87E=@emersion.fr> <20231201115709.61c0817e.pekka.paalanen@collabora.com> Feedback-ID: 1358184:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Fri, 01 Dec 2023 02:25:26 -0800 (PST) On Friday, December 1st, 2023 at 10:57, Pekka Paalanen wrote: > > > +An atomic commit can be flagged with DRM_MODE_ATOMIC_TEST_ONLY, whic= h means the =20 > >=20 > > It would be nice to link DRM_MODE_ATOMIC_TEST_ONLY to the actual docs h= ere. > > This can be done with markup such as: > >=20 > > :c:macro:`DRM_MODE_ATOMIC_TEST_ONLY` > >=20 > > Same applies to other #defines. > >=20 > > > +complete state change is validated but not applied. Userspace shoul= d use this =20 > >=20 > > I'd s/should/can/ here, because there are valid cases where user-space = doesn't > > really need to test before applying. Applying a state first validates i= t in the > > kernel anwyays. >=20 > Those cases a very much an exception. If you want to explain in what > cases testing is not necessary, that's fine to add, but without it I do > want to always recommend testing first. There is no harm in testing too > much, but there is harm in not testing which implies that there is > likely no fallback either. Without fallbacks, the kernel developers > have less room to change things, and the userspace itself is probably > too fragile to be generally useful. >=20 > Or, if you think this concern is moot, then why would userspace ever > use testing? >=20 > However, I have understood from past kernel discussions that userspace > really does need to test and fall back on test failure in almost all > cases. Otherwise userspace becomes too driver/hardware dependent. >=20 > In general, I think recommending best practices with "should" is a good > idea. I was mostly thinking about very simple KMS clients that only use the most basic configuration (full-screen buffer with no scaling/cropping). That's actually a quite common case. But I see what you mean here, I don't mind keeping the current wording. > > > +flag to validate any state change before asking to apply it. If vali= dation fails > > > +for any reason, userspace should attempt to fall back to another, pe= rhaps > > > +simpler, final state. This allows userspace to probe for various co= nfigurations > > > +without causing visible glitches on screen and without the need to u= ndo a > > > +probing change. > > > + > > > +The changes recorded in an atomic commit apply on top the current KM= S state in > > > +the kernel. Hence, the complete new KMS state is the complete old KM= S 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, du= e to the > > > +need to acquire locks for some attributes. Userspace needs to be awa= re that some > > > +redundant information might result in oversynchronization issues. N= o-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 shal= l not be a > > > +modeset on its own. As a special exception for VRR needs, explicitly= setting > > > +FB_ID to its current value is not a no-op. =20 > >=20 > > I'm not sure talking about FB_ID is the right thing to do here. There i= s > > nothing special about FB_ID in particular. For instance, setting CRTC_I= D to the > > same value as before has the same effect. Talking specifically about FB= _ID here > > can be surprising for user-space: reading these docs, I'd assume settin= g > > CRTC_ID to the same value as before is a no-op, but in reality it's not= . >=20 > Whoa, I never knew that! That's a big surprise! Aha! Seems like KMS always has a trick up its sleeve to surprise user-space devs :) > People have always been talking only about FB_ID so far. >=20 > > Instead, I'd suggest explaining how referencing a plane/CRTC/connector = in an > > atomic commit adds it to the new state, even if there are no effective = property > > value changes. >=20 > So, if a CRTC object is pulled into drm_atomic_state(?) at all, on VRR > it will trigger a new scanout cycle always, avoiding the front porch > timeout? >=20 > Yikes. Yeah, I believe so. Any property (regardless of whether the value actually changed or not) included in the atomic commit may directly (applied on a CR= TC object) or indirectly (applied on a plane/connector linked to a CRTC) pull = in a CRTC and have side-effects. (Also, as noted on IRC, a driver might pull i= n a CRTC on its own, e.g. when reconfiguring a DP-MST tree.) > > > +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 c= hange 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 t= o > > > +effectively change only the FB_ID property on any planes. No-operati= on changes > > > +are ignored as always. Changing any other property will cause the co= mmit to be > > > +rejected. Each driver may relax this restriction if they have guaran= tees that > > > +such property change doesn't cause modesets. Userspace can use TEST_= ONLY commits > > > +to query the driver about this. =20 > >=20 > > This doesn't 100% match reality at the moment, because core DRM now rej= ects any > > async commit which changes FB_ID on a non-primary plane. And there is n= o way > > for drivers to relax this currently. > >=20 > > I'm not sure this is a good place to state such a rule. In the end, it'= s the > > same as always: the kernel will reject commits it can't perform. > > DRM_MODE_PAGE_FLIP_ASYNC does not need to be a special case here. Even = when > > changing only FB_ID, the kernel might reject the commit (e.g. i915 does= in some > > cases). >=20 > I think the paragraph is good to drop here, if it's documented in a > more appropriate place. Yeah, maybe we should expand the DRM_MODE_PAGE_FLIP_ASYNC docs a bit.