[Kernel][6.15] Fix missing cpufreq_get_policy and asm/amd/nb.h

This commit is contained in:
CyrIng
2025-05-31 10:05:27 +02:00
parent 2c03ceab46
commit 90d4825ad0
4 changed files with 90 additions and 6 deletions

View File

@@ -2298,6 +2298,26 @@ static PROCESSOR_SPECIFIC *LookupProcessor(void)
return NULL;
}
#ifdef CONFIG_CPU_FREQ
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
static int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
{
struct cpufreq_policy *cpu_policy __free(put_cpufreq_policy);
if (!policy)
return -EINVAL;
cpu_policy = cpufreq_cpu_get(cpu);
if (!cpu_policy)
return -EINVAL;
memcpy(policy, cpu_policy, sizeof(*policy));
return 0;
}
#endif
#endif /* CONFIG_CPU_FREQ */
static void Query_DeviceTree(unsigned int cpu)
{
CORE_RO *Core = (CORE_RO *) PUBLIC(RO(Core, AT(cpu)));
@@ -2308,7 +2328,7 @@ static void Query_DeviceTree(unsigned int cpu)
unsigned int max_freq = 0, min_freq = 0, cur_freq = 0;
COF_ST COF;
#ifdef CONFIG_CPU_FREQ
if (cpufreq_get_policy(pFreqPolicy,cpu) == 0)
if (cpufreq_get_policy(pFreqPolicy, cpu) == 0)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
struct cpufreq_frequency_table *table;
@@ -3933,7 +3953,7 @@ static long Sys_OS_Driver_Query(void)
StrCopy(PUBLIC(RO(Proc))->OS.FreqDriver.Name,
pFreqDriver, CPUFREQ_NAME_LEN);
}
if ((rc=cpufreq_get_policy(pFreqPolicy,PUBLIC(RO(Proc))->Service.Core)) == 0)
if ((rc=cpufreq_get_policy(pFreqPolicy, PUBLIC(RO(Proc))->Service.Core)) == 0)
{
struct cpufreq_governor *pGovernor = pFreqPolicy->governor;
if (pGovernor != NULL) {

View File

@@ -958,6 +958,26 @@ static PROCESSOR_SPECIFIC *LookupProcessor(void)
return NULL;
}
#ifdef CONFIG_CPU_FREQ
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
static int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
{
struct cpufreq_policy *cpu_policy __free(put_cpufreq_policy);
if (!policy)
return -EINVAL;
cpu_policy = cpufreq_cpu_get(cpu);
if (!cpu_policy)
return -EINVAL;
memcpy(policy, cpu_policy, sizeof(*policy));
return 0;
}
#endif
#endif /* CONFIG_CPU_FREQ */
static void Query_DeviceTree(unsigned int cpu)
{
CORE_RO *Core = (CORE_RO *) PUBLIC(RO(Core, AT(cpu)));
@@ -968,7 +988,7 @@ static void Query_DeviceTree(unsigned int cpu)
unsigned int max_freq = 0, min_freq = 0, cur_freq = 0;
COF_ST COF;
#ifdef CONFIG_CPU_FREQ
if (cpufreq_get_policy(pFreqPolicy,cpu) == 0)
if (cpufreq_get_policy(pFreqPolicy, cpu) == 0)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
struct cpufreq_frequency_table *table;
@@ -2290,7 +2310,7 @@ static long Sys_OS_Driver_Query(void)
StrCopy(PUBLIC(RO(Proc))->OS.FreqDriver.Name,
pFreqDriver, CPUFREQ_NAME_LEN);
}
if ((rc=cpufreq_get_policy(pFreqPolicy,PUBLIC(RO(Proc))->Service.Core)) == 0)
if ((rc=cpufreq_get_policy(pFreqPolicy, PUBLIC(RO(Proc))->Service.Core)) == 0)
{
struct cpufreq_governor *pGovernor = pFreqPolicy->governor;
if (pGovernor != NULL) {

View File

@@ -942,6 +942,26 @@ static PROCESSOR_SPECIFIC *LookupProcessor(void)
return NULL;
}
#ifdef CONFIG_CPU_FREQ
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
static int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
{
struct cpufreq_policy *cpu_policy __free(put_cpufreq_policy);
if (!policy)
return -EINVAL;
cpu_policy = cpufreq_cpu_get(cpu);
if (!cpu_policy)
return -EINVAL;
memcpy(policy, cpu_policy, sizeof(*policy));
return 0;
}
#endif
#endif /* CONFIG_CPU_FREQ */
static void Query_DeviceTree(unsigned int cpu)
{
CORE_RO *Core = (CORE_RO *) PUBLIC(RO(Core, AT(cpu)));
@@ -952,7 +972,7 @@ static void Query_DeviceTree(unsigned int cpu)
unsigned int max_freq = 0, min_freq = 0, cur_freq = 0;
COF_ST COF;
#ifdef CONFIG_CPU_FREQ
if (cpufreq_get_policy(pFreqPolicy,cpu) == 0)
if (cpufreq_get_policy(pFreqPolicy, cpu) == 0)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
struct cpufreq_frequency_table *table;
@@ -2277,7 +2297,7 @@ static long Sys_OS_Driver_Query(void)
StrCopy(PUBLIC(RO(Proc))->OS.FreqDriver.Name,
pFreqDriver, CPUFREQ_NAME_LEN);
}
if ((rc=cpufreq_get_policy(pFreqPolicy,PUBLIC(RO(Proc))->Service.Core)) == 0)
if ((rc=cpufreq_get_policy(pFreqPolicy, PUBLIC(RO(Proc))->Service.Core)) == 0)
{
struct cpufreq_governor *pGovernor = pFreqPolicy->governor;
if (pGovernor != NULL) {

View File

@@ -53,8 +53,12 @@
#endif /* CONFIG_XEN */
#include <asm/mwait.h>
#ifdef CONFIG_AMD_NB
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
#include <asm/amd/nb.h>
#else
#include <asm/amd_nb.h>
#endif
#endif /* CONFIG_AMD_NB */
#ifdef CONFIG_ACPI
#include <linux/acpi.h>
#include <acpi/processor.h>
@@ -20826,6 +20830,26 @@ static void Stop_Uncore_AMD_Family_17h(void *arg)
}
#ifdef CONFIG_CPU_FREQ
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
static int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
{
struct cpufreq_policy *cpu_policy __free(put_cpufreq_policy);
if (!policy)
return -EINVAL;
cpu_policy = cpufreq_cpu_get(cpu);
if (!cpu_policy)
return -EINVAL;
memcpy(policy, cpu_policy, sizeof(*policy));
return 0;
}
#endif
#endif /* CONFIG_CPU_FREQ */
static long Sys_OS_Driver_Query(void)
{
int rc = RC_SUCCESS;