[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v5 18/18] xen/cpufreq: Adapt SET/GET_CPUFREQ_CPPC xen_sysctl_pm_op for amd-cppc driver
On 27.05.2025 10:48, Penny Zheng wrote: > +int set_amd_cppc_para(struct cpufreq_policy *policy, > + const struct xen_set_cppc_para *set_cppc) > +{ > + unsigned int cpu = policy->cpu; > + struct amd_cppc_drv_data *data = per_cpu(amd_cppc_drv_data, cpu); > + uint8_t max_perf, min_perf, des_perf = 0, epp; > + > + if ( data == NULL ) > + return -ENOENT; > + > + /* Validate all parameters */ > + if ( set_cppc->minimum > UINT8_MAX || set_cppc->maximum > UINT8_MAX || > + set_cppc->desired > UINT8_MAX || set_cppc->energy_perf > UINT8_MAX ) > + return -EINVAL; > + > + /* Only allow values if params bit is set. */ > + if ( (!(set_cppc->set_params & XEN_SYSCTL_CPPC_SET_DESIRED) && > + set_cppc->desired) || > + (!(set_cppc->set_params & XEN_SYSCTL_CPPC_SET_MINIMUM) && > + set_cppc->minimum) || > + (!(set_cppc->set_params & XEN_SYSCTL_CPPC_SET_MAXIMUM) && > + set_cppc->maximum) || > + (!(set_cppc->set_params & XEN_SYSCTL_CPPC_SET_ENERGY_PERF) && > + set_cppc->energy_perf) ) > + return -EINVAL; > + > + /* Activity window not supported in MSR */ > + if ( set_cppc->set_params & XEN_SYSCTL_CPPC_SET_ACT_WINDOW ) > + return -EOPNOTSUPP; > + > + /* Return if there is nothing to do. */ > + if ( set_cppc->set_params == 0 ) > + return 0; > + > + epp = per_cpu(epp_init, cpu); > + /* > + * Apply presets: > + * XEN_SYSCTL_CPPC_SET_DESIRED reflects whether desired perf is set, > which > + * is also the flag to distinguish between passive mode and active mode. > + * When it is set, CPPC in passive mode, only > + * XEN_SYSCTL_CPPC_SET_PRESET_NONE could be chosen. > + * when it is not set, CPPC in active mode, three different profile > + * XEN_SYSCTL_CPPC_SET_PRESET_POWERSAVE/PERFORMANCE/BALANCE are provided, > + */ > + switch ( set_cppc->set_params & XEN_SYSCTL_CPPC_SET_PRESET_MASK ) > + { > + case XEN_SYSCTL_CPPC_SET_PRESET_POWERSAVE: > + if ( set_cppc->set_params & XEN_SYSCTL_CPPC_SET_DESIRED ) > + return -EINVAL; > + policy->policy = CPUFREQ_POLICY_POWERSAVE; > + min_perf = data->caps.lowest_perf; > + /* Lower max frequency to lowest */ > + max_perf = data->caps.lowest_perf; > + epp = CPPC_ENERGY_PERF_MAX_POWERSAVE; > + break; > + > + case XEN_SYSCTL_CPPC_SET_PRESET_PERFORMANCE: > + if ( set_cppc->set_params & XEN_SYSCTL_CPPC_SET_DESIRED ) > + return -EINVAL; > + /* Increase idle frequency to highest */ > + policy->policy = CPUFREQ_POLICY_PERFORMANCE; > + min_perf = data->caps.highest_perf; > + max_perf = data->caps.highest_perf; > + epp = CPPC_ENERGY_PERF_MAX_PERFORMANCE; > + break; > + > + case XEN_SYSCTL_CPPC_SET_PRESET_BALANCE: > + if ( set_cppc->set_params & XEN_SYSCTL_CPPC_SET_DESIRED ) > + return -EINVAL; > + policy->policy = CPUFREQ_POLICY_BALANCE; > + min_perf = data->caps.lowest_perf; > + max_perf = data->caps.highest_perf; > + epp = CPPC_ENERGY_PERF_BALANCE; > + break; > + > + case XEN_SYSCTL_CPPC_SET_PRESET_NONE: > + /* > + * In paasive mode, Xen governor is responsible for perfomance > tuning. > + * we shall set lowest_perf with "lowest_nonlinear_perf" to ensure > + * governoring performance in P-states range. > + */ > + min_perf = data->caps.lowest_nonlinear_perf; > + max_perf = data->caps.highest_perf; > + break; Oh, also - can you really leave policy->policy unaltered here? Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |