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 <sultan@kerneltoast.com>
Signed-off-by: Diab Neiroukh <lazerl0rd@thezest.dev>
This commit is contained in:
Sultan Alsawaf 2021-01-26 08:03:12 -08:00 committed by spakkkk
parent 2fb480b5de
commit 238880552e
6 changed files with 25 additions and 21 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
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_LINE_COUNT);
info->wr_ptr_line_count = val & 0xffff;

View File

@ -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

View File

@ -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;
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_LINE_COUNT);
info->wr_ptr_line_count = val & 0xffff;

View File

@ -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