From patchwork Wed Sep 14 17:37:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 9332183 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 4B032607FD for ; Wed, 14 Sep 2016 17:39:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4058D2A246 for ; Wed, 14 Sep 2016 17:39:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 356392A24F; Wed, 14 Sep 2016 17:39: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, UNPARSEABLE_RELAY 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 AD0E42A246 for ; Wed, 14 Sep 2016 17:39: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 1bkE7E-00010C-Kk; Wed, 14 Sep 2016 17:36:56 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkE7D-0000zX-KW for xen-devel@lists.xenproject.org; Wed, 14 Sep 2016 17:36:55 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 58/D9-13744-6BA89D75; Wed, 14 Sep 2016 17:36:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsXSO6nOVXdb181 wg6uHBCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxJz6exFKwVrNh1gruBsZW3i5GLQ0hgMpPE ia13WSGc34wSPS/+M0M4GxklLk1oZuti5ARyGhklDk/WA7HZBPQkWs9/ZgaxRQSUJO6tmswE0 sAs0MEo8eX8KSaQhLCAvcTZ/d9ZQWwWAVWJ3t3HWUBsXgEPia9vdzKC2BICchLnj/8EG8Qp4C nx48ZnFohlHhIHHtxihqgxlmh/e5FtAiPfAkaGVYwaxalFZalFusbGeklFmekZJbmJmTm6hgZ mermpxcWJ6ak5iUnFesn5uZsYgaHCAAQ7GHeuDzzEKMnBpCTKWxp8M1yILyk/pTIjsTgjvqg0 J7X4EKMMB4eSBO+ETqCcYFFqempFWmYOMGhh0hIcPEoivGEgad7igsTc4sx0iNQpRkUpcd4Qk IQASCKjNA+uDRYplxhlpYR5GYEOEeIpSC3KzSxBlX/FKM7BqCTMuwlkCk9mXgnc9FdAi5mAFm 9Zcx1kcUkiQkqqgdFUbvtqm9ubVhfO3SHwI8Pn1iPjafXfN8XeXRWwrv7WtvmByplyl9TWv54 2/WjOm/brNWU7l7MfOpmS83Zx26PTma0yBkp8yYse+bDemNQ2W4Fl9p8GWROllhM/+0uX+0x4 wlmtce63Sp3zJnNdo8t+T41uZgp90I3cv0h+uY9k9epNuw+YOUspsRRnJBpqMRcVJwIAitLmw o8CAAA= X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1473874612!19376138!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6385 invoked from network); 14 Sep 2016 17:36:53 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-2.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 14 Sep 2016 17:36:53 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8EHaoOt014324 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Sep 2016 17:36:51 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id u8EHaob6019098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Sep 2016 17:36:50 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u8EHanbj005511; Wed, 14 Sep 2016 17:36:49 GMT Received: from paddy.lan (/89.114.92.174) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 14 Sep 2016 10:36:49 -0700 From: Joao Martins To: xen-devel@lists.xenproject.org Date: Wed, 14 Sep 2016 18:37:46 +0100 Message-Id: <1473874670-4986-2-git-send-email-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1473874670-4986-1-git-send-email-joao.m.martins@oracle.com> References: <1473874670-4986-1-git-send-email-joao.m.martins@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: Andrew Cooper , Joao Martins , Jan Beulich Subject: [Xen-devel] [PATCH v4 1/5] 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-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 Reviewed-by: Jan Beulich --- xen/arch/x86/time.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 73e0f98..0c1ad45 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -576,6 +576,24 @@ static void resume_platform_timer(void) plt_stamp = plt_src.read_counter(); } +static s64 __init try_platform_timer(struct platform_timesource *pts) +{ + s64 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); + plt_src = *pts; + + return rc; +} + static u64 __init init_platform_timer(void) { static struct platform_timesource * __initdata plt_timers[] = { @@ -593,7 +611,7 @@ static u64 __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; } } @@ -609,21 +627,13 @@ static u64 __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); - plt_src = *pts; - printk("Platform timer is %s %s\n", freq_string(pts->frequency), pts->name);