From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1523C4727D for ; Wed, 23 Sep 2020 19:17:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 720B6221EF for ; Wed, 23 Sep 2020 19:17:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 720B6221EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1FE4A6E9F2; Wed, 23 Sep 2020 19:17:32 +0000 (UTC) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A3C46E9EE; Wed, 23 Sep 2020 19:17:30 +0000 (UTC) Received: from xpredator (unknown [IPv6:2a02:2f08:4c14:a400:24d7:51ff:fed6:906d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: mvlad) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 4CC8929963E; Wed, 23 Sep 2020 20:17:28 +0100 (BST) Date: Wed, 23 Sep 2020 22:17:24 +0300 From: Marius Vlad To: Daniel Vetter Message-ID: <20200923191724.GA62596@xpredator> References: <20200923105737.2943649-1-daniel.vetter@ffwll.ch> <20200923151852.2952812-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 In-Reply-To: <20200923151852.2952812-1-daniel.vetter@ffwll.ch> Subject: Re: [Intel-gfx] [PATCH] drm/atomic: document and enforce rules around "spurious" EBUSY X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , DRI Development , Pekka Paalanen Content-Type: multipart/mixed; boundary="===============1052615191==" Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" --===============1052615191== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="17pEHd4RhPHOinZp" Content-Disposition: inline --17pEHd4RhPHOinZp Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 23, 2020 at 05:18:52PM +0200, Daniel Vetter wrote: > When doing an atomic modeset with ALLOW_MODESET drivers are allowed to > pull in arbitrary other resources, including CRTCs (e.g. when > reconfiguring global resources). >=20 > But in nonblocking mode userspace has then no idea this happened, > which can lead to spurious EBUSY calls, both: > - when that other CRTC is currently busy doing a page_flip the > ALLOW_MODESET commit can fail with an EBUSY > - on the other CRTC a normal atomic flip can fail with EBUSY because > of the additional commit inserted by the kernel without userspace's > knowledge >=20 > For blocking commits this isn't a problem, because everyone else will > just block until all the CRTC are reconfigured. Only thing userspace > can notice is the dropped frames without any reason for why frames got > dropped. >=20 > Consensus is that we need new uapi to handle this properly, but no one > has any idea what exactly the new uapi should look like. Since this > has been shipping for years already compositors need to deal no matter > what, so as a first step just try to enforce this across drivers > better with some checks. >=20 > v2: Add comments and a WARN_ON to enforce this only when allowed - we > don't want to silently convert page flips into blocking plane updates > just because the driver is buggy. >=20 > v3: Fix inverted WARN_ON (Pekka). >=20 > v4: Drop the uapi changes, only add a WARN_ON for now to enforce some > rules for drivers. >=20 > v5: Make the WARNING more informative (Daniel) >=20 > v6: Add unconditional debug output for compositor hackers to figure > out what's going on when they get an EBUSY (Daniel) >=20 > References: https://lists.freedesktop.org/archives/dri-devel/2018-July/18= 2281.html > Bugzilla: https://gitlab.freedesktop.org/wayland/weston/issues/24#note_95= 68 > Cc: Daniel Stone > Cc: Pekka Paalanen > Cc: Simon Ser > Cc: Ville Syrj=E4l=E4 > Signed-off-by: Daniel Vetter > --- > drivers/gpu/drm/drm_atomic.c | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) >=20 > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c > index 58527f151984..f1a912e80846 100644 > --- a/drivers/gpu/drm/drm_atomic.c > +++ b/drivers/gpu/drm/drm_atomic.c > @@ -281,6 +281,10 @@ EXPORT_SYMBOL(__drm_atomic_state_free); > * needed. It will also grab the relevant CRTC lock to make sure that th= e state > * is consistent. > * > + * WARNING: Drivers may only add new CRTC states to a @state if > + * drm_atomic_state.allow_modeset is set, or if it's a driver-internal c= ommit > + * not created by userspace through an IOCTL call. > + * > * Returns: > * > * Either the allocated state or the error code encoded into the pointer= =2E When > @@ -1262,10 +1266,15 @@ int drm_atomic_check_only(struct drm_atomic_state= *state) > struct drm_crtc_state *new_crtc_state; > struct drm_connector *conn; > struct drm_connector_state *conn_state; > + unsigned requested_crtc =3D 0; > + unsigned affected_crtc =3D 0; > int i, ret =3D 0; > =20 > DRM_DEBUG_ATOMIC("checking %p\n", state); > =20 > + for_each_new_crtc_in_state(state, crtc, old_crtc_state, i) > + requested_crtc |=3D drm_crtc_mask(crtc); > + > for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane= _state, i) { > ret =3D drm_atomic_plane_check(old_plane_state, new_plane_state); > if (ret) { > @@ -1313,6 +1322,26 @@ int drm_atomic_check_only(struct drm_atomic_state = *state) > } > } > =20 > + for_each_new_crtc_in_state(state, crtc, old_crtc_state, i) > + affected_crtc |=3D drm_crtc_mask(crtc); > + > + /* > + * For commits that allow modesets drivers can add other CRTCs to the > + * atomic commit, e.g. when they need to reallocate global resources. > + * This can cause spurious EBUSY, which robs compositors of a very > + * effective sanity check for their drawing loop. Therefor only allow > + * drivers to add unrelated CRTC states for modeset commits. > + * > + * FIXME: Should add affected_crtc mask to the ATOMIC IOCTL as an output > + * so compositors know what's going on. > + */ > + if (affected_crtc !=3D requested_crtc) { > + DRM_DEBUG_ATOMIC("driver added CRTC to commit: requested 0x%x, affecte= d 0x%0x\n", > + requested_crtc, affected_crtc); > + WARN(!state->allow_modeset, "adding CRTC not allowed without modesets:= requested 0x%x, affected 0x%0x\n", > + requested_crtc, affected_crtc); Previous patch had the warn on state->allow_modeset now is !state->allow_modeset. Is that correct? I haven't followed the entire thread on this matter, but I guess the idea is that somehow the kernel would pass to userspace a CRTC mask of affected_crtc (somehow, we don't know how atm) and with it, userspace can then issue a new commit (this commit blocking) with those? > + } > + > return 0; > } > EXPORT_SYMBOL(drm_atomic_check_only); > --=20 > 2.28.0 >=20 > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel --17pEHd4RhPHOinZp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEcDKHej6x6uPk3J379jQS5glH1u8FAl9rn0EACgkQ9jQS5glH 1u943RAAmNIK2ma1gGkqyOtPhcLahZ6hWAmlY+cb3cJdpKAG+zCDuNw16NHCuXDP bLSKCR+c9yOaqWDJjsl1RPexR+BBINyBLEccgK+OajE10ZkDazEtGfl70uHUQQd9 a7j6FW8OpmvmKxR8r/iaC/A1V4UUomjkDznplmN+0HJChzKt2DwMU4+Q2/UgSHkL F8qR/nSaHhAYsVnjwSrFzfZYNR8UMMld0f8vNZdFJD9YDRvL1Ef+BIG43gvo6UUs z5QJBlglmBKI8+fnHXj+9U+VtsfITVn2XgSsDxnMlBMbcdqi6l+WgYq8rqGvpJP8 EPKAX6WE++wq/58OeerJYp6fYLqvHn2nL00wcpC9wMGglS03NQbMixCGPa2+1lh/ 64prR4mfKeHFgxRXLmd8PMRU0jPeSAHAidR9I4APXfp5GtF+cLfswUKYomCFfILx jooVR2D5V4BVlUSllAT1WQYErP4FO9RugqaXdzcUkFlrhWpPGppgnqp1DGFQNhWz aXji7y2NbqFAOwUIRpWpUGPOqZ1kzKJwR7T5e60N4A/6K8J3E84hndtIP14Mqg6Y cVrNrQT2gTbDTIFbm/itb3xeWkYvqIEEoO+XB8bDBtNtc7V431bcfJ2UNSUP8F/6 l3Mk+MQXhnd74Kelkyvo2NrokrcGEJm6XLlJN6aI0mFmHuL6rBo= =6uDo -----END PGP SIGNATURE----- --17pEHd4RhPHOinZp-- --===============1052615191== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx --===============1052615191==--