diff mbox

[v10,16/25] x86: refactor psr: CDP: implement get value flow.

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

Commit Message

Yi Sun April 1, 2017, 1:53 p.m. UTC
This patch implements L3 CDP get value callback function.

With this patch, 'psr-cat-show' can work for L3 CDP.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
---
v10:
    - add 'enum cbm_type type' into 'get_val' parameters to handle CDP case.
      (suggested by Jan Beulich)
v9:
    - modify the type of 'l3_cdp_get_val' to 'void'.
    - cos checking has been done in common function so remove related codes
      in CDP callback function.
      (suggested by Jan Beulich)
    - changes about 'uint64_t' to 'uint32_t'.
      (suggested by Jan Beulich)
v5:
    - remove type check in callback function.
      (suggested by Jan Beulich)
v4:
    - create this patch to make codes easier to understand.
      (suggested by Jan Beulich)
---
 xen/arch/x86/psr.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

Comments

Jan Beulich April 11, 2017, 3:39 p.m. UTC | #1
>>> On 01.04.17 at 15:53, <yi.y.sun@linux.intel.com> wrote:
> @@ -755,7 +765,7 @@ static int gather_val_array(uint32_t val[],
>              cos = 0;
>  
>          /* Value getting order is same as feature array. */
> -        feat->props->get_val(feat, cos, &val[0]);
> +        feat->props->get_val(feat, cos, 0, &val[0]);

How can this be literal zero here (and in further cases below)?

Jan
Yi Sun April 12, 2017, 6:05 a.m. UTC | #2
On 17-04-11 09:39:55, Jan Beulich wrote:
> >>> On 01.04.17 at 15:53, <yi.y.sun@linux.intel.com> wrote:
> > @@ -755,7 +765,7 @@ static int gather_val_array(uint32_t val[],
> >              cos = 0;
> >  
> >          /* Value getting order is same as feature array. */
> > -        feat->props->get_val(feat, cos, &val[0]);
> > +        feat->props->get_val(feat, cos, 0, &val[0]);
> 
> How can this be literal zero here (and in further cases below)?
> 
Because the 'type[]' is not introduced yet. Please refer CDP patch
which implements this.

> Jan
Jan Beulich April 12, 2017, 9:14 a.m. UTC | #3
>>> On 12.04.17 at 08:05, <yi.y.sun@linux.intel.com> wrote:
> On 17-04-11 09:39:55, Jan Beulich wrote:
>> >>> On 01.04.17 at 15:53, <yi.y.sun@linux.intel.com> wrote:
>> > @@ -755,7 +765,7 @@ static int gather_val_array(uint32_t val[],
>> >              cos = 0;
>> >  
>> >          /* Value getting order is same as feature array. */
>> > -        feat->props->get_val(feat, cos, &val[0]);
>> > +        feat->props->get_val(feat, cos, 0, &val[0]);
>> 
>> How can this be literal zero here (and in further cases below)?
>> 
> Because the 'type[]' is not introduced yet. Please refer CDP patch
> which implements this.

Again, type[] should be introduced together with the cos_num
field.

Jan
diff mbox

Patch

diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index f0611ad..aced012 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -100,7 +100,7 @@  struct feat_node {
 
         /* get_val is used to get feature COS register value. */
         void (*get_val)(const struct feat_node *feat, unsigned int cos,
-                        uint32_t *val);
+                        enum cbm_type type, uint32_t *val);
 
         /* write_msr is used to write out feature MSR register. */
         void (*write_msr)(unsigned int cos, uint32_t val,
@@ -366,7 +366,7 @@  static bool cat_get_feat_info(const struct feat_node *feat,
 }
 
 static void cat_get_val(const struct feat_node *feat, unsigned int cos,
-                        uint32_t *val)
+                        enum cbm_type type, uint32_t *val)
 {
     *val = feat->cos_reg_val[cos];
 }
@@ -401,9 +401,19 @@  static bool l3_cdp_get_feat_info(const struct feat_node *feat,
     return true;
 }
 
+static void l3_cdp_get_val(const struct feat_node *feat, unsigned int cos,
+                           enum cbm_type type, uint32_t *val)
+{
+    if ( type == PSR_CBM_TYPE_L3_DATA )
+        *val = get_cdp_data(feat, cos);
+    else
+        *val = get_cdp_code(feat, cos);
+}
+
 static struct feat_props l3_cdp_props = {
     .cos_num = 2,
     .get_feat_info = l3_cdp_get_feat_info,
+    .get_val = l3_cdp_get_val,
 };
 
 static void __init parse_psr_bool(char *s, char *value, char *feature,
@@ -701,7 +711,7 @@  int psr_get_val(struct domain *d, unsigned int socket,
     if ( cos > feat->props->cos_max )
         cos = 0;
 
-    feat->props->get_val(feat, cos, val);
+    feat->props->get_val(feat, cos, type, val);
 
     return 0;
 }
@@ -755,7 +765,7 @@  static int gather_val_array(uint32_t val[],
             cos = 0;
 
         /* Value getting order is same as feature array. */
-        feat->props->get_val(feat, cos, &val[0]);
+        feat->props->get_val(feat, cos, 0, &val[0]);
 
         array_len -= feat->props->cos_num;
 
@@ -851,7 +861,7 @@  static int find_cos(const uint32_t val[], unsigned int array_len,
              * COS ID 0 always stores the default value so input 0 to get
              * default value.
              */
-            feat->props->get_val(feat, 0, &default_val);
+            feat->props->get_val(feat, 0, 0, &default_val);
 
             /*
              * Compare value according to feature array order.
@@ -912,7 +922,7 @@  static bool fits_cos_max(const uint32_t val[],
 
         if ( cos > feat->props->cos_max )
         {
-            feat->props->get_val(feat, 0, &default_val);
+            feat->props->get_val(feat, 0, 0, &default_val);
             if ( val[0] != default_val )
                 return false;
         }