From patchwork Tue Nov 20 14:43:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 10690561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6C6214E2 for ; Tue, 20 Nov 2018 15:51:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3AE62AA20 for ; Tue, 20 Nov 2018 15:51:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97F862AA40; Tue, 20 Nov 2018 15:51:49 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 596C12AA20 for ; Tue, 20 Nov 2018 15:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UjfU3S2st0DMnrCt37cnuGYNt79BAmd63xH4b4N/qCs=; b=j83S67ZDsrt7cF T6L78hUxiHLGVz3C4EWks1gP+knekxJl1XFEWZewGG02UnzcRuCc4jiqJYBwSU0E3vj+JctH7yJoo sWqL2YG60zpH2HvSfKhx2vZWCs+oVBpDZS5HGT3SaJGRrjCo1qHy+snfh18QlfiC/iG4XfEjEQ7Ze zqaVroNBhkVDVrm6Kpj/ckzR9IRTpOclQ6v3myC+4sZrgnsO5DOT+mgvAWEh3xpfbSD4yawtoI5Cf ddYhNhr8SHXhNN2KxsTwBXHVwtEX/5Ym+QHCG1MmNBlj3B85skkg6XN2m2VbJaD1XibFT2j6KE9sO obSenQlS6MAhAoo0PRdw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP8JQ-0001H4-Pd; Tue, 20 Nov 2018 15:51:40 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP8Fl-0003nl-Qk for linux-arm-kernel@bombadil.infradead.org; Tue, 20 Nov 2018 15:47:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=UnUiGYEW/uorxQqYZvnlVGMF6D60RaYNRJLOaXoi1RI=; b=1bqfscEQSbD32dEvd4TQqmDOem v985/uOkKNw+GiU76tEWZalUN4qamkjP5/RYug7kRQAjL7m5PdLk3C0alYrG4wt0/AlqCeykJ7Syx M32XLCSzj51YdIqsUU5XcMN2CK4Y9Oxukj9+i+WH0AHM/3Gayu9Xr84YHAiaZBnOiA9gq8Pj2eZHi 2/XYhRARwjcTAPTYDGLFcASyyJvZkpI/FAb2QG4n4+AjDOgMUGdcr5n+SJhVtU442EvxiJh/R01Bz cbIeda9bACmlpJkOhQ/RjASK/+Y4kfQA0mza9aOZ2lRxFffa66it/EvUaCTtfeJ6hpAdpMKm99z8G Gv/xzrYw==; Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP7Gw-0000Lk-OI for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2018 14:45:03 +0000 Received: by mail-qt1-x841.google.com with SMTP id z16so215500qtq.4 for ; Tue, 20 Nov 2018 06:44:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UnUiGYEW/uorxQqYZvnlVGMF6D60RaYNRJLOaXoi1RI=; b=Q0Csj2ycF8fRsLX8Pv9j2xgiid/1Ru+mS26mzYWc9Rqd+LhMBknNqNSwldrlwISN42 dme5Fn8G5HF6/tWQAgCDnSQMVt8M/zvBATnyS8xSgGAtHwFhQPKkdwXIOxvwvAxBrubC RzLJKvfZUlgzs4IOtsJHOPsJU7M0wkvTEI8ZKM/sBrrMbOyr/gyAo2Apf4XAuZczEZIf AtDfyAnBpvVpUdCUOcY/VY082n7N1h+/HNjXj/c57Gw2c6HnQdG1fFtD3O3r//CqBwtB bIYLsPCitkbBfYmT7UYxP6npoPo1qrVuAL6AF/G0HVHX2fT+0nONHOPaHimEyDAAgiAV afeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UnUiGYEW/uorxQqYZvnlVGMF6D60RaYNRJLOaXoi1RI=; b=BLl626ExG7Tkqlaom+/WJ70lVvNczzvrqzi1NW+tG6jBCAfbdA/SnG+CZkr10qnSe5 4noGKR8moLpA/2ycigM2fyZAJm13b19YrUOFMuZibwL8lx00b5suJIkTTNwcXDVKm6it 44XLCSmE93xUYhF4ajRMuSJiptmWhomfOlLb7n93FUxu+g+e/Fooo700Q/CvI8DEeD3K rsvwQCICBK1mMKdCXNNSTvFyo+V6xcpgeBvj30YWx025zOaQlk9mtcXUiVC7PGHlsiqk Ys3X1TKyG/NpA0sz4Bgrtg0KYjCAFMFKyOgS3mozelemZ5ij4n7xPrR2niOFZOJ5p3po Yr9g== X-Gm-Message-State: AGRZ1gLbHa1YRvW7TFxbVgo0DE76rHyLoXCpgBJtnuK57PQKVVB/gI4X w3nwwHaRlxwneNKwTZpHLtRXRA== X-Google-Smtp-Source: AJdET5cxsokrFGpnfQ4BuyinKwn/hrQ7XnF55wUdZ+Qy+y5Wm/oHdCvdHOgaukdEf10H33w86/7PYw== X-Received: by 2002:ac8:75cc:: with SMTP id z12mr2032847qtq.249.1542725025345; Tue, 20 Nov 2018 06:43:45 -0800 (PST) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id r16sm30046529qkh.71.2018.11.20.06.43.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 06:43:44 -0800 (PST) From: Pavel Tatashin To: catalin.marinas@arm.com, will.deacon@arm.com, akpm@linux-foundation.org, rppt@linux.vnet.ibm.com, mhocko@suse.com, ard.biesheuvel@linaro.org, andrew.murray@arm.com, james.morse@arm.com, marc.zyngier@arm.com, sboyd@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com Subject: [PATCH v2 1/1] arm64: Early boot time stamps Date: Tue, 20 Nov 2018 09:43:40 -0500 Message-Id: <20181120144340.30201-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120144340.30201-1-pasha.tatashin@soleen.com> References: <20181120144340.30201-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181120_094502_799234_089C49B8 X-CRM114-Status: GOOD ( 18.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Allow printk time stamps/sched_clock() to be available from the early boot. Signed-off-by: Pavel Tatashin --- arch/arm64/kernel/setup.c | 25 +++++++++++++++++++++++++ drivers/clocksource/arm_arch_timer.c | 8 ++++---- include/clocksource/arm_arch_timer.h | 3 +++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index f4fc1e0544b7..7a43e63b737b 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -279,8 +280,32 @@ arch_initcall(reserve_memblock_reserved_regions); u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID }; +/* + * Get time stamps available early in boot, useful to identify boot time issues + * from the early boot. + */ +static __init void sched_clock_early_init(void) +{ + u64 freq = arch_timer_get_cntfrq(); + + /* + * The arm64 boot protocol mandates that CNTFRQ_EL0 reflects + * the timer frequency. To avoid breakage on misconfigured + * systems, do not register the early sched_clock if the + * programmed value if zero. Other random values will just + * result in random output. + */ + if (!freq) + return; + + arch_timer_read_counter = arch_counter_get_cntvct; + sched_clock_register(arch_timer_read_counter, ARCH_TIMER_NBITS, freq); +} + void __init setup_arch(char **cmdline_p) { + sched_clock_early_init(); + init_mm.start_code = (unsigned long) _text; init_mm.end_code = (unsigned long) _etext; init_mm.end_data = (unsigned long) _edata; diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 9a7d4dc00b6e..e4843ad48bd3 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -175,13 +175,13 @@ static struct clocksource clocksource_counter = { .name = "arch_sys_counter", .rating = 400, .read = arch_counter_read, - .mask = CLOCKSOURCE_MASK(56), + .mask = CLOCKSOURCE_MASK(ARCH_TIMER_NBITS), .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; static struct cyclecounter cyclecounter __ro_after_init = { .read = arch_counter_read_cc, - .mask = CLOCKSOURCE_MASK(56), + .mask = CLOCKSOURCE_MASK(ARCH_TIMER_NBITS), }; struct ate_acpi_oem_info { @@ -963,8 +963,8 @@ static void __init arch_counter_register(unsigned type) timecounter_init(&arch_timer_kvm_info.timecounter, &cyclecounter, start_count); - /* 56 bits minimum, so we assume worst case rollover */ - sched_clock_register(arch_timer_read_counter, 56, arch_timer_rate); + sched_clock_register(arch_timer_read_counter, ARCH_TIMER_NBITS, + arch_timer_rate); } static void arch_timer_stop(struct clock_event_device *clk) diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h index 349e5957c949..c485512e1d01 100644 --- a/include/clocksource/arm_arch_timer.h +++ b/include/clocksource/arm_arch_timer.h @@ -71,6 +71,9 @@ enum arch_timer_spi_nr { #define ARCH_TIMER_EVT_STREAM_FREQ \ (USEC_PER_SEC / ARCH_TIMER_EVT_STREAM_PERIOD_US) +/* 56 bits minimum, so we assume worst case rollover */ +#define ARCH_TIMER_NBITS 56 + struct arch_timer_kvm_info { struct timecounter timecounter; int virtual_irq;