From patchwork Mon Oct 23 09:58:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 10022291 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 E19D0601E8 for ; Mon, 23 Oct 2017 10:02:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D016B2818A for ; Mon, 23 Oct 2017 10:02:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3D8E28824; Mon, 23 Oct 2017 10:02:00 +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,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 4F5492818A for ; Mon, 23 Oct 2017 10:02:00 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=4b9QKof6m4/tCVeDd9BD/QPVEIxzFMLhTBdo1Xzwro0=; b=CNFgLtZhvxXgcgJ3CGla4n9Q5Q EjvufgtGAlOs9PrxfSteJVkAF03qG/Nm6vDXG8RUl9aieHB85w+pqel2N3JrvPNtwFm9hk7LbPxV3 l3YNctyuPafsXj6b5jPrZ2nouqgTXFCEhkVfIAVjw13A6wTKGcb0eU19L4tRGbOaFlR3jg2Qnr/b/ RrEOmZP5zywxJrYthLDWhOJs+hmVvMeZmGCWQNn6tdwabWsR52y7w6wmlQeIQfFjEArMnDvY8/MpL UL4gSYGBeMf6antZjaE5iOup9sRObl3h4UrQSOJ414mg8QZ4itQiUdYGCjlgEk7JT4LHOMu/2awxP IiBpY8zQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e6ZYP-0001pv-9I; Mon, 23 Oct 2017 10:01:53 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e6ZWg-0007fp-H1 for linux-arm-kernel@lists.infradead.org; Mon, 23 Oct 2017 10:00:13 +0000 Received: by mail-wr0-x244.google.com with SMTP id l8so3843475wre.12 for ; Mon, 23 Oct 2017 02:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PBuftzBNZ8pv3WBT1kU/v6f4WslKfi8lGTuTBIvTL/g=; b=a5AanEZEdACVJBZ00h16dg2G8EvY4njKQo9RWTnGgp9IoNjNzM/3lCdGA1p6hY+EW+ mmdMeX/026FkNSs/30k18jQ8q2kMX6XpMLc2HaBRVBwyX8nybZS0AxQ3RmhZLyrDnNM7 uqnjDmCb1Lrll9qv8+d8LSZOu2Wog3OpxSUr8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PBuftzBNZ8pv3WBT1kU/v6f4WslKfi8lGTuTBIvTL/g=; b=OatETNRNL/m469IjoZ+qCTmO8X9uHXEcl15UcECwtgsbBVk+u+Z7waQG0pKpy0JmbX nn2adMv0+vUtghwq17g/yboaivMSt4qfebeAeTJX4eUpgX40TyvnkR4pJbKpbrbYZPGa ym7gwy+Pjxarop4wi6boBAfi9ijWHKQ4qzWdDHoohAQNJcNb7K+P4plM8+K3lTCHSrKp Wqf0f/BGicIwNN1ysPq9VgUUIDyvAx4xxRqZT88CW5b6Xrz8WcDVz/i6c4ygoqflYtpt 7vXdP+RQ0Y0CICKW+d/MkKkIA/quv7fHmNsGPFQ89uCPjloi5WaHqJ0I/qNW9ZPuuhdf f9bw== X-Gm-Message-State: AMCzsaXiT5eUT0hpHUyFMWJHqBReJ5cXXUb4NPj3bVixGIvPoWe61ahV dNZvV7Uqir2P2GwA2uS5eu3Cv6e5tn0= X-Google-Smtp-Source: ABhQp+Ttr+Q6K1Ru+iZCaoRzcqdf5weDUiPRiOEwSTuuZkE+bvCiom34gzEhLKRuaxHVqY47uA+xdA== X-Received: by 10.223.162.139 with SMTP id s11mr11121101wra.231.1508752785736; Mon, 23 Oct 2017 02:59:45 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.214.127.33]) by smtp.gmail.com with ESMTPSA id q188sm3626900wmb.43.2017.10.23.02.59.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Oct 2017 02:59:45 -0700 (PDT) From: Benjamin Gaignard To: robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, daniel.lezcano@linaro.org, tglx@linutronix.de, ludovic.barre@st.com, julien.thierry@arm.com Subject: [PATCH v7 4/6] clocksource: stm32: only use 32 bits timers Date: Mon, 23 Oct 2017 11:58:40 +0200 Message-Id: <1508752722-4489-5-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508752722-4489-1-git-send-email-benjamin.gaignard@linaro.org> References: <1508752722-4489-1-git-send-email-benjamin.gaignard@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171023_030006_753472_30D6DD8D X-CRM114-Status: GOOD ( 13.72 ) 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: , Cc: devicetree@vger.kernel.org, Benjamin Gaignard , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 The clock driving counters is at 90MHz so resolution is 11 ns and wrap depends of the number of bits of the counter. For 32 bits counters the wrap time is around 21 seconds while for 16 bits it is around 0.3 ms which is really to short to be used. If a 16 bits counter become used it could block boot sequence or later make hang calls to bash functions like sleep. This patch remove 16 bits counters support and makes sure that they won't be probed anymore. The boot log of 32, 16 bits counters and arm system timer (24 bits) that give more details about wraps, resolution and idle time. sched_clock: 32 bits at 90MHz, resolution 11ns, wraps every 23860929530ns clocksource: stm32_timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 21236227187 ns sched_clock: 16 bits at 90MHz, resolution 11ns, wraps every 364083ns clocksource: stm32_timer: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 324034 ns clocksource: arm_system_timer: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 331816030 ns Signed-off-by: Benjamin Gaignard --- drivers/clocksource/timer-stm32.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c index dc9fee6..d8e5636 100644 --- a/drivers/clocksource/timer-stm32.c +++ b/drivers/clocksource/timer-stm32.c @@ -83,9 +83,9 @@ static irqreturn_t stm32_clock_event_handler(int irq, void *dev_id) static int __init stm32_clockevent_init(struct device_node *node) { struct reset_control *rstc; - unsigned long max_delta; - int ret, bits, prescaler = 1; + unsigned long max_arr; struct timer_of *to; + int ret; to = kzalloc(sizeof(*to), GFP_KERNEL); if (!to) @@ -115,30 +115,29 @@ static int __init stm32_clockevent_init(struct device_node *node) /* Detect whether the timer is 16 or 32 bits */ writel_relaxed(~0U, timer_of_base(to) + TIM_ARR); - max_delta = readl_relaxed(timer_of_base(to) + TIM_ARR); - if (max_delta == ~0U) { - prescaler = 1; - bits = 32; - } else { - prescaler = 1024; - bits = 16; + max_arr = readl_relaxed(timer_of_base(to) + TIM_ARR); + if (max_arr != ~0U) { + pr_err("32 bits timer is needed\n"); + ret = -EINVAL; + goto deinit; } + writel_relaxed(0, timer_of_base(to) + TIM_ARR); - writel_relaxed(prescaler - 1, timer_of_base(to) + TIM_PSC); + writel_relaxed(0, timer_of_base(to) + TIM_PSC); writel_relaxed(TIM_EGR_UG, timer_of_base(to) + TIM_EGR); writel_relaxed(TIM_DIER_UIE, timer_of_base(to) + TIM_DIER); writel_relaxed(0, timer_of_base(to) + TIM_SR); clockevents_config_and_register(&to->clkevt, timer_of_period(to), - MIN_DELTA, max_delta); - - pr_info("%pOF: STM32 clockevent driver initialized (%d bits)\n", - node, bits); + MIN_DELTA, ~0U); return 0; +deinit: + timer_of_exit(to); + err: kfree(to); return ret;