[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC 06/16] x86: implement init flow for MBA.
This patch implements init flow for MBA including its callback functions. Signed-off-by: Yi Sun <yi.y.sun@xxxxxxxxxxxxxxx> --- xen/arch/x86/psr.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++- xen/include/asm-x86/psr.h | 1 + 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index eca9c43..e2ca6fb 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -41,6 +41,7 @@ #define CAT_CBM_LEN_MASK 0x1f #define CAT_COS_MAX_MASK 0xffff +#define MBA_THRTL_MAX_MASK 0xfff /* Linear bit. */ #define MBA_LINEAR (1<<2) @@ -265,6 +266,7 @@ static DEFINE_PER_CPU(struct psr_assoc, psr_assoc); static struct feat_node *feat_l3_cat; static struct feat_node *feat_l3_cdp; static struct feat_node *feat_l2_cat; +static struct feat_node *feat_mba; /* Common functions. */ static void free_feature(struct psr_socket_info *info) @@ -299,6 +301,12 @@ static void free_feature(struct psr_socket_info *info) xfree(feat_l2_cat); feat_l2_cat = NULL; } + + if ( feat_mba ) + { + xfree(feat_mba); + feat_mba = NULL; + } } static bool_t psr_check_cbm(unsigned int cbm_len, uint64_t cbm) @@ -934,6 +942,53 @@ struct feat_ops l2_cat_ops = { .write_msr = l2_cat_write_msr, }; +/* MBA callback functions implementation. */ +static void mba_init_feature(unsigned int eax, unsigned int ebx, + unsigned int ecx, unsigned int edx, + struct feat_node *feat, + struct psr_socket_info *info) +{ + struct psr_mba_hw_info mba_info; + unsigned int socket; + + /* No valid values so do not enable the feature. */ + if ( !eax || !edx ) + return; + + mba_info.thrtl_max = (eax & 0xfff) + 1; + mba_info.cos_max = min(opt_cos_max, edx & CAT_COS_MAX_MASK); + if ( ecx & MBA_LINEAR ) + mba_info.linear = 1; + + /* cos=0 is reserved as default thrtl(0), the max bandwidth. */ + feat->cos_reg_val[0] = 0; + + feat->feature = PSR_SOCKET_MBA; + __set_bit(PSR_SOCKET_MBA, &info->feat_mask); + + feat->info.mba_info = mba_info; + + info->nr_feat++; + + /* Add this feature into list. */ + list_add_tail(&feat->list, &info->feat_list); + + socket = cpu_to_socket(smp_processor_id()); + printk(XENLOG_INFO "MBA: enabled on socket %u, cos_max:%u, thrtl_max:%u, linear:%u.\n", + socket, feat->info.mba_info.cos_max, + feat->info.mba_info.thrtl_max, feat->info.mba_info.linear); +} + +static unsigned int mba_get_max_cos_max(const struct feat_node *feat) +{ + return feat->info.mba_info.cos_max; +} + +struct feat_ops mba_ops = { + .init_feature = mba_init_feature, + .get_max_cos_max = mba_get_max_cos_max, +}; + static void __init parse_psr_bool(char *s, char *value, char *feature, unsigned int mask) { @@ -1659,6 +1714,20 @@ static int cpu_prepare_work(unsigned int cpu) return -ENOMEM; } + if ( feat_mba == NULL && + (feat_mba = xzalloc(struct feat_node)) == NULL ) + { + xfree(feat_l3_cat); + feat_l3_cat = NULL; + + xfree(feat_l3_cdp); + feat_l3_cdp = NULL; + + xfree(feat_l2_cat); + feat_l2_cat = NULL; + return -ENOMEM; + } + return 0; } @@ -1712,6 +1781,18 @@ static void cpu_init_work(void) feat_tmp->ops = l2_cat_ops; feat_tmp->ops.init_feature(eax, ebx, ecx, edx, feat_tmp, info); } + + cpuid_count(PSR_CPUID_LEVEL_CAT, 0, &eax, &ebx, &ecx, &edx); + if ( ebx & PSR_RESOURCE_TYPE_MBA ) + { + feat_tmp = feat_mba; + feat_mba = NULL; + + /* Initialize MBA according to CPUID. */ + cpuid_count(PSR_CPUID_LEVEL_CAT, 3, &eax, &ebx, &ecx, &edx); + feat_tmp->ops = mba_ops; + feat_tmp->ops.init_feature(eax, ebx, ecx, edx, feat_tmp, info); + } } static void cpu_fini_work(unsigned int cpu) @@ -1817,7 +1898,7 @@ static int __init psr_presmp_init(void) if ( (opt_psr & PSR_CMT) && opt_rmid_max ) init_psr_cmt(opt_rmid_max); - if ( opt_psr & PSR_CAT ) + if ( opt_psr & (PSR_CAT | PSR_MBA) ) init_psr(); if ( psr_cpu_prepare(0) ) diff --git a/xen/include/asm-x86/psr.h b/xen/include/asm-x86/psr.h index 4d52918..9dd7782 100644 --- a/xen/include/asm-x86/psr.h +++ b/xen/include/asm-x86/psr.h @@ -24,6 +24,7 @@ /* Resource Type Enumeration */ #define PSR_RESOURCE_TYPE_L3 0x2 #define PSR_RESOURCE_TYPE_L2 0x4 +#define PSR_RESOURCE_TYPE_MBA 0x8 /* L3 Monitoring Features */ #define PSR_CMT_L3_OCCUPANCY 0x1 -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |