From 44d862fb4dfd1df30c38096ca7fe138519150ed0 Mon Sep 17 00:00:00 2001 From: Samantha Tran Date: Fri, 19 Apr 2019 11:59:12 -0700 Subject: [PATCH] disp: msm: sde: set bounds on debugfs core perf input Previously debugfs nodes for fix_core_ab_vote, fix_core_clk_rate, and fix_core_ib_vote could be set to any value. This change will compare fixed values to userspace values and set it to the maximum of the two to avoid crashes with invalid input. Change-Id: Iae89279eb1effe3daf8cd0aef5acceb55992ab03 Signed-off-by: Samantha Tran --- msm/sde/sde_core_perf.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/msm/sde/sde_core_perf.c b/msm/sde/sde_core_perf.c index a044b8e7..61acee6a 100644 --- a/msm/sde/sde_core_perf.c +++ b/msm/sde/sde_core_perf.c @@ -162,10 +162,14 @@ static void _sde_core_perf_calc_crtc(struct sde_kms *kms, perf->core_clk_rate = 0; } else if (kms->perf.perf_tune.mode == SDE_PERF_MODE_FIXED) { for (i = 0; i < SDE_POWER_HANDLE_DBUS_ID_MAX; i++) { - perf->bw_ctl[i] = kms->perf.fix_core_ab_vote; - perf->max_per_pipe_ib[i] = kms->perf.fix_core_ib_vote; + perf->bw_ctl[i] = max(kms->perf.fix_core_ab_vote, + perf->bw_ctl[i]); + perf->max_per_pipe_ib[i] = max( + kms->perf.fix_core_ib_vote, + perf->max_per_pipe_ib[i]); } - perf->core_clk_rate = kms->perf.fix_core_clk_rate; + perf->core_clk_rate = max(kms->perf.fix_core_clk_rate, + perf->core_clk_rate); } SDE_EVT32(crtc->base.id, perf->core_clk_rate); @@ -632,8 +636,10 @@ static void _sde_core_perf_crtc_update_bus(struct sde_kms *kms, bus_ib_quota = perf.max_per_pipe_ib[bus_id]; if (kms->perf.perf_tune.mode == SDE_PERF_MODE_FIXED) { - bus_ab_quota = kms->perf.fix_core_ab_vote; - bus_ib_quota = kms->perf.fix_core_ib_vote; + bus_ab_quota = max(kms->perf.fix_core_ab_vote, + bus_ab_quota); + bus_ib_quota = max(kms->perf.fix_core_ib_vote, + bus_ib_quota); } client_vote = _get_sde_client_type(curr_client_type, &kms->perf); @@ -775,7 +781,7 @@ static u64 _sde_core_perf_get_core_clk_rate(struct sde_kms *kms) } if (kms->perf.perf_tune.mode == SDE_PERF_MODE_FIXED) - clk_rate = kms->perf.fix_core_clk_rate; + clk_rate = max(kms->perf.fix_core_clk_rate, clk_rate); SDE_DEBUG("clk:%llu\n", clk_rate);