From: Alexandru-Cosmin Gheorghe <Alexandru-Cosmin.Gheorghe@arm.com>
To: Sean Paul <seanpaul@chromium.org>
Cc: nd@arm.com, ayan.halder@arm.com, liviu.dudau@arm.com,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH hwc v2 14/18] drm_hwcomposer: Fix race in ApplyFrame
Date: Wed, 18 Apr 2018 11:43:53 +0100 [thread overview]
Message-ID: <20180418104353.GD10633@e114479-lin.cambridge.arm.com> (raw)
In-Reply-To: <20180417170218.GJ73214@art_vandelay>
On Tue, Apr 17, 2018 at 01:02:18PM -0400, Sean Paul wrote:
> On Wed, Apr 11, 2018 at 04:22:25PM +0100, Alexandru Gheorghe wrote:
> > ApplyFrame holds the lock just when it swaps the value of
> > active_composition_, in a multithread context we could end up in a
> > situation where something is shown on the screen, but something else
> > is set in active_composition_. Fix it by holding the lock during
> > CommitFrame.
> >
> > Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
> > ---
> > drmdisplaycompositor.cpp | 40 +++++++++++++++++-----------------------
> > drmdisplaycompositor.h | 2 +-
> > 2 files changed, 18 insertions(+), 24 deletions(-)
> >
> > diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp
> > index afd3b05..576539b 100644
> > --- a/drmdisplaycompositor.cpp
> > +++ b/drmdisplaycompositor.cpp
> > @@ -791,11 +791,6 @@ std::tuple<int, uint32_t> DrmDisplayCompositor::CreateModeBlob(
> > }
> >
> > void DrmDisplayCompositor::ClearDisplay() {
> > - AutoLock lock(&lock_, "compositor");
> > - int ret = lock.Lock();
> > - if (ret)
> > - return;
> > -
> > if (!active_composition_)
> > return;
> >
> > @@ -808,11 +803,25 @@ void DrmDisplayCompositor::ClearDisplay() {
> > }
> >
> > void DrmDisplayCompositor::ApplyFrame(
> > - std::unique_ptr<DrmDisplayComposition> composition, int status) {
> > + std::unique_ptr<DrmDisplayComposition> composition, int status,
> > + bool writeback) {
>
> The writeback argument addition seems unrelated to this change.
Agree.
>
> > + AutoLock lock(&lock_, __FUNCTION__);
> > + if (lock.Lock())
> > + return;
> > int ret = status;
> > -
> > - if (!ret)
> > + if (!ret) {
> > + if (writeback && !CountdownExpired()) {
> > + ALOGE("Abort playing back scene");
> > + return;
> > + }
> > ret = CommitFrame(composition.get(), false);
> > + if (!ret) {
> > + ++dump_frames_composited_;
> > + if (active_composition_)
> > + active_composition_->SignalCompositionDone();
> > + active_composition_.swap(composition);
>
> Why move this stuff?
Because both CommitFrame and swap need the lock, the code in between
don't need that.
>
> > + }
> > + }
> >
> > if (ret) {
> > ALOGE("Composite failed for display %d", display_);
> > @@ -821,21 +830,6 @@ void DrmDisplayCompositor::ApplyFrame(
> > ClearDisplay();
> > return;
> > }
> > - ++dump_frames_composited_;
> > -
> > - if (active_composition_)
> > - active_composition_->SignalCompositionDone();
> > -
> > - ret = pthread_mutex_lock(&lock_);
> > - if (ret)
> > - ALOGE("Failed to acquire lock for active_composition swap");
> > -
> > - active_composition_.swap(composition);
> > -
> > - if (!ret)
> > - ret = pthread_mutex_unlock(&lock_);
> > - if (ret)
> > - ALOGE("Failed to release lock for active_composition swap");
> > }
> >
> > int DrmDisplayCompositor::ApplyComposition(
> > diff --git a/drmdisplaycompositor.h b/drmdisplaycompositor.h
> > index 0f8daad..b35ef70 100644
> > --- a/drmdisplaycompositor.h
> > +++ b/drmdisplaycompositor.h
> > @@ -127,7 +127,7 @@ class DrmDisplayCompositor {
> >
> > void ClearDisplay();
> > void ApplyFrame(std::unique_ptr<DrmDisplayComposition> composition,
> > - int status);
> > + int status, bool writeback = false);
> >
> > std::tuple<int, uint32_t> CreateModeBlob(const DrmMode &mode);
> >
> > --
> > 2.7.4
> >
>
> --
> Sean Paul, Software Engineer, Google / Chromium OS
--
Cheers,
Alex G
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2018-04-18 10:44 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-11 15:22 [PATCH hwc v2 00/18] Add scene flattening support Alexandru Gheorghe
2018-04-11 15:22 ` [PATCH hwc v2 01/18] drm_hwcomposer: vsyncworker: Fix uninitialized enabled_ field Alexandru Gheorghe
2018-04-16 10:30 ` Robert Foss
2018-04-16 12:18 ` Alexandru-Cosmin Gheorghe
2018-04-17 13:45 ` Sean Paul
2018-04-17 14:09 ` Alexandru-Cosmin Gheorghe
2018-04-11 15:22 ` [PATCH hwc v2 02/18] drm_hwcomposer: vsyncworker: Fix deadlock on exit path Alexandru Gheorghe
2018-04-16 10:31 ` Robert Foss
2018-04-16 19:25 ` Sean Paul
2018-04-17 13:32 ` Alexandru-Cosmin Gheorghe
2018-04-11 15:22 ` [PATCH hwc v2 03/18] drm_hwcomposer: drmeventlistener: Set nl_pid to 0 Alexandru Gheorghe
2018-04-16 10:32 ` Robert Foss
2018-04-11 15:22 ` [PATCH hwc v2 04/18] drm_hwcomposer: Add resource manager class Alexandru Gheorghe
2018-04-17 15:33 ` Sean Paul
2018-04-17 16:08 ` Robert Foss
2018-04-18 10:12 ` Alexandru-Cosmin Gheorghe
2018-04-18 10:14 ` Robert Foss
2018-04-11 15:22 ` [PATCH hwc v2 05/18] drm_hwcomposer: Enable resource manager support Alexandru Gheorghe
2018-04-16 19:54 ` Sean Paul
2018-04-17 13:43 ` Alexandru-Cosmin Gheorghe
2018-04-17 14:22 ` Sean Paul
2018-04-17 14:26 ` Sean Paul
2018-04-11 15:22 ` [PATCH hwc v2 06/18] drm_hwcomposer: Add writeback connector support Alexandru Gheorghe
2018-04-16 19:59 ` Sean Paul
2018-04-17 13:46 ` Alexandru-Cosmin Gheorghe
2018-04-11 15:22 ` [PATCH hwc v2 07/18] drm_hwcomposer: Add display field to Drmencoder Alexandru Gheorghe
2018-04-16 20:02 ` Sean Paul
2018-04-17 13:49 ` Alexandru-Cosmin Gheorghe
2018-04-11 15:22 ` [PATCH hwc v2 08/18] drm_hwcomposer: Parse and store possible_clones information Alexandru Gheorghe
2018-04-16 20:19 ` Sean Paul
2018-04-17 14:03 ` Alexandru-Cosmin Gheorghe
2018-04-11 15:22 ` [PATCH hwc v2 09/18] drm_hwcomposer: Handle writeback connectors Alexandru Gheorghe
2018-04-17 15:45 ` Sean Paul
2018-04-11 15:22 ` [PATCH hwc v2 10/18] drm_hwcomposer: hwcutils: Add function for cloning a DrmHwcLayer Alexandru Gheorghe
2018-04-17 16:14 ` Sean Paul
2018-04-18 10:22 ` Alexandru-Cosmin Gheorghe
2018-04-11 15:22 ` [PATCH hwc v2 11/18] drm_hwcomposer: Add utility functions to copy displaycomposition internals Alexandru Gheorghe
2018-04-17 16:34 ` Sean Paul
2018-04-11 15:22 ` [PATCH hwc v2 12/18] drm_hwcomposer: Add utility function to create an initialized composition Alexandru Gheorghe
2018-04-17 16:37 ` Sean Paul
2018-04-18 10:29 ` Alexandru-Cosmin Gheorghe
2018-04-11 15:22 ` [PATCH hwc v2 13/18] drm_hwcomposer: Pass buffer sizes to Prepareframebuffer Alexandru Gheorghe
2018-04-17 16:51 ` Sean Paul
2018-04-11 15:22 ` [PATCH hwc v2 14/18] drm_hwcomposer: Fix race in ApplyFrame Alexandru Gheorghe
2018-04-17 17:02 ` Sean Paul
2018-04-18 10:43 ` Alexandru-Cosmin Gheorghe [this message]
2018-04-11 15:22 ` [PATCH hwc v2 15/18] drm_hwcomposer: Add worker to trigger scene flattenning Alexandru Gheorghe
2018-04-17 17:07 ` Sean Paul
2018-04-11 15:22 ` [PATCH hwc v2 16/18] drm_hwcomposer: Find writeback connector for scene flattening Alexandru Gheorghe
2018-04-17 17:15 ` Sean Paul
2018-04-11 15:22 ` [PATCH hwc v2 17/18] drm_hwcomposer: Flatten scene synchronously Alexandru Gheorghe
2018-04-17 17:47 ` Sean Paul
2018-04-18 11:14 ` Alexandru-Cosmin Gheorghe
2018-04-18 14:49 ` Sean Paul
2018-04-11 15:22 ` [PATCH hwc v2 18/18] drm_hwcomposer: Flatten scene asynchronously Alexandru Gheorghe
2018-04-12 23:18 ` [PATCH hwc v2 00/18] Add scene flattening support John Stultz
2018-04-13 9:52 ` Alexandru-Cosmin Gheorghe
2018-04-13 12:48 ` Alexandru-Cosmin Gheorghe
2018-04-18 17:21 ` John Stultz
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=20180418104353.GD10633@e114479-lin.cambridge.arm.com \
--to=alexandru-cosmin.gheorghe@arm.com \
--cc=ayan.halder@arm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=liviu.dudau@arm.com \
--cc=nd@arm.com \
--cc=seanpaul@chromium.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