From patchwork Sat Apr 1 13:53:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9657937 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 C2CED60349 for ; Sat, 1 Apr 2017 13:55:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7840285C2 for ; Sat, 1 Apr 2017 13:55:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A969E28610; Sat, 1 Apr 2017 13:55:57 +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 1CCDF285C2 for ; Sat, 1 Apr 2017 13:55:57 +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 1cuJTw-0005zo-Ku; Sat, 01 Apr 2017 13:54:20 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cuJTv-0005yT-Gw for xen-devel@lists.xenproject.org; Sat, 01 Apr 2017 13:54:19 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 06/F0-23854-A01BFD85; Sat, 01 Apr 2017 13:54:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsXS1tYhosu18X6 Ewe4pQhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bqR73MBQtEK7pPLmVqYOwS6GLk4mARuMUk 0fRpHVsXIyeHkMA0RonJjckgtoQAr8SRZTNYIWx/iSm71zND1NRLHPy3mQnEZhNQl3j8tQfMF hFQkri3ajITyFBmgZ1MEutOfwdrEBbwk9h7/zfYIBYBVYm5U3eBLeMV8JTY336OCWKBnMTJY5 PBajiB4lde7GOBWOYhsWrSJeYJjHwLGBlWMWoUpxaVpRbpGlroJRVlpmeU5CZm5ugaGhjr5aY WFyemp+YkJhXrJefnbmIEBko9AwPjDsbfpz0PMUpyMCmJ8n4vvhchxJeUn1KZkVicEV9UmpNa fIhRhoNDSYJXYcP9CCHBotT01Iq0zBxgyMKkJTh4lER4j60HSvMWFyTmFmemQ6ROMSpKifOmg vQJgCQySvPg2mBxcolRVkqYl5GBgUGIpyC1KDezBFX+FaM4B6OSMK88yHiezLwSuOmvgBYzAS 22+HoXZHFJIkJKqoGRXdryz63lwXMucNfJij8Wfv41snJZ/CNZNZsqq28de7UnzjHQF1me4Jn icIV73j7Fwmuvv2hoePv+7Db4eW89z8qKqLwjRooeijK9NppeK8I33c7XMX+zwzliUUX1zwsv Sk5t812U9O6tB8N9JwbWlDUrO7bKtN+0TVOqej3BgGnmCoevPpZKLMUZiYZazEXFiQCQdviCj gIAAA== X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1491054811!37933881!16 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 53924 invoked from network); 1 Apr 2017 13:54:17 -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:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491054857; x=1522590857; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Uh60uIJIP+55GvBNnmgQOyn+TYmJatNS6VTyZNfNRYs=; b=smHUvSSDi6KTyCxxvAth4Qi2APcIcAgMc8mtKryecL2TDGZE6sLzOGVb XEdpAwKcZfYvU+gl9MK++7PTnWmMAQ==; 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:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,258,1486454400"; d="scan'208";a="950545025" Received: from yisun1-ubuntu.bj.intel.com ([10.238.156.112]) by orsmga003.jf.intel.com with ESMTP; 01 Apr 2017 06:54:14 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Sat, 1 Apr 2017 21:53:46 +0800 Message-Id: <1491054836-30488-16-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 15/25] 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 --- 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index 58970fa..f0611ad 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -237,6 +237,10 @@ 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; break; + case PSR_CBM_TYPE_L3_DATA: + case PSR_CBM_TYPE_L3_CODE: + feat_type = PSR_SOCKET_L3_CDP; + break; default: ASSERT_UNREACHABLE(); } @@ -386,8 +390,20 @@ static struct feat_props l3_cat_props = { }; /* L3 CDP ops */ +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, @@ -641,6 +657,14 @@ int psr_get_info(unsigned int socket, enum cbm_type type, if ( IS_ERR(feat) ) return PTR_ERR(feat); + /* If type is L3 CAT but we cannot find it in feature array, try CDP. */ + if ( !feat && type == PSR_CBM_TYPE_L3 ) + { + feat = psr_get_feat(socket, PSR_CBM_TYPE_L3_CODE); + if ( IS_ERR(feat) ) + return PTR_ERR(feat); + } + if ( !feat ) return -ENOENT;