Unverified Commit 1579902a authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!15430 cpufreq: Fix some boost errors related to CPU online and offline

Merge Pull Request from: @ci-robot 
 
PR sync from: Lifeng Zheng <zhenglifeng1@huawei.com>
https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/L3N56HGSSH76Q53LXYN277VKWFFQMS3U/ 
From: Xinghai Cen <cenxinghai@h-partners.com>

cpufreq: Fix some boost errors related to CPU online and offline:

Aboorva Devarajan (1):
  cpufreq: prevent NULL dereference in cpufreq_online()

Lifeng Zheng (4):
  cpufreq: Fix re-boost issue after hotplugging a CPU
  cpufreq: Introduce a more generic way to set default per-policy boost
    flag
  cpufreq: CPPC: Fix wrong max_freq in policy initialization
  cpufreq: ACPI: Remove set_boost in acpi_cpufreq_cpu_init()

 
https://gitee.com/openeuler/kernel/issues/IBQYEH 
 
Link:https://gitee.com/openeuler/kernel/pulls/15430

 

Reviewed-by: default avatarZhang Peng <zhangpeng362@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents f3ab695b 0f9b4296
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -953,11 +953,6 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
	if (perf->states[0].core_frequency * 1000 != freq_table[0].frequency)
		pr_warn(FW_WARN "P-state 0 is not max freq\n");

	if (acpi_cpufreq_driver.set_boost) {
		set_boost(policy, acpi_cpufreq_driver.boost_enabled);
		policy->boost_enabled = acpi_cpufreq_driver.boost_enabled;
	}

	return result;

err_unreg:
+3 −2
Original line number Diff line number Diff line
@@ -638,7 +638,8 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
	 * Section 8.4.7.1.1.5 of ACPI 6.1 spec)
	 */
	policy->min = cppc_perf_to_khz(caps, caps->lowest_nonlinear_perf);
	policy->max = cppc_perf_to_khz(caps, caps->nominal_perf);
	policy->max = cppc_perf_to_khz(caps, policy->boost_enabled ?
						caps->highest_perf : caps->nominal_perf);

	/*
	 * Set cpuinfo.min_freq to Lowest to make the full range of performance
@@ -646,7 +647,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
	 * nonlinear perf
	 */
	policy->cpuinfo.min_freq = cppc_perf_to_khz(caps, caps->lowest_perf);
	policy->cpuinfo.max_freq = cppc_perf_to_khz(caps, caps->nominal_perf);
	policy->cpuinfo.max_freq = policy->max;

	policy->transition_delay_us = cppc_cpufreq_get_transition_delay_us(cpu);
	policy->shared_type = cpu_data->shared_type;
+17 −4
Original line number Diff line number Diff line
@@ -1421,10 +1421,6 @@ static int cpufreq_online(unsigned int cpu)
			goto out_free_policy;
		}

		/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
		if (cpufreq_boost_enabled() && policy_has_boost_freq(policy))
			policy->boost_enabled = true;

		/*
		 * The initialization has succeeded and the policy is online.
		 * If there is a problem with its frequency table, take it
@@ -1487,6 +1483,10 @@ static int cpufreq_online(unsigned int cpu)

		blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
				CPUFREQ_CREATE_POLICY, policy);
	} else {
		ret = freq_qos_update_request(policy->max_freq_req, policy->max);
		if (ret < 0)
			goto out_destroy_policy;
	}

	if (cpufreq_driver->get && has_target()) {
@@ -1581,6 +1581,19 @@ static int cpufreq_online(unsigned int cpu)
	if (new_policy && cpufreq_thermal_control_enabled(cpufreq_driver))
		policy->cdev = of_cpufreq_cooling_register(policy);

	/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
	if (cpufreq_driver->set_boost &&
	    policy->boost_enabled != cpufreq_boost_enabled()) {
		policy->boost_enabled = cpufreq_boost_enabled();
		ret = cpufreq_driver->set_boost(policy, policy->boost_enabled);
		if (ret) {
			/* If the set_boost fails, the online operation is not affected */
			pr_info("%s: CPU%d: Cannot %s BOOST\n", __func__, policy->cpu,
				policy->boost_enabled ? "enable" : "disable");
			policy->boost_enabled = !policy->boost_enabled;
		}
	}

	pr_debug("initialization complete\n");

	return 0;