Received: by 10.192.165.148 with SMTP id m20csp618299imm; Fri, 27 Apr 2018 04:54:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqpYMdWAD3CXjIeZg1knuPIVWigVSG1ee9v5CUtqNO+38swxSO+sLet0smAx1sTh7uN8yMR X-Received: by 10.98.130.140 with SMTP id w134mr1977958pfd.127.1524830075263; Fri, 27 Apr 2018 04:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524830075; cv=none; d=google.com; s=arc-20160816; b=cMm3v148+Co+dcfxMdsTX5+qpZVi+Aq4VQCkcgMjouWDKqyah0u0n/82aJzer3fJTD 8cm1MijU9x10WmIg9X6CgjR3klT8hVPqOMr/mbSJzr9aaieuROpGbRhahcJQy+DGXiz1 UNxBEgkXn3pG5RpaIn62qCDviNos0spJQsMy5fCto6SCTsbng+KUTQazfxnxRiSI0xZA M8Aqm6dMme6q1bHqy6CxmDvVqrEsn0DddAiZmKTUUXl0uVL20rUzZbBcFK5nc7oviW85 ijl9jWUcYt81J1BZnxCzQZi6PxQuirZPYpfCvKffNIve6kw5O/aWrEdNNQKhL53eibkp RB2w== 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=QiiSzbkNQpLBD2Jsn7Evhy3lMCkTWc6B2TNKJKgH7rc=; b=CIHsk3qW7SKJdOf2fV46TV9Wui7rmDVnOepvAI44SLHdW6kHVrPR9/ANA8r5ycqTHy 0tSmaemzqkaQaVGp5l8Jz8JZlJoI4/nk6r5DJxXsPGixOzQPzCBkK/1/xdiNRXyPQkU7 zTCkbw3qAiTNKx65e+S/EMyXC67v4RPHVdrk3erwG20JQUqyjBf1V/GHtma0rXjCApub U8yBBfG6nbZjTcWddnfbzsm+LMazjk++9HUHFOthyeydY3own1o4KyIH6ESSRarP5tNy wy19fxIqT9pIRZXN7nfQs429Kup99s1o+ss4oOzeOcoJZBcKIVie14bpQg6v6HFGhzvc B2sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=uTvT9VZh; 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 j123si1116552pfg.156.2018.04.27.04.54.21; Fri, 27 Apr 2018 04:54:35 -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=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=uTvT9VZh; 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 S1757789AbeD0LxT (ORCPT + 99 others); Fri, 27 Apr 2018 07:53:19 -0400 Received: from mail-it0-f41.google.com ([209.85.214.41]:51588 "EHLO mail-it0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750863AbeD0LxR (ORCPT ); Fri, 27 Apr 2018 07:53:17 -0400 Received: by mail-it0-f41.google.com with SMTP id n202-v6so844516ita.1 for ; Fri, 27 Apr 2018 04:53:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=QiiSzbkNQpLBD2Jsn7Evhy3lMCkTWc6B2TNKJKgH7rc=; b=uTvT9VZhZyluJJHTMQsiSUU+/jrHdiyrO4g2T2nEQM+xEXYO5qNR4RRk6mUR8QL45+ OfCtg3rutvwWKH2ZWeXmBiSa/yUyzKzzl5vo8Gwvtv4Ng7akwEd9pcFziCNu04OtNiyX NzHJftKWrJhQ+7UvptpU7vagN36AXSa7Cx1gMR/lS81D5WO9hAWQmwLuu86U4XIrkHIg F6W30G9ExiyuGOnmle0ekT1GfGruI4pp8iK06mpgaW9pZl7wzRQHw8/jSwOLNW9dDX2w 0QlS5yuFEFthPIV31Lne34dZNImbH99ALG8tavIAL1yhFtBQU/HZml/GS5Y2r8VfcV/b S5Cg== 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=QiiSzbkNQpLBD2Jsn7Evhy3lMCkTWc6B2TNKJKgH7rc=; b=uHX7XM0gBYgAR4Dup33iUyZ25quNotD7RywwIQLpf08yzFch+xXQHjAKJ7od0d9OzZ dWqBKTWWURg5RxTS8mOHtioPJOh8uX2YWs9uKWSgHmcs89xibof1AkvtRXOBLNhJ6ihH krLTiBb+kHhkwthO8MKKoE+U8s4/RdZjMg7OFiiqAVhsZ3U5D1gjk6EueI95HM/Zgdmc pww3teVSwgTYC1EQO2vqSVEN+b1ceBkXnRRwEiVIoZt9wFbiy4IebGW7FM/3Cf3AViUC ozoWU93uMnIEpVJTprpb0y6rmdEF5ytSCgze25oZCDgkSBWrR6ytBR6fibIYSXcncn76 TYUg== X-Gm-Message-State: ALQs6tAPVdb00+Mi6KKtiB7DHcNr17siuNscqXAJGY10sXx5p61v7KNN FyNvZNwSCAm1dJlQbxwwI355orWqspffs8zSRn2D1w== X-Received: by 2002:a24:b310:: with SMTP id e16-v6mr1616941itf.58.1524829996812; Fri, 27 Apr 2018 04:53:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.181.1 with HTTP; Fri, 27 Apr 2018 04:53:16 -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 13:53:16 +0200 Message-ID: Subject: Re: [PATCH RFC PoC 0/2] platform: different approach to early platform drivers To: Arnd Bergmann Cc: Bartosz Golaszewski , David Lechner , Rich Felker , 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 12:18 GMT+02:00 Arnd Bergmann : > 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. > I'm not reusing the name - in fact I set the prefix to earlydev_ exactly in order to not confuse anyone. I'm also not reusing any code in the second series. > 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. > Yes, this is a good idea, but what about the sh-specific drivers that rely on it? Is including headers from arch/ in driver code still an accepted practice? > 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. > I don't see why we wouldn't want to unify these two cases. The best solution to me seems having only one entry point into the driver code - the probe() function stored in platform_driver - whether we're probing it from DT, platform data, ACPI or early boot code. Best regards, Bartosz Golaszewski