From patchwork Tue Jan 10 07:42:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9506637 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 F38EC606E1 for ; Tue, 10 Jan 2017 07:45:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7B3628156 for ; Tue, 10 Jan 2017 07:45:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC97A28497; Tue, 10 Jan 2017 07:45:47 +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 7F67728156 for ; Tue, 10 Jan 2017 07:45:47 +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 1cQr5w-000439-Mq; Tue, 10 Jan 2017 07:43:48 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQr5v-00041w-BO for xen-devel@lists.xenproject.org; Tue, 10 Jan 2017 07:43:47 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id 0A/77-25093-2B094785; Tue, 10 Jan 2017 07:43:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRWlGSWpSXmKPExsVywNykWHfThJI Ig1Pr2Cy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyOxbUFfXIV3c8nMDUwbhPrYuTkEBKolLj8 dAMjiC0hwCtxZNkMVgjbX2JJfxdLFyMXUE0Do8SHf2uYQBJsAuoSj7/2gNkiAkoS91ZNZgIpY hbYzygx//hxZpCEsICtxIwZLWCTWARUJdpbXrOA2LwC7hLH+qawQWyQkzh5bDJYDaeAh0TL1X WMEBe5SzS/vc84gZF3ASPDKkaN4tSistQiXWNjvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKR iveT83E2MwHBgAIIdjDvXBx5ilORgUhLlTdEtiRDiS8pPqcxILM6ILyrNSS0+xCjDwaEkwfu1 HygnWJSanlqRlpkDDEyYtAQHj5IILwtImre4IDG3ODMdInWKUVFKnHcvSEIAJJFRmgfXBouGS 4yyUsK8jECHCPEUpBblZpagyr9iFOdgVBLmZQeZwpOZVwI3/RXQYiagxZF2xSCLSxIRUlINjI 9esrXt3iCdeMyCV19GV6EiPW19ZN2EB42/NU9H1PexLZ68jks7/fV5rtU+m2t2Ptkee/fB8XR +CSnbU2JGXAuV612F8jN28st6mJkY+J92vzVtmsWMl2uc3TRmNi7eeHCK9aY0az2HF8/6Q8Ps FXeIy+i0dkaXaa7tm7Fet4dpfWZ9z5JMJZbijERDLeai4kQAtBk2EYECAAA= X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1484034222!51795053!2 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15230 invoked from network); 10 Jan 2017 07:43:45 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-11.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 10 Jan 2017 07:43:45 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 09 Jan 2017 23:43:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,343,1477983600"; d="scan'208";a="211583087" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.63]) by fmsmga004.fm.intel.com with ESMTP; 09 Jan 2017 23:43:32 -0800 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Tue, 10 Jan 2017 15:42:26 +0800 Message-Id: <1484034155-4521-8-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1484034155-4521-1-git-send-email-yi.y.sun@linux.intel.com> References: <1484034155-4521-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] [RFC 07/16] x86: implement get hw info flow for MBA. 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 MBA including its callback function and sysctl interface. Signed-off-by: Yi Sun --- xen/arch/x86/psr.c | 15 +++++++++++++++ xen/arch/x86/sysctl.c | 16 ++++++++++++++++ xen/include/asm-x86/psr.h | 3 +++ xen/include/public/sysctl.h | 8 ++++++++ 4 files changed, 42 insertions(+) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index e2ca6fb..52452a7 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -984,9 +984,24 @@ static unsigned int mba_get_max_cos_max(const struct feat_node *feat) return feat->info.mba_info.cos_max; } +static bool mba_get_feat_info(const struct feat_node *feat, + enum psr_val_type type, + uint32_t dat[], uint32_t array_len) +{ + if ( !dat || 3 > array_len || type != PSR_VAL_TYPE_MBA ) + return false; + + dat[THRTL_MAX] = feat->info.mba_info.thrtl_max; + dat[COS_MAX] = feat->info.mba_info.cos_max; + dat[LINEAR] = feat->info.mba_info.linear; + + return true; +} + struct feat_ops mba_ops = { .init_feature = mba_init_feature, .get_max_cos_max = mba_get_max_cos_max, + .get_feat_info = mba_get_feat_info, }; static void __init parse_psr_bool(char *s, char *value, char *feature, diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 739909b..3dd0aa3 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -222,6 +222,22 @@ long arch_do_sysctl( ret = -EFAULT; break; } + case XEN_SYSCTL_PSR_MBA_get_info: + { + uint32_t dat[3]; + ret = psr_get_info(sysctl->u.psr_alloc_op.target, + PSR_VAL_TYPE_MBA, dat, 3); + if ( ret ) + break; + + sysctl->u.psr_alloc_op.u.mba_info.thrtl_max = dat[THRTL_MAX]; + sysctl->u.psr_alloc_op.u.mba_info.cos_max = dat[COS_MAX]; + sysctl->u.psr_alloc_op.u.mba_info.linear = dat[LINEAR]; + + if ( !ret && __copy_field_to_guest(u_sysctl, sysctl, u.psr_alloc_op) ) + ret = -EFAULT; + break; + } default: ret = -EOPNOTSUPP; break; diff --git a/xen/include/asm-x86/psr.h b/xen/include/asm-x86/psr.h index 9dd7782..a37abdf 100644 --- a/xen/include/asm-x86/psr.h +++ b/xen/include/asm-x86/psr.h @@ -39,6 +39,8 @@ #define CBM_LEN 0 #define COS_MAX 1 #define CDP_FLAG 2 +#define THRTL_MAX 0 +#define LINEAR 2 struct psr_cmt_l3 { unsigned int features; @@ -58,6 +60,7 @@ enum psr_val_type { PSR_VAL_TYPE_L3_CODE, PSR_VAL_TYPE_L3_DATA, PSR_VAL_TYPE_L2, + PSR_VAL_TYPE_MBA, }; extern struct psr_cmt *psr_cmt; diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 71edcf0..f14c921 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -745,6 +745,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_pcitopoinfo_t); #define XEN_SYSCTL_PSR_CAT_get_l3_info 0 #define XEN_SYSCTL_PSR_CAT_get_l2_info 1 +#define XEN_SYSCTL_PSR_MBA_get_info 2 struct xen_sysctl_psr_alloc_op { uint32_t cmd; /* IN: XEN_SYSCTL_PSR_* */ uint32_t target; /* IN */ @@ -760,6 +761,13 @@ struct xen_sysctl_psr_alloc_op { uint32_t cbm_len; /* OUT: CBM length */ uint32_t cos_max; /* OUT: Maximum COS */ } l2_info; + + struct { + uint32_t thrtl_max; /* OUT: Maximum throttle */ + uint32_t cos_max; /* OUT: Maximum COS */ +#define XEN_SYSCTL_PSR_MBA_LINEAR (1u << 0) + uint32_t linear; /* OUT: Linear mode */ + } mba_info; } u; }; typedef struct xen_sysctl_psr_alloc_op xen_sysctl_psr_alloc_op_t;