diff mbox

[v3,10/15] x86: refactor psr: Implement function to get the max cos_max.

Message ID 1477366863-5246-11-git-send-email-yi.y.sun@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yi Sun Oct. 25, 2016, 3:40 a.m. UTC
When set ASSOC register, we need a cos_mask to calculate the COS
ID to set. The cos_mask is calculated by cos_max. When supporting
more than one feature, the cos_max to calculate cos_mask should be
the max one of all features.

This patch implements 'get_max_cos_max' function and the corresponding
callback function to get the max cos_max of all features.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
---
 xen/arch/x86/psr.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index b8bb09b..fdf4e3a 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -55,6 +55,8 @@  struct feat_ops {
     /* get_val is used to get feature COS register value. */
     int (*get_val)(const struct feat_node *feat, unsigned int cos,
                    enum cbm_type type, uint64_t *val);
+    /* get_max_cos_max is used to get feature's cos_max. */
+    unsigned int (*get_max_cos_max)(const struct feat_node *feat);
 };
 
 /* CAT/CDP HW info data structure. */
@@ -279,10 +281,16 @@  static int l3_cat_get_val(const struct feat_node *feat, unsigned int cos,
     return 1;
 }
 
+static unsigned int l3_cat_get_max_cos_max(const struct feat_node *feat)
+{
+    return feat->info.cos_max;
+}
+
 struct feat_ops l3_cat_ops = {
     .init_feature = l3_cat_init_feature,
     .get_feat_info = l3_cat_get_feat_info,
     .get_val = l3_cat_get_val,
+    .get_max_cos_max = l3_cat_get_max_cos_max,
 };
 
 static unsigned int get_socket_cpu(unsigned int socket)
@@ -434,6 +442,18 @@  void psr_free_rmid(struct domain *d)
     d->arch.psr_rmid = 0;
 }
 
+static inline unsigned int get_max_cos_max(
+                       const struct psr_cat_socket_info *info)
+{
+    const struct feat_node *feat_tmp;
+    unsigned int cos_max = 0;
+
+    list_for_each_entry(feat_tmp, &info->feat_list, list)
+        cos_max = max(feat_tmp->ops.get_max_cos_max(feat_tmp), cos_max);
+
+    return cos_max;
+}
+
 static inline void psr_assoc_init(void)
 {
     struct psr_assoc *psra = &this_cpu(psr_assoc);
@@ -441,16 +461,11 @@  static inline void psr_assoc_init(void)
     if ( cat_socket_info )
     {
         unsigned int socket = cpu_to_socket(smp_processor_id());
-        struct psr_cat_socket_info *info = cat_socket_info + socket;
-        struct feat_node *feat_tmp;
-
-        feat_tmp = get_feat_l3(info);
-        if ( !feat_tmp )
-            return;
+        const struct psr_cat_socket_info *info = cat_socket_info + socket;
+        unsigned int cos_max = get_max_cos_max(info);
 
         if ( info->feat_mask )
-            psra->cos_mask = ((1ull << get_count_order(
-                              feat_tmp->info.cos_max)) - 1) << 32;
+            psra->cos_mask = ((1ull << get_count_order(cos_max)) - 1) << 32;
     }
 
     if ( psr_cmt_enabled() || psra->cos_mask )