All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Rob Clark <robdclark@gmail.com>
Cc: "dri-devel@lists.freedesktop.org" <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 14/17] drm/msm: add atomic support
Date: Tue, 27 May 2014 19:50:17 +0200	[thread overview]
Message-ID: <20140527175017.GJ14841@phenom.ffwll.local> (raw)
In-Reply-To: <CAF6AEGvTEobkJfLSpCP_+v1-vaGRp_k+6piEn8+BgiSLsfwkqA@mail.gmail.com>

On Tue, May 27, 2014 at 11:58:33AM -0400, Rob Clark wrote:
> On Mon, May 26, 2014 at 1:54 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
> > Ok, I think I should have read your msm implementation a _lot_ earlier.
> > Explains your desing choices neatly.
> >
> > Two observations:
> >
> > - A GO bit makes nuclear pageflips ridiculously easy to implement,
> >   presuming the hardware actually works. And it's the sane model, so imo a
> >   good one to wrap the atomic helpers around.
> >
> >   But reality is often a lot more ugly, especially if you're employed by
> >   Intel. Which is why I'm harping so much on this helpers-vs-core
> >   interface issues ... We really need the full state transition in one
> >   piece to do anything useful.
> >
> > - msm doesn't have any resource sharing going on for modeset operations
> >   (which I mean lighting up crtcs to feed pixel streams to connectors).
> >   Which means the simplistic "loop over all crtcs and call the old
> >   ->setcrtc" approach actually works.
> 
> we do actually have some shared resources on mdp5 generation (the
> "smp" blocks, basically a shared buffer which we need to allocate fifo
> space from for each plane)..
> 
> I'm mostly ignoring this at the moment, because we don't support
> enough crtc's yet to run out of smp blocks.  But hooking in at the
> current ->atomic_commit() would be enough for me, I think.  Tbh, it is
> something that should be handled at the ->atomic_check() stage so I
> hadn't given much though to ->atomic_commit() stage.
> 
> That all said, I've no problem with adding one more hook, after
> ->atomic_commit() and lock magic, before loop over planes/crtcs, so
> drivers that need to can replace the loops and do their own thing.
> Current state should be reasonably good for sane hw.  I'm just waiting
> for patches for i915 to add whatever it needs.

I don't think that will be enough for you. Example, slightly hypothetical:

- Configuration A: crtc 0 displays a small screen, crtc 1 a giant screen.
  Together they just barely fit into your fifo space.

- Configuration B: crtc 0 drives a giant screen, crtc 1 a tiny one.
  Presume different outputs here so that no implicit output stealing
  happens upon mode switching.

Atomic switch should work, but don't since if you just loop over crtcs you
have the intermediate stage where you try to drive 2 giant screens, which
will run out of fifo resources. And I think it's really common to have
such implicit resource sharing, maybe except for the most beefy desktop
gpu which simply can't run out of memory bw with today's screen.

So afaics you really need to push a bit of smarts into the crtc helpers to
make atomic possible, which then leaves you with interaction issues
between the atomic stuff for GO bit capable hw for plane updates and the
modeset ordering hell.

> >   The problem I see here is that if you have hardware with more elaborate
> >   needs (e.g. shared dplls), but otherwise sanity for plane updates (i.e.
> >   a GO bit) then your current atomic helpers will make it rather hard to
> >   mix this. So I think we should pimp the crtc helpers a bit to be atomic
> >   compliant (i.e. kill all outputs first before enabling anything new) and
> >   try to integrate this with the atomic helpers used for GO bit style
> >   updates.
> 
> Not really, I don't think.  You can still do whatever shared resource
> setup in ->atomic_commit().  For drivers which want to defer commit
> (ie. doing commit after fb's ready from cpu, rather than from gpu), it
> would probably be more convenient to split up atomic_commit() so
> drivers have a post lock hook.  I think it is just a few line patch,
> and I think that it probably isn't really needed until i915 is ready.
> I'm pretty sure we can change this to do what i915 needs, while at the
> same time keeping it simple for 'GO bit' drivers.
>
> The bit about crtc helpers, I'll have to think about.  I'm not sure
> that we want to require that 'atomic' (modeset or pageflip) completely
> *replaces* current state.  So disabling unrelated crtcs doesn't seem
> like the right thing.  But we have some time to decide about the
> semantics of an atomic modeset before we expose to userspace.

I'm not talking about replacing unrelated crtcs. It's also not about
underspecified state or about enabling/changing global resources.

It is _only_ about ordering of the various operations: If both the
current and the desired new configuration are at the limit of what the hw
can do you can't switch to the new configuration by looping over all
crtcs. The fact that this doesn't work is the entire point of atomic
modesets. And if we have helpers which aren't cut out for the task at hand
for any hw where we need to have atomic modesets to make such changes
possible without userspace going nuts, then the helpers are imo simply not
useful

> >   i915 has dpll sharing on ivb/hsw, but doesn't use the the crtc helpers
> >   anymore. But the radone eyefinity (or whatever the damn thing is called)
> >   I have lying around here fits the bill: It has 5 DP+ outputs but only 2
> >   dplls. So you can drive e.g. 3 DP screens and then switch to 2 HDMI
> >   screens atomically and it should all pan out.
> >
> >   But since your current helpers just loop over all crtcs without any
> >   regard to ordering constraints this will fall over if the 2 HDMI outputs
> >   get enabled before the 3 DP outputs get disabled all disabled.
> 
> the driver should have rejected the config before it gets to commit
> stage, if it were an impossible config.

The configuration _is_ possible. We simply have to be somewhat careful
with transitioning to it, since not _all_ intermediate states are
possible. Your current helpers presume that's the case, which afaik isn't
the case on any hw where we have global limits. For modesets.

Nuclear pageflips are a completely different thing, as long as your hw has
a GO bit.

> > So with all that in mind I have 3 sanity checks for the atomic interfaces
> > and helpers:
> >
> > 1. The atomic helpers should make enabling sane hw with a GO bit easy for
> > nuclear pageflips. Benchmark would be sane hw like msm or omap.
> >
> > 2. It should cooperate with the crtc helpers such that hw with some shared
> > resources (like dplls) works for atomic modesets. That pretty much means
> > "disable everything (including crtc/connetor pipelines that only changed
> > some parts) before enabling anything". Benchmark would be a platform with
> > shared dplls.
> 
> btw, not something I'd thought about before, but shared dplls seem
> common enough, that it is something core could help with.  (Assuming
> they are all related to pixel clk and not some derived thing that core
> wouldn't know about.)

Yup, that's what I'm trying to say ;-) But it was just an example, I
believe that atm your helpers don't help for any shared modeset resources
at all.

> I think we do need to decide what partial state updates me in the
> context of modeset or pageflip.  I kinda think the right thing is
> different for modeset vs pageflip.  Maybe we want to define an atomic
> flag to mean "disable/discard everything else"..  at any rate, we only
> need to sort that before exposing the API to userspace.

Yeah, I still strongly support this split in the api itself. For i915 my
plan is to have separate configuration structures for modeset state and
pageflip/plane config state. When we do an atomic modeset we compute both
(maybe with some shortcut if we know that the pipe config didn't change at
all). Then comes the big switch:

- If we have the same pipe config, we simply to a vblank synce nuclear
  flip to the new config.

- If pipe configs change it will be much more elaborate:

  1. Do a vblank synced nuclear flip to black on all pipes that need to go
  off (whether they get disabled or reconfigured doesn't matter for now).

  2. Disable pipes.

  3. Commit new state on the sw side.

  4. Enable all pipes with the new config, but only scanning out black.

  5. Do a vblank-synced nuclear flip to the new config. This would also be
  the one that would signale the drm events that the atomic update
  completed.

  For fastboot we might need some hacks to fuse this all together, e.g for
  some panel fitter changes we don't need to disable the pipe completely.
  But that's the advanced stuff really.

I think modelling the crtc helpers after this model could work. But that
means that the crtc helpers and the nuclear flip atomic helpers for GO
bit capable hw need to be rather tightly integrated, while still allowing
drivers to override the nuclear flip parts.

> > 3. The core->driver interface should be powerful enough to support
> > insanity like i915, but no more. Which means all the code that's share
> > (i.e. the set_prop code I've been harping all over the place about) should
> > be done in the core, without any means for drivers to override. Currently
> > the drm core also takes care of a bunch of things like basic locking and
> > refcounting, and that's kinda the spirit for this. i915 is the obvious
> > benchmark here.
> 
> The more I think about it, the more I think we should leave set_prop
> as it is (although possibly with drm_atomic_state ->
> drm_{plane,crtc,etc}_state).
> 
> In the past, before primary plane, I really needed this.  And I expect
> having a convenient way to 'sniff' changing properties as they go by
> will be useful in some cases.

I actually really like the addition of the state object to ->set_prop. At
least for i915 (which already has a fair pile of additional properties)
that looks like the perfect way to prep the stage.

But at least for the transition we should keep the impact minimal. So no
manadatory callbacks and don't enforce the usage of the state object until
the drm core is fully converted to always follow a set_prop with a
->commit. Since currently we have internal mode_set calls in all i915
set_prop functions and we need to convert them all. But we can't do that
until all the core stuff uses the atomic interface for all legacy ioctl
ops.

> > I think we can roll this out piecemeal (and it's probably better to do it
> > that way), but I also think that until we've resolved the requirements of
> > 2&3 we should try to minimize subsystem wide changes as much as possible
> > by making them opt-in and the vfuncs optional.
> 
> the new mandatory vfuncs don't amount to too much churn.. not as much
> as the extra param for crtc lock/unlock fxns.  Maybe if I was planning
> on keeping this alive on a branch for so long in the beginning I would
> have arranged a few things slightly different, but meh.
> 
> A very early iteration of atomic preserved the old pageflip, setcrtc,
> setplane, etc paths for drivers not implementing atomic fxns.  But
> that was at least a bit ugly.  I like the current approach since the
> code paths are very much the same for atomic and non-atomic.

I'm not advertising for keeping the old driver interfaces, that would be
much worse. I'm only saying that we'll likely change this a few times, and
we will transition fairly slowly anyway. Reducing the overall churn and
especially reducing the amount of code we might need to fix up if we
change our minds seems like a good approach to me.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

  reply	other threads:[~2014-05-27 17:50 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-24 18:30 [PATCH 00/17] prepare for atomic/nuclear modeset/pageflip Rob Clark
2014-05-24 18:30 ` [PATCH 01/17] drm: fix typo Rob Clark
2014-05-24 18:30 ` [PATCH 02/17] drm: add atomic fxns Rob Clark
2014-05-24 18:30 ` [PATCH 03/17] drm: convert crtc and mode_config to ww_mutex Rob Clark
2014-05-25 22:10   ` Daniel Vetter
2014-05-25 23:16     ` Rob Clark
2014-05-26  8:23       ` Daniel Vetter
2014-05-26 11:56         ` Rob Clark
2014-05-26 14:35           ` Daniel Vetter
2014-05-26 14:36             ` Daniel Vetter
2014-05-26 15:04             ` Rob Clark
2014-05-26 15:07               ` Daniel Vetter
2014-05-26 15:20                 ` Rob Clark
2014-05-26 15:35                   ` Daniel Vetter
2014-05-26 15:49                     ` Rob Clark
2014-05-26 16:09                       ` Daniel Vetter
2014-05-24 18:30 ` [PATCH 04/17] drm: add object property type Rob Clark
2014-05-26  8:29   ` Daniel Vetter
2014-05-26  8:33     ` Daniel Vetter
2014-05-26 11:06     ` Rob Clark
2014-05-24 18:30 ` [PATCH 05/17] drm: add signed-range " Rob Clark
2014-05-24 18:30 ` [PATCH 06/17] drm: helpers to find mode objects Rob Clark
2014-05-26  8:37   ` Daniel Vetter
2014-05-26  8:55     ` Daniel Vetter
2014-05-26 11:12     ` Rob Clark
2014-05-24 18:30 ` [PATCH 07/17] drm: split propvals out and blob property support Rob Clark
2014-05-24 18:30 ` [PATCH 08/17] drm: Allow drm_mode_object_find() to look up an object of any type Rob Clark
2014-05-24 18:30 ` [PATCH 09/17] drm: Refactor object property check code Rob Clark
2014-05-24 18:30 ` [PATCH 10/17] drm: allow FB's in drm_mode_object_find Rob Clark
2014-05-26  8:39   ` Daniel Vetter
2014-05-24 18:30 ` [PATCH 11/17] drm: convert plane to properties/state Rob Clark
2014-05-26  9:12   ` Daniel Vetter
2014-05-26 11:32     ` Rob Clark
2014-05-26 14:52       ` Daniel Vetter
2014-05-24 18:30 ` [PATCH 12/17] drm: convert crtc " Rob Clark
2014-05-26  9:31   ` Daniel Vetter
2014-05-26 11:35     ` Rob Clark
2014-05-26 14:56       ` Daniel Vetter
2014-05-26 15:15         ` Rob Clark
2014-05-26 15:23     ` Ville Syrjälä
2014-05-26 15:37       ` Daniel Vetter
2014-05-26 15:42         ` Rob Clark
2014-05-26 15:46         ` Ville Syrjälä
2014-05-26 16:12           ` Daniel Vetter
2014-05-24 18:30 ` [PATCH 13/17] drm: push locking down into restore_fbdev_mode Rob Clark
2014-05-26  9:34   ` Daniel Vetter
2014-05-24 18:30 ` [PATCH 14/17] drm/msm: add atomic support Rob Clark
2014-05-26 17:54   ` Daniel Vetter
2014-05-27 15:58     ` Rob Clark
2014-05-27 17:50       ` Daniel Vetter [this message]
2014-05-27 18:48         ` Rob Clark
2014-05-27 19:26           ` Daniel Vetter
2014-05-27 20:06             ` Rob Clark
2014-05-27 22:09               ` Daniel Vetter
2014-05-27 23:32                 ` Rob Clark
2014-05-28 13:21                   ` Daniel Vetter
2014-05-28 14:14                     ` Ville Syrjälä
2014-05-28 14:50                       ` Daniel Vetter
2014-05-28 15:19                     ` Rob Clark
2014-05-27 23:47                 ` Rob Clark
2014-05-28 13:32                   ` Daniel Vetter
2014-05-24 18:30 ` [PATCH 15/17] drm: spiff out FB refcnting traces Rob Clark
2014-05-24 18:30 ` [PATCH 16/17] drm: more conservative locking Rob Clark
2014-05-24 18:30 ` [PATCH 17/17] drm: Fix up the atomic legacy paths so they work Rob Clark
2014-05-26 10:40 ` [PATCH 00/17] prepare for atomic/nuclear modeset/pageflip Daniel Vetter
2014-05-26 12:48   ` Rob Clark
2014-05-26 15:24     ` Daniel Vetter
2014-05-26 16:12       ` Rob Clark
2014-05-26 17:36         ` 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=20140527175017.GJ14841@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robdclark@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.