SmartAudio/lichee/linux-4.9/drivers/cpufreq/autohotplug.h

129 lines
4.1 KiB
C
Executable File

/*
* drivers/cpufreq/autohotplug.h
*
* Copyright (C) 2016-2020 Allwinnertech.
* East Yang <yangdong@allwinnertech.com>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __AUTOHOTPLUG__
#define __AUTOHOTPLUG__
#define INVALID_LOAD 0xffffffff
#define INVALID_CPU 0xffffffff
#define STABLE_DOWN 0
#define STABLE_UP 1
#define STABLE_BOOST 2
#define STABLE_LAST_BIG 3
#if defined(CONFIG_SCHED_HMP)
#define AUTOHOTPLUG_SUNXI_SYSFS_MAX (7)
#elif defined(CONFIG_SCHED_SMP_DCMP)
#define AUTOHOTPLUG_SUNXI_SYSFS_MAX (2)
#else
#define AUTOHOTPLUG_SUNXI_SYSFS_MAX (0)
#endif
#ifdef CONFIG_CPU_AUTOHOTPLUG_STATS
#define AUTOHOTPLUG_STATS_SYSFS_MAX (3 * (CONFIG_NR_CPUS))
#else
#define AUTOHOTPLUG_STATS_SYSFS_MAX (0)
#endif
#define HOTPLUG_DATA_SYSFS_MAX (9 + AUTOHOTPLUG_SUNXI_SYSFS_MAX + \
AUTOHOTPLUG_STATS_SYSFS_MAX)
struct autohotplug_loadinfo {
unsigned int cpu_load[CONFIG_NR_CPUS];
unsigned int cpu_load_relative[CONFIG_NR_CPUS];
unsigned int max_load;
unsigned int min_load;
unsigned int max_cpu;
unsigned int min_cpu;
unsigned int big_min_load;
};
struct autohotplug_governor_loadinfo {
struct timer_list cpu_timer;
struct autohotplug_loadinfo load;
};
struct autohotplug_cpuinfo {
spinlock_t load_lock; /* protects the next 4 fields */
u64 time_in_idle;
u64 time_in_idle_timestamp;
};
struct autohotplug_global_attr {
struct attribute attr;
ssize_t (*show)(struct kobject *kobj,
struct attribute *attr, char *buf);
ssize_t (*store)(struct kobject *a, struct attribute *b,
const char *c, size_t count);
unsigned int *value;
unsigned int (*to_sysfs)(unsigned int, unsigned int *);
unsigned int (*from_sysfs)(unsigned int, unsigned int *);
};
struct autohotplug_data_struct {
struct attribute_group attr_group;
struct attribute *attributes[HOTPLUG_DATA_SYSFS_MAX + 1];
struct autohotplug_global_attr attr[HOTPLUG_DATA_SYSFS_MAX];
};
struct autohotplug_governor {
void (*init_attr)(void);
int (*get_fast_and_slow_cpus)(struct cpumask *hmp_fast_cpu_mask,
struct cpumask *hmp_slow_cpu_mask);
int (*try_up)(struct autohotplug_loadinfo *load);
int (*try_down)(struct autohotplug_loadinfo *load);
void (*try_freq_limit)(void);
};
extern unsigned int is_cpu_big(int cpu);
extern unsigned int is_cpu_little(int cpu);
extern int do_cpu_down(unsigned int cpu);
extern int try_up_little(void);
extern int try_up_big(void);
extern void autohotplug_attr_add(const char *name,
unsigned int *value, umode_t mode,
unsigned int (*to_sysfs)(unsigned int, unsigned int *),
unsigned int (*from_sysfs)(unsigned int, unsigned int*));
extern int get_cpus_under(struct autohotplug_loadinfo *load,
unsigned char level, unsigned int *first);
extern int get_bigs_above(struct autohotplug_loadinfo *load,
unsigned char level, unsigned int *first);
extern int get_littles_under(struct autohotplug_loadinfo *load,
unsigned char level, unsigned int *first);
extern int get_bigs_under(struct autohotplug_loadinfo *load,
unsigned char level, unsigned int *first);
extern int get_cpus_stable_under(struct autohotplug_loadinfo *load,
unsigned char level, unsigned int *first, int is_up);
extern int get_cpus_online(struct autohotplug_loadinfo *load,
int *little, int *big);
extern struct autohotplug_governor autohotplug_smart;
extern unsigned int load_try_down;
extern unsigned int load_try_up;
extern unsigned long cpu_up_lasttime;
extern unsigned int load_up_stable_us;
extern unsigned int load_down_stable_us;
#ifdef CONFIG_SCHED_HMP
extern void __init arch_get_fast_and_slow_cpus(struct cpumask *fast,
struct cpumask *slow);
#endif
#endif /* #ifndef __AUTOHOTPLUG__ */