From patchwork Mon Jan 8 13:28:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10149597 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 F2FDD602CA for ; Mon, 8 Jan 2018 13:34:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D621528784 for ; Mon, 8 Jan 2018 13:34:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D49D22887A; Mon, 8 Jan 2018 13:34:18 +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 4679328784 for ; Mon, 8 Jan 2018 13:33:25 +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=FrR3a3rwZxZ1X9068B1G4LHQgZuWaj+pXiaIva+uVIQ=; b=T9ZifU0PNCl6PhmdwG6KsajXVF CZsU1RMFg8Yi/yQBsMwBAilUotYmSqm6Duk8cVh1spw/6efCLbOfvcmQvzo7O1J4As47z33l8rpW6 nfACb9+DCjfwVZrVfy+wyeSM9TJFByKtw1DZc56SGAD83XOaewTpObxvhrjoqghsJJlf5uLQaoymD Amy1LnCllRraTk2fvFLCazoEYiogoZq8Sxf2ZsBDlWNupGsjETHsZA2waBnqvmAmka33FcGYNVQGM q4rocdRbUvypkDrIRpcgdQ3qv4WHQn8MRcRRPPWLIqxXLEAp4dObWZc7f+EHhr+nRmpsu0g3094w1 umlrV7+Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eYXYE-0006dw-T1; Mon, 08 Jan 2018 13:33:18 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eYXVG-0003kW-Kw for linux-arm-kernel@bombadil.infradead.org; Mon, 08 Jan 2018 13:30:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding: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=m1H2f7beiH31JuAk86AoPNEnMD6CLJANQrwsbZWl3bk=; b=pyqVACaP03Dib89Tg4W3VRX6+ 6gQ1MZAsgGFiKcMJnY0YHszMBvurFUSd9757gu4qPR7WMnLnvOKX4NPMlUo+wm/uNnuDttBH6q4yc lHcpSULNnyc53rMD9QFGq5lxWOR2myiOBb/I7HMcAiUZyuV/0q0TSdqmsfTLhcrtuWZjY/FTUmNtB fC3/irG3b+/4PEg8j+lnnN+vzo5BbtFWesdULwPr2U5o/aDSn7vUqYlYPFPFGTQIGW6CC7bhxsJAR BiRDiAqwwMWG2J8rj+bx7GEIUIGTbTJhmNw6GY6aFeHssjd7DH0KfEzViWIYdx7iEk+ljl9PQSw8V QzaOI/Hxg==; Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eYXVC-0004XF-VR for linux-arm-kernel@lists.infradead.org; Mon, 08 Jan 2018 13:30:13 +0000 Received: by mail-wm0-x241.google.com with SMTP id 64so14210488wme.3 for ; Mon, 08 Jan 2018 05:30:00 -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=m1H2f7beiH31JuAk86AoPNEnMD6CLJANQrwsbZWl3bk=; b=GU9e0XDxOWOMGnW9ZU5nWTspHyghUVoS4T2Rl1+IMVls8VGfL0sTmNtpKa5aiZ5mrL hHZRBvrIAgtFSdwJP95L3UGoK8S9iyk7I/E1lYu4epbNkWaqQvg5SDqPCe4VuiNTNbvF 5Eex1hk2DZdTj23PR6Seor1O8yjiSFq7cVGTw= 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=m1H2f7beiH31JuAk86AoPNEnMD6CLJANQrwsbZWl3bk=; b=H/tbEfhQObdbofhab83av2+1R5ZG1fNC97qqNK3bt6G26X4RwEiBCkCKg5Wz/dpW/S XLQn115geu3u5Hz925cdWKkQzjxSnMtXsIN6ub5Wl6Zzj7vdZQpVVo8PWPPlPDNCdvAp ju3K5Y3yMytq9Wf4ImrkXDMpO/1Fpm0N+ppU4FeQeJgRXav15pacNsWx73Uk0mzcLc9m /TvbWFd9BhC0YXFtYjo5lZZ6kBxocpTIywk1cqSxDm4i6pbWoFo7I3V0GKiDrUWUtrd8 fW3SvqiImCCHiMhg2olwnVSC0B8u184g29SxFK6H0Ukx4EtoMrT0cvw3kk3hTvzSLIg6 PVGw== X-Gm-Message-State: AKGB3mIvnu9tLI4E3AKkb9Kdw3gfxWlormlx4vpflcn+JjLZoxgCtULt NjZmZbXTnzYLvGxuxOv9Igc/cg== X-Google-Smtp-Source: ACJfBotG7YewbEjah6PuSt31Kd/q9izm11bG8L43yzm3x6YiKnR2micOguxST9Rk8TU7jr62r5it/Q== X-Received: by 10.28.128.83 with SMTP id b80mr10041445wmd.41.1515418199098; Mon, 08 Jan 2018 05:29:59 -0800 (PST) Received: from mai.lan ([2001:41d0:fe90:b800:312a:53a5:1bef:6622]) by smtp.gmail.com with ESMTPSA id q196sm14354222wmb.22.2018.01.08.05.29.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Jan 2018 05:29:58 -0800 (PST) From: Daniel Lezcano To: tglx@linutronix.de Subject: [PATCH 20/20] clocksource/drivers/stm32: Start the timer's counter sooner Date: Mon, 8 Jan 2018 14:28:59 +0100 Message-Id: <1515418139-23276-20-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515418139-23276-1-git-send-email-daniel.lezcano@linaro.org> References: <1bbaef2e-4080-3f54-7db3-a8989acfd691@free.fr> <1515418139-23276-1-git-send-email-daniel.lezcano@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180108_133011_000581_4390B0E3 X-CRM114-Status: GOOD ( 15.80 ) 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: "moderated list:ARM/STM32 ARCHITECTURE" , Alexandre Torgue , linux-kernel@vger.kernel.org, Maxime Coquelin , Benjamin Gaignard 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 As we have a lot of timers on this platform, we can have potentially all the timers enabled in the DT, so we don't want to start the timer for every probe otherwise they will be running for nothing as only one will be used. Start the timer only when setting the mode or when the clocksource is enabled. Signed-off-by: Daniel Lezcano Tested-by: Benjamin Gaignard Acked-by: Benjamin Gaignard --- drivers/clocksource/timer-stm32.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c index dcf8445..4ce2345 100644 --- a/drivers/clocksource/timer-stm32.c +++ b/drivers/clocksource/timer-stm32.c @@ -101,7 +101,15 @@ static void stm32_clock_event_disable(struct timer_of *to) writel_relaxed(0, timer_of_base(to) + TIM_DIER); } -static void stm32_clock_event_enable(struct timer_of *to) +/** + * stm32_timer_start - Start the counter without event + * @to: a timer_of structure pointer + * + * Start the timer in order to have the counter reset and start + * incrementing but disable interrupt event when there is a counter + * overflow. By default, the counter direction is used as upcounter. + */ +static void stm32_timer_start(struct timer_of *to) { writel_relaxed(TIM_CR1_UDIS | TIM_CR1_CEN, timer_of_base(to) + TIM_CR1); } @@ -137,7 +145,7 @@ static int stm32_clock_event_set_periodic(struct clock_event_device *clkevt) { struct timer_of *to = to_timer_of(clkevt); - stm32_clock_event_enable(to); + stm32_timer_start(to); return stm32_clock_event_set_next_event(timer_of_period(to), clkevt); } @@ -146,7 +154,7 @@ static int stm32_clock_event_set_oneshot(struct clock_event_device *clkevt) { struct timer_of *to = to_timer_of(clkevt); - stm32_clock_event_enable(to); + stm32_timer_start(to); return 0; } @@ -235,6 +243,13 @@ static int __init stm32_clocksource_init(struct timer_of *to) * sched_clock. */ if (bits == 32 && !stm32_timer_cnt) { + + /* + * Start immediately the counter as we will be using + * it right after. + */ + stm32_timer_start(to); + stm32_timer_cnt = timer_of_base(to) + TIM_CNT; sched_clock_register(stm32_read_sched_clock, bits, timer_of_rate(to)); pr_info("%s: STM32 sched_clock registered\n", name);