From patchwork Wed Aug 24 12:43:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 9297623 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 8B6D260757 for ; Wed, 24 Aug 2016 12:45:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CE4A28F6A for ; Wed, 24 Aug 2016 12:45:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7179E28F6D; Wed, 24 Aug 2016 12:45:20 +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 E3ADB28F6A for ; Wed, 24 Aug 2016 12:45:19 +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 1bcXWY-0000PK-0m; Wed, 24 Aug 2016 12:43:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcXWW-0000OW-QL for xen-devel@lists.xenproject.org; Wed, 24 Aug 2016 12:43:16 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 1B/02-28857-4669DB75; Wed, 24 Aug 2016 12:43:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsXSO6nOVddl2t5 wg35ni+9bJjM5MHoc/nCFJYAxijUzLym/IoE14+nhTywFe4Qqul8cY25g/MvbxcjFISQwkUmi 6fME9i5GTiDnL6PE08/GEImNjBLv7y9nhHAaGSUu3FvBBFLFJqAn0Xr+MzOILSKgJHFv1WSwO LOAn0TTrgOsILawgL3Eruv/WUBsFgFVibPtJ8DqeQU8JbaeeQO2TUJATuL88Z9gcU4BL4lbR7 6xQFzhKbFszQZWiBpDic8blzJPYORbwMiwilG9OLWoLLVI10wvqSgzPaMkNzEzR9fQwEwvN7W 4ODE9NScxqVgvOT93EyMwTBiAYAfjvBP+hxglOZiURHnDm/aGC/El5adUZiQWZ8QXleakFh9i lOHgUJLgNZ0KlBMsSk1PrUjLzAEGLExagoNHSYS3ewpQmre4IDG3ODMdInWKUVFKnPcNSEIAJ JFRmgfXBouSS4yyUsK8jECHCPEUpBblZpagyr9iFOdgVBLm/Q8yhSczrwRu+iugxUxAi1vu7w ZZXJKIkJJqYDz+4OG1nEI1i7M8QTbzTflFA05JccxlSn4+Nefo9zWf1/ROPJG44ZJ8emamTap UpdMWw91a349O+sd8pE/FOsQx9YyPqn+QQJbPibS4Jd92zcvfn7nF7c3fP0dUBM9GOYSKX5vS Hack/JBz2+4ZDztruWaVW1m37/6nZGQS/0rmuVRuNwfjNSWW4oxEQy3mouJEAGKw8pCNAgAA X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1472042562!55250282!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 63806 invoked from network); 24 Aug 2016 12:42:43 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-3.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 24 Aug 2016 12:42:43 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u7OCgewC023112 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Aug 2016 12:42:40 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u7OCgd8E002340 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Aug 2016 12:42:39 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u7OCgdEt031293; Wed, 24 Aug 2016 12:42:39 GMT Received: from paddy.lan (/89.114.92.174) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 24 Aug 2016 05:42:39 -0700 From: Joao Martins To: xen-devel@lists.xenproject.org Date: Wed, 24 Aug 2016 13:43:47 +0100 Message-Id: <1472042632-12883-2-git-send-email-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1472042632-12883-1-git-send-email-joao.m.martins@oracle.com> References: <1472042632-12883-1-git-send-email-joao.m.martins@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH v3 1/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-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 --- Cc: Jan Beulich Cc: Andrew Cooper Changes since v2: - Remove pointless intializer and replace it with the platform_time init return. --- 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 b316f23..6750e46 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);