Re: [PATCH 4/5] drm/atomic: Make the drm_atomic_state documentation less ambiguous

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

 



On Tue, Dec 05, 2023 at 10:51:06AM +0200, Pekka Paalanen wrote:
> On Mon,  4 Dec 2023 13:17:06 +0100
> Maxime Ripard <mripard@xxxxxxxxxx> wrote:
> 
> > The current documentation of drm_atomic_state says that it's the "global
> > state object". This is confusing since, while it does contain all the
> > objects affected by an update and their respective states, if an object
> > isn't affected by this update it won't be part of it.
> > 
> > Thus, it's not truly a "global state", unlike object state structures
> > that do contain the entire state of a given object.
> > 
> > Signed-off-by: Maxime Ripard <mripard@xxxxxxxxxx>
> > ---
> >  include/drm/drm_atomic.h | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> > index 914574b58ae7..81ad7369b90d 100644
> > --- a/include/drm/drm_atomic.h
> > +++ b/include/drm/drm_atomic.h
> > @@ -346,11 +346,19 @@ struct __drm_private_objs_state {
> >  };
> >  
> >  /**
> > - * struct drm_atomic_state - the global state object for atomic updates
> > + * struct drm_atomic_state - Atomic Update structure
> > + *
> > + * This structure is the kernel counterpart of @drm_mode_atomic and contains
> > + * all the objects affected by an atomic modeset update and their states.
> 
> Drop "modeset"? An update can be without a modeset.

Yeah, good point

> >   *
> >   * States are added to an atomic update by calling drm_atomic_get_crtc_state(),
> >   * drm_atomic_get_plane_state(), drm_atomic_get_connector_state(), or for
> >   * private state structures, drm_atomic_get_private_obj_state().
> > + *
> > + * NOTE: While this structure looks to be global and affecting the whole DRM
> > + * device, it only contains the objects affected by the atomic commit.
> 
> This new phrasing is much more clear to me than the old one.

Great

> > + * Unaffected objects will not be part of that update, unless they have been
> > + * explicitly added by either the framework or the driver.
> 
> If the framework or a driver adds an object, then it's no longer
> unaffected, is it?

I guess what I meant to say is that it's affected as a side effect that
the userspace cannot anticipate.

The typical example being that changing a property on a connector would
need to pull the CRTC into the update to disable / enable the CRTC,
encoder and connector.

As far as userspace is concerned, only the connector will be affected,
and only the connector will initially be part of the drm_atomic_state.

But then some part of the atomic_check logic will pull the CRTC into the
update.

It's still invisible to userspace, so I guess
"unaffected-but-turns-out-to-be-affected" would be the right term :)

Would something like:

Unaffected objects will not be part of the initial update, but might be
added explicitly by either the framework or the driver during
atomic_check.

be better?

> Should there be some discussion how this struct starts with only what
> userspace mentioned, and more affected objects may be added by the
> framework or a driver? And adding more objects can surprise the
> userspace and cause even failures (e.g. random, hard-to-diagnose EBUSY
> errors from atomic commit when a driver added a CRTC that was not
> supposed to be affected)? Even unexpected failures on *future* atomic
> commits, as in the CRTC example.
> 
> Was there actually a rule of when the kernel can add unmentioned
> objects, like needing ALLOW_MODESET from userspace?

Sima (iirc?) recently made that explicit, yeah, but there's plenty of
commits that need at the very least the encoder and connector to be
disabled and enabled again to handle them.

Maxime

Attachment: signature.asc
Description: PGP 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