static void enable_callback(struct cpuquiet_attribute *attr) { int disabled = -1; mutex_lock(tegra3_cpu_lock); if (!enable && cpq_state != TEGRA_CPQ_DISABLED) { disabled = 1; cpq_state = TEGRA_CPQ_DISABLED; } else if (enable && cpq_state == TEGRA_CPQ_DISABLED) { disabled = 0; cpq_state = TEGRA_CPQ_IDLE; tegra_cpu_set_speed_cap(NULL); } mutex_unlock(tegra3_cpu_lock); if (disabled == -1) return; pr_info(CPUQUIET_TAG "enable=%d\n", enable); if (disabled == 1) { cancel_delayed_work_sync(&cpuquiet_work); pr_info(CPUQUIET_TAG "enable_callback: clusterswitch disabled\n"); cpuquiet_device_busy(); } else if (!disabled) { pr_info(CPUQUIET_TAG "enable_callback: clusterswitch enabled\n"); cpuquiet_device_free(); } }
static void tegra_cpuquiet_work_func(struct work_struct *work) { int device_busy = -1; mutex_lock(tegra3_cpu_lock); switch(cpq_state) { case TEGRA_CPQ_DISABLED: case TEGRA_CPQ_IDLE: break; case TEGRA_CPQ_SWITCH_TO_G: if (is_lp_cluster()) { if(!clk_set_parent(cpu_clk, cpu_g_clk)) { /*catch-up with governor target speed */ tegra_cpu_set_speed_cap(NULL); /* process pending core requests*/ device_busy = 0; } } break; case TEGRA_CPQ_SWITCH_TO_LP: if (!is_lp_cluster() && !no_lp && !pm_qos_request(PM_QOS_MIN_ONLINE_CPUS) && num_online_cpus() == 1) { if (!clk_set_parent(cpu_clk, cpu_lp_clk)) { /*catch-up with governor target speed*/ tegra_cpu_set_speed_cap(NULL); device_busy = 1; } } break; default: pr_err("%s: invalid tegra hotplug state %d\n", __func__, cpq_state); } mutex_unlock(tegra3_cpu_lock); if (device_busy == 1) { cpuquiet_device_busy(); } else if (!device_busy) { apply_core_config(); cpuquiet_device_free(); } }
static void set_manual_hotplug(unsigned int mode) { if (manual_hotplug == mode) return; manual_hotplug = mode; pr_info(CPUQUIET_TAG "manual_hotplug=%d\n", manual_hotplug); // stop governor if (manual_hotplug) { cancel_delayed_work_sync(&cpuquiet_work); cpuquiet_device_busy(); schedule_work(&cpu_core_state_work); } else { cpuquiet_device_free(); } }
static void enable_callback(struct cpuquiet_attribute *attr) { mutex_lock(tegra3_cpu_lock); if (!enable && cpq_state != TEGRA_CPQ_DISABLED) { cpq_state = TEGRA_CPQ_DISABLED; mutex_unlock(tegra3_cpu_lock); cancel_delayed_work_sync(&cpuquiet_work); pr_info("Tegra cpuquiet clusterswitch disabled\n"); cpuquiet_device_busy(); mutex_lock(tegra3_cpu_lock); } else if (enable && cpq_state == TEGRA_CPQ_DISABLED) { cpq_state = TEGRA_CPQ_IDLE; pr_info("Tegra cpuquiet clusterswitch enabled\n"); tegra_cpu_set_speed_cap(NULL); cpuquiet_device_free(); } mutex_unlock(tegra3_cpu_lock); }
static void tegra_cpuquiet_work_func(struct work_struct *work) { int device_busy = -1; cputime64_t on_time = 0; #if CPUQUIET_DEBUG_VERBOSE pr_info(CPUQUIET_TAG "%s\n", __func__); #endif if (!mutex_trylock (&hotplug_lock)){ #if CPUQUIET_DEBUG_VERBOSE pr_info(CPUQUIET_TAG "%s failed to get hotplug_lock\n", __func__); #endif return; } mutex_lock(tegra3_cpu_lock); switch(cpq_state) { case TEGRA_CPQ_DISABLED: case TEGRA_CPQ_IDLE: break; case TEGRA_CPQ_SWITCH_TO_G: if (is_lp_cluster()) { if (!switch_clk_to_gmode()) { on_time = ktime_to_ms(ktime_get()) - lp_on_time; show_status("LP -> off", on_time, -1); /*catch-up with governor target speed */ tegra_cpu_set_speed_cap(NULL); device_busy = 0; } else pr_err(CPUQUIET_TAG "tegra_cpuquiet_work_func - switch_clk_to_gmode failed\n"); } #if CPUQUIET_DEBUG_VERBOSE else pr_info(CPUQUIET_TAG "skipping queued TEGRA_CPQ_SWITCH_TO_G - cond failed\n"); #endif break; case TEGRA_CPQ_SWITCH_TO_LP: if (lp_possible()) { if (!switch_clk_to_lpmode()) { show_status("LP -> on", 0, -1); /*catch-up with governor target speed*/ tegra_cpu_set_speed_cap(NULL); device_busy = 1; lp_on_time = ktime_to_ms(ktime_get()); } #if CPUQUIET_DEBUG_VERBOSE else pr_info(CPUQUIET_TAG "skipping queued TEGRA_CPQ_SWITCH_TO_LP - switch_clk_to_lpmode failed\n"); #endif } #if CPUQUIET_DEBUG_VERBOSE else pr_info(CPUQUIET_TAG "skipping queued TEGRA_CPQ_SWITCH_TO_LP - cond failed\n"); #endif break; default: pr_err(CPUQUIET_TAG "%s: invalid tegra hotplug state %d\n", __func__, cpq_state); } mutex_unlock(tegra3_cpu_lock); mutex_unlock(&hotplug_lock); if (!manual_hotplug){ if (device_busy == 1) { cpuquiet_device_busy(); } else if (!device_busy) { cpuquiet_device_free(); } } }