Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1231645rdb; Fri, 1 Dec 2023 10:09:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2IFwlFhT5r13GjWD/FIVLV7QlKTP5Zo9ugY42v1MS+90mvz/XP2hAR1zulexWmIuEKve1 X-Received: by 2002:a17:903:1207:b0:1ce:5f67:cfd3 with SMTP id l7-20020a170903120700b001ce5f67cfd3mr27079060plh.18.1701454197461; Fri, 01 Dec 2023 10:09:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701454197; cv=none; d=google.com; s=arc-20160816; b=004BFT2M+vJImDtbDpRChqPaapyIaRNHWPGqbjeW6msMV849mvK2LEH/FOVdlpKVZF xBzSwQs9F+lEA+gGkQZd3RwWrdtGZrJOgGB3TuI+lVbC4yPEIO5qF25FQpUD+8gcc+fD yccQKQQi2A1iUrm9yVixdr5zwNJNlZ4PJJcoK0h1RCUiAataadqyl9JFl/ZYpfC9FTbt OxwCFjGUx8Ebc3x7MXYosZDWeowT+nyjZ8lZVJ0PBAn2JwqkHSTKGJzg4UBOQkR8EXfg FfbgLM47OQ3lFIkbEyWkwQO8tZTL+3qr0TljSiMHPHKvitvITlT3E93A0FWrDQgLkmRz VGRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9YaithIQHVswQmHqg3UlcTTLn9gPZJER0sDFJxMqVQA=; fh=x+bQoBGZkfTSxDMJBukVShvuUbRZQJMZ/ZKVMzSh2O8=; b=wUzABEaLdAyQYhsiXdcGm+aaBuJiuUe5tMhzJUY1hchX6BSP2GvjBWv4eOBtfRu8+E HtV0gy3DvTReJfCD7nCOpwdvCU62cDJDsqhHMZhqfMm7+r+/G8lrPOhTjCcuJsDFj69D GjxobDmZRuoj2xTD54c7DqKN/zjvUZuLYP2EFQ2SGs1xA65Jm8dDKZ9QlxA7VZHAS9x6 OPdoffqa5TrcRW10b8ed1YG7iM3jgvMivJsE4Hv+Rj0m9EeHXvr0NkdMbPdlUQ3VoHOZ jp6G0RQC9lTTitWCR0WVOgg+ZUij87/rDn7PAx5IQyVvfFOvyFe5W0zlpjx8q4s0TBEL fQeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hImsLTcq; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n4-20020a170903110400b001cfba111acasi3876876plh.372.2023.12.01.10.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 10:09:57 -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=@intel.com header.s=Intel header.b=hImsLTcq; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id CF594812D216; Fri, 1 Dec 2023 10:09:40 -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 S230259AbjLASJY (ORCPT + 99 others); Fri, 1 Dec 2023 13:09:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjLASJX (ORCPT ); Fri, 1 Dec 2023 13:09:23 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D303106; Fri, 1 Dec 2023 10:09:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701454169; x=1732990169; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=CJz00CJihd1qEeBYs0fVFfE3n80bQ76KtRuppz6FAPc=; b=hImsLTcqg6KtA8Vx+2VeOr2uaHrEPaeENgpBcdUj7Ds4175SvFiLOFTD QzzKE850RYkp+SdafNnsj4b35OaqspLp3zkk2Dmq6Tkt1A43pLMsTZ3+b kl1ATmf1rh5sp2G4i80zxJK1CTZtk3SbAuE0WEmuYADHFVKJp8CWx8QWX sJJnpMBKzKAYNIm/Vfq34vtwaSzQsD4wJ7fzt4x41vEkg2GHL9ao8ph3i BjNQNtpCUUL24HkA8ptY51fSIDEebxmS9pFNsaWF/eCmqpDz1UC+bGA/T Hd4Xm0q//O0cv4p4jCRmaH7cAqiWjIY5nHvmFq/SEVjyTV9IeBPW2g6zJ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10911"; a="424689904" X-IronPort-AV: E=Sophos;i="6.04,242,1695711600"; d="scan'208";a="424689904" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2023 10:09:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10911"; a="763215712" X-IronPort-AV: E=Sophos;i="6.04,242,1695711600"; d="scan'208";a="763215712" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orsmga007.jf.intel.com with SMTP; 01 Dec 2023 10:09:23 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 01 Dec 2023 20:09:22 +0200 Date: Fri, 1 Dec 2023 20:09:22 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Pekka Paalanen Cc: =?iso-8859-1?Q?Andr=E9?= Almeida , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Maxime Ripard , Jonathan Corbet , 'Marek =?utf-8?B?T2zFocOhayc=?= , Michel =?iso-8859-1?Q?D=E4nzer?= , Randy Dunlap , linux-doc@vger.kernel.org, Thomas Zimmermann , kernel-dev@igalia.com, alexander.deucher@amd.com, christian.koenig@amd.com Subject: Re: [PATCH] drm/doc: Define KMS atomic state set Message-ID: References: <20231130200740.53454-1-andrealmeid@igalia.com> <20231201181616.4c1f0acc.pekka.paalanen@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231201181616.4c1f0acc.pekka.paalanen@collabora.com> X-Patchwork-Hint: comment X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 10:09:40 -0800 (PST) On Fri, Dec 01, 2023 at 06:16:16PM +0200, Pekka Paalanen wrote: > On Fri, 1 Dec 2023 17:00:32 +0200 > Ville Syrj?l? wrote: > > > On Thu, Nov 30, 2023 at 05:07:40PM -0300, Andr? Almeida wrote: > > > 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 > > > --- > > > > > > This is a standalone patch from the following serie, the other patches are > > > already merged: > > > https://lore.kernel.org/lkml/20231122161941.320564-1-andrealmeid@igalia.com/ > > > > > > Documentation/gpu/drm-uapi.rst | 47 ++++++++++++++++++++++++++++++++++ > > > 1 file changed, 47 insertions(+) > > > > > > 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 > > > > > > 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 > > > +================ > > > + > > > +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, > > > > Not how things work. The driver may try to avoid some really > > expensive operations, but generally it will just blindly blast > > the full state to the hardware. > > > > IIRC this was discussed long ago when atomic was being designed > > and the general concensus was that the kernel shouldn't generally > > do this kind of stuff, and instead we just leave it to userspace > > to generate optimal commits. > > I don't think userspace ever got that memo. If I was cheeky, I could > ask where that is documented, so you could point at it and say "told > you so". Probably not docuemented anywhere. > > When I was working on Weston atomic KMS support many years ago, I > created a framework that emitted KMS property changes only when they > actually needed changing. By review feedback (*), all that machinery was > dropped in a re-design, and today Weston always emits all KMS > properties it knows to program for a specific CRTC update including all > relevant planes and connectors. > > (*) Why do we need to repeat the same state tracking that the kernel > does anyway, and also risk getting out of sync with the kernel due to > bugs which then become more difficult to diagnose. I guess (assumed) > kernel internals leaked to userspace. Oops. The kernel does track the full state sure, but it doesn't generally go out of its way to figure out what specifically changed in that state. Doing so would be a lot of extra checks, and kinda less convenient to do inside the driver since at that point the state is already spread all over the various structures. And the fact that those structures are a mismash of uapi and internal bits of state (and other metadata for the single commit that really shouldn't be stored there) doesn't help matters. I did propose to split the state cleanly into pure uapi vs. internal stuff but that didn't gain any traction unfortunately. So I think it might be simpler to do on the uapi property level. It may result in a somewhat coarser idea of what changed, but it avoids having to track down all the little bits of state everwhere that could have changed in response to a single property changing. The kernel could do that I suppose, but someone would need to come up with a good way to track that information. Currently there are a handful of foo_changed booleans ad-hocced here and there, but nothing consistent that covers everything. > > > > so it is safe for userspace to send redundant property > > > +settings. > > > > Safe but not optimal. Any object included in the state will cause said > > object to be part of the commit, and side effects will also need to be > > observed. > > > > So if you add an extra crtc (either directly or indirectly) it will > > have a new commit inserted into the queue and thus and any subsequent > > commit will either block or be rejected with -EBUSY. Also for directly > > added crtcs an event will be emitted once the commit is done. > > It is not too hard to keep CRTCs well separated, Sure. But the way this was worded implied that you can just throw everything and the kitchen sink into the commit without any repercussions, which is not the case. > until the kernel > driver decides under the hood to pull in an unwanted CRTC. That is sadly needed too sometimes. Hardware design is often a bit disappointing. > > But yes, that caveat could use extending in the doc. > > > Any plane added will also need to observe side effects even if the FB > > doesn't change, such as invalidating any internal compressed version > > of the old FB contents, PSR/DSI command mode/etc. will need to upload > > the frame to the display, etc. I suppose we could specify that if no > > FB is specified at all then these kind of side effects could be ignored, > > but that is certainly not how things are implemented right now. > > Well, this is all surprise news to me. > > > So for optimal behaviour userspace should be minimizing the commits. > > > > > Thanks, > pq -- Ville Syrj?l? Intel