mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-26 07:21:37 +00:00
hv: some cosmetic fixes to rdt.c/rdt.h
Rename the clos_max field in struct rdt_info to num_closids Rename variable valid_clos_num to common_num_closids and make it static Tracked-On: #5917 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
This commit is contained in:
parent
2de395b6f6
commit
f4cdbba0bd
@ -18,12 +18,12 @@
|
|||||||
#include <asm/msr.h>
|
#include <asm/msr.h>
|
||||||
|
|
||||||
const uint16_t hv_clos = 0U;
|
const uint16_t hv_clos = 0U;
|
||||||
/* RDT features can support different numbers of CLOS. Set the lowers numerical
|
/* RDT features can support different numbers of CLOS. Set the lowest numerical
|
||||||
* clos value (valid_clos_num) that is common between the resources as
|
* clos value (common_num_closids - 1) that is common between the resources as
|
||||||
* each resource's clos max value to have consistent allocation.
|
* each resource's clos max value to have consistent allocation.
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_RDT_ENABLED
|
#ifdef CONFIG_RDT_ENABLED
|
||||||
uint16_t valid_clos_num = HV_SUPPORTED_MAX_CLOS;
|
static uint16_t common_num_closids = HV_SUPPORTED_MAX_CLOS;
|
||||||
|
|
||||||
static struct rdt_info res_cap_info[RDT_NUM_RESOURCES] = {
|
static struct rdt_info res_cap_info[RDT_NUM_RESOURCES] = {
|
||||||
[RDT_RESOURCE_L3] = {
|
[RDT_RESOURCE_L3] = {
|
||||||
@ -32,7 +32,7 @@ static struct rdt_info res_cap_info[RDT_NUM_RESOURCES] = {
|
|||||||
.cbm_len = 0U,
|
.cbm_len = 0U,
|
||||||
.msr_qos_cfg = MSR_IA32_L3_QOS_CFG,
|
.msr_qos_cfg = MSR_IA32_L3_QOS_CFG,
|
||||||
},
|
},
|
||||||
.clos_max = 0U,
|
.num_closids = 0U,
|
||||||
.res_id = RDT_RESID_L3,
|
.res_id = RDT_RESID_L3,
|
||||||
.msr_base = MSR_IA32_L3_MASK_BASE,
|
.msr_base = MSR_IA32_L3_MASK_BASE,
|
||||||
.platform_clos_array = platform_l3_clos_array,
|
.platform_clos_array = platform_l3_clos_array,
|
||||||
@ -43,7 +43,7 @@ static struct rdt_info res_cap_info[RDT_NUM_RESOURCES] = {
|
|||||||
.cbm_len = 0U,
|
.cbm_len = 0U,
|
||||||
.msr_qos_cfg = MSR_IA32_L2_QOS_CFG,
|
.msr_qos_cfg = MSR_IA32_L2_QOS_CFG,
|
||||||
},
|
},
|
||||||
.clos_max = 0U,
|
.num_closids = 0U,
|
||||||
.res_id = RDT_RESID_L2,
|
.res_id = RDT_RESID_L2,
|
||||||
.msr_base = MSR_IA32_L2_MASK_BASE,
|
.msr_base = MSR_IA32_L2_MASK_BASE,
|
||||||
.platform_clos_array = platform_l2_clos_array,
|
.platform_clos_array = platform_l2_clos_array,
|
||||||
@ -53,7 +53,7 @@ static struct rdt_info res_cap_info[RDT_NUM_RESOURCES] = {
|
|||||||
.mba_max = 0U,
|
.mba_max = 0U,
|
||||||
.delay_linear = true,
|
.delay_linear = true,
|
||||||
},
|
},
|
||||||
.clos_max = 0U,
|
.num_closids = 0U,
|
||||||
.res_id = RDT_RESID_MBA,
|
.res_id = RDT_RESID_MBA,
|
||||||
.msr_base = MSR_IA32_MBA_MASK_BASE,
|
.msr_base = MSR_IA32_MBA_MASK_BASE,
|
||||||
.platform_clos_array = platform_mba_clos_array,
|
.platform_clos_array = platform_mba_clos_array,
|
||||||
@ -81,13 +81,13 @@ static void init_cat_capability(int res)
|
|||||||
res_cap_info[res].res.cache.is_cdp_enabled = false;
|
res_cap_info[res].res.cache.is_cdp_enabled = false;
|
||||||
#endif
|
#endif
|
||||||
if (res_cap_info[res].res.cache.is_cdp_enabled) {
|
if (res_cap_info[res].res.cache.is_cdp_enabled) {
|
||||||
res_cap_info[res].clos_max = (uint16_t)((edx & 0xffffU) >> 1U) + 1U;
|
res_cap_info[res].num_closids = (uint16_t)((edx & 0xffffU) >> 1U) + 1U;
|
||||||
/* enable CDP before setting COS to simplify CAT mask remapping
|
/* enable CDP before setting COS to simplify CAT mask remapping
|
||||||
* and prevent unintended behavior.
|
* and prevent unintended behavior.
|
||||||
*/
|
*/
|
||||||
msr_write(res_cap_info[res].res.cache.msr_qos_cfg, 0x1UL);
|
msr_write(res_cap_info[res].res.cache.msr_qos_cfg, 0x1UL);
|
||||||
} else {
|
} else {
|
||||||
res_cap_info[res].clos_max = (uint16_t)(edx & 0xffffU) + 1U;
|
res_cap_info[res].num_closids = (uint16_t)(edx & 0xffffU) + 1U;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,11 +103,11 @@ static void init_mba_capability(int res)
|
|||||||
cpuid_subleaf(CPUID_RDT_ALLOCATION, res_cap_info[res].res_id, &eax, &ebx, &ecx, &edx);
|
cpuid_subleaf(CPUID_RDT_ALLOCATION, res_cap_info[res].res_id, &eax, &ebx, &ecx, &edx);
|
||||||
res_cap_info[res].res.membw.mba_max = (uint16_t)((eax & 0xfffU) + 1U);
|
res_cap_info[res].res.membw.mba_max = (uint16_t)((eax & 0xfffU) + 1U);
|
||||||
res_cap_info[res].res.membw.delay_linear = ((ecx & 0x4U) != 0U);
|
res_cap_info[res].res.membw.delay_linear = ((ecx & 0x4U) != 0U);
|
||||||
res_cap_info[res].clos_max = (uint16_t)(edx & 0xffffU) + 1U;
|
res_cap_info[res].num_closids = (uint16_t)(edx & 0xffffU) + 1U;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @pre valid_clos_num > 0U
|
* @pre common_num_closids > 0U
|
||||||
*/
|
*/
|
||||||
void init_rdt_info(void)
|
void init_rdt_info(void)
|
||||||
{
|
{
|
||||||
@ -133,13 +133,11 @@ void init_rdt_info(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0U; i < RDT_NUM_RESOURCES; i++) {
|
for (i = 0U; i < RDT_NUM_RESOURCES; i++) {
|
||||||
/* If clos_max == 0, the resource is not supported. Set the
|
/* If num_closids == 0, the resource is not supported. Set the
|
||||||
* valid_clos_num as the minimal clos_max of all support rdt resource.
|
* common_num_closids as the minimal num_closids of all support rdt resource.
|
||||||
*/
|
*/
|
||||||
if (res_cap_info[i].clos_max > 0U) {
|
if ((res_cap_info[i].num_closids > 0U) && (res_cap_info[i].num_closids < common_num_closids)) {
|
||||||
if (res_cap_info[i].clos_max < valid_clos_num) {
|
common_num_closids = res_cap_info[i].num_closids;
|
||||||
valid_clos_num = res_cap_info[i].clos_max;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,7 +150,7 @@ void init_rdt_info(void)
|
|||||||
*/
|
*/
|
||||||
static void setup_res_clos_msr(uint16_t pcpu_id, uint16_t res, struct platform_clos_info *res_clos_info)
|
static void setup_res_clos_msr(uint16_t pcpu_id, uint16_t res, struct platform_clos_info *res_clos_info)
|
||||||
{
|
{
|
||||||
uint16_t i, mask_array_size = valid_clos_num;
|
uint16_t i, mask_array_size = common_num_closids;
|
||||||
uint32_t msr_index;
|
uint32_t msr_index;
|
||||||
uint64_t val;
|
uint64_t val;
|
||||||
|
|
||||||
@ -181,10 +179,10 @@ void setup_clos(uint16_t pcpu_id)
|
|||||||
uint16_t i;
|
uint16_t i;
|
||||||
|
|
||||||
for (i = 0U; i < RDT_NUM_RESOURCES; i++) {
|
for (i = 0U; i < RDT_NUM_RESOURCES; i++) {
|
||||||
/* If clos_max == 0, the resource is not supported
|
/* If num_closids == 0, the resource is not supported
|
||||||
* so skip setting up resource MSR.
|
* so skip setting up resource MSR.
|
||||||
*/
|
*/
|
||||||
if (res_cap_info[i].clos_max > 0U) {
|
if (res_cap_info[i].num_closids > 0U) {
|
||||||
setup_res_clos_msr(pcpu_id, i, res_cap_info[i].platform_clos_array);
|
setup_res_clos_msr(pcpu_id, i, res_cap_info[i].platform_clos_array);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,9 +205,9 @@ bool is_platform_rdt_capable(void)
|
|||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if ((res_cap_info[RDT_RESOURCE_L3].clos_max > 0U) ||
|
if ((res_cap_info[RDT_RESOURCE_L3].num_closids > 0U) ||
|
||||||
(res_cap_info[RDT_RESOURCE_L2].clos_max > 0U) ||
|
(res_cap_info[RDT_RESOURCE_L2].num_closids > 0U) ||
|
||||||
(res_cap_info[RDT_RESOURCE_MBA].clos_max > 0U)) {
|
(res_cap_info[RDT_RESOURCE_MBA].num_closids > 0U)) {
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ enum {
|
|||||||
#define RDT_RESID_MBA 3U
|
#define RDT_RESID_MBA 3U
|
||||||
|
|
||||||
extern const uint16_t hv_clos;
|
extern const uint16_t hv_clos;
|
||||||
extern uint16_t valid_clos_num;
|
|
||||||
|
|
||||||
/* The intel Resource Director Tech(RDT) based Allocation Tech support */
|
/* The intel Resource Director Tech(RDT) based Allocation Tech support */
|
||||||
struct rdt_info {
|
struct rdt_info {
|
||||||
@ -38,9 +37,9 @@ struct rdt_info {
|
|||||||
bool delay_linear; /* True if memory B/W delay is in linear scale */
|
bool delay_linear; /* True if memory B/W delay is in linear scale */
|
||||||
} membw;
|
} membw;
|
||||||
} res;
|
} res;
|
||||||
uint16_t clos_max; /* Maximum CLOS supported, 0 indicates resource is not supported.*/
|
uint16_t num_closids; /* Number of CLOSIDs available, 0 indicates resource is not supported.*/
|
||||||
uint32_t res_id;
|
uint32_t res_id;
|
||||||
uint32_t msr_base; /* MSR base to program clos mask*/
|
uint32_t msr_base; /* MSR base to program clos value */
|
||||||
struct platform_clos_info *platform_clos_array; /* user configured mask and MSR info for each CLOS*/
|
struct platform_clos_info *platform_clos_array; /* user configured mask and MSR info for each CLOS*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user