Received: by 10.192.165.148 with SMTP id m20csp465161imm; Fri, 27 Apr 2018 01:58:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoooMzcESaofMFQlXBfpY7vzoXxREGB4NJBMthTpHDuCF6EdkVrgN2eq6v2XPwTjbwFAg3o X-Received: by 2002:a17:902:d681:: with SMTP id v1-v6mr1521044ply.16.1524819523402; Fri, 27 Apr 2018 01:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524819523; cv=none; d=google.com; s=arc-20160816; b=oCO+/1AjP2nfHUulgoHrO5zcjIQ92atutUUaLFP89L3PLJbKACTeUdJ9YSIeiqbqU1 3p+gtRIwHLqf1i2suorzZR9tqQR7gegjzCecJz4fHzRd4xutxz6CWwGCfa0YlYBEiVL7 DKGFrFbsvo221e3237hnbzE9QisffyVuRLV/3pKGOBvyUP7V5WVrcU7tUyV/lQaeYPZi od8nObp6Tw7ZOtfCpiG1CR8wk5HpCcm8WrwW2412JcWynxDmlPxjoQGKnfIfjcvo/cfX rWS8CdyyKPD/7YhtuGMlguzWez8JApIrfhYw4quIsEXsMmpnyTu5LBIyfl2ufADHu/dt RCBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Vmcu81HICqAcPPuaFc7+fQYke8YyM/yfVCmG101+XiI=; b=ooVCCvldKMJXYAuTNdMGHLDxBsOf9HRJ25soFo5N+sTvJ332c7PhlZv3Ih3l9SanDG EW7+Xr9MoEd+5fjU6iK2LBM90AvRPAxP093BWVGvV2CGEogKs2oXTX5JeahxODnPM4cc 0jNI96xmAzUUqAGmN6ga88bupxbmzXKRoz6Mn1TjKRpvxLvDqIL6NeQ/28rmczxOhaYj 2B4CvXFOka8R4nnQMqlBi0nViW+XJDrBUHYpaNgr3UQ+l9OdogRnERC+XaxlpFvnSFyU e2FPW/axheMrFxWXMCqKkJRgBv0O8HKSX77DUE2wiSNxHvkckF7x52e3P1kBFA7cTDnx 98wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=chk5hP1f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2-v6si811933pgv.611.2018.04.27.01.58.29; Fri, 27 Apr 2018 01:58:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=chk5hP1f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932492AbeD0I5L (ORCPT + 99 others); Fri, 27 Apr 2018 04:57:11 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:42775 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932434AbeD0I5H (ORCPT ); Fri, 27 Apr 2018 04:57:07 -0400 Received: by mail-ot0-f193.google.com with SMTP id l13-v6so1220215otk.9 for ; Fri, 27 Apr 2018 01:57:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Vmcu81HICqAcPPuaFc7+fQYke8YyM/yfVCmG101+XiI=; b=chk5hP1fAcHK/RqjAY4G9da0sbRWzb3xmcMYaj2YOwnSzGevPH66TwFXkBrRub/UxE e05dEIb86/E7tV38KHDs3xN/v8V3xPlc2kOdfCS7WFO9IUoOJ4xe6qZ+cprWpTsbeQHZ 4MWPbX97eevBre8A2W2Zv0H51/CG01qEQHQhwBZBOB2LVoYB1WG6ZIWzVtHN05OJa4/1 um1cit6LuXAuVJScMVA7rOOKoHBNK7+pjHkMGr9lNtFovws9CV6TbJdm0J1rIq7G4qye lWSny8dZQFV/8PxPzkBxQcgK1jLX5YNh0aKHyB+jC12a8VH/iRAx56dBQW8iB+2Dycx7 0wNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Vmcu81HICqAcPPuaFc7+fQYke8YyM/yfVCmG101+XiI=; b=Kd3WX17IJA+EoUIpF1TpnPVpVk/0fwm1yW53ngITZb7b1YbUu9KuppKtofveUS9U+I UE/c5BSHIOnehsK5B3kB/CElqku6CtKqzQTjHMMtZCS7PMtSIs04/st3IpBzOCcqDoCZ uJnY7qGvxx6JBN1zPTSS6D+IkSwzqGJdy1PyYGTwL2EcFncFA4zp6enPdMjIFOm2mkEp Sr/Cvkvsuhth/KdFbAFRWceWhD8wJd1bQEQejQ6kISve5WjP9DGCi2MPGTG8Hd0U9GRD 3p7RXgU+1r5abpN8gmC8Ovl6YloYWi+0iYV7bIyLR2y/1osDLvSVZ3T5YVM7OwLMhcMb kR7A== X-Gm-Message-State: ALQs6tDLQqzYAgCOS1VfrDox5W6ebglkSL9Ew7Gwxb8RJBMpNwovUnEI 7WNsPy9xky5TR3EW/umHY4PVmaNnZy1XnxuHyZutNQ== X-Received: by 2002:a9d:28eb:: with SMTP id s98-v6mr917311ota.246.1524819426550; Fri, 27 Apr 2018 01:57:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.138.0.213 with HTTP; Fri, 27 Apr 2018 01:57:06 -0700 (PDT) In-Reply-To: References: <20180426152920.21569-1-brgl@bgdev.pl> <20180426173151.GJ3094@brightrain.aerifal.cx> <6d1f9114-f1d1-961f-4f36-74adff059dc3@lechnology.com> From: Bartosz Golaszewski Date: Fri, 27 Apr 2018 10:57:06 +0200 Message-ID: Subject: Re: [PATCH RFC PoC 0/2] platform: different approach to early platform drivers To: Arnd Bergmann Cc: David Lechner , Rich Felker , Bartosz Golaszewski , Sekhar Nori , Kevin Hilman , Michael Turquette , Stephen Boyd , Greg Kroah-Hartman , Rob Herring , Mark Rutland , Yoshinori Sato , Frank Rowand , "Rafael J . Wysocki" , Jarkko Sakkinen , Dmitry Torokhov , Arend van Spriel , Heikki Krogerus , Michal Suchanek , Jan Kiszka , Andy Shevchenko , Marc Zyngier , Peter Rosin , Linux ARM , Linux Kernel Mailing List , DTML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-04-27 9:52 GMT+02:00 Arnd Bergmann : > On Fri, Apr 27, 2018 at 4:28 AM, David Lechner wrote: >> On 04/26/2018 12:31 PM, Rich Felker wrote: >>> >>> On Thu, Apr 26, 2018 at 05:29:18PM +0200, Bartosz Golaszewski wrote: >>>> >>>> From: Bartosz Golaszewski >>>> >>>> This is a follow to my series[1] the aim of which was to introduce device >>>> tree >>>> support for early platform devices. >>>> >>>> It was received rather negatively. Aside from using device tree to pass >>>> implementation specific details to the system, two important concerns >>>> were >>>> raised: no probe deferral support and the fact that currently the early >>>> devices >>>> never get converted to actual platform drivers. This series is a >>>> proof-of-concept that's trying to address those issues. >>>> >>>> The only user of the current version of early platform drivers is the >>>> SuperH >>>> architecture. If this series eventually gets merged, we could simply >>>> replace >>>> the other solution. >>> >>> >>> Looking at a quick output of: >>> >>> grep -r -A10 early_devices[[] arch/sh/kernel/ >>> >>> it looks like all of the existing early platform devices are serial >>> ports, clocks, and clocksources. The switch to device tree should pick >>> them all up from CLK_OF_DECLARE, TIMER_OF_DECLARE, and >>> EARLYCON_DECLARE. Until that's complete, the existing code works >>> as-is. I don't see what problem you're trying to solve. >> >> >> The problem for us is that clk maintainers don't want new drivers to use >> CLK_OF_DECLARE and instead use platform devices. I have just written such >> a new driver that is shared by 6 different SoCs. For some combinations of >> SoCs and clocks, using a platform device is fine but on others we need to >> register early, so the drivers now have to handle both cases, which is >> kind of messy and fragile. If there is a generic way to register platform >> devices early, then the code is simplified because we only have to handle >> one method of registering the clocks instead of two. > > The early_platform code is certainly not a way to make things simpler, > it just adds one more way of doing the same thing that OF_CLK_DECLARE > already does. We removed the last early_platform users on ARM a few > years ago, and I would hope to leave it like that. > > I haven't seen the discussion about your clock drivers, but I know that > usually only a very small subset of the clocks on an SoC are needed > that 'early', and you should use a regular platform driver for the rest. > > Can you elaborate on which devices need to access your clocks before > you are able to initialize the clk driver through the regular platform_driver > framework? Do any of these need complex interactions with the clk > subsystem, or do you just need to ensure they are turned on? > > Arnd The problem I'm trying to solve is the following: We have platforms out there which still use both board files and device tree. They are still comercially supported and are not going anywhere anytime soon. Some of these platforms are being actively maintained and cleaned-up. An example is the DaVinci platform: David has recently converted all the SoCs and boards to using the common clock framework. I'm cleaning up some other parts too. The problem with the legacy board code is that a lot of things that should be platform drivers ended up in arch/arm/mach-*. We're now slowly moving this code to drivers/ but some initialization code (timers, critical clocks, irqs) needs to be called early in the boot sequence. When you're saying that we already have all the OF_DECLARE macros, it seems to me that you're forgetting that we also want to keep supporting the board files. So without the early platform drivers we need to use a mix of OF_DECLARE and handcrafted initialization in arch/arm/mach-* since we can't call platform_device_register() that early. This blocks us from completely moving the should-be-driver code to drivers/, because these drivers *need* to support both cases. The main problem with OF_DECLARE is that although we have corresponding device nodes, we never actually register any real linux devices. If we add to this the fact that current early platform drivers implementation is broken (for reasons I mentioned in the cover letter) the support gets really messy, since we can have up to three entry points to the driver's code. Other issues come to mind as well: if we're using OF_DECLARE we can't benefit from devm* routines. My aim is to provide a clean, robust and generic way of probing certain devices early and then converting them to actual platform devices when we're advanced enough into the boot sequence. If we merged such a framework, we could work towards removing both the previous early platform devices (in favor of the new mechanism) and maybe even deprecating and replacing OF_DECLARE(), since we could simply early probe the DT drivers. Personally I see OF_DECLARE as a bigger hack than early devices. My patch tries to address exactly the use cases we're facing - for example by providing means to probe devices twice (early and late) and to check the state we're at in order for users to be able to just do the critical initialization early on and then continue with regular stuff later. Best regards, Bartosz Golaszewski