From 504fdd06db63a771c063e9dfc2afd98fea85caf9 Mon Sep 17 00:00:00 2001 From: Ingrid Gallardo Date: Fri, 21 Oct 2022 19:44:00 -0700 Subject: [PATCH 1/3] 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 d824a443..8ca69353 100644 --- a/msm/sde/sde_crtc.c +++ b/msm/sde/sde_crtc.c @@ -3724,7 +3724,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) { @@ -3740,6 +3739,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; @@ -3750,9 +3751,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; } From e6499cbbd023eed2e34efb810fda4aa459196aad Mon Sep 17 00:00:00 2001 From: Ingrid Gallardo Date: Fri, 21 Oct 2022 14:03:30 -0700 Subject: [PATCH 2/3] disp: msm: sde: add events to input and output hw-fences Add extra display driver debug events for input and output hw-fences. Change-Id: I32be1d25d98c510ebba5d39f8aff2a0c54144ba1 Signed-off-by: Ingrid Gallardo --- msm/sde/sde_encoder_phys_vid.c | 1 - msm/sde/sde_fence.c | 27 +++++++++++++++++++++++++++ msm/sde_dbg.h | 3 +++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/msm/sde/sde_encoder_phys_vid.c b/msm/sde/sde_encoder_phys_vid.c index 6c799f21..ba4c46ae 100644 --- a/msm/sde/sde_encoder_phys_vid.c +++ b/msm/sde/sde_encoder_phys_vid.c @@ -963,7 +963,6 @@ static void sde_encoder_phys_vid_update_txq(struct sde_encoder_phys *phys_enc) if (!sde_enc) return; - SDE_EVT32(DRMID(phys_enc->parent)); sde_encoder_helper_update_out_fence_txq(sde_enc, true); } diff --git a/msm/sde/sde_fence.c b/msm/sde/sde_fence.c index 4bc74720..d2931a87 100644 --- a/msm/sde/sde_fence.c +++ b/msm/sde/sde_fence.c @@ -301,10 +301,26 @@ int sde_fence_register_hw_fences_wait(struct sde_hw_ctl *hw_ctl, struct dma_fenc dma_fence_get(array->fences[j]); fence_list[fence_list_index++] = array->fences[j]; } + + if (array->num_fences) /* print the first fence from array */ + SDE_EVT32(ctl_id, num_fences, array->num_fences, i, + SDE_EVTLOG_H32(array->fences[0]->context), + SDE_EVTLOG_L32(array->fences[0]->context), + SDE_EVTLOG_H32(array->fences[0]->seqno), + SDE_EVTLOG_L32(array->fences[0]->seqno)); + else + SDE_EVT32(ctl_id, num_fences, array->num_fences, i, + SDE_EVTLOG_ERROR); + /* remove refcount on parent */ dma_fence_put(fences[i]); } else { fence_list[fence_list_index++] = fences[i]; + + SDE_EVT32(ctl_id, num_fences, i, SDE_EVTLOG_H32(fences[i]->context), + SDE_EVTLOG_L32(fences[i]->context), + SDE_EVTLOG_H32(fences[i]->seqno), + SDE_EVTLOG_L32(fences[i]->seqno)); } } @@ -322,8 +338,17 @@ int sde_fence_register_hw_fences_wait(struct sde_hw_ctl *hw_ctl, struct dma_fenc num_hw_fences = 1; } else { + struct dma_fence_array *tmp_array; + hw_fences = fences; num_hw_fences = num_fences; + tmp_array = dma_fence_is_array(fences[0]) ? + container_of(fences[0], struct dma_fence_array, base) : + NULL; + SDE_EVT32(ctl_id, num_hw_fences, SDE_EVTLOG_H32(fences[0]->context), + SDE_EVTLOG_L32(fences[0]->context), SDE_EVTLOG_H32(fences[0]->seqno), + SDE_EVTLOG_L32(fences[0]->seqno), fences[0]->flags, + tmp_array ? tmp_array->num_fences : SDE_EVTLOG_FUNC_CASE2); } /* register for wait */ @@ -481,6 +506,8 @@ int sde_fence_update_hw_fences_txq(struct sde_fence_context *ctx, bool vid_mode, } /* update hw-fence tx queue */ + SDE_EVT32(ctl_id, SDE_EVTLOG_H32(fc->hwfence_index), + SDE_EVTLOG_L32(fc->hwfence_index)); ret = msm_hw_fence_update_txq(data->hw_fence_handle, fc->hwfence_index, 0, 0); if (ret) { SDE_ERROR("fail txq update index:%llu fctx:%llu seqno:%llu client:%d\n", diff --git a/msm/sde_dbg.h b/msm/sde_dbg.h index a4d9591a..4075836c 100644 --- a/msm/sde_dbg.h +++ b/msm/sde_dbg.h @@ -31,6 +31,9 @@ #define SDE_EVTLOG_FATAL 0xbad #define SDE_EVTLOG_ERROR 0xebad +#define SDE_EVTLOG_H32(val) (val >> 32) +#define SDE_EVTLOG_L32(val) (val & 0xffffffff) + /* flags to enable the HW block dumping */ #define SDE_DBG_SDE BIT(0) #define SDE_DBG_RSC BIT(1) From 4bfae64bbea75e38159b45d10f728bf139fcaf17 Mon Sep 17 00:00:00 2001 From: Ingrid Gallardo Date: Wed, 26 Oct 2022 12:13:48 -0700 Subject: [PATCH 3/3] disp: msm: sde: remove unnecessary debug message Move print message from error to debug for a failure that is not fatal but can be expected when a crtc doesn't have a hw ctl, in this case driver will handle the output fence as a sw-fence. Change-Id: I908135dce4336b0c9ec3fa388dc9211c6df97f68 Signed-off-by: Ingrid Gallardo --- msm/sde/sde_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msm/sde/sde_crtc.c b/msm/sde/sde_crtc.c index 8ca69353..30b5a6e5 100644 --- a/msm/sde/sde_crtc.c +++ b/msm/sde/sde_crtc.c @@ -3707,7 +3707,7 @@ static struct sde_hw_ctl *_sde_crtc_get_hw_ctl(struct drm_crtc *drm_crtc) struct sde_crtc *sde_crtc = to_sde_crtc(drm_crtc); if (!sde_crtc || !sde_crtc->mixers[0].hw_ctl) { - DRM_ERROR("invalid crtc params %d\n", !sde_crtc); + SDE_DEBUG("invalid crtc params %d\n", !sde_crtc); return NULL; }