Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752665AbdLNUB1 (ORCPT ); Thu, 14 Dec 2017 15:01:27 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:45441 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752046AbdLNUBW (ORCPT ); Thu, 14 Dec 2017 15:01:22 -0500 Date: Thu, 14 Dec 2017 21:01:20 +0100 From: Boris Brezillon To: Rob Herring Cc: Alexandre Belloni , Mark Rutland , "devicetree@vger.kernel.org" , Daniel Lezcano , "linux-kernel@vger.kernel.org" , Thomas Gleixner , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH 1/3] dt-bindings: chosen: Add clocksource and clockevent selection Message-ID: <20171214210120.6b436e0d@bbrezillon> In-Reply-To: References: <20171213185313.20017-1-alexandre.belloni@free-electrons.com> <20171213185313.20017-2-alexandre.belloni@free-electrons.com> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3620 Lines: 79 Hi Rob, On Wed, 13 Dec 2017 16:57:50 -0600 Rob Herring wrote: > On Wed, Dec 13, 2017 at 12:53 PM, Alexandre Belloni > wrote: > > The clocksource and clockevent timer are probed early in the boot process. > > At that time it is difficult for linux to know whether a particular timer > > can be used as the clocksource or the clockevent or by another driver, > > especially when they are all identical or have similar features. > > If all identical, then it shouldn't matter. "similar" means some > difference. Describe those differences. We had this discussion already. Those timers might be connected to external pins and may serve the role of PWM generators or capture devices. We can also chain timers and provide a clocksource with a better resolution or one that wraps less often. In the end it's all about how the user plans to use its system, and this has to be described somehow. Assuming that the software can decide by itself which timer should be used or how many of them should be chained is just an utopia. > > > Until now, multiple strategies have been used to solve that: > > - use Kconfig option as MXC_USE_EPIT or ATMEL_TCB_CLKSRC_BLOCK > > Compile time probably means only one option is really used. Compile time selection prevents using the same kernel for different boards (in other words, no multi-v7), so not really an option here. > > > - use a kernel parameter as the "clocksource" early_param in mach-omap2 > > Yeah, OMAP was one of the previous times this came up and also > attempted something like this. This parameter predates selecting > timers based on features described in DT. Look at commit > 2eb03937df3ebc (ARM: OMAP3: Update clocksource timer selection). Then, would you accept to have a property saying that a specific timer is a free-running timer (suitable for clocksource) or a programmable timer (suitable for clkevent)? Or are you saying that you don't like the way timers are differentiated on omap? > > > - registering the first seen timer as a clockevent and the second one as > > a clocksource as in rk_timer_init or dw_apb_timer_init > > > > Add a linux,clocksource and a linux,clockevent node in chosen with a timer > > property pointing to the timer to use. Other properties, like the targeted > > precision may be added later. > > Open ended expansion of this does not help convince me it is needed. It's not an open ended expansion, we're just trying to find a way to describe which timer blocks should be used as free running timers (clksource) and which one should be used as programmable timers (clkevent). Automatically selecting timer blocks to assign to the clkevent or clocksource is not so easy (as has been explained earlier) because at the time the system registers its clksource/clkevent devices we might not have all the necessary information to know which timer blocks will be reserved for other usage later on. The use case I have in mind is DT overlays, where one of the overlay is using a timer as a PWM generator. If the clkevent or clksource has already claimed the timer connected to the pins the overlay is using, then we're screwed, and there's no way the system can know that ahead of time except by pre-assigning a timer to the clksource or clkevent feature. So really, we need a way to assign a specific timer to a specific feature. You've refused the different proposals we made so far, so what's your alternative? I mean a real alternative that solve the "an auto-selected timer might be claimed by another driver at some point" problem. Thanks, Boris