From patchwork Tue Oct 25 03:40:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9393895 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 681B060762 for ; Tue, 25 Oct 2016 02:36:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AB3128B39 for ; Tue, 25 Oct 2016 02:36:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CD1B2927F; Tue, 25 Oct 2016 02:36:18 +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 ACF5728B39 for ; Tue, 25 Oct 2016 02:36: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 1byrZ4-0004Xq-1d; Tue, 25 Oct 2016 02:34:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1byrZ3-0004Wu-AB for xen-devel@lists.xenproject.org; Tue, 25 Oct 2016 02:34:09 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id B6/E0-28497-0A4CE085; Tue, 25 Oct 2016 02:34:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLLMWRWlGSWpSXmKPExsVywNykWHfBEb4 Ig23bBS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owD97MKNohVHL19l7mBcZdgFyMnh5BAhcT3 yf/ZQWwJAV6JI8tmsELYARJze54ydTFyAdU0MErcePOHESTBJqAu8fhrDxOILSKgJHFv1WSwI maB/YwSv14+ZgFJCAuES1x/0gxkc3CwCKhKvJtfBxLmFfCQ+DH3ONQCOYmTxyaD2ZxA8Tt7j7 NDHOQu0dfQxDiBkXcBI8MqRo3i1KKy1CJdQ3O9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK 95PzcTYzAYGAAgh2MtzcGHGKU5GBSEuWduYkvQogvKT+lMiOxOCO+qDQntfgQowwHh5IE7/rD QDnBotT01Iq0zBxgWMKkJTh4lER4n4CkeYsLEnOLM9MhUqcYFaXEeReBJARAEhmleXBtsFi4x CgrJczLCHSIEE9BalFuZgmq/CtGcQ5GJWHeFyBTeDLzSuCmvwJazAS0WDCeB2RxSSJCSqqBMd ot9U5cxGbm4JRzEvvEH9tJeRmECzDnmV5laJrWEDR16RnBlef1dqcm/7ktuW7uUUdVdudXzFo z5u8+prL4yHaeQulDFz7zvcg/cWLDfL/1C/PcP5smF+49V95ea8Tn21b+2WO31q5vJtU6ySL+ r+a+XnXhPcvLzshkXsfcY9bZ9Stn2p5epcRSnJFoqMVcVJwIAJF9xZ2AAgAA X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1477362814!54875270!11 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.13; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52445 invoked from network); 25 Oct 2016 02:34:07 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-14.tower-27.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 25 Oct 2016 02:34:07 -0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 24 Oct 2016 19:34:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,544,1473145200"; d="scan'208"; a="1049570218" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.60]) by orsmga001.jf.intel.com with ESMTP; 24 Oct 2016 19:34:05 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Tue, 25 Oct 2016 11:40:58 +0800 Message-Id: <1477366863-5246-11-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477366863-5246-1-git-send-email-yi.y.sun@linux.intel.com> References: <1477366863-5246-1-git-send-email-yi.y.sun@linux.intel.com> Cc: wei.liu2@citrix.com, he.chen@linux.intel.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, Yi Sun , jbeulich@suse.com, chao.p.peng@linux.intel.com Subject: [Xen-devel] [PATCH v3 10/15] x86: refactor psr: Implement function to get the max cos_max. 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 When set ASSOC register, we need a cos_mask to calculate the COS ID to set. The cos_mask is calculated by cos_max. When supporting more than one feature, the cos_max to calculate cos_mask should be the max one of all features. This patch implements 'get_max_cos_max' function and the corresponding callback function to get the max cos_max of all features. Signed-off-by: Yi Sun --- xen/arch/x86/psr.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index b8bb09b..fdf4e3a 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -55,6 +55,8 @@ struct feat_ops { /* get_val is used to get feature COS register value. */ int (*get_val)(const struct feat_node *feat, unsigned int cos, enum cbm_type type, uint64_t *val); + /* get_max_cos_max is used to get feature's cos_max. */ + unsigned int (*get_max_cos_max)(const struct feat_node *feat); }; /* CAT/CDP HW info data structure. */ @@ -279,10 +281,16 @@ static int l3_cat_get_val(const struct feat_node *feat, unsigned int cos, return 1; } +static unsigned int l3_cat_get_max_cos_max(const struct feat_node *feat) +{ + return feat->info.cos_max; +} + struct feat_ops l3_cat_ops = { .init_feature = l3_cat_init_feature, .get_feat_info = l3_cat_get_feat_info, .get_val = l3_cat_get_val, + .get_max_cos_max = l3_cat_get_max_cos_max, }; static unsigned int get_socket_cpu(unsigned int socket) @@ -434,6 +442,18 @@ void psr_free_rmid(struct domain *d) d->arch.psr_rmid = 0; } +static inline unsigned int get_max_cos_max( + const struct psr_cat_socket_info *info) +{ + const struct feat_node *feat_tmp; + unsigned int cos_max = 0; + + list_for_each_entry(feat_tmp, &info->feat_list, list) + cos_max = max(feat_tmp->ops.get_max_cos_max(feat_tmp), cos_max); + + return cos_max; +} + static inline void psr_assoc_init(void) { struct psr_assoc *psra = &this_cpu(psr_assoc); @@ -441,16 +461,11 @@ static inline void psr_assoc_init(void) if ( cat_socket_info ) { unsigned int socket = cpu_to_socket(smp_processor_id()); - struct psr_cat_socket_info *info = cat_socket_info + socket; - struct feat_node *feat_tmp; - - feat_tmp = get_feat_l3(info); - if ( !feat_tmp ) - return; + const struct psr_cat_socket_info *info = cat_socket_info + socket; + unsigned int cos_max = get_max_cos_max(info); if ( info->feat_mask ) - psra->cos_mask = ((1ull << get_count_order( - feat_tmp->info.cos_max)) - 1) << 32; + psra->cos_mask = ((1ull << get_count_order(cos_max)) - 1) << 32; } if ( psr_cmt_enabled() || psra->cos_mask )