Skip to content

Commit 97eb9ea

Browse files
author
Laurent Pinchart
committed
drm: writeback: Cleanup job ownership handling when queuing job
The drm_writeback_queue_job() function takes ownership of the passed job and requires the caller to manually set the connector state writeback_job pointer to NULL. To simplify drivers and avoid errors (such as the missing NULL set in the vc4 driver), pass the connector state pointer to the function instead of the job pointer, and set the writeback_job pointer to NULL internally. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Reviewed-by: Brian Starkey <brian.starkey@arm.com> Acked-by: Eric Anholt <eric@anholt.net> Acked-by: Liviu Dudau <liviu.dudau@arm.com> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
1 parent a63722a commit 97eb9ea

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

‎drivers/gpu/drm/arm/malidp_mw.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,7 @@ void malidp_mw_atomic_commit(struct drm_device *drm,
252252
&mw_state->addrs[0],
253253
mw_state->format);
254254

255-
drm_writeback_queue_job(mw_conn, conn_state->writeback_job);
256-
conn_state->writeback_job = NULL;
255+
drm_writeback_queue_job(mw_conn, conn_state);
257256
hwdev->hw->enable_memwrite(hwdev, mw_state->addrs,
258257
mw_state->pitches, mw_state->n_planes,
259258
fb->width, fb->height, mw_state->format,

‎drivers/gpu/drm/drm_writeback.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,12 @@ EXPORT_SYMBOL(drm_writeback_connector_init);
242242
/**
243243
* drm_writeback_queue_job - Queue a writeback job for later signalling
244244
* @wb_connector: The writeback connector to queue a job on
245-
* @job: The job to queue
245+
* @conn_state: The connector state containing the job to queue
246246
*
247-
* This function adds a job to the job_queue for a writeback connector. It
248-
* should be considered to take ownership of the writeback job, and so any other
249-
* references to the job must be cleared after calling this function.
247+
* This function adds the job contained in @conn_state to the job_queue for a
248+
* writeback connector. It takes ownership of the writeback job and sets the
249+
* @conn_state->writeback_job to NULL, and so no access to the job may be
250+
* performed by the caller after this function returns.
250251
*
251252
* Drivers must ensure that for a given writeback connector, jobs are queued in
252253
* exactly the same order as they will be completed by the hardware (and
@@ -258,10 +259,14 @@ EXPORT_SYMBOL(drm_writeback_connector_init);
258259
* See also: drm_writeback_signal_completion()
259260
*/
260261
void drm_writeback_queue_job(struct drm_writeback_connector *wb_connector,
261-
struct drm_writeback_job *job)
262+
struct drm_connector_state *conn_state)
262263
{
264+
struct drm_writeback_job *job;
263265
unsigned long flags;
264266

267+
job = conn_state->writeback_job;
268+
conn_state->writeback_job = NULL;
269+
265270
spin_lock_irqsave(&wb_connector->job_lock, flags);
266271
list_add_tail(&job->list_entry, &wb_connector->job_queue);
267272
spin_unlock_irqrestore(&wb_connector->job_lock, flags);

‎drivers/gpu/drm/vc4/vc4_txp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static void vc4_txp_connector_atomic_commit(struct drm_connector *conn,
327327

328328
TXP_WRITE(TXP_DST_CTRL, ctrl);
329329

330-
drm_writeback_queue_job(&txp->connector, conn_state->writeback_job);
330+
drm_writeback_queue_job(&txp->connector, conn_state);
331331
}
332332

333333
static const struct drm_connector_helper_funcs vc4_txp_connector_helper_funcs = {

‎include/drm/drm_writeback.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int drm_writeback_connector_init(struct drm_device *dev,
123123
const u32 *formats, int n_formats);
124124

125125
void drm_writeback_queue_job(struct drm_writeback_connector *wb_connector,
126-
struct drm_writeback_job *job);
126+
struct drm_connector_state *conn_state);
127127

128128
void drm_writeback_cleanup_job(struct drm_writeback_job *job);
129129

0 commit comments

Comments
 (0)