Browse Source

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 <[email protected]>
Samantha Tran 6 years ago
parent
commit
44d862fb4d
1 changed files with 12 additions and 6 deletions
  1. 12 6
      msm/sde/sde_core_perf.c

+ 12 - 6
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);