From patchwork Tue Oct 25 03:40:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9393887 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 B8D1A60762 for ; Tue, 25 Oct 2016 02:36:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC0CD28B39 for ; Tue, 25 Oct 2016 02:36:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A035B2927D; Tue, 25 Oct 2016 02:36:11 +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 663D528B39 for ; Tue, 25 Oct 2016 02:36:10 +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 1byrYn-0004IA-AJ; Tue, 25 Oct 2016 02:33:53 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1byrYl-0004HN-BD for xen-devel@lists.xenproject.org; Tue, 25 Oct 2016 02:33:51 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id F4/DF-08293-E84CE085; Tue, 25 Oct 2016 02:33:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsVywNykWLf3CF+ Ewe9Z1hbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bEc8uYC7YqVMyb+oexgfGVeBcjJ4eQQIXE tin7mUFsCQFeiSPLZrBC2AESZ7ZPYOti5AKqaWCUeLnlPiNIgk1AXeLx1x4mEFtEQEni3qrJT CBFzAL7GSV+vXzMApIQBuqeM/M8O4jNIqAqMW/lGrAGXgF3ifdbGhkhNshJnDw2GWwbp4CHxJ 29x9khLnKX6GtoYpzAyLuAkWEVo0ZxalFZapGuobleUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5 iUrFecn7uJkZgQDAAwQ7G2xsDDjFKcjApifLO3MQXIcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mC d/1hoJxgUWp6akVaZg4wNGHSEhw8SiK8T0DSvMUFibnFmekQqVOMuhxbFtxYyyTEkpeflyolz rsIpEgApCijNA9uBCxOLjHKSgnzMgIdJcRTkFqUm1mCKv+KUZyDUUmY9wXIFJ7MvBK4Ta+Ajm ACOkIwngfkiJJEhJRUA6PcjlPcB4oc2PJqvkv16k/uZ+tV+PdE4r+m4cmYpjNXjuxo4LjHKmm z5Ctfzu28IJ9wy01uLav0p6y423PCLqNV2efFq48fQ3KVq3+GnZ+9nkNqo2hWwN+tEWxLIpPY 6+0tpb4u3XDQZEHCw7/vvmU7rV2kPl89Sr+tXYC1LP/6bF8T0zqOFCWW4oxEQy3mouJEAErOM yWOAgAA X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1477362814!54875270!5 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 49781 invoked from network); 25 Oct 2016 02:33:49 -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:33:49 -0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 24 Oct 2016 19:33:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,544,1473145200"; d="scan'208"; a="1049570109" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.60]) by orsmga001.jf.intel.com with ESMTP; 24 Oct 2016 19:33:47 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Tue, 25 Oct 2016 11:40:52 +0800 Message-Id: <1477366863-5246-5-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 04/15] x86: refactor psr: Encapsulate 'cbm_len' and 'cbm_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 'cbm_len' and 'cbm_max' are CAT/CDP specific feature HW info. So encapsulate them into 'struct psr_cat_hw_info'. If new feature is supported, we can define other structure to save its HW info. Signed-off-by: Yi Sun --- xen/arch/x86/psr.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index a0342ce..97f1c33 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -26,9 +26,14 @@ /* Per spec, the maximum COS register number is 128. */ #define MAX_COS_REG_NUM 128 -struct psr_cat_socket_info { +/* CAT/CDP HW info data structure. */ +struct psr_cat_hw_info { unsigned int cbm_len; unsigned int cos_max; +}; + +struct psr_cat_socket_info { + struct psr_cat_hw_info l3_info; /* * Store the values of COS registers: * CAT uses 1 entry for one COS ID; @@ -235,7 +240,7 @@ static inline void psr_assoc_init(void) if ( test_bit(socket, cat_socket_enable) ) psra->cos_mask = ((1ull << get_count_order( - cat_socket_info[socket].cos_max)) - 1) << 32; + cat_socket_info[socket].l3_info.cos_max)) - 1) << 32; } if ( psr_cmt_enabled() || psra->cos_mask ) @@ -299,8 +304,8 @@ int psr_get_cat_l3_info(unsigned int socket, uint32_t *cbm_len, if ( IS_ERR(info) ) return PTR_ERR(info); - *cbm_len = info->cbm_len; - *cos_max = info->cos_max; + *cbm_len = info->l3_info.cbm_len; + *cos_max = info->l3_info.cos_max; *flags = 0; if ( cdp_is_enabled(socket) ) @@ -465,14 +470,14 @@ int psr_set_l3_cbm(struct domain *d, unsigned int socket, if ( IS_ERR(info) ) return PTR_ERR(info); - if ( !psr_check_cbm(info->cbm_len, cbm) ) + if ( !psr_check_cbm(info->l3_info.cbm_len, cbm) ) return -EINVAL; if ( !cdp_enabled && (type == PSR_CBM_TYPE_L3_CODE || type == PSR_CBM_TYPE_L3_DATA) ) return -ENXIO; - cos_max = info->cos_max; + cos_max = info->l3_info.cos_max; old_cos = d->arch.psr_cos_ids[socket]; ref = info->cos_ref; @@ -617,11 +622,11 @@ static void cat_cpu_init(void) { cpuid_count(PSR_CPUID_LEVEL_CAT, 1, &eax, &ebx, &ecx, &edx); info = cat_socket_info + socket; - info->cbm_len = (eax & 0x1f) + 1; - info->cos_max = min(opt_cos_max, edx & 0xffff); + info->l3_info.cbm_len = (eax & 0x1f) + 1; + info->l3_info.cos_max = min(opt_cos_max, edx & 0xffff); /* cos=0 is reserved as default cbm(all ones). */ - info->cos_reg_val[0] = (1ull << info->cbm_len) - 1; + info->cos_reg_val[0] = (1ull << info->l3_info.cbm_len) - 1; spin_lock_init(&info->ref_lock); @@ -631,23 +636,23 @@ static void cat_cpu_init(void) cdp_socket_enable && !test_bit(socket, cdp_socket_enable) ) { /* CODE */ - get_cdp_code(info, 0) = (1ull << info->cbm_len) - 1; + get_cdp_code(info, 0) = (1ull << info->l3_info.cbm_len) - 1; /* DATA */ - get_cdp_data(info, 0) = (1ull << info->cbm_len) - 1; + get_cdp_data(info, 0) = (1ull << info->l3_info.cbm_len) - 1; /* We only write mask1 since mask0 is always all ones by default. */ - wrmsrl(MSR_IA32_PSR_L3_MASK(1), (1ull << info->cbm_len) - 1); + wrmsrl(MSR_IA32_PSR_L3_MASK(1), (1ull << info->l3_info.cbm_len) - 1); rdmsrl(MSR_IA32_PSR_L3_QOS_CFG, val); wrmsrl(MSR_IA32_PSR_L3_QOS_CFG, val | (1 << PSR_L3_QOS_CDP_ENABLE_BIT)); /* Cut half of cos_max when CDP is enabled. */ - info->cos_max >>= 1; + info->l3_info.cos_max >>= 1; set_bit(socket, cdp_socket_enable); } printk(XENLOG_INFO "CAT: enabled on socket %u, cos_max:%u, cbm_len:%u, CDP:%s\n", - socket, info->cos_max, info->cbm_len, + socket, info->l3_info.cos_max, info->l3_info.cbm_len, cdp_is_enabled(socket) ? "on" : "off"); } }