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

drm/vc4: kms: Add missing drm_crtc_commit_put

Commit 9ec03d7f1ed3 ("drm/vc4: kms: Wait on previous FIFO users before a
commit") introduced a global state for the HVS, with each FIFO storing
the current CRTC commit so that we can properly synchronize commits.

However, the refcounting was off and we thus ended up leaking the
drm_crtc_commit structure every commit. Add a drm_crtc_commit_put to
prevent the leakage.

Fixes: 9ec03d7f1ed3 ("drm/vc4: kms: Wait on previous FIFO users before a commit")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Tested-by: Jian-Hong Pan <jhp@endlessos.org>
Link: https://lore.kernel.org/r/20211117094527.146275-4-maxime@cerno.tech

+8 -1
+8 -1
drivers/gpu/drm/vc4/vc4_kms.c
··· 361 361 struct vc4_crtc_state *vc4_crtc_state = 362 362 to_vc4_crtc_state(old_crtc_state); 363 363 unsigned int channel = vc4_crtc_state->assigned_channel; 364 + struct drm_crtc_commit *commit; 364 365 int ret; 365 366 366 367 if (channel == VC4_HVS_CHANNEL_DISABLED) ··· 370 369 if (!old_hvs_state->fifo_state[channel].in_use) 371 370 continue; 372 371 373 - ret = drm_crtc_commit_wait(old_hvs_state->fifo_state[channel].pending_commit); 372 + commit = old_hvs_state->fifo_state[channel].pending_commit; 373 + if (!commit) 374 + continue; 375 + 376 + ret = drm_crtc_commit_wait(commit); 374 377 if (ret) 375 378 drm_err(dev, "Timed out waiting for commit\n"); 379 + 380 + drm_crtc_commit_put(commit); 376 381 } 377 382 378 383 if (vc4->hvs->hvs5)