Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(kernel-rolling) arch: Add LoongArch CPU Frequency Scaling (cpufreq) support #182

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arch/loongarch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ config ARCH_SUSPEND_POSSIBLE
config ARCH_HIBERNATION_POSSIBLE
def_bool y

source "drivers/cpufreq/Kconfig"
source "kernel/power/Kconfig"
source "drivers/acpi/Kconfig"

Expand Down
4 changes: 4 additions & 0 deletions arch/loongarch/configs/deepin_loongarch_desktop_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ CONFIG_ACPI_TAD=m
CONFIG_ACPI_DOCK=y
CONFIG_ACPI_IPMI=m
CONFIG_ACPI_PCI_SLOT=y
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_LOONGSON3_ACPI_CPUFREQ=y
CONFIG_ACPI_HOTPLUG_MEMORY=y
CONFIG_ACPI_HED=y
CONFIG_ACPI_CUSTOM_METHOD=y
Expand Down
4 changes: 4 additions & 0 deletions arch/loongarch/configs/loongson3_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ CONFIG_ACPI_DOCK=y
CONFIG_ACPI_IPMI=m
CONFIG_ACPI_HOTPLUG_CPU=y
CONFIG_ACPI_PCI_SLOT=y
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_LOONGSON3_ACPI_CPUFREQ=y
CONFIG_ACPI_HOTPLUG_MEMORY=y
CONFIG_VIRTUALIZATION=y
CONFIG_KVM=m
Expand Down
13 changes: 12 additions & 1 deletion arch/loongarch/include/asm/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ static inline void disable_lasx(void);
static inline void save_lasx(struct task_struct *t);
static inline void restore_lasx(struct task_struct *t);

#ifdef CONFIG_LOONGSON3_ACPI_CPUFREQ
DECLARE_PER_CPU(unsigned long, lsx_count);
DECLARE_PER_CPU(unsigned long, lasx_count);
#endif
/*
* Mask the FCSR Cause bits according to the Enable bits, observing
* that Unimplemented is always enabled.
Expand Down Expand Up @@ -210,6 +214,9 @@ static inline void enable_lsx(void)
{
if (cpu_has_lsx)
csr_xchg32(CSR_EUEN_LSXEN, CSR_EUEN_LSXEN, LOONGARCH_CSR_EUEN);
#ifdef CONFIG_LOONGSON3_ACPI_CPUFREQ
per_cpu(lsx_count, raw_smp_processor_id())++;
#endif
}

static inline void disable_lsx(void)
Expand Down Expand Up @@ -256,8 +263,12 @@ static inline void restore_lsx_upper(struct task_struct *t) {}
static inline void enable_lasx(void)
{

if (cpu_has_lasx)
if (cpu_has_lasx) {
csr_xchg32(CSR_EUEN_LASXEN, CSR_EUEN_LASXEN, LOONGARCH_CSR_EUEN);
#ifdef CONFIG_LOONGSON3_ACPI_CPUFREQ
per_cpu(lasx_count, raw_smp_processor_id())++;
#endif
}
}

static inline void disable_lasx(void)
Expand Down
11 changes: 11 additions & 0 deletions drivers/cpufreq/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,17 @@ config LOONGSON2_CPUFREQ
If in doubt, say N.
endif

if LOONGARCH
config LOONGSON3_ACPI_CPUFREQ
bool "Loongson3 ACPI cpufreq driver"
depends on ACPI_PROCESSOR
help
This driver adds a CPUFreq driver which utilizes the ACPI
Processor Performance States.
This driver supports Loongson 3A5000 compatible CPUs.
If in doubt, say N.
endif

if SPARC64
config SPARC_US3_CPUFREQ
tristate "UltraSPARC-III CPU Frequency driver"
Expand Down
1 change: 1 addition & 0 deletions drivers/cpufreq/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ obj-$(CONFIG_POWERNV_CPUFREQ) += powernv-cpufreq.o
# Other platform drivers
obj-$(CONFIG_BMIPS_CPUFREQ) += bmips-cpufreq.o
obj-$(CONFIG_LOONGSON2_CPUFREQ) += loongson2_cpufreq.o
obj-$(CONFIG_LOONGSON3_ACPI_CPUFREQ) += loongson3-acpi-cpufreq.o
obj-$(CONFIG_SH_CPU_FREQ) += sh-cpufreq.o
obj-$(CONFIG_SPARC_US2E_CPUFREQ) += sparc-us2e-cpufreq.o
obj-$(CONFIG_SPARC_US3_CPUFREQ) += sparc-us3-cpufreq.o
Loading