From patchwork Tue Mar 29 13:44:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 8687291 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D94D79F36E for ; Tue, 29 Mar 2016 13:46:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 05E5320154 for ; Tue, 29 Mar 2016 13:46:56 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id C94532014A for ; Tue, 29 Mar 2016 13:46:52 +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 1aktwc-0007PR-Dr; Tue, 29 Mar 2016 13:44:30 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aktwa-0007PL-Vi for xen-devel@lists.xen.org; Tue, 29 Mar 2016 13:44:29 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 04/ED-03814-CB68AF65; Tue, 29 Mar 2016 13:44:28 +0000 X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1459259065!31843562!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8764 invoked from network); 29 Mar 2016 13:44:27 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-10.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 29 Mar 2016 13:44:27 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u2TDiNLq012327 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 29 Mar 2016 13:44:24 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u2TDiNgw017073 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 29 Mar 2016 13:44:23 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u2TDiMTX008187; Tue, 29 Mar 2016 13:44:22 GMT Received: from localhost.localdomain (/193.126.154.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 29 Mar 2016 06:44:22 -0700 From: Joao Martins To: xen-devel@lists.xen.org Date: Tue, 29 Mar 2016 14:44:07 +0100 Message-Id: <1459259051-4943-3-git-send-email-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1459259051-4943-1-git-send-email-joao.m.martins@oracle.com> References: <1459259051-4943-1-git-send-email-joao.m.martins@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: Andrew Cooper , Joao Martins , Keir Fraser , Jan Beulich Subject: [Xen-devel] [PATCH v2 2/6] x86/time: refactor init_platform_time() 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP And accomodate platform time source initialization in try_platform_time(). This is a preparatory patch for deferring TSC clocksource initialization to the stage where all CPUS are up (verify_tsc_reliability init call). Signed-off-by: Joao Martins Reviewed-by: Konrad Rzeszutek Wilk --- Cc: Keir Fraser Cc: Jan Beulich Cc: Andrew Cooper New in v2. --- xen/arch/x86/time.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 687e39b..ed4ed24 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -533,6 +533,30 @@ static void resume_platform_timer(void) plt_stamp = plt_src.read_counter(); } +static int __init try_platform_timer(struct platform_timesource *pts) +{ + int rc = -1; + + rc = pts->init(pts); + if ( rc <= 0 ) + return rc; + + plt_mask = (u64)~0ull >> (64 - pts->counter_bits); + + set_time_scale(&plt_scale, pts->frequency); + + plt_overflow_period = scale_delta( + 1ull << (pts->counter_bits - 1), &plt_scale); + init_timer(&plt_overflow_timer, plt_overflow, NULL, 0); + plt_src = *pts; + plt_overflow(NULL); + + platform_timer_stamp = plt_stamp64; + stime_platform_stamp = NOW(); + + return rc; +} + static void __init init_platform_timer(void) { static struct platform_timesource * __initdata plt_timers[] = { @@ -549,7 +573,7 @@ static void __init init_platform_timer(void) pts = plt_timers[i]; if ( !strcmp(opt_clocksource, pts->id) ) { - rc = pts->init(pts); + rc = try_platform_timer(pts); break; } } @@ -565,26 +589,13 @@ static void __init init_platform_timer(void) for ( i = 0; i < ARRAY_SIZE(plt_timers); i++ ) { pts = plt_timers[i]; - if ( (rc = pts->init(pts)) > 0 ) + if ( (rc = try_platform_timer(pts)) > 0 ) break; } } BUG_ON(rc <= 0); - plt_mask = (u64)~0ull >> (64 - pts->counter_bits); - - set_time_scale(&plt_scale, pts->frequency); - - plt_overflow_period = scale_delta( - 1ull << (pts->counter_bits-1), &plt_scale); - init_timer(&plt_overflow_timer, plt_overflow, NULL, 0); - plt_src = *pts; - plt_overflow(NULL); - - platform_timer_stamp = plt_stamp64; - stime_platform_stamp = NOW(); - printk("Platform timer is %s %s\n", freq_string(pts->frequency), pts->name); }