From patchwork Wed May 3 08:44:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9709033 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 C9DCF60385 for ; Wed, 3 May 2017 08:56:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB8E328602 for ; Wed, 3 May 2017 08:56:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A044528606; Wed, 3 May 2017 08:56:36 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 4243128602 for ; Wed, 3 May 2017 08:56:36 +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 1d5q3E-0000y8-1e; Wed, 03 May 2017 08:54:24 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d5q3C-0000v8-IY for xen-devel@lists.xenproject.org; Wed, 03 May 2017 08:54:22 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id 8B/28-01752-DBA99095; Wed, 03 May 2017 08:54:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPLMWRWlGSWpSXmKPExsXS1tYhobtrFme kwe4TQhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8a+nb9ZC57KVPT13WZtYPwm2sXIxSEkMJ1R YsPL52xdjJwcEgK8EkeWzWCFsP0ldi15ywpR1MAo0X36KlgRm4C6xOOvPUwgtoiAksS9VZOZQ IqYBXYySaw7/Z0ZJCEs4CfxtusWmM0ioCrRfmMvmM0r4CnxuWE31AY5iZPHJoPZnEDx5182so PYQgIeEoeevWeawMi7gJFhFaN6cWpRWWqRrrFeUlFmekZJbmJmjq6hgalebmpxcWJ6ak5iUrF ecn7uJkZgQDAAwQ7Gvf+cDjFKcjApifKqv2KPFOJLyk+pzEgszogvKs1JLT7EKMPBoSTB+3Am Z6SQYFFqempFWmYOMDRh0hIcPEoivF0gad7igsTc4sx0iNQpRkUpcd7pIAkBkERGaR5cGyweL jHKSgnzMgIdIsRTkFqUm1mCKv+KUZyDUUmYNxlkCk9mXgnc9FdAi5mAFjfLcoAsLklESEk1MN r1PHwieSdwkmNVgeif2QY3vq68djrxhfjTC4tLFa90bVe+8fuEqM3suCX3Z0V9DPmkZvxp1uZ AGwXDGD4LjmeS1dP7jRsYk/m7lzoq7OO633VylYzV2rzq4JkPjqx3Omy2gH+G3OL/c10qZ2Ra yC9MyZ4mtHP7rBLr9cvDZ5Q66CbxnPizOVKJpTgj0VCLuag4EQBzHeCUggIAAA== X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1493801620!75519330!15 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12060 invoked from network); 3 May 2017 08:54:16 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-2.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 3 May 2017 08:54:16 -0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2017 01:54:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,283,1491289200"; d="scan'208";a="852347649" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.39]) by FMSMGA003.fm.intel.com with ESMTP; 03 May 2017 01:54:13 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Wed, 3 May 2017 16:44:14 +0800 Message-Id: <1493801063-38513-15-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1493801063-38513-1-git-send-email-yi.y.sun@linux.intel.com> References: <1493801063-38513-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 v11 14/23] x86: refactor psr: CDP: implement get hw info 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 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 --- 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 | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index 7000d95..55ac221 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -207,7 +207,9 @@ static void free_socket_resources(unsigned int socket) memset(info->dom_ids, 0, ((DOMID_IDLE + 1) + 7) / 8); } -static enum psr_feat_type psr_cbm_type_to_feat_type(enum cbm_type type) +static enum psr_feat_type psr_cbm_type_to_feat_type( + const struct psr_socket_info *info, + enum cbm_type type) { enum psr_feat_type feat_type = PSR_SOCKET_FEAT_UNKNOWN; @@ -215,7 +217,18 @@ 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 feature array, try CDP. */ + if ( !info->features[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(); } @@ -328,8 +341,20 @@ static 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 struct feat_props l3_cdp_props = { .cos_num = 2, + .get_feat_info = l3_cdp_get_feat_info, }; static void __init parse_psr_bool(char *s, char *value, char *feature, @@ -574,7 +599,7 @@ static struct feat_node *psr_get_feat_and_type(unsigned int socket, if ( IS_ERR(info) ) return ERR_PTR(PTR_ERR(info)); - *feat_type = psr_cbm_type_to_feat_type(type); + *feat_type = psr_cbm_type_to_feat_type(info, type); if ( *feat_type >= ARRAY_SIZE(info->features) ) return NULL; @@ -1040,7 +1065,7 @@ int psr_set_val(struct domain *d, unsigned int socket, val = new_val; - feat_type = psr_cbm_type_to_feat_type(type); + feat_type = psr_cbm_type_to_feat_type(info, type); if ( feat_type >= ARRAY_SIZE(info->features) || !info->features[feat_type] ) return -ENOENT;