Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+13 -9
+1 -2
drivers/gpu/drm/arm/malidp_mw.c
··· 252 252 &mw_state->addrs[0], 253 253 mw_state->format); 254 254 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); 257 256 hwdev->hw->enable_memwrite(hwdev, mw_state->addrs, 258 257 mw_state->pitches, mw_state->n_planes, 259 258 fb->width, fb->height, mw_state->format,
+10 -5
drivers/gpu/drm/drm_writeback.c
··· 242 242 /** 243 243 * drm_writeback_queue_job - Queue a writeback job for later signalling 244 244 * @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 246 246 * 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. 250 251 * 251 252 * Drivers must ensure that for a given writeback connector, jobs are queued in 252 253 * exactly the same order as they will be completed by the hardware (and ··· 259 258 * See also: drm_writeback_signal_completion() 260 259 */ 261 260 void drm_writeback_queue_job(struct drm_writeback_connector *wb_connector, 262 - struct drm_writeback_job *job) 261 + struct drm_connector_state *conn_state) 263 262 { 263 + struct drm_writeback_job *job; 264 264 unsigned long flags; 265 + 266 + job = conn_state->writeback_job; 267 + conn_state->writeback_job = NULL; 265 268 266 269 spin_lock_irqsave(&wb_connector->job_lock, flags); 267 270 list_add_tail(&job->list_entry, &wb_connector->job_queue);
+1 -1
drivers/gpu/drm/vc4/vc4_txp.c
··· 327 327 328 328 TXP_WRITE(TXP_DST_CTRL, ctrl); 329 329 330 - drm_writeback_queue_job(&txp->connector, conn_state->writeback_job); 330 + drm_writeback_queue_job(&txp->connector, conn_state); 331 331 } 332 332 333 333 static const struct drm_connector_helper_funcs vc4_txp_connector_helper_funcs = {
+1 -1
include/drm/drm_writeback.h
··· 123 123 const u32 *formats, int n_formats); 124 124 125 125 void drm_writeback_queue_job(struct drm_writeback_connector *wb_connector, 126 - struct drm_writeback_job *job); 126 + struct drm_connector_state *conn_state); 127 127 128 128 void drm_writeback_cleanup_job(struct drm_writeback_job *job); 129 129