[PATCH 4/7] drm/cirrus: add return 0 to make sure if (bo->pin_count) early_exit

John Hunter zhjwpku at gmail.com
Wed Aug 5 00:22:53 PDT 2015

From: Zhao Junwang <zhjwpku at gmail.com>

when the first modeset calls prepare_fb, bo->pin_count change from
0 to 1, then the second modeset with the same fb, that should set
bo->pin_count to 2, and then when cleanup_fb was called, bo->pin_count
should be 2 to 1.

But in the cirrus_bo_pin, it will set bo->pin_count = 1 at the end
of the function, this results that bo->bin_count will never be larger
than 1 no matter how many times cirrus_bo_pin was called.

So we need to add a condition before bo->pin_count = 1

V2: if (bo->pin_count) early_exit; do_the_real_pinning work

Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Cc: Gerd Hoffmann <kraxel at redhat.com>
Cc: Matthew Garrett <mjg59 at coreos.com>
Cc: Dave Airlie <airlied at redhat.com>
Signed-off-by: Zhao Junwang <zhjwpku at gmail.com>
 drivers/gpu/drm/cirrus/cirrus_ttm.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index dfffd52..756b6d0 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -364,6 +364,8 @@ int cirrus_bo_pin(struct cirrus_bo *bo, u32 pl_flag, u64 *gpu_addr)
 		if (gpu_addr)
 			*gpu_addr = cirrus_bo_gpu_offset(bo);
+		return 0;
 	cirrus_ttm_placement(bo, pl_flag);

More information about the dri-devel mailing list