// SPDX-License-Identifier: GPL-2.0-or-later/* * amd-pstate.c - AMD Processor P-state Frequency Driver * * Copyright (C) 2021 Advanced Micro Devices, Inc. All Rights Reserved. * * Author: Huang Rui <ray.huang@amd.com> * * AMD P-State introduces a new CPU performance scaling design for AMD * processors using the ACPI Collaborative Performance and Power Control (CPPC) * feature which works with the AMD SMU firmware providing a finer grained * frequency control range. It is to replace the legacy ACPI P-States control, * allows a flexible, low-latency interface for the Linux kernel to directly * communicate the performance hints to hardware. * * AMD P-State is supported on recent AMD Zen base CPU series include some of * Zen2 and Zen3 processors. _CPC needs to be present in the ACPI tables of AMD * P-State supported system. And there are two types of hardware implementations * for AMD P-State: 1) Full MSR Solution and 2) Shared Memory Solution. * X86_FEATURE_CPPC CPU feature flag is used to distinguish the different types. */#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt#include<linux/kernel.h>#include<linux/module.h>#include<linux/init.h>#include<linux/smp.h>#include<linux/sched.h>#include<linux/cpufreq.h>#include<linux/compiler.h>#include<linux/dmi.h>#include<linux/slab.h>#include<linux/acpi.h>#include<linux/io.h>#include<linux/delay.h>#include<linux/uaccess.h>#include<linux/static_call.h>#include<linux/amd-pstate.h>#include<acpi/processor.h>#include<acpi/cppc_acpi.h>#include<asm/msr.h>#include<asm/processor.h>#include<asm/cpufeature.h>#include<asm/cpu_device_id.h>#include"amd-pstate-trace.h"#define AMD_PSTATE_TRANSITION_LATENCY 20000#define AMD_PSTATE_TRANSITION_DELAY 1000/* * TODO: We need more time to fine tune processors with shared memory solution * with community together. * * There are some performance drops on the CPU benchmarks which reports from * Suse. We are co-working with them to fine tune the shared memory solution. So * we disable it by default to go acpi-cpufreq on these processors and add a * module parameter to be able to enable it manually for debugging. */staticstructcpufreq_driver*current_pstate_driver;staticstructcpufreq_driveramd_pstate_driver;static