Re: [PATCH v4] Documentation: gpu: Mention the requirements for new properties

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 6 Jul 2021 18:42:41 +0200
Maxime Ripard <maxime@xxxxxxxxxx> wrote:

> On Tue, Jul 06, 2021 at 12:37:23PM +0300, Pekka Paalanen wrote:
> > > > > +- It must provide a generic helper in the core code to register that
> > > > > +  property on the object it attaches to.
> > > > > +
> > > > > +- Its content must be decoded by the core and provided in the object's
> > > > > +  associated state structure. That includes anything drivers might want to
> > > > > +  precompute, like :c:type:`struct drm_clip_rect <drm_clip_rect>` for planes.
> > > > > +
> > > > > +- An IGT test must be submitted where reasonable.    
> > > > 
> > > > Would it be too much to replace "where reasonable" with "if it is at
> > > > all possible to write a test."?
> > > >     
> > > > > +    
> > > > 
> > > > How about adding the following somewhere?
> > > > 
> > > > - The initial state of the property (set during driver initialization)
> > > >   must match how the driver+hardware behaved before introducing this
> > > >   property. It may be some fixed value or it may be inherited from e.g.
> > > >   the firmware that booted the system. How the initial state is
> > > >   determined must also be documented, that is, where does it come from.
> > > > 
> > > > The initial state must not be called "default", because I want to
> > > > reserve the term default for something else if possible: the phrase
> > > > "reset everything to defaults", which is a whole another discussion.    
> > > 
> > > I've taken into account your previous comments, thanks
> > >   
> > > > How about also saying that fbcon/fbdev must set this property when
> > > > taking over? That sounds to be like a common omission leading to funky
> > > > KMS state in fbcon. The value fbdev sets it to only needs to make
> > > > sense to fbdev, and it does not need to be ~~the initial value~~ nor the
> > > > default value. Or are we hoping to kill fbcon in favor of a userspace
> > > > kmscon soon? ;-)
> > > > 
> > > > Ooh, maybe the KMS property documentation should also say what value
> > > > fbdev will set the property to. That's kind of UABI, because userspace
> > > > probably implicitly relies on it in many cases. ...which means fbdev
> > > > should set the property to its initial value, otherwise userspace will
> > > > break.    
> > > 
> > > I'm not sure about this one: fbdev and fbcon are still optional features
> > > of the kernel and can be disabled at the user discretion. Having any
> > > part of the user-space rely on the fbdev behavior seems a bit broken,
> > > especially when we have a mechanism to retrieve the state when the
> > > application starts.  
> > 
> > yes, exactly that is why fbdev/fbcon should reset the properties to
> > their initial values. You would not want userspace inheriting a
> > different KMS state with vs. without fbcon when it starts.  
> 
> I'm not sure I'm following you when fbdev/fbcon should reset these
> properties. When a master takes over?

Hi,

when fbcon/fbdev takes over. If it doesn't reset things like GAMMA
LUT, it's possible it won't be readable even though nothing fails.

(Let's say you fumble with an xrandr incantation and manage to set a
LUT that turns everything into a single shade of green or something.
How do you recover?)

When a userspace KMS client hands off to another userspace KMS client,
fbcon/fbdev should not do anything. If it did, that would cause extra
flicker.

I'm assuming fbcon/fbdev already implement all the necessary
mechanisms, but they just don't poke at all the KMS properties
necessary, as is evident from e.g. Michel Dänzer's testing seeing wrong
colors in fbcon after a userspace KMS client changed GAMMA or DEGAMMA
once.

Handling this properly would offer an escape hatch without reboot when
something goes wrong in a display server. It's not a fix for userspace
KMS client handing off to another userspace KMS client, for that we
need something else.

> If we consider fbdev as any KMS client, isn't it a fundamental change
> with how it's currently done? I haven't seen anywhere that a compositor
> (or any client for that matter) should put the KMS device in the same
> state that it started it with. In case of a crash it would be fairly
> difficult to achieve.

It has long been agreed IMO but never implemented anywhere AFAIK that a
userspace KMS client should fully reset the whole KMS state to the KMS
state it started with when it *comes back* after being switched away. I
have talked with Daniel Vetter about this several times over the years.
The problem with resetting the full KMS state is what to do with those
KMS properties the KMS client does not understand but are exposed by the
driver.

When a userspace KMS client switches out or quits, what is implemented
and what should be implemented differs again. I believe that KMS
clients of today do not change anything, so that the number of modesets
is minimized. This is sufficient if the KMS client didn't use any less
commonly used KMS properties. It's also consistent with crash behaviour.

If the KMS client wants to support seamless hand-off to another KMS
client, the practical approach is "reset everything to the sane KMS
state except keep the video mode" so that if the next KMS client
doesn't understand everything, it still works. I don't know if display
servers care to implement this, or do they just assume switching to
another instance of themselves in which case they know what the next
KMS client does. Or maybe the don't even use KMS properties others
don't use too.

Btw. Xorg understands very few KMS properties by itself I think. It
just exposes everything via RandR and assumes that whatever X11 clients
are running, some of them will take care of the KMS properties. So one
cannot look at Xorg as a single entity, one also needs to look at all
the different desktop environments and whatever.

Another idea that has come up is that userspace should invent a KMS
hand-off protocol completely in userspace. I'm not aware of anyone
working on that. It would allow better smooth KMS hand-off between KMS
clients, as the current and the next KMS client could negotiate about
which KMS properties they understand and which need to be reset
abruptly.

In any case, consensus seems to be that when a KMS client switches back
in, there are no guarantees at all about the KMS state it inherits at
that point. Therefore fbcon as a KMS client needs to reset everything.
People just don't seem to care about fbcon working that much.

There is also the assumption that when a KMS client starts, the KMS
state it inherits is... "reasonable". This should be true if the KMS
state is the initial state chosen by a driver, and also if the state
has been touched by fbcon, because it's not uncommon for fbcon to
be up before the first KMS userspace client starts. But after the first
KMS userspace client has started, all bets are practically off for the
next KMS client starting.

> > Retrieving the current KMS state is useless if the current KMS state is
> > somehow wonky and the application does not understand that specific KMS
> > property that is wonky. It cannot set the property to any value other
> > than it already had without user intervention.  
> 
> Yeah, that's true. But the same could be said if you switch from one
> client to the other for example, at the moment there's no guarantee that
> the first one didn't change a property to a value you don't expect in
> the second. Unless we manage to tie that somehow to a first open of the
> device?

As I wrote above, yes, this is an open problem. Fbcon being just a KMS
client needs a solution like all KMS clients. None of it is a
regression per se, unless you see adding new KMS properties that
provoke this problem more as a regression.

The idea I've been pondering about is a flag in atomic commit: instead
of basing the changes on the current KMS state, start with "the default
KMS state".

The definition of the default KMS state is tricky, because it should
not depend on e.g. firmware. So it is not the same as the initial KMS
state programmed in driver initialization. It needs to be defined
separately and individually for each KMS property. In my opinion, the
default KMS state should be defined as everything being off (planes,
crtcs), disabled (dithering, HDR), pass-through/identity (GAMMA,
DEGAMMA, CTM), "auto" where that applies and is the initial state, and
so on. The goal is to make it as neutral and as "off" as possible while
still giving good chances of letting the simpler KMS clients work
correctly.

If there was a mechanism for this "reset to default", fbdev could just
hit it.

There have been opinions that this problem does not need solving,
because an average Linux user will never switch between arbitrary KMS
clients. At most, they switch from bootsplash to a login manager, and
then to a desktop compositor. Bootsplash won't change "advanced" KMS
state, and the login manager's display server acts as the resetting
entity as it is maintained to explicitly(?) support all the different
desktops. If a desktop uses a new KMS property, the login manager is
updated(?) to reset that property.

Hence I didn't go all the way suggesting in the rules that the default
state needs to be defined.

And if fbcon is good to leave rotting, then no need to mention that
either.

> > I'd say fbcon causing all KMS state to be reset is a quality of life
> > thing. It's possible to live without by rebooting, but it would
> > certainly make at least developers' and testers' life easier until we
> > get the real "reset KMS" knob (which fbcon could then use too).
> > 
> > Besides, even if it is broken for userspace to rely on the KMS state
> > set by fbcon/fbdev, userspace is already doing that and not on purpose
> > because new KMS properties get added in the kernel. I would bet that
> > there is not a single userspace program that would actually set all KMS
> > properties that drivers might expose. So they are depending on
> > inherited KMS state, which could be left by driver initialization, by
> > fbdev/fbcon, or by any other userspace.
> > 
> > But yeah, this idea is something new, so don't let this discussion
> > delay landing the docs.  
> 
> Ack, I've sent a new version

Thank you!
pq

Attachment: pgpo0IjMNyOFA.pgp
Description: OpenPGP digital signature


[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux