Skip to content

Commit deaf49f

Browse files
suryasaimadhushiloong
authored andcommitted
x86/cpufeatures: Carve out CQM features retrieval
commit 45fc56e upstream. ... into a separate function for better readability. Split out from a patch from Fenghua Yu <fenghua.yu@intel.com> to keep the mechanical, sole code movement separate for easy review. No functional changes. Signed-off-by: Borislav Petkov <bp@suse.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: x86@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com> Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>
1 parent 46de2e5 commit deaf49f

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

arch/x86/kernel/cpu/common.c

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,38 @@ static void init_speculation_control(struct cpuinfo_x86 *c)
808808
}
809809
}
810810

811+
static void init_cqm(struct cpuinfo_x86 *c)
812+
{
813+
u32 eax, ebx, ecx, edx;
814+
815+
/* Additional Intel-defined flags: level 0x0000000F */
816+
if (c->cpuid_level >= 0x0000000F) {
817+
818+
/* QoS sub-leaf, EAX=0Fh, ECX=0 */
819+
cpuid_count(0x0000000F, 0, &eax, &ebx, &ecx, &edx);
820+
c->x86_capability[CPUID_F_0_EDX] = edx;
821+
822+
if (cpu_has(c, X86_FEATURE_CQM_LLC)) {
823+
/* will be overridden if occupancy monitoring exists */
824+
c->x86_cache_max_rmid = ebx;
825+
826+
/* QoS sub-leaf, EAX=0Fh, ECX=1 */
827+
cpuid_count(0x0000000F, 1, &eax, &ebx, &ecx, &edx);
828+
c->x86_capability[CPUID_F_1_EDX] = edx;
829+
830+
if ((cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC)) ||
831+
((cpu_has(c, X86_FEATURE_CQM_MBM_TOTAL)) ||
832+
(cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL)))) {
833+
c->x86_cache_max_rmid = ecx;
834+
c->x86_cache_occ_scale = ebx;
835+
}
836+
} else {
837+
c->x86_cache_max_rmid = -1;
838+
c->x86_cache_occ_scale = -1;
839+
}
840+
}
841+
}
842+
811843
void get_cpu_cap(struct cpuinfo_x86 *c)
812844
{
813845
u32 eax, ebx, ecx, edx;
@@ -839,33 +871,6 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
839871
c->x86_capability[CPUID_D_1_EAX] = eax;
840872
}
841873

842-
/* Additional Intel-defined flags: level 0x0000000F */
843-
if (c->cpuid_level >= 0x0000000F) {
844-
845-
/* QoS sub-leaf, EAX=0Fh, ECX=0 */
846-
cpuid_count(0x0000000F, 0, &eax, &ebx, &ecx, &edx);
847-
c->x86_capability[CPUID_F_0_EDX] = edx;
848-
849-
if (cpu_has(c, X86_FEATURE_CQM_LLC)) {
850-
/* will be overridden if occupancy monitoring exists */
851-
c->x86_cache_max_rmid = ebx;
852-
853-
/* QoS sub-leaf, EAX=0Fh, ECX=1 */
854-
cpuid_count(0x0000000F, 1, &eax, &ebx, &ecx, &edx);
855-
c->x86_capability[CPUID_F_1_EDX] = edx;
856-
857-
if ((cpu_has(c, X86_FEATURE_CQM_OCCUP_LLC)) ||
858-
((cpu_has(c, X86_FEATURE_CQM_MBM_TOTAL)) ||
859-
(cpu_has(c, X86_FEATURE_CQM_MBM_LOCAL)))) {
860-
c->x86_cache_max_rmid = ecx;
861-
c->x86_cache_occ_scale = ebx;
862-
}
863-
} else {
864-
c->x86_cache_max_rmid = -1;
865-
c->x86_cache_occ_scale = -1;
866-
}
867-
}
868-
869874
/* AMD-defined flags: level 0x80000001 */
870875
eax = cpuid_eax(0x80000000);
871876
c->extended_cpuid_level = eax;
@@ -896,6 +901,7 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
896901

897902
init_scattered_cpuid_features(c);
898903
init_speculation_control(c);
904+
init_cqm(c);
899905

900906
/*
901907
* Clear/Set all flags overridden by options, after probe.

0 commit comments

Comments
 (0)