From patchwork Wed Jun 14 01:12: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: 9785155 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 1129560384 for ; Wed, 14 Jun 2017 01:28:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03AC826E75 for ; Wed, 14 Jun 2017 01:28:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC88928472; Wed, 14 Jun 2017 01:28:17 +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 9DF6C26E75 for ; Wed, 14 Jun 2017 01:28:17 +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 1dKx4J-0007kP-1Y; Wed, 14 Jun 2017 01:25:59 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKx4I-0007j6-3y for xen-devel@lists.xenproject.org; Wed, 14 Jun 2017 01:25:58 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id 45/4F-02181-5A090495; Wed, 14 Jun 2017 01:25:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPLMWRWlGSWpSXmKPExsVywNykWHfRBId Ig5MzrSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozp50sLfopWzGroZmlgPCPQxcjFISQwjVHi 9IN+1i5GTg4JAV6JI8tmQNl+Ek2zbrNBFDUwSpxbNIMJJMEmoC7x+GsPmC0ioCRxb9VkJpAiZ oGdTBLrTn9nBkkIA3Uva9nAAmKzCKhKPP10kBHE5hXwlFiyewoLxAY5iZPHJoNt4wSKd79+Bj ZUSMBD4ueVqUwTGHkXMDKsYtQoTi0qSy3SNTLUSyrKTM8oyU3MzNE1NDDVy00tLk5MT81JTCr WS87P3cQIDIh6BgbGHYx3J/sdYpTkYFIS5V1i5xApxJeUn1KZkVicEV9UmpNafIhRhoNDSYL3 TR9QTrAoNT21Ii0zBxiaMGkJDh4lEd7aNqA0b3FBYm5xZjpE6hSjopQ47ymQPgGQREZpHlwbL B4uMcpKCfMyMjAwCPEUpBblZpagyr9iFOdgVBLmPd4PNIUnM68EbvoroMVMQIuvX7EBWVySiJ CSamC88qhOY0UJg9jTrxayjHkH92fvkjvdFp918t2qD4nhfOVvfgWo/pC3/91+KnBC4OHv3a3 xcvFNM4Rkn6fMenuu2eb2wW2F9z55LhS+/SftYsyM25zldavmnb1s/4Rn02avJRd1GA5eMd14 w/6C+PccfjZRM47iMzvbJK8UTAn5eFfuzozTBuZblFiKMxINtZiLihMBW0UjwYICAAA= X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1497403511!87398197!15 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49452 invoked from network); 14 Jun 2017 01:25:54 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-16.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 14 Jun 2017 01:25:54 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jun 2017 18:25:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,340,1493708400"; d="scan'208";a="99173965" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.64]) by orsmga002.jf.intel.com with ESMTP; 13 Jun 2017 18:25:51 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Wed, 14 Jun 2017 09:12:47 +0800 Message-Id: <1497402776-22348-15-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497402776-22348-1-git-send-email-yi.y.sun@linux.intel.com> References: <1497402776-22348-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 v12 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 Reviewed-by: Jan Beulich --- 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(+) 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,