]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86/resctrl: Remove hard-coded memory bandwidth limit
authorBabu Moger <babu.moger@amd.com>
Mon, 15 Jan 2024 22:52:27 +0000 (16:52 -0600)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:19:19 +0000 (18:19 -0400)
[ Upstream commit 0976783bb123f30981bc1e7a14d9626a6f63aeac ]

The QOS Memory Bandwidth Enforcement Limit is reported by
CPUID_Fn80000020_EAX_x01 and CPUID_Fn80000020_EAX_x02:

  Bits  Description
  31:0  BW_LEN: Size of the QOS Memory Bandwidth Enforcement Limit.

Newer processors can support higher bandwidth limit than the current
hard-coded value. Remove latter and detect using CPUID instead. Also,
update the register variables eax and edx to match the AMD CPUID
definition.

The CPUID details are documented in the Processor Programming Reference
(PPR) Vol 1.1 for AMD Family 19h Model 11h B1 - 55901 Rev 0.25 in the
Link tag below.

Fixes: 4d05bf71f157 ("x86/resctrl: Introduce AMD QOS feature")
Signed-off-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
Link: https://lore.kernel.org/r/c26a8ca79d399ed076cf8bf2e9fbc58048808289.1705359148.git.babu.moger@amd.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kernel/cpu/resctrl/core.c
arch/x86/kernel/cpu/resctrl/internal.h

index 030d3b409768dea54875186085a0b6c26c593aaa..8073fd3042939c9bb7056e3719379767e1b9d3ee 100644 (file)
@@ -230,9 +230,7 @@ static bool __get_mem_config_intel(struct rdt_resource *r)
 static bool __rdt_get_mem_config_amd(struct rdt_resource *r)
 {
        struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
-       union cpuid_0x10_3_eax eax;
-       union cpuid_0x10_x_edx edx;
-       u32 ebx, ecx, subleaf;
+       u32 eax, ebx, ecx, edx, subleaf;
 
        /*
         * Query CPUID_Fn80000020_EDX_x01 for MBA and
@@ -240,9 +238,9 @@ static bool __rdt_get_mem_config_amd(struct rdt_resource *r)
         */
        subleaf = (r->rid == RDT_RESOURCE_SMBA) ? 2 :  1;
 
-       cpuid_count(0x80000020, subleaf, &eax.full, &ebx, &ecx, &edx.full);
-       hw_res->num_closid = edx.split.cos_max + 1;
-       r->default_ctrl = MAX_MBA_BW_AMD;
+       cpuid_count(0x80000020, subleaf, &eax, &ebx, &ecx, &edx);
+       hw_res->num_closid = edx + 1;
+       r->default_ctrl = 1 << eax;
 
        /* AMD does not use delay */
        r->membw.delay_linear = false;
index 85ceaf9a31ac20099c86647b4958e4ca0f28fa6b..81d90f1a8ce58b6649767997023116cafa5d91a4 100644 (file)
@@ -18,7 +18,6 @@
 #define MBM_OVERFLOW_INTERVAL          1000
 #define MAX_MBA_BW                     100u
 #define MBA_IS_LINEAR                  0x4
-#define MAX_MBA_BW_AMD                 0x800
 #define MBM_CNTR_WIDTH_OFFSET_AMD      20
 
 #define RMID_VAL_ERROR                 BIT_ULL(63)