From: "james qian wang (Arm Technology China)" <james.qian.wang@arm.com>
To: Liviu Dudau <Liviu.Dudau@arm.com>,
"airlied@linux.ie" <airlied@linux.ie>,
Brian Starkey <Brian.Starkey@arm.com>,
"maarten.lankhorst@linux.intel.com"
<maarten.lankhorst@linux.intel.com>,
"maxime.ripard@bootlin.com" <maxime.ripard@bootlin.com>,
"sean@poorly.run" <sean@poorly.run>
Cc: "Jonathan Chai (Arm Technology China)" <Jonathan.Chai@arm.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"Julien Yin (Arm Technology China)" <Julien.Yin@arm.com>,
"james qian wang (Arm Technology China)"
<james.qian.wang@arm.com>, nd <nd@arm.com>
Subject: [PATCH] drm: Fix writeback_job leak when state is check only or check failed
Date: Thu, 21 Feb 2019 11:14:02 +0000 [thread overview]
Message-ID: <20190221111304.846-1-james.qian.wang@arm.com> (raw)
The writeback job will not be added to writeback queue if the state is
check only or check failed, to avoid leak, need to cleanup writeback job
in connector_destroy_state if the job existed.
Signed-off-by: James Qian Wang (Arm Technology China) <james.qian.wang@arm.com>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 4 ++++
drivers/gpu/drm/drm_writeback.c | 21 ++++++++++++++++++---
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index 4985384e51f6..6a8e414233de 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -28,6 +28,7 @@
#include <drm/drm_crtc.h>
#include <drm/drm_plane.h>
#include <drm/drm_connector.h>
+#include <drm/drm_writeback.h>
#include <drm/drm_atomic.h>
#include <drm/drm_device.h>
@@ -407,6 +408,9 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_duplicate_state);
void
__drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state)
{
+ if (state->writeback_job)
+ drm_writeback_cleanup_job(state->writeback_job);
+
if (state->crtc)
drm_connector_put(state->connector);
diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c
index c20e6fe00cb3..486121150eaa 100644
--- a/drivers/gpu/drm/drm_writeback.c
+++ b/drivers/gpu/drm/drm_writeback.c
@@ -268,6 +268,22 @@ void drm_writeback_queue_job(struct drm_writeback_connector *wb_connector,
}
EXPORT_SYMBOL(drm_writeback_queue_job);
+/**
+ * drm_writeback_cleanup_job - cleanup a writeback job
+ * @job: The job to cleanup
+ */
+void drm_writeback_cleanup_job(struct drm_writeback_job *job)
+{
+ if (job->fb)
+ drm_framebuffer_put(job->fb);
+
+ if (job->out_fence)
+ dma_fence_put(job->out_fence);
+
+ kfree(job);
+}
+EXPORT_SYMBOL(drm_writeback_cleanup_job);
+
/*
* @cleanup_work: deferred cleanup of a writeback job
*
@@ -280,11 +296,9 @@ static void cleanup_work(struct work_struct *work)
struct drm_writeback_job *job = container_of(work,
struct drm_writeback_job,
cleanup_work);
- drm_framebuffer_put(job->fb);
- kfree(job);
+ drm_writeback_cleanup_job(job);
}
-
/**
* drm_writeback_signal_completion - Signal the completion of a writeback job
* @wb_connector: The writeback connector whose job is complete
@@ -319,6 +333,7 @@ drm_writeback_signal_completion(struct drm_writeback_connector *wb_connector,
dma_fence_set_error(job->out_fence, status);
dma_fence_signal(job->out_fence);
dma_fence_put(job->out_fence);
+ job->out_fence = NULL;
}
}
spin_unlock_irqrestore(&wb_connector->job_lock, flags);
--
2.17.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2019-02-21 11:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 11:14 james qian wang (Arm Technology China) [this message]
2019-02-21 13:56 ` [PATCH] drm: Fix writeback_job leak when state is check only or check failed Maarten Lankhorst
2019-02-22 7:39 ` james qian wang (Arm Technology China)
2019-02-22 16:06 ` Brian Starkey
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=20190221111304.846-1-james.qian.wang@arm.com \
--to=james.qian.wang@arm.com \
--cc=Brian.Starkey@arm.com \
--cc=Jonathan.Chai@arm.com \
--cc=Julien.Yin@arm.com \
--cc=Liviu.Dudau@arm.com \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=maxime.ripard@bootlin.com \
--cc=nd@arm.com \
--cc=sean@poorly.run \
/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