Received: by 10.192.165.148 with SMTP id m20csp531515imm; Fri, 27 Apr 2018 03:19:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpzXwALgiHE7B+rAAhdtTHH+7YbqOEBsXhPACO1a2ojXdGfDmAgjiaO+3DNEFBaeLIcHa29 X-Received: by 2002:a17:902:4303:: with SMTP id i3-v6mr1808702pld.394.1524824372823; Fri, 27 Apr 2018 03:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524824372; cv=none; d=google.com; s=arc-20160816; b=M1cKL8gWsV9ey6+4pRlL70yq9t+wi1OufFHj8j2iiLnIihCRlkCfAPL6c/xuCp+DSg UpSazFooUtdFa4KzE1T8Yqo2CatIKTUHxdBQRhljS6PP+TcLGFxZq+NJzyxQLt7IPuh7 0+BlM3TZhx89hgsqbCCeVyOg0f+b8t/oVRnAheSmunGyRLswUJLJIXkaYtzrsVzAKYkw iGneQ7JzkEf7vpWw27hBOv8aD1ZfVzJxPn+7+wNYsQ98Sddcnso+fCP2jSC+mnAL+4Xa AHf9/ADo23iyPabGtgtF5tf6QXQcGFYYBAB/Z7k9U+RNWkSEFc0r21iDgq/hCpCBdMHf TG/A== 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=Z2L0H80XesDdwERbKjUp2wGPOQc89Q1yDFcJyM2th3E=; b=hY5gLgeHn3u+ES7zFZwhSUWE6p0fdR6sq2SwtcYd1wObFKVa/49Qi+Nearwl9cXDmf ucBUo7kZssPWMGQuJ7zCfQLBbJANQHpHSq0C8h492wBSOPwdbRNbq8Z7l3KZ1Ek1xxF7 Pm+CkU06dpoEGxJ7ENdEBqAYKtMv6E/CYqmW+J9KcTc8XtialT5ROAQlB68+bdc3QNkn 1Id0Tx/gqrpx15aqiU24zgPZ55RXjX4JkjGbMRnH64PBs1AZWissmMjzkAtL0PTDUv9i F/95KdDhRW2p67B4HMbC8uEcI0RB9sZnQL3hG/BlpxnNc1ji3X5e/r04lcpv2JyoR77H Pl3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=rZMbIC6S; 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 w10si994449pfg.174.2018.04.27.03.19.18; Fri, 27 Apr 2018 03:19:32 -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=fail header.i=@gmail.com header.s=20161025 header.b=rZMbIC6S; 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 S1757922AbeD0KSN (ORCPT + 99 others); Fri, 27 Apr 2018 06:18:13 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:44669 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757657AbeD0KSL (ORCPT ); Fri, 27 Apr 2018 06:18:11 -0400 Received: by mail-qt0-f194.google.com with SMTP id d3-v6so1518191qtp.11; Fri, 27 Apr 2018 03:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Z2L0H80XesDdwERbKjUp2wGPOQc89Q1yDFcJyM2th3E=; b=rZMbIC6SISV7sdeLle3BgFo2BW8Z8kykrcZ657Mh6fq8rJX8p9Eah3st5MnhkBlEiZ V4KcE16WCvnfr19N3tx+l4KK5sZhB2u2wWBsR4AnYev+jE73ppT1M58JJnlZNlmZwfpV t8O7ER3+Tzex6BNb+2sgYujxwU3HdpeD5Kfglrc/6R9glpqfoc2axrNlW0hV5yV2EfAR zW3k0RbNb0ALcLGd8lJoWStEk4GqHAeZuQpgQzHBvD4LQH2i1QYjY0wcVjlzUsYJtxbF U5wjy3HVFDzBrfF7rnYhpIp4yvb1DRHkEwmSaUx4/2mL13P7UeaUTf7BzkDGOxxHaoqO Rekg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Z2L0H80XesDdwERbKjUp2wGPOQc89Q1yDFcJyM2th3E=; b=SOnVsZDGPxRoflNmAvtww0CbY8Cp6Xl5IHkm8k5NWHS9MfBKYfS+D92KyDwtG3cRaK wJfnPoaOO5jpcQ2PI3cw0sQpEE1k+RoYZ8CNDxQyx8jvJbRp4bXW85MzaE6uy6WTX96u yMvwc6yA2JvVYNCsQeVdv8c+I/PvAk8zNtU5LjWNsxwTFfeg41a8cLXt1+QjQpdD0SG3 K0WS+i6Jb0mLSQz3fJbrKEuc5y9KUxzFg+o6XEK4VKi2thYNTAbHFsIoZ20VMhRaWTnz HMNAZk7c0AGv0q3u8zlewoefv8TMt3kMXR5C1w1FzG5rwZz/zMXTOSVKhUh6eIHZvT2Q QGdA== X-Gm-Message-State: ALQs6tBNeBBDEt2nBf+Mjxgh0x+MlmypCCRtIIgvdw8vHB1+xUhh7a0W k7KoUadKwa6O4C0sFbRH7xdF7bInbU+/cuYffMM= X-Received: by 2002:ac8:1c12:: with SMTP id a18-v6mr1427395qtk.280.1524824290268; Fri, 27 Apr 2018 03:18:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.185.3 with HTTP; Fri, 27 Apr 2018 03:18:09 -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: Arnd Bergmann Date: Fri, 27 Apr 2018 12:18:09 +0200 X-Google-Sender-Auth: P3WDmTlGndAHNnaeRPsyF2Sfrz0 Message-ID: Subject: Re: [PATCH RFC PoC 0/2] platform: different approach to early platform drivers To: Bartosz Golaszewski 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 On Fri, Apr 27, 2018 at 10:57 AM, Bartosz Golaszewski wrote: > 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: > > 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. Right, and that's very good work. > 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 OF_DECLARE_* functions were initially added as a way to remove board files that just consist of callbacks into early initialization for some subsystems. As long as you still have board files and you are looking for a way to reuse code between OF_DECLARE_* functions and board files, why not just leave those functions globally visible and call them from the non-DT board files? > 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. Right, the devm_* problem has come up before. > 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. Maybe the problem is reusing the name and some of the code from an existing functionality that we've been trying to get rid of. If what you want to do is completely different from the existing early_platform implementation, how about starting by moving that out of drivers/base/platform.c into something under arch/sh/ and renaming it to something with an sh_ prefix. Let's just leave the non-DT part out of it by making it sh specific. Then we can come up with improvements to the current platform_device handling for DT based platforms that you can use on DT-based davinci to replace what currently happens on board-file based davinci systems, without mixing up those two code paths too much in the base driver support. Arnd