dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Simon Ser <contact@emersion.fr>
Cc: "dri-devel@lists.freedesktop.org" <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm: drivers may provide multiple primary planes per CRTC
Date: Fri, 7 Aug 2020 15:03:44 +0200	[thread overview]
Message-ID: <20200807130344.GC2352366@phenom.ffwll.local> (raw)
In-Reply-To: <6XQa3_NXcCPK17tzRXXF9AwPRk0dRNLDau9MIHoRiblQq4dE5_h002dK9gReNVxt2NjPn8_d-S2UA2X0XagLeBqicdSfeFQWUD3eQLxcbyo=@emersion.fr>

On Fri, Aug 07, 2020 at 09:33:16AM +0000, Simon Ser wrote:
> On Friday, August 7, 2020 11:07 AM, Daniel Vetter <daniel@ffwll.ch> wrote:
> > On Thu, Aug 06, 2020 at 10:33:31AM +0000, Simon Ser wrote:
> > > Some drivers may expose primary planes compatible with multiple CRTCs.
> > > Make this clear in the docs: the current wording may be misunderstood as
> > > "exactly one primary plane per CRTC".
> > >
> > > Signed-off-by: Simon Ser <contact@emersion.fr>
> > > Cc: Daniel Vetter <daniel@ffwll.ch>
> > > ---
> > >  drivers/gpu/drm/drm_plane.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > index b7b90b3a2e38..108a922e8c23 100644
> > > --- a/drivers/gpu/drm/drm_plane.c
> > > +++ b/drivers/gpu/drm/drm_plane.c
> > > @@ -49,8 +49,8 @@
> > >   * &struct drm_plane (possibly as part of a larger structure) and registers it
> > >   * with a call to drm_universal_plane_init().
> > >   *
> > > - * Cursor and overlay planes are optional. All drivers should provide one
> > > - * primary plane per CRTC to avoid surprising userspace too much. See enum
> > > + * Cursor and overlay planes are optional. All drivers should provide at least
> > > + * one primary plane per CRTC to avoid surprising userspace too much. See enum
> >
> > I think that's even more confusing, since this reads like there could be
> > multiple primary planes for a specific CRTC. That's not the case, there'
> > only one pointer going from drm_crtc->primary to a drm_plane in the
> > kernel.
> >
> > The problem is that userspace doesn't have a drm_property to read this
> > pointer, and needs to guess.
> >
> > I thought the rule is:
> >
> > Nth primary plane (or cursor) is the primary plane for the Nth crtc.
> > Enumaration with increasing drm kms object ids.
> >
> > And I guess we should explain that on some hw any plane (including primary
> > ones, since that's only a sw construct) can be freely assinged to crtc.
> 
> Eh, wow. Okay, I didn't expect that. :P
> 
> What does drm_crtc->primary mean in case a GPU exposes more than one CRTC in
> the primary planes' possible_crtcs bitfield? Does this pointer change if I
> assign primary plane 2 to CRTC 1? Is the primary n → CRTC n assignment just a
> default?

Nope this pointer is entirely static. It's simply the plane that legacy
ioctls (SETCRTC, PAGE_FLIP, ...) will pick. If you've done something funny
and assigned that plane to a different crtc, then the page_flip or setcrtc
might actually fail, because we can't steal it.

Wrt the rule, it's just a guess. I think we should actually verify it at
drm_dev_register time, if we document it as uapi. So example, 2 crtc, 2
plane:

CRTC ids: 0, 1
PLANE ids: 2, 3

possible_crtc for both planes: 0x3

So here userspace should assume that plane id 2 is the primary plane for
crtc 0, and plane id 3 is the primary plane for crtc 1.

But if you only have one output, you can use both planes on a single crtc.

Now if you have more planes, e.g. 4 planes, then maybe the example is:

CRTC ids: 0, 1,
PLANE ids with primary tag: 2, 4
PLANE ids with overlay tag: 3, 5

Then plane id 2 is primary plane for crtc 0, and plane id 4 is primary
plane for crtc 1. It could also be that the crtc ids are interleaved in
the planes, depending how planes/crtc are initialized in the driver.

> Maybe we can just say that at most a single primary plane may be assigned to a
> CRTC, and that a primary plane may be compatible with multiple CRTCs?

Nope, see above example, if you have true universal plane hw you can
assign _all_ planes, including primary ones, to a single crtc. If the
memory bw and all these other constraints allow that ofc.

Primary plane is purely a tag for legacy uapi users, it tells you nothing
about what a plane can do.

> > Yes it's probably the most gloriously bonkers uapi we've come up with.
> > Might be so bad that a libdrm helper to look up the primary plane for a
> > crtc (or it's cursor plane if it exists) would be in order :-)
> 
> Well, if user-space can change drm_crtc->primary, I'm not sure this is a good
> idea.

Nope you cannot. It's just a tag for the kernel ioctls.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-08-07 13:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-06 10:33 [PATCH] drm: drivers may provide multiple primary planes per CRTC Simon Ser
2020-08-07  9:07 ` Daniel Vetter
2020-08-07  9:33   ` Simon Ser
2020-08-07 13:03     ` Daniel Vetter [this message]
2020-08-07  9:38   ` Pekka Paalanen
2020-08-07 13:06     ` Daniel Vetter
2020-12-06 15:24       ` Simon Ser
2020-12-07  8:45         ` Pekka Paalanen
2020-12-07  9:10           ` Simon Ser
2020-12-09  0:36             ` Daniel Vetter
2020-12-09  8:23               ` Pekka Paalanen
2020-12-09 10:40                 ` Daniel Vetter

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=20200807130344.GC2352366@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=contact@emersion.fr \
    --cc=dri-devel@lists.freedesktop.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox