Skip to content

Commit

Permalink
common: Fix to handle min freq changes when CPU cores hotplugged.
Browse files Browse the repository at this point in the history
        Finds which CPU cores is online and does following below
            1.Gets scaling governor
            2.Sets scaling min freq

Change-Id: I209a6228294c945e943ff285ac8f38b7f97337d6
  • Loading branch information
Nikhil Kumar Kansal authored and Gerrit - the friendly Code Review server committed Sep 22, 2015
1 parent 377557a commit 34fe98f
Showing 1 changed file with 42 additions and 17 deletions.
59 changes: 42 additions & 17 deletions power/power-8916.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
#define MIN_FREQ_CPU0_DISP_OFF 400000
#define MIN_FREQ_CPU0_DISP_ON 960000

char scaling_min_freq[4][80] ={
"sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq",
"sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq",
"sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq",
"sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq"
};

static int saved_dcvs_cpu0_slack_max = -1;
static int saved_dcvs_cpu0_slack_min = -1;
static int saved_mpdecision_slack_max = -1;
Expand Down Expand Up @@ -101,6 +108,8 @@ int power_hint_override(struct power_module *module, power_hint_t hint,
return HINT_HANDLED;
case POWER_HINT_VIDEO_DECODE: /*Do nothing for encode case */
return HINT_HANDLED;
default:
return HINT_HANDLED;
}
return HINT_NONE;
}
Expand All @@ -113,11 +122,15 @@ int set_interactive_override(struct power_module *module, int on)
int rc;

ALOGI("Got set_interactive hint");

if (get_scaling_governor(governor, sizeof(governor)) == -1) {
ALOGE("Can't obtain scaling governor.");

return HINT_HANDLED;
if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU0) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU1) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU2) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU3) == -1) {
ALOGE("Can't obtain scaling governor.");
return HINT_HANDLED;
}
}
}
}

if (!on) {
Expand Down Expand Up @@ -148,11 +161,17 @@ int set_interactive_override(struct power_module *module, int on)
/* Set CPU0 MIN FREQ to 400Mhz avoid extra peak power
impact in volume key press */
snprintf(tmp_str, NODE_MAX, "%d", MIN_FREQ_CPU0_DISP_OFF);
if (sysfs_write(SCALING_MIN_FREQ, tmp_str) != 0) {
if(!slack_node_rw_failed) {
ALOGE("Failed to write to %s",SCALING_MIN_FREQ );
}
rc = 1;
if (sysfs_write(scaling_min_freq[0], tmp_str) != 0) {
if (sysfs_write(scaling_min_freq[1], tmp_str) != 0) {
if (sysfs_write(scaling_min_freq[2], tmp_str) != 0) {
if (sysfs_write(scaling_min_freq[3], tmp_str) != 0) {
if(!slack_node_rw_failed) {
ALOGE("Failed to write to %s",SCALING_MIN_FREQ );
}
rc = 1;
}
}
}
}

if (!display_hint_sent) {
Expand Down Expand Up @@ -184,13 +203,19 @@ int set_interactive_override(struct power_module *module, int on)
(strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) {

/* Recovering MIN_FREQ in display ON case */
snprintf(tmp_str, NODE_MAX, "%d", MIN_FREQ_CPU0_DISP_ON);
if (sysfs_write(SCALING_MIN_FREQ, tmp_str) != 0) {
if(!slack_node_rw_failed) {
ALOGE("Failed to write to %s",SCALING_MIN_FREQ );
}
rc = 1;
}
snprintf(tmp_str, NODE_MAX, "%d", MIN_FREQ_CPU0_DISP_ON);
if (sysfs_write(scaling_min_freq[0], tmp_str) != 0) {
if (sysfs_write(scaling_min_freq[1], tmp_str) != 0) {
if (sysfs_write(scaling_min_freq[2], tmp_str) != 0) {
if (sysfs_write(scaling_min_freq[3], tmp_str) != 0) {
if(!slack_node_rw_failed) {
ALOGE("Failed to write to %s",SCALING_MIN_FREQ );
}
rc = 1;
}
}
}
}
undo_hint_action(DISPLAY_STATE_HINT_ID);
display_hint_sent = 0;
}
Expand Down

0 comments on commit 34fe98f

Please sign in to comment.