From 238880552e98968127828cbd784e2d0b667f7481 Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Tue, 26 Jan 2021 08:03:12 -0800 Subject: [PATCH] drm/msm/sde: Skip unneeded register reads when getting write line count More often than not, get_vsync_info() is used to only get the write line count, while the other values it returns are left unused. This is not optimal since it is done on every display commit. We can eliminate the superfluous register reads by adding a parameter specifying if only the write line count is requested. Signed-off-by: Sultan Alsawaf Signed-off-by: Diab Neiroukh --- techpack/display/msm/sde/sde_encoder.c | 2 +- techpack/display/msm/sde/sde_encoder_phys_cmd.c | 12 ++++++------ techpack/display/msm/sde/sde_hw_intf.c | 14 ++++++++------ techpack/display/msm/sde/sde_hw_intf.h | 2 +- techpack/display/msm/sde/sde_hw_pingpong.c | 14 ++++++++------ techpack/display/msm/sde/sde_hw_pingpong.h | 2 +- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/techpack/display/msm/sde/sde_encoder.c b/techpack/display/msm/sde/sde_encoder.c index 5e2366c46c8f..9e47bdd9b57b 100644 --- a/techpack/display/msm/sde/sde_encoder.c +++ b/techpack/display/msm/sde/sde_encoder.c @@ -5109,7 +5109,7 @@ void sde_encoder_helper_get_pp_line_count(struct drm_encoder *drm_enc, if (phys && phys->hw_intf && phys->hw_pp && phys->hw_intf->ops.get_vsync_info) { ret = phys->hw_intf->ops.get_vsync_info( - phys->hw_intf, &info[i]); + phys->hw_intf, &info[i], true); if (!ret) { info[i].pp_idx = phys->hw_pp->idx - PINGPONG_0; info[i].intf_idx = phys->hw_intf->idx - INTF_0; diff --git a/techpack/display/msm/sde/sde_encoder_phys_cmd.c b/techpack/display/msm/sde/sde_encoder_phys_cmd.c index 8c51c5a82bca..eb0b3b578434 100644 --- a/techpack/display/msm/sde/sde_encoder_phys_cmd.c +++ b/techpack/display/msm/sde/sde_encoder_phys_cmd.c @@ -612,9 +612,9 @@ static int _sde_encoder_phys_cmd_poll_write_pointer_started( } if (phys_enc->has_intf_te) - ret = hw_intf->ops.get_vsync_info(hw_intf, &info); + ret = hw_intf->ops.get_vsync_info(hw_intf, &info, false); else - ret = hw_pp->ops.get_vsync_info(hw_pp, &info); + ret = hw_pp->ops.get_vsync_info(hw_pp, &info, false); if (ret) return ret; @@ -663,13 +663,13 @@ static bool _sde_encoder_phys_cmd_is_ongoing_pptx( if (!hw_intf || !hw_intf->ops.get_vsync_info) return false; - hw_intf->ops.get_vsync_info(hw_intf, &info); + hw_intf->ops.get_vsync_info(hw_intf, &info, true); } else { hw_pp = phys_enc->hw_pp; if (!hw_pp || !hw_pp->ops.get_vsync_info) return false; - hw_pp->ops.get_vsync_info(hw_pp, &info); + hw_pp->ops.get_vsync_info(hw_pp, &info, true); } SDE_EVT32(DRMID(phys_enc->parent), @@ -1279,14 +1279,14 @@ static int sde_encoder_phys_cmd_get_write_line_count( if (!hw_intf->ops.get_vsync_info) return -EINVAL; - if (hw_intf->ops.get_vsync_info(hw_intf, &info)) + if (hw_intf->ops.get_vsync_info(hw_intf, &info, true)) return -EINVAL; } else { hw_pp = phys_enc->hw_pp; if (!hw_pp->ops.get_vsync_info) return -EINVAL; - if (hw_pp->ops.get_vsync_info(hw_pp, &info)) + if (hw_pp->ops.get_vsync_info(hw_pp, &info, true)) return -EINVAL; } diff --git a/techpack/display/msm/sde/sde_hw_intf.c b/techpack/display/msm/sde/sde_hw_intf.c index f6ac49701657..08b51b2dd9ae 100644 --- a/techpack/display/msm/sde/sde_hw_intf.c +++ b/techpack/display/msm/sde/sde_hw_intf.c @@ -610,7 +610,7 @@ static int sde_hw_intf_connect_external_te(struct sde_hw_intf *intf, } static int sde_hw_intf_get_vsync_info(struct sde_hw_intf *intf, - struct sde_hw_pp_vsync_info *info) + struct sde_hw_pp_vsync_info *info, bool wr_ptr_only) { struct sde_hw_blk_reg_map *c = &intf->hw; u32 val; @@ -620,12 +620,14 @@ static int sde_hw_intf_get_vsync_info(struct sde_hw_intf *intf, c = &intf->hw; - val = SDE_REG_READ(c, INTF_TEAR_VSYNC_INIT_VAL); - info->rd_ptr_init_val = val & 0xffff; + if (!wr_ptr_only) { + val = SDE_REG_READ(c, INTF_TEAR_VSYNC_INIT_VAL); + info->rd_ptr_init_val = val & 0xffff; - val = SDE_REG_READ(c, INTF_TEAR_INT_COUNT_VAL); - info->rd_ptr_frame_count = (val & 0xffff0000) >> 16; - info->rd_ptr_line_count = val & 0xffff; + val = SDE_REG_READ(c, INTF_TEAR_INT_COUNT_VAL); + info->rd_ptr_frame_count = (val & 0xffff0000) >> 16; + info->rd_ptr_line_count = val & 0xffff; + } val = SDE_REG_READ(c, INTF_TEAR_LINE_COUNT); info->wr_ptr_line_count = val & 0xffff; diff --git a/techpack/display/msm/sde/sde_hw_intf.h b/techpack/display/msm/sde/sde_hw_intf.h index 403ac6b286b1..0327fb800aa3 100644 --- a/techpack/display/msm/sde/sde_hw_intf.h +++ b/techpack/display/msm/sde/sde_hw_intf.h @@ -140,7 +140,7 @@ struct sde_hw_intf_ops { * line_count */ int (*get_vsync_info)(struct sde_hw_intf *intf, - struct sde_hw_pp_vsync_info *info); + struct sde_hw_pp_vsync_info *info, bool wr_ptr_only); /** * configure and enable the autorefresh config diff --git a/techpack/display/msm/sde/sde_hw_pingpong.c b/techpack/display/msm/sde/sde_hw_pingpong.c index 0d44b21e2c3c..50ec3639eb48 100644 --- a/techpack/display/msm/sde/sde_hw_pingpong.c +++ b/techpack/display/msm/sde/sde_hw_pingpong.c @@ -398,7 +398,7 @@ static int sde_hw_pp_connect_external_te(struct sde_hw_pingpong *pp, } static int sde_hw_pp_get_vsync_info(struct sde_hw_pingpong *pp, - struct sde_hw_pp_vsync_info *info) + struct sde_hw_pp_vsync_info *info, bool wr_ptr_only) { struct sde_hw_blk_reg_map *c; u32 val; @@ -407,12 +407,14 @@ static int sde_hw_pp_get_vsync_info(struct sde_hw_pingpong *pp, return -EINVAL; c = &pp->hw; - val = SDE_REG_READ(c, PP_VSYNC_INIT_VAL); - info->rd_ptr_init_val = val & 0xffff; + if (!wr_ptr_only) { + val = SDE_REG_READ(c, PP_VSYNC_INIT_VAL); + info->rd_ptr_init_val = val & 0xffff; - val = SDE_REG_READ(c, PP_INT_COUNT_VAL); - info->rd_ptr_frame_count = (val & 0xffff0000) >> 16; - info->rd_ptr_line_count = val & 0xffff; + val = SDE_REG_READ(c, PP_INT_COUNT_VAL); + info->rd_ptr_frame_count = (val & 0xffff0000) >> 16; + info->rd_ptr_line_count = val & 0xffff; + } val = SDE_REG_READ(c, PP_LINE_COUNT); info->wr_ptr_line_count = val & 0xffff; diff --git a/techpack/display/msm/sde/sde_hw_pingpong.h b/techpack/display/msm/sde/sde_hw_pingpong.h index 102cfc03afe8..b18e060d509f 100644 --- a/techpack/display/msm/sde/sde_hw_pingpong.h +++ b/techpack/display/msm/sde/sde_hw_pingpong.h @@ -65,7 +65,7 @@ struct sde_hw_pingpong_ops { * line_count */ int (*get_vsync_info)(struct sde_hw_pingpong *pp, - struct sde_hw_pp_vsync_info *info); + struct sde_hw_pp_vsync_info *info, bool wr_ptr_only); /** * configure and enable the autorefresh config