diff mbox

[v12,14/23] x86: refactor psr: CDP: implement get hw info flow.

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

Commit Message

Yi Sun June 14, 2017, 1:12 a.m. UTC
This patch implements get HW info flow for CDP including L3 CDP callback
function. The flow is almost same as L3 CAT.

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

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
---
v12:
    - remove input parameter 'info' in 'psr_cbm_type_to_feat_type'. Use
      'feat_props' array to check.
      (suggested by Jan Beulich)
v11:
    - modify 'psr_get_info' flow to make it simple to cover CDP case.
v10:
    - update renamed macros used by psr_get_info.
      (suggested by Jan Beulich)
    - change 'psr_get_info' flow to cover CDP case to make codes in sysctl
      more simple.
      (suggested by Jan Beulich)
    - remove sysctl redundant codes after applying above changes.
      (suggested by Jan Beulich)
v9:
    - modify commit message to explain flow more clearly.
    - reuse 'cat_get_feat_info' for CDP to reduce redundant codes.
      (suggested by Roger Pau)
    - fix coding style issues.
      (suggested by Wei Liu and Roger Pau)
    - rename macros used by psr_get_info to make them meaningful.
      (suggested by Jan Beulich)
v5:
    - rename 'dat[]' to 'data[]'.
      (suggested by Jan Beulich)
    - 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 | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Jan Beulich June 30, 2017, 6:41 a.m. UTC | #1
>>> Yi Sun <yi.y.sun@linux.intel.com> 06/14/17 3:26 AM >>>
> --- a/xen/arch/x86/psr.c
> +++ b/xen/arch/x86/psr.c
> @@ -217,7 +217,21 @@ static enum psr_feat_type psr_cbm_type_to_feat_type(enum cbm_type type)
>      {
>      case PSR_CBM_TYPE_L3:
>          feat_type = PSR_SOCKET_L3_CAT;
> +
> +        /*
> +         * If type is L3 CAT but we cannot find it in feat_props array,
> +         * try CDP.
> +         */
> +        if ( !feat_props[feat_type] )
> +            feat_type = PSR_SOCKET_L3_CDP;
> +
>          break;
> +
> +    case PSR_CBM_TYPE_L3_DATA:
> +    case PSR_CBM_TYPE_L3_CODE:
> +        feat_type = PSR_SOCKET_L3_CDP;
> +        break;

I think the CAT part here would better be done as a fall-through to the CDP
cases, but I won't insist on it, i.e.
Reviewed-by: Jan Beulich <jbeulich@suse.com>
either way.

Jan
diff mbox

Patch

diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index 814f0e1..aee6e3e 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -217,7 +217,21 @@  static enum psr_feat_type psr_cbm_type_to_feat_type(enum cbm_type type)
     {
     case PSR_CBM_TYPE_L3:
         feat_type = PSR_SOCKET_L3_CAT;
+
+        /*
+         * If type is L3 CAT but we cannot find it in feat_props array,
+         * try CDP.
+         */
+        if ( !feat_props[feat_type] )
+            feat_type = PSR_SOCKET_L3_CDP;
+
         break;
+
+    case PSR_CBM_TYPE_L3_DATA:
+    case PSR_CBM_TYPE_L3_CODE:
+        feat_type = PSR_SOCKET_L3_CDP;
+        break;
+
     default:
         ASSERT_UNREACHABLE();
     }
@@ -333,10 +347,22 @@  static const struct feat_props l3_cat_props = {
 };
 
 /* L3 CDP props */
+static bool l3_cdp_get_feat_info(const struct feat_node *feat,
+                                 uint32_t data[], uint32_t array_len)
+{
+    if ( !cat_get_feat_info(feat, data, array_len) )
+        return false;
+
+    data[PSR_INFO_IDX_CAT_FLAG] |= XEN_SYSCTL_PSR_CAT_L3_CDP;
+
+    return true;
+}
+
 static const struct feat_props l3_cdp_props = {
     .cos_num = 2,
     .type[0] = PSR_CBM_TYPE_L3_DATA,
     .type[1] = PSR_CBM_TYPE_L3_CODE,
+    .get_feat_info = l3_cdp_get_feat_info,
 };
 
 static void __init parse_psr_bool(char *s, char *value, char *feature,