From patchwork Thu Jul 6 01:53:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9827449 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 475FC602BD for ; Thu, 6 Jul 2017 02:09:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 374E1285C9 for ; Thu, 6 Jul 2017 02:09:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C1AA285CB; Thu, 6 Jul 2017 02:09:25 +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 CF608285C9 for ; Thu, 6 Jul 2017 02:09:23 +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 1dSwCP-00011T-NT; Thu, 06 Jul 2017 02:07:21 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSwCO-0000zm-IT for xen-devel@lists.xenproject.org; Thu, 06 Jul 2017 02:07:20 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id 25/64-03582-75B9D595; Thu, 06 Jul 2017 02:07:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsXS1tYhrxs+Ozb S4NVhIYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPB4R7GgkNiFf9WNbM0MHYJdjFycggJVEr8 XPCSEcSWEOCVOLJsBiuEHSDRvPwGcxcjF1BNA6PEhodzmUESbALqEo+/9jCB2CICShL3Vk1mA iliFpjPJPH6/AOwImEBP4lz8+cCTeXgYBFQlZgxhQMkzCvgKbG25TszxAI5iZPHJoMt4wSKH7 nazA5xkIfExvbXTBMYeRcwMqxi1ChOLSpLLdI1tNRLKspMzyjJTczM0TU0MNPLTS0uTkxPzUl MKtZLzs/dxAgMBwYg2MH4Y1nAIUZJDiYlUd4/+rGRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4 dWYB5QSLUtNTK9Iyc4CBCZOW4OBREuFdLQyU5i0uSMwtzkyHSJ1i1OV4NeH/NyYhlrz8vFQpc V57kBkCIEUZpXlwI2BRcolRVkqYlxHoKCGegtSi3MwSVPlXjOIcjErCvMEgU3gy80rgNr0COo IJ6AjFxhiQI0oSEVJSDYxa2y6qGOTOFvDV4Ai/kMSUe3FHUEWWpY9+RD+jxrpKl7eWqhyTzp+ d43847n2YpV1Y14UCy1v2Cnm3Vgf2HdFa4X9U7FBKi9H7ihT9yZs+dW9deeZK/MKNs9aGdCfM d11fHGk3Q4kjTEtV+Pz1k+wSWYZ75rkJxVg41+xL4l3XYndQcvW2NUosxRmJhlrMRcWJANDQB O6NAgAA X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1499306837!105490986!1 X-Originating-IP: [134.134.136.31] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34422 invoked from network); 6 Jul 2017 02:07:18 -0000 Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by server-3.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 6 Jul 2017 02:07:18 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP; 05 Jul 2017 19:07:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.40,314,1496127600"; d="scan'208"; a="1191048105" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.80]) by fmsmga002.fm.intel.com with ESMTP; 05 Jul 2017 19:07:13 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Thu, 6 Jul 2017 09:53:07 +0800 Message-Id: <1499305996-19029-15-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499305996-19029-1-git-send-email-yi.y.sun@linux.intel.com> References: <1499305996-19029-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, 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 v13 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 13d5c2f..46b8d32 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -223,7 +223,21 @@ static enum psr_feat_type psr_cbm_type_to_feat_type(enum cbm_type type) { case PSR_CBM_TYPE_L3: feat_type = FEAT_TYPE_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 = FEAT_TYPE_L3_CDP; + break; + + case PSR_CBM_TYPE_L3_DATA: + case PSR_CBM_TYPE_L3_CODE: + feat_type = FEAT_TYPE_L3_CDP; + break; + default: ASSERT_UNREACHABLE(); } @@ -348,11 +362,23 @@ 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, .alt_type = FEAT_TYPE_L3_CAT, + .get_feat_info = l3_cdp_get_feat_info, }; static void __init parse_psr_bool(char *s, char *value, char *feature,