aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/intel_rdt.h1
-rw-r--r--arch/x86/kernel/cpu/intel_rdt.c2
-rw-r--r--arch/x86/kernel/cpu/intel_rdt_schemata.c43
3 files changed, 46 insertions, 0 deletions
diff --git a/arch/x86/include/asm/intel_rdt.h b/arch/x86/include/asm/intel_rdt.h
index 4a9005766d96..bd184e1fd207 100644
--- a/arch/x86/include/asm/intel_rdt.h
+++ b/arch/x86/include/asm/intel_rdt.h
@@ -181,6 +181,7 @@ struct rdt_resource {
181void rdt_get_cache_infofile(struct rdt_resource *r); 181void rdt_get_cache_infofile(struct rdt_resource *r);
182void rdt_get_mba_infofile(struct rdt_resource *r); 182void rdt_get_mba_infofile(struct rdt_resource *r);
183int parse_cbm(char *buf, struct rdt_resource *r, struct rdt_domain *d); 183int parse_cbm(char *buf, struct rdt_resource *r, struct rdt_domain *d);
184int parse_bw(char *buf, struct rdt_resource *r, struct rdt_domain *d);
184 185
185extern struct mutex rdtgroup_mutex; 186extern struct mutex rdtgroup_mutex;
186 187
diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c
index 1e410ea6905e..731f70ae57d0 100644
--- a/arch/x86/kernel/cpu/intel_rdt.c
+++ b/arch/x86/kernel/cpu/intel_rdt.c
@@ -116,6 +116,8 @@ struct rdt_resource rdt_resources_all[] = {
116 .msr_base = IA32_MBA_THRTL_BASE, 116 .msr_base = IA32_MBA_THRTL_BASE,
117 .msr_update = mba_wrmsr, 117 .msr_update = mba_wrmsr,
118 .cache_level = 3, 118 .cache_level = 3,
119 .parse_ctrlval = parse_bw,
120 .format_str = "%d=%*d",
119 }, 121 },
120}; 122};
121 123
diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c
index c72c9cc17aac..9467a00c947b 100644
--- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
@@ -29,6 +29,49 @@
29#include <asm/intel_rdt.h> 29#include <asm/intel_rdt.h>
30 30
31/* 31/*
32 * Check whether MBA bandwidth percentage value is correct. The value is
33 * checked against the minimum and max bandwidth values specified by the
34 * hardware. The allocated bandwidth percentage is rounded to the next
35 * control step available on the hardware.
36 */
37static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)
38{
39 unsigned long bw;
40 int ret;
41
42 /*
43 * Only linear delay values is supported for current Intel SKUs.
44 */
45 if (!r->membw.delay_linear)
46 return false;
47
48 ret = kstrtoul(buf, 10, &bw);
49 if (ret)
50 return false;
51
52 if (bw < r->membw.min_bw || bw > r->default_ctrl)
53 return false;
54
55 *data = roundup(bw, (unsigned long)r->membw.bw_gran);
56 return true;
57}
58
59int parse_bw(char *buf, struct rdt_resource *r, struct rdt_domain *d)
60{
61 unsigned long data;
62
63 if (d->have_new_ctrl)
64 return -EINVAL;
65
66 if (!bw_validate(buf, &data, r))
67 return -EINVAL;
68 d->new_ctrl = data;
69 d->have_new_ctrl = true;
70
71 return 0;
72}
73
74/*
32 * Check whether a cache bit mask is valid. The SDM says: 75 * Check whether a cache bit mask is valid. The SDM says:
33 * Please note that all (and only) contiguous '1' combinations 76 * Please note that all (and only) contiguous '1' combinations
34 * are allowed (e.g. FFFFH, 0FF0H, 003CH, etc.). 77 * are allowed (e.g. FFFFH, 0FF0H, 003CH, etc.).