hv: fix bugs in RDT's CDP code

In current RDT code, if CDP is configured, L2/L3 resources' num_closids calculation
is wrong:
res_cap_info[res].num_closids = (uint16_t)((edx & 0xffffU) >> 1U) + 1U;

Should be:
res_cap_info[res].num_closids = (uint16_t)((edx & 0xffffU) >> 1U + 1) >> 1U;

Aslo, in order to enable CDP system-wide, need to enable the CDP bit (bit 0) on all pcpus,
not just on pcpu 0.

Tracked-On: #5917
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
This commit is contained in:
dongshen 2021-09-14 16:38:08 -07:00 committed by Xie, Nanlin
parent f4cdbba0bd
commit 08d4517431
1 changed files with 8 additions and 7 deletions

View File

@ -80,14 +80,9 @@ static void init_cat_capability(int res)
#else
res_cap_info[res].res.cache.is_cdp_enabled = false;
#endif
res_cap_info[res].num_closids = (uint16_t)(edx & 0xffffU) + 1U;
if (res_cap_info[res].res.cache.is_cdp_enabled) {
res_cap_info[res].num_closids = (uint16_t)((edx & 0xffffU) >> 1U) + 1U;
/* enable CDP before setting COS to simplify CAT mask remapping
* and prevent unintended behavior.
*/
msr_write(res_cap_info[res].res.cache.msr_qos_cfg, 0x1UL);
} else {
res_cap_info[res].num_closids = (uint16_t)(edx & 0xffffU) + 1U;
res_cap_info[res].num_closids >>= 1U;
}
}
@ -156,7 +151,13 @@ static void setup_res_clos_msr(uint16_t pcpu_id, uint16_t res, struct platform_c
if (res != RDT_RESOURCE_MBA && res_cap_info[res].res.cache.is_cdp_enabled) {
mask_array_size = mask_array_size << 1U;
/* enable CDP before setting COS to simplify CAT mask remapping
* and prevent unintended behavior.
*/
msr_write(res_cap_info[res].res.cache.msr_qos_cfg, 0x1UL);
}
for (i = 0U; i < mask_array_size; i++) {
switch (res) {
case RDT_RESOURCE_L3: