ANDROID: cpufreq: create dummy cpufreq driver

/proc/uid_time_in_state has no data on cuttlefish because its cpu
frequency tables are empty. Because time in state & concurrent time
accounting are intertwined this causes the
/proc/uid_concurrent_{policy,active}_time files to also not contain
any data.

Add a minimal, fake cpufreq driver that creates a freq table with 2
frequencies per policy, to allow testing time in state functionality.

Test: all 3 proc files show reasonable data on cuttlefish
Test: log shows no errors from bad /proc/uid_time_in_state format
Bug: 139763108
Bug: 140796321
Bug: 141206930
Change-Id: I8c7fe1007a80c21a9bcba9455bf837947cf42963
Signed-off-by: Connor O'Brien <connoro@google.com>
This commit is contained in:
Connor O'Brien 2019-02-19 17:36:53 -08:00 committed by Alistair Delva
parent 0a39c7fe72
commit 18b7a1479e
5 changed files with 67 additions and 0 deletions

View File

@ -61,6 +61,7 @@ CONFIG_CPU_FREQ_TIMES=y
CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
CONFIG_CPUFREQ_DUMMY=m
CONFIG_ARM_SCPI_CPUFREQ=y
CONFIG_ARM_SCMI_CPUFREQ=y
CONFIG_ARM_SCMI_PROTOCOL=y

View File

@ -46,6 +46,7 @@ CONFIG_PM_WAKELOCKS_LIMIT=0
# CONFIG_PM_WAKELOCKS_GC is not set
CONFIG_CPU_FREQ_TIMES=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPUFREQ_DUMMY=m
CONFIG_IA32_EMULATION=y
CONFIG_KPROBES=y
CONFIG_MODULES=y

View File

@ -229,6 +229,15 @@ config CPUFREQ_DT_PLATDEV
If in doubt, say N.
config CPUFREQ_DUMMY
tristate "Dummy CPU frequency driver"
help
This option adds a generic dummy CPUfreq driver, which sets a fake
2-frequency table when initializing each policy and otherwise does
nothing.
If in doubt, say N
if X86
source "drivers/cpufreq/Kconfig.x86"
endif

View File

@ -20,6 +20,8 @@ obj-$(CONFIG_CPU_FREQ_GOV_ATTR_SET) += cpufreq_governor_attr_set.o
obj-$(CONFIG_CPUFREQ_DT) += cpufreq-dt.o
obj-$(CONFIG_CPUFREQ_DT_PLATDEV) += cpufreq-dt-platdev.o
obj-$(CONFIG_CPUFREQ_DUMMY) += dummy-cpufreq.o
##################################################################################
# x86 drivers.
# Link order matters. K8 is preferred to ACPI because of firmware bugs in early

View File

@ -0,0 +1,54 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 Google, Inc.
*/
#include <linux/cpufreq.h>
#include <linux/module.h>
static struct cpufreq_frequency_table freq_table[] = {
{ .frequency = 1 },
{ .frequency = 2 },
{ .frequency = CPUFREQ_TABLE_END },
};
static int dummy_cpufreq_target_index(struct cpufreq_policy *policy,
unsigned int index)
{
return 0;
}
static int dummy_cpufreq_driver_init(struct cpufreq_policy *policy)
{
policy->freq_table = freq_table;
return 0;
}
static int dummy_cpufreq_verify(struct cpufreq_policy *policy)
{
return 0;
}
static struct cpufreq_driver dummy_cpufreq_driver = {
.name = "dummy",
.target_index = dummy_cpufreq_target_index,
.init = dummy_cpufreq_driver_init,
.verify = dummy_cpufreq_verify,
.attr = cpufreq_generic_attr,
};
static int __init dummy_cpufreq_init(void)
{
return cpufreq_register_driver(&dummy_cpufreq_driver);
}
static void __exit dummy_cpufreq_exit(void)
{
cpufreq_unregister_driver(&dummy_cpufreq_driver);
}
module_init(dummy_cpufreq_init);
module_exit(dummy_cpufreq_exit);
MODULE_AUTHOR("Connor O'Brien <connoro@google.com>");
MODULE_DESCRIPTION("dummy cpufreq driver");
MODULE_LICENSE("GPL");