From patchwork Sat Apr 1 13:53:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9657941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6567560349 for ; Sat, 1 Apr 2017 13:55:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C052285C2 for ; Sat, 1 Apr 2017 13:55:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FC1228610; Sat, 1 Apr 2017 13:55:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF924285C2 for ; Sat, 1 Apr 2017 13:55:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuJTz-00063Z-TB; Sat, 01 Apr 2017 13:54:23 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuJTy-00061k-Hn for xen-devel@lists.xenproject.org; Sat, 01 Apr 2017 13:54:22 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 48/8F-20914-D01BFD85; Sat, 01 Apr 2017 13:54:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsXS1tYhosu78X6 Ewe43XBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bydX+ZC/5LV/x9dZqxgXGtSBcjFweLwC0m iQnXtzODOEIC0xglVl+9wdbFyMkhIcArcWTZDFYI21/iSe9URhBbSKBe4tDES2A2m4C6xOOvP UwgtoiAksS9VZOZQAYxC+xkklh3+jszSEJYwEdi6esWsKEsAqoSb2/vAhrKwcEr4Ckxe74nxH w5iZPHJoPt4gQKX3mxjwVil4fEqkmXmCcw8i1gZFjFqFGcWlSWWqRraKGXVJSZnlGSm5iZo2t oYKyXm1pcnJiempOYVKyXnJ+7iREYKPUMDIw7GH+f9jzEKMnBpCTK+734XoQQX1J+SmVGYnFG fFFpTmrxIUYZDg4lCV6FDfcjhASLUtNTK9Iyc4AhC5OW4OBREuE9th4ozVtckJhbnJkOkTrFq CglzpsK0icAksgozYNrg8XJJUZZKWFeRgYGBiGegtSi3MwSVPlXjOIcjErCvPIg43ky80rgpr 8CWswEtNji612QxSWJCCmpBsbye0EVr7PPSU35/nCm25nnQY222SZdq75cTN2wRM4o8esJoeJ nf1sUv+TuyJ/vtftc2V6lVzvdFFLfzDhnnnhQqzbe6zyr6F7+eUGmX+aFOGa89LV95RTGb9s6 RWh+5tYpt5liBNwmRxm/n2V++eV6/shEi403Zq1o9puV0GmZ6FSZ3qlrnq3EUpyRaKjFXFScC ADu6MRTjgIAAA== X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1491054811!37933881!17 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54047 invoked from network); 1 Apr 2017 13:54:20 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-9.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Apr 2017 13:54:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491054860; x=1522590860; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=+72jWFVxW1VxfFiYTGfAMr4Nkhqso5R4frZ9r6nfjlk=; b=b38AnggByUaPCsnk7zpkE0rtrKwXGBSi45aKqwoCduuzD7hpBga2Xg1R 9Ebpocjrr027neWIC0U6W+ETKbegpA==; Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2017 06:54:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,258,1486454400"; d="scan'208";a="950545082" Received: from yisun1-ubuntu.bj.intel.com ([10.238.156.112]) by orsmga003.jf.intel.com with ESMTP; 01 Apr 2017 06:54:17 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Sat, 1 Apr 2017 21:53:47 +0800 Message-Id: <1491054836-30488-17-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1491054836-30488-1-git-send-email-yi.y.sun@linux.intel.com> References: <1491054836-30488-1-git-send-email-yi.y.sun@linux.intel.com> Cc: kevin.tian@intel.com, wei.liu2@citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, he.chen@linux.intel.com, ian.jackson@eu.citrix.com, Yi Sun , mengxu@cis.upenn.edu, jbeulich@suse.com, chao.p.peng@linux.intel.com, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v10 16/25] x86: refactor psr: CDP: implement get value flow. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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(-) 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; }