Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752366AbcKRKn0 (ORCPT ); Fri, 18 Nov 2016 05:43:26 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:49428 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751095AbcKRKnX (ORCPT ); Fri, 18 Nov 2016 05:43:23 -0500 X-AuditID: cbfec7f1-f79f46d0000008eb-4a-582edb45d8ea Subject: Re: [PATCH v2] ARM: Drop fixed 200 Hz timer requirement from Samsung platforms To: Arnd Bergmann , linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski Cc: Russell King , Kukjin Kim , Javier Martinez Canillas , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Bartlomiej Zolnierkiewicz , Tomasz Figa , Ben Dooks , Lee Jones , Marek Szyprowski From: Sylwester Nawrocki Message-id: <8dfbb04f-d377-b51a-3010-481a5f977507@samsung.com> Date: Fri, 18 Nov 2016 11:43:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-version: 1.0 In-reply-to: <22757093.ejshJp9T7L@wuerfel> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA01SWUhUYRj1v3eW6+TYbbT6sEUalFLcUbiUiVHChV6CHhp90UEvKs2ozLik UG6ZWy6p4zIFajomZqijWZpaau7RaG4tLpWZqKmYGaYWOXMVfDvfd875DufnJ3BRL9eCCA4J ZxQhUpmYJ+A0dv/R2Xt9cpA4Ta7YU39zuvlUXWENl/r8MQmjfixVY1TWzCJO6XS1fGp6vQtR 2pkxLjXc/IBHFeraMKpD1YqoJ68n+VRV8zbyFNLDY0M4vbWZg+jv87kY3aSe5NPaqlQePTHW wqPry2PphqydVWZDFaLXtCevCHwE7gGMLDiSUTh6+AmC1p9qsLBZuFE7MsmLQ1/N0hBBAOkK pZWhach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NFmRolXR2+BdTALTGOWWPr+ IztIFZuAoUTv0T6wDl4BO4kNXbPB4iwCqhLvd04Fi4sKREhs+jqHBaJGUOLH5HtgNqeAlsT1 7d+AhnIADdWTuH9RCyTMLCAvsXnNW+YJjAKzkHTMQqiahaRqASPzKkaR1NLi3PTcYkO94sTc 4tK8dL3k/NxNjMBI3nbs5+YdjJc2Bh9iFOBgVOLhXXBKN0KINbGsuDL3EKMEB7OSCG/UFb0I Id6UxMqq1KL8+KLSnNTiQ4ymQC9MZJYSTc4HJpm8knhDE0NzS0MjYwsLcyMjJXHekg9XwoUE 0hNLUrNTUwtSi2D6mDg4pRoYbcXUrpyfFamf+1hnsueBCxN8lp89JpnilPu8ftaz+ykpD/yr 2mqe1Bz2Y3gkPP9XaPAbe03tSzx6hk85Gl/l738Yu/CSz1+Bj0EB3bdTpKcplQdH/0/1NKzp yLiRwHZr6sXqH2k/MjmvLIycsNf2xZZs7U2+jP23eicHz9LqDTCdvkO0N/WdEktxRqKhFnNR cSIAruI5e/oCAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161118104317eucas1p24303df035d782d45188cd0b10c1828d6 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?U3lsd2VzdGVyIE5hd3JvY2tpG1NSUE9MLUtlcm5lbCAoVFAp?= =?UTF-8?B?G+yCvOyEseyghOyekBtTZW5pb3IgU29mdHdhcmUgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?U3lsd2VzdGVyIE5hd3JvY2tpG1NSUE9MLUtlcm5lbCAoVFAp?= =?UTF-8?B?G1NhbXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIFNvZnR3YXJlIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20161118084812epcas4p496b847251f6919e5edc4801a247e0857 X-RootMTR: 20161118084812epcas4p496b847251f6919e5edc4801a247e0857 References: <1479453418-25314-1-git-send-email-krzk@kernel.org> <22757093.ejshJp9T7L@wuerfel> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3097 Lines: 76 On 11/18/2016 09:46 AM, Arnd Bergmann wrote: > On Friday, November 18, 2016 9:16:58 AM CET Krzysztof Kozlowski wrote: >> > All Samsung platforms, including the Exynos, are selecting HZ_FIXED with >> > 200 Hz. Unfortunately in case of multiplatform image this affects also >> > other platforms when Exynos is enabled. >> > >> > This looks like an very old legacy code, dating back to initial >> > upstreaming of S3C24xx. Probably it was required for s3c24xx timer >> > driver, which was removed in commit ad38bdd15d5b ("ARM: SAMSUNG: Remove >> > unused plat-samsung/time.c"). >> > >> > Since then, this fixed 200 Hz spread everywhere, including out-of-tree >> > Samsung kernels (SoC vendor's and Tizen's). I believe this choice >> > was rather an effect of coincidence instead of conscious choice. >> > >> > Exynos uses its own MCT or arch timer and can work with all HZ values. >> > Older platforms use newer Samsung PWM timer driver which should handle >> > down to 100 Hz. >> > >> > Few perf mem and sched tests on Odroid XU3 board (Exynos5422, 4x Cortex >> > A7, 4x Cortex A15) show no regressions when switching from 200 Hz to >> > other values. >> > >> > Reported-by: Lee Jones >> > [Dropping 200_HZ from S3C/S5P suggested by Arnd] >> > Reported-by: Arnd Bergmann >> > Signed-off-by: Krzysztof Kozlowski >> > Cc: Kukjin Kim >> > Tested-by: Javier Martinez Canillas >> > > Acked-by: Arnd Bergmann > > Maybe add a paragraph about the specific problem: > > "On s3c24xx, the PWM counter is only 16 bit wide, and with the > typical 12MHz input clock that overflows every 5.5ms. This works > with HZ=200 or higher but not with HZ=100 which needs a 10ms > interval between ticks. On Later chips (S3C64xx, S5P and EXYNOS), > the counter is 32 bits and does not have this problem. > The new samsung_pwm_timer driver solves the problem by scaling > the input clock by a factor of 50 on s3c24xx, which makes it > less accurate but allows HZ=100 as well as CONFIG_NO_HZ with > fewer wakeups". I've tested on S3C2440 SoC based board and I didn't notice any issues with HZ=100. Clock frequencies look a bit different because AFAIU MPLL clock is mostly used as a root clock. The 12 MHz oscillator clock is used a root clock for the MPLL. refclk: 12000 kHz mpll: 405000 kHz upll: 48000 kHz fclk: 405000 kHz hclk: 101250 kHz pclk: 50625 kHz So frequency of the timer block's source clock (PCLK) is 50.625 MHz. This is further divided by 50 in the prescaler as you pointed out. So the 16-bit is clocked with 1012500 Hz clock. I added some printks to verify this. Here is boot log for HZ=200: http://pastebin.com/JuWZdYwh and HZ=100 http://pastebin.com/HnDnBfhc samsung_clocksource_init:351 pclk: 50625000, timer clock_rate: 1012500 sched_clock: 16 bits at 1012kHz, resolution 987ns, wraps every 32362962ns I just don't understand why the log says timer overflow is every 32.362 ms and not twice this value (65536 * 1/1012500). -- Thanks, Sylwester