From 188cfbc717b259461b1e223888f5ec41bf97f44d Mon Sep 17 00:00:00 2001 From: Ingrid Gallardo Date: Fri, 21 Oct 2022 19:44:00 -0700 Subject: [PATCH] disp: msm: sde: fix to avoid creating hw-fences for empty spec fences Current display driver sets the hw-fences as valid even when the speculative fence is empty. Avoid this issue by doing a positive check and only create hw-fences if all the fences in the speculative fence are valid. Change-Id: Iec9636641ac9146eb651be08615e2478994c2508 Signed-off-by: Ingrid Gallardo --- msm/sde/sde_crtc.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/msm/sde/sde_crtc.c b/msm/sde/sde_crtc.c index 62772ae0e4..4973945f09 100644 --- a/msm/sde/sde_crtc.c +++ b/msm/sde/sde_crtc.c @@ -3725,7 +3725,6 @@ static struct dma_fence *_sde_plane_get_input_hw_fence(struct drm_plane *plane) struct dma_fence *input_hw_fence = NULL; struct dma_fence_array *array = NULL; struct dma_fence *spec_fence = NULL; - bool spec_hw_fence = true; int i; if (!plane || !plane->state) { @@ -3741,6 +3740,8 @@ static struct dma_fence *_sde_plane_get_input_hw_fence(struct drm_plane *plane) fence = (struct dma_fence *)pstate->input_fence; if (test_bit(SPEC_FENCE_FLAG_FENCE_ARRAY, &fence->flags)) { + bool spec_hw_fence = false; + array = container_of(fence, struct dma_fence_array, base); if (IS_ERR_OR_NULL(array)) goto exit; @@ -3751,9 +3752,18 @@ static struct dma_fence *_sde_plane_get_input_hw_fence(struct drm_plane *plane) for (i = 0; i < array->num_fences; i++) { spec_fence = array->fences[i]; - if (IS_ERR_OR_NULL(spec_fence) || - !(test_bit(MSM_HW_FENCE_FLAG_ENABLED_BIT, - &spec_fence->flags))) { + + if (!IS_ERR_OR_NULL(spec_fence) && + test_bit(MSM_HW_FENCE_FLAG_ENABLED_BIT, + &spec_fence->flags)) { + spec_hw_fence = true; + } else { + /* + * all child-fences of the spec fence must be hw-fences for + * this fence to be considered hw-fence. Otherwise just + * fail here to set the hw-fences and driver will use + * sw-fences instead. + */ spec_hw_fence = false; break; }