[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v7 08/13] xen/cpufreq: implement amd-cppc driver for CPPC in passive mode
On 22.08.2025 12:52, Penny Zheng wrote: > @@ -50,10 +141,335 @@ int __init amd_cppc_cmdline_parse(const char *s, const > char *e) > return 0; > } > > +/* > + * If CPPC lowest_freq and nominal_freq registers are exposed then we can > + * use them to convert perf to freq and vice versa. The conversion is > + * extrapolated as an linear function passing by the 2 points: > + * - (Low perf, Low freq) > + * - (Nominal perf, Nominal freq) > + * Parameter freq is always in kHz. > + */ > +static int amd_cppc_khz_to_perf(const struct amd_cppc_drv_data *data, > + unsigned int freq, uint8_t *perf) > +{ > + const struct xen_processor_cppc *cppc_data = data->cppc_data; > + unsigned int mul, div; > + int offset = 0, res; > + > + if ( cppc_data->cpc.lowest_mhz && > + data->caps.nominal_perf > data->caps.lowest_perf && > + cppc_data->cpc.nominal_mhz > cppc_data->cpc.lowest_mhz ) > + { > + mul = data->caps.nominal_perf - data->caps.lowest_perf; > + div = cppc_data->cpc.nominal_mhz - cppc_data->cpc.lowest_mhz; > + > + /* > + * We don't need to convert to kHz for computing offset and can > + * directly use nominal_mhz and lowest_mhz as the division > + * will remove the frequency unit. > + */ > + offset = data->caps.nominal_perf - > + (mul * cppc_data->cpc.nominal_mhz) / div; > + } > + else > + { > + /* Read Processor Max Speed(MHz) as anchor point */ > + mul = data->caps.highest_perf; > + div = this_cpu(pxfreq_mhz); > + if ( !div ) > + return -EOPNOTSUPP; > + } > + > + res = offset + (mul * freq) / (div * 1000); > + if ( res > UINT8_MAX ) > + { > + printk_once(XENLOG_WARNING > + "Perf value exceeds maximum value 255: %d\n", res); > + *perf = UINT8_MAX; > + return 0; > + } > + if ( res <= 0 ) > + { > + printk_once(XENLOG_WARNING > + "Perf value smaller than minimum value 0: %d\n", res); The message text doesn't fit the if() condition anymore. Perhaps simply omit the "0" from the text? Then: Acked-by: Jan Beulich <jbeulich@xxxxxxxx> Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |