dri-devel Archive on lore.kernel.org
 help / color / Atom feed
From: Pekka Paalanen <ppaalanen@gmail.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	DRI Development <dri-devel@lists.freedesktop.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH 12/12] drm/modifiers: Enforce consistency between the cap an IN_FORMATS
Date: Wed, 14 Apr 2021 10:45:30 +0300
Message-ID: <20210414104530.44b16355@eldfell> (raw)
In-Reply-To: <YHWmkZYqUeZKQN9R@phenom.ffwll.local>

[-- Attachment #1.1: Type: text/plain, Size: 5786 bytes --]

On Tue, 13 Apr 2021 16:11:29 +0200
Daniel Vetter <daniel@ffwll.ch> wrote:

> On Tue, Apr 13, 2021 at 02:56:02PM +0300, Pekka Paalanen wrote:
> > On Tue, 13 Apr 2021 11:49:03 +0200
> > Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> >   
> > > It's very confusing for userspace to have to deal with inconsistencies
> > > here, and some drivers screwed this up a bit. Most just ommitted the
> > > format list when they meant to say that only linear modifier is
> > > allowed, but some also meant that only implied modifiers are
> > > acceptable (because actually none of the planes registered supported
> > > modifiers).
> > > 
> > > Now that this is all done consistently across all drivers, document
> > > the rules and enforce it in the drm core.
> > > 
> > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > Cc: Maxime Ripard <mripard@kernel.org>
> > > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > > Cc: David Airlie <airlied@linux.ie>
> > > Cc: Daniel Vetter <daniel@ffwll.ch>
> > > ---
> > >  drivers/gpu/drm/drm_plane.c   | 16 +++++++++++++++-
> > >  include/drm/drm_mode_config.h |  2 ++
> > >  2 files changed, 17 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > index 0dd43882fe7c..16a7e3e57f7f 100644
> > > --- a/drivers/gpu/drm/drm_plane.c
> > > +++ b/drivers/gpu/drm/drm_plane.c
> > > @@ -128,6 +128,11 @@
> > >   *     pairs supported by this plane. The blob is a struct
> > >   *     drm_format_modifier_blob. Without this property the plane doesn't
> > >   *     support buffers with modifiers. Userspace cannot change this property.
> > > + *
> > > + *     Note that userspace can check the DRM_CAP_ADDFB2_MODIFIERS driver
> > > + *     capability for general modifier support. If this flag is set then every
> > > + *     plane will have the IN_FORMATS property, even when it only supports
> > > + *     DRM_FORMAT_MOD_LINEAR.  
> > 
> > Ooh, that's even better. But isn't that changing the meaning of the
> > cap? Isn't the cap older than IN_FORMATS?  
> 
> Hm indeed. But also how exactly are you going to user modifiers without
> IN_FORMATS ... it's a bit hard.

Easy for at least one specific case, as Daniel Stone said in IRC. Use
GBM to allocate using the no-modifiers API but specify USE_LINEAR. That
basically gives you MOD_LINEAR buffer. Then you can try to make a DRM
FB for it using AddFB2-with-modifiers.

Does anyone do this, I have no idea.

Actually, I think this semantic change is fine. Old userspace did not
know that the cap means all planes have IN_FORMATS, so they can deal
with IN_FORMATS missing, but if it is never missing, no problem.

It could be a problem with new userspace and old kernel, but that's by
definition not a kernel bug, right? Just... inconvenient for userspace
as they can't make full use of the flag and need to keep the fallback
path for missing IN_FORMATS.

As long as there are KMS drivers that don't support modifiers, generic
userspace probably needs the fallback path anyway.

> I think this is all because we've enabled
> modifiers piece-by-piece and never across the entire thing (e.g. with
> compositor and protocols), so the missing pieces only became apparent
> later on.
> 
> I'm not sure whether compositors really want to support this, I guess
> worst case we could disable the cap on these old kernels.
> 
> > What about the opposite? Is it allowed to have even a single IN_FORMATS
> > if you don't have the cap?  
> 
> That direction is enforced since 5.1, because some drivers screwed it up
> and confusion in userspace ensued.
> 
> Should I add a bug that on kernels older than 5.1 the situation is more
> murky and there's lots of bugs?

Yes, that would help to set expectations.

I'm currently on Debian stable FWIW, so 4.19 based kernel with I don't
know what patches.

On Tue, 13 Apr 2021 16:19:10 +0200
Daniel Vetter <daniel@ffwll.ch> wrote:

> On Tue, Apr 13, 2021 at 04:11:29PM +0200, Daniel Vetter wrote:
> > 
> > Should I add a bug that on kernels older than 5.1 the situation is more
> > murky and there's lots of bugs?  
> 
> I guess we should recommend to userspace that if they spot an
> inconsistency between IN_FORMATS across planes and the cap then maybe they
> want to disable modifier support because it might be all kinds of broken?

Yes please!


------

> >   
> > >   */
> > >  
> > >  static unsigned int drm_num_planes(struct drm_device *dev)
> > > @@ -277,8 +282,14 @@ static int __drm_universal_plane_init(struct drm_device *dev,
> > >  			format_modifier_count++;
> > >  	}
> > >  
> > > -	if (format_modifier_count)
> > > +	/* autoset the cap and check for consistency across all planes */
> > > +	if (format_modifier_count) {
> > > +		WARN_ON(!config->allow_fb_modifiers &&
> > > +			!list_empty(&config->plane_list));  
> > 
> > What does this mean?  
> 
> If allow_fb_modifiers isn't set yet (we do that in the line below) and we
> are _not_ the first plane that gets added to the driver (that's done
> towards the end of the function) then that means there's already a plane
> registered without modifiers and hence IN_FORMAT. Which we then warn
> about.

Ah, ok! Would have taken a while for me to decipher that, and
impossible with just this patch context.

> >   
> > >  		config->allow_fb_modifiers = true;
> > > +	} else {
> > > +		WARN_ON(config->allow_fb_modifiers);  
> 
> This warning here checks the other case of an earlier plane with
> modifiers, but the one we're adding now doesn't have them.

Cool.


Thanks,
pq

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply index

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13  9:48 [PATCH 01/12] drm/arm: Don't set allow_fb_modifiers explicitly Daniel Vetter
2021-04-13  9:48 ` [PATCH 02/12] drm/arm/malidp: Always list modifiers Daniel Vetter
2021-04-13  9:48 ` [PATCH 03/12] drm/exynos: Don't set allow_fb_modifiers explicitly Daniel Vetter
2021-04-20  6:31   ` Inki Dae
2021-04-20  8:41     ` Daniel Vetter
2021-04-13  9:48 ` [PATCH 04/12] drm/i915: " Daniel Vetter
2021-04-13  9:48 ` [PATCH 05/12] drm/imx: " Daniel Vetter
2021-04-13 11:47   ` Lucas Stach
2021-04-13 14:04     ` Daniel Vetter
2021-04-13 14:14       ` Lucas Stach
2021-04-14  2:24         ` Liu Ying
2021-04-14  9:10           ` Daniel Vetter
2021-04-15 11:35     ` Daniel Vetter
2021-04-13  9:48 ` [PATCH 06/12] drm/msm/dpu1: " Daniel Vetter
2021-04-13  9:48 ` [PATCH 07/12] drm/msm/mdp4: Fix modifier support enabling Daniel Vetter
2021-04-13  9:48 ` [PATCH 08/12] drm/nouveau: Don't set allow_fb_modifiers explicitly Daniel Vetter
2021-04-13  9:49 ` [PATCH 09/12] drm/stm: " Daniel Vetter
2021-04-13  9:49 ` [PATCH 10/12] drm/tegra: " Daniel Vetter
2021-04-13 11:37   ` Thierry Reding
2021-04-15 11:33     ` Daniel Vetter
2021-04-13  9:49 ` [PATCH 11/12] drm/vc4: " Daniel Vetter
2021-04-14  8:51   ` Maxime Ripard
2021-04-13  9:49 ` [PATCH 12/12] drm/modifiers: Enforce consistency between the cap an IN_FORMATS Daniel Vetter
2021-04-13 11:54   ` Lucas Stach
2021-04-13 14:17     ` Daniel Vetter
2021-04-13 11:56   ` Pekka Paalanen
2021-04-13 14:11     ` Daniel Vetter
2021-04-13 14:19       ` Daniel Vetter
2021-04-14  7:45       ` Pekka Paalanen [this message]
2021-04-13 15:22   ` Simon Ser
2021-04-14  8:52   ` Maxime Ripard
2021-04-14  9:08   ` [PATCH] " Daniel Vetter
2021-04-14 12:14     ` Pekka Paalanen
2021-04-16  6:30     ` Simon Ser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210414104530.44b16355@eldfell \
    --to=ppaalanen@gmail.com \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

dri-devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dri-devel/0 dri-devel/git/0.git
	git clone --mirror https://lore.kernel.org/dri-devel/1 dri-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dri-devel dri-devel/ https://lore.kernel.org/dri-devel \
		dri-devel@lists.freedesktop.org
	public-inbox-index dri-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.freedesktop.lists.dri-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git