drm: writeback: Cleanup job ownership handling when queuing job
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Thu, 21 Feb 2019 10:17:32 +0000 (12:17 +0200)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Mon, 18 Mar 2019 15:24:30 +0000 (17:24 +0200)
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>
drivers/gpu/drm/arm/malidp_mw.c
drivers/gpu/drm/drm_writeback.c
drivers/gpu/drm/vc4/vc4_txp.c
include/drm/drm_writeback.h

index 041a64dc7167c7839d5362c20547e2197dd40d2f..87627219ce3bbf1c3983168e635a6284553e4e86 100644 (file)
@@ -252,8 +252,7 @@ void malidp_mw_atomic_commit(struct drm_device *drm,
                                     &mw_state->addrs[0],
                                     mw_state->format);
 
-               drm_writeback_queue_job(mw_conn, conn_state->writeback_job);
-               conn_state->writeback_job = NULL;
+               drm_writeback_queue_job(mw_conn, conn_state);
                hwdev->hw->enable_memwrite(hwdev, mw_state->addrs,
                                           mw_state->pitches, mw_state->n_planes,
                                           fb->width, fb->height, mw_state->format,
index c20e6fe00cb387dba675f10d15ef75a7e39cf7cb..338b993d7c9fb86ec532a18502bca911a0da7679 100644 (file)
@@ -242,11 +242,12 @@ EXPORT_SYMBOL(drm_writeback_connector_init);
 /**
  * drm_writeback_queue_job - Queue a writeback job for later signalling
  * @wb_connector: The writeback connector to queue a job on
- * @job: The job to queue
+ * @conn_state: The connector state containing the job to queue
  *
- * This function adds a job to the job_queue for a writeback connector. It
- * should be considered to take ownership of the writeback job, and so any other
- * references to the job must be cleared after calling this function.
+ * This function adds the job contained in @conn_state to the job_queue for a
+ * writeback connector. It takes ownership of the writeback job and sets the
+ * @conn_state->writeback_job to NULL, and so no access to the job may be
+ * performed by the caller after this function returns.
  *
  * Drivers must ensure that for a given writeback connector, jobs are queued in
  * exactly the same order as they will be completed by the hardware (and
@@ -258,10 +259,14 @@ EXPORT_SYMBOL(drm_writeback_connector_init);
  * See also: drm_writeback_signal_completion()
  */
 void drm_writeback_queue_job(struct drm_writeback_connector *wb_connector,
-                            struct drm_writeback_job *job)
+                            struct drm_connector_state *conn_state)
 {
+       struct drm_writeback_job *job;
        unsigned long flags;
 
+       job = conn_state->writeback_job;
+       conn_state->writeback_job = NULL;
+
        spin_lock_irqsave(&wb_connector->job_lock, flags);
        list_add_tail(&job->list_entry, &wb_connector->job_queue);
        spin_unlock_irqrestore(&wb_connector->job_lock, flags);
index aa279b5b0de78cb4eb7dab5e6ba5dd892b59abaa..5dabd91f2d7e28b27bb82e0d9194a145661dd15a 100644 (file)
@@ -327,7 +327,7 @@ static void vc4_txp_connector_atomic_commit(struct drm_connector *conn,
 
        TXP_WRITE(TXP_DST_CTRL, ctrl);
 
-       drm_writeback_queue_job(&txp->connector, conn_state->writeback_job);
+       drm_writeback_queue_job(&txp->connector, conn_state);
 }
 
 static const struct drm_connector_helper_funcs vc4_txp_connector_helper_funcs = {
index 23df9d46300328452bca14212be467d93ead539a..47662c362743a91ab816e42249eac3c576ce4242 100644 (file)
@@ -123,7 +123,7 @@ int drm_writeback_connector_init(struct drm_device *dev,
                                 const u32 *formats, int n_formats);
 
 void drm_writeback_queue_job(struct drm_writeback_connector *wb_connector,
-                            struct drm_writeback_job *job);
+                            struct drm_connector_state *conn_state);
 
 void drm_writeback_cleanup_job(struct drm_writeback_job *job);