From patchwork Fri Dec 8 11:32:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 10102367 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 AF09260325 for ; Fri, 8 Dec 2017 11:34:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD2C5288BA for ; Fri, 8 Dec 2017 11:34:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0B7228BB0; Fri, 8 Dec 2017 11:34:34 +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 3CA77288BA for ; Fri, 8 Dec 2017 11:34:33 +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=QJ5NUyzuKwRFCNFx6Xf3FpcSFPae+pUyC+aAxD5ee/M=; b=QlqfsqtKslg1TL1ueBemJZuThn mnVQMiSo7504nT+GfUqwjT8qB0JkBnZspl8ObuX0fRLbwr46zgN8imt7cOEbxwX1snrdO6dEH+sZa W/5rofarEisaUmZyXaOiKJs4c4vQKL7kDZbe/28iZEHHZ8BzGnQAn1QFVvo7bqyIi/wMZgoS4Wa/2 XQf7kQQOY7Oj0fwEuGHiruOCCG/wF2rv1KfD5gMHtKL+720gdxmkmKQmivMY5Xej3IUKuVkrzozc+ PPPDaxK8SXwdA8cz3Gb+ChqKskgIwxIJHa2jvqpX9p7GFxDZ9DAibQpT8/lZLZaEIueEM7Coqovyz xS3wfvIQ==; 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 1eNGvB-0002rB-P8; Fri, 08 Dec 2017 11:34:25 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eNGuK-0001sW-OV for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2017 11:33:40 +0000 Received: by mail-wm0-x243.google.com with SMTP id 9so2794405wme.4 for ; Fri, 08 Dec 2017 03:33:09 -0800 (PST) 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=+ofLvKtyAnHtAQQFL19bsjsi2JNpkm6HYTbMdM+2Ntk=; b=Q6EKbDt7OHyEe2YbnwyiBt8V72uZfE5t6XfEafAzqw6dH7MaeKU+/5UW5ZKsc4Njm6 sv0ypmVoR7s/073x3OAUWdomEeQrQ660HozEeLXqZRqEP4SL7d4X6TESoXmirGkCPH6v DY5i3tqTqnafexSpatwMVs8Lw8Zy7Jpe+TPAI= 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=+ofLvKtyAnHtAQQFL19bsjsi2JNpkm6HYTbMdM+2Ntk=; b=METEHp0+rT49ViLWBl2fldxsVShkGX88ExB+HSPomsVFIloT1vnfDaM3/Pa6bdKJuS TDYfdKeRSML+xE9LcwG+oniszRYx/y9RGlOekMFM4l/bK1rprj2Cd6Y6nKmS3vSxYZbB /zQFWGcil8IEyIDd9i1F6Im33+Z6yInahCebEuQSpDQwdKxEIM259qAdmuXBrNJDpitP WFX0g4jaY4BHEw5pEblbQFyyaSHvcYj6QgGAFMhlHdDylvK7t/18T4t5e3a8G1zOnO5G fq3WxAmUJcmSbuzvoI2cayg9RzpTjUwQPRp+Obpm5KwJsfcdHjjD2aOGV0qUJR/v7+K8 mHpg== X-Gm-Message-State: AKGB3mK1fGXCmCQKNi/e+cXO24zj9HHn91rYtzg6s7o9zMwOkjet9j42 GrJAK7bpwTnAnLBHAfxMbYywKA== X-Google-Smtp-Source: AGs4zMZNIp2LatibO4JOuVFVdBI8SeJYYClT+mRhSuObNhcDdK/sYV4ppY/cN08m95o5fl1lZD7aNg== X-Received: by 10.28.91.74 with SMTP id p71mr4046428wmb.61.1512732788012; Fri, 08 Dec 2017 03:33:08 -0800 (PST) Received: from lmecxl0911.lme.st.com ([80.215.241.46]) by smtp.gmail.com with ESMTPSA id x52sm9184518wrb.25.2017.12.08.03.33.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Dec 2017 03:33:07 -0800 (PST) From: Benjamin Gaignard X-Google-Original-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, arnd@arndb.de Subject: [PATCH v9 3/6] clocksource: stm32: only use 32 bits timers Date: Fri, 8 Dec 2017 12:32:47 +0100 Message-Id: <20171208113250.359-4-benjamin.gaignard@st.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171208113250.359-1-benjamin.gaignard@st.com> References: <20171208113250.359-1-benjamin.gaignard@st.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171208_033333_474265_95BECFAA X-CRM114-Status: GOOD ( 14.25 ) 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 From: Benjamin Gaignard The clock driving counters is at 90MHz so the maximum period for 16 bis counters is around 728us (2^16 / 90.000.000). For 32 bits counters this period is close 47 secondes which is more acceptable. When using 16 bits counters the kernel may not be able to boot because it has a too high overhead compare to the clockevent period. Downgrading the rating of 16bits counter won't change anything to this problem so this patch remove 16 bits counters support and makes sure that they won't be probed anymore. Signed-off-by: Benjamin Gaignard --- drivers/clocksource/timer-stm32.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c index a45f1f1cd040..707808d91bf0 100644 --- a/drivers/clocksource/timer-stm32.c +++ b/drivers/clocksource/timer-stm32.c @@ -84,12 +84,16 @@ static irqreturn_t stm32_clock_event_handler(int irq, void *dev_id) return IRQ_HANDLED; } +static bool stm32_timer_is_32bits(struct timer_of *to) +{ + return readl_relaxed(timer_of_base(to) + TIM_ARR) == ~0UL; +} + static int __init stm32_clockevent_init(struct device_node *node) { struct reset_control *rstc; - unsigned long max_delta; - int ret, bits, prescaler = 1; struct timer_of *to; + int ret; to = kzalloc(sizeof(*to), GFP_KERNEL); if (!to) @@ -118,31 +122,27 @@ 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; + if (!stm32_timer_is_32bits(to)) { + pr_warn("Timer %pOF is a 16 bits timer\n", node); + 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_cleanup(to); err: kfree(to); return ret;