dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime@cerno.tech>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Mark Rutland <mark.rutland@arm.com>,
	devicetree@vger.kernel.org, Tim Gover <tim.gover@raspberrypi.com>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org, Rob Herring <robh+dt@kernel.org>,
	bcm-kernel-feedback-list@broadcom.com,
	linux-rpi-kernel@lists.infradead.org,
	Daniel Vetter <daniel.vetter@intel.com>,
	Frank Rowand <frowand.list@gmail.com>,
	Phil Elwell <phil@raspberrypi.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 6/8] drm/vc4: kms: Wait on previous FIFO users before a commit
Date: Tue, 1 Dec 2020 18:06:49 +0100	[thread overview]
Message-ID: <20201201170649.g2uo6c7ngxdvfw3j@gilmour> (raw)
In-Reply-To: <8c5f37b3-a4ff-d4d0-ebe0-8bc931416293@suse.de>


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

Hi Thomas,

On Fri, Nov 20, 2020 at 02:19:45PM +0100, Thomas Zimmermann wrote:
> Am 13.11.20 um 16:29 schrieb Maxime Ripard:
> > If we're having two subsequent, non-blocking, commits on two different
> > CRTCs that share no resources, there's no guarantee on the order of
> > execution of both commits.
> 
> Can there only ever be two commits that flip order?

It needs a bit of bad luck, but the patch 2 provides a bit more details.

Basically, if there's two subsequent non-blocking commits, affecting
different CRTCs without anything shared between those CRTCs (so no
plane, encoder or connector in common), you have no guarantee on the
commit order.

Most of the time it's not a big deal precisely because they don't share
anything. However if the private state is shared between the CRTCs then
it becomes an issue and we need to make sure that the ordering is
respected.

> > However, the second one will consider the first one as the old state,
> > and will be in charge of freeing it once that second commit is done.
> > 
> > If the first commit happens after that second commit, it might access
> > some resources related to its state that has been freed, resulting in a
> > use-after-free bug.
> > 
> > The standard DRM objects are protected against this, but our HVS private
> > state isn't so let's make sure we wait for all the previous FIFO users
> > to finish their commit before going with our own.
> 
> I'd appreciate a comment in the code that explains a bit how this works.
> It's sort of clear to me, but not enough to fully get it.

I'm not sure to get what "this" means and what do you want me to comment
there?

> > 
> > Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> > ---
> >   drivers/gpu/drm/vc4/vc4_kms.c | 118 +++++++++++++++++++++++++++++++++-
> >   1 file changed, 117 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
> > index 3034a5a6637e..849bc6b4cea4 100644
> > --- a/drivers/gpu/drm/vc4/vc4_kms.c
> > +++ b/drivers/gpu/drm/vc4/vc4_kms.c
> > @@ -40,6 +40,11 @@ static struct vc4_ctm_state *to_vc4_ctm_state(struct drm_private_state *priv)
> >   struct vc4_hvs_state {
> >   	struct drm_private_state base;
> >   	unsigned int unassigned_channels;
> > +
> > +	struct {
> > +		unsigned in_use: 1;
> > +		struct drm_crtc_commit *last_user;
> 
> Can these updates run concurrently? If so, the concurrency control via
> in_use is dubious.

No, there's only ever one commit being done. We just need to make sure
they are in the right order.

I'll address your other comments

Maxime

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 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

  reply	other threads:[~2020-12-02  8:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13 15:29 [PATCH 0/8] vc4: Convert to drm_atomic_helper_commit Maxime Ripard
2020-11-13 15:29 ` [PATCH 1/8] drm: Introduce an atomic_commit_setup function Maxime Ripard
2020-11-13 21:02   ` Daniel Vetter
2020-11-20 13:34     ` Maxime Ripard
2020-11-20 14:50       ` Daniel Vetter
2020-11-19  9:59   ` Thomas Zimmermann
2020-11-19 15:32     ` Daniel Vetter
2020-11-20  8:38       ` Thomas Zimmermann
2020-11-20  9:29         ` Daniel Vetter
2020-11-13 15:29 ` [PATCH 2/8] drm: Document use-after-free gotcha with private objects Maxime Ripard
2020-11-19 15:38   ` Daniel Vetter
2020-11-13 15:29 ` [PATCH 3/8] drm/vc4: kms: Move HVS state helpers around Maxime Ripard
2020-11-19  9:26   ` Thomas Zimmermann
2020-11-13 15:29 ` [PATCH 4/8] drm/vc4: kms: Simplify a bit the private obj state hooks Maxime Ripard
2020-11-19  9:27   ` Thomas Zimmermann
2020-11-13 15:29 ` [PATCH 5/8] drm/vc4: Simplify a bit the global atomic_check Maxime Ripard
2020-11-19  9:32   ` Thomas Zimmermann
2020-11-13 15:29 ` [PATCH 6/8] drm/vc4: kms: Wait on previous FIFO users before a commit Maxime Ripard
2020-11-20 13:19   ` Thomas Zimmermann
2020-12-01 17:06     ` Maxime Ripard [this message]
2020-11-13 15:29 ` [PATCH 7/8] drm/vc4: kms: Remove async modeset semaphore Maxime Ripard
2020-11-20 14:03   ` Thomas Zimmermann
2020-11-13 15:29 ` [PATCH 8/8] drm/vc4: kms: Convert to atomic helpers Maxime Ripard
2020-11-20 14:08   ` Thomas Zimmermann

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=20201201170649.g2uo6c7ngxdvfw3j@gilmour \
    --to=maxime@cerno.tech \
    --cc=airlied@linux.ie \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=daniel.vetter@intel.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=phil@raspberrypi.com \
    --cc=robh+dt@kernel.org \
    --cc=tim.gover@raspberrypi.com \
    --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
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;
as well as URLs for NNTP newsgroup(s).