Received: by 10.192.165.148 with SMTP id m20csp818889imm; Fri, 27 Apr 2018 08:01:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrQlaHXj0uzYxHCQqBnDJVx0OqdEdWH8nsdbQjZkBeqsq1rAVIQX7CwfMcVKm0ZU8Fp1fvU X-Received: by 2002:a17:902:3e5:: with SMTP id d92-v6mr2717785pld.104.1524841312637; Fri, 27 Apr 2018 08:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524841312; cv=none; d=google.com; s=arc-20160816; b=OmcbFRyPfBh9mzmGfLMA64Ey5ohV/NanW4Ckf6BoUy4xAyjsZ1GlZkowkqAphlGWZi JjgippHwD8Zu+XuG9BgtoLeipF9sJV+v82+g0ke87cjq6CKwOIJxv09qcYbmJLBAQYK+ WnHYLaFfNbV+68pztp+rc1Q63mq3J03uclo5+85UcWGr7ue3G9XxnDcbAv2QFz6/2Dgu vlaaK0PZSaSIXLnEhy6CSI9Bd3EOhzLAIUFbOntj4WHTWI0p+FlsZuaCsKuw2oAB3mRK lmpxAOR25E5qnpb4ldtU/eLgTpwPeVYnnusbelDwb4NTk5LeWI6xkXiTLP2p6YsYQZYz Rppg== 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=BFV6PpldPWAZdnkvAhcr1RZvxABEwkU/8vbkhzSzrnc=; b=fcYS53Pq7D7fn/WTDfzkvzwNC6E8xv2E0lMaZq4PgJiIxvlcvn5i+Wmpkwjul3dBbT ZGBpMmjnXYQeQyYmL6eAWelAzgZKGQbHjYxdLJQVZtZiLYog0tCzfer259mPDP6uQLw5 Favl36329jWDU3mTq2zZ6SLpmog0WqLfxalEOJ7rwkxmwQPZkWWAokU8T6IaXjnQEtIK kIDI+apun/cN3zgAASrZQGW3Z1kxAzqVa8KNW71CjHQeo1LNjw0PFLuh1DVImtl4ZR5o StM/HYzYMR+sTqXaTs2r9BhTyXo6D4lKiZ+oCK7ILC/hpUS5em3ELYEaF+iFbzVFdkAn nQVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=ahzBfWCq; 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 f15-v6si1357053pgu.455.2018.04.27.08.01.38; Fri, 27 Apr 2018 08:01:52 -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=ahzBfWCq; 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 S933945AbeD0OFs (ORCPT + 99 others); Fri, 27 Apr 2018 10:05:48 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:45476 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933965AbeD0OFk (ORCPT ); Fri, 27 Apr 2018 10:05:40 -0400 Received: by mail-oi0-f68.google.com with SMTP id b130-v6so1665349oif.12 for ; Fri, 27 Apr 2018 07:05:40 -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=BFV6PpldPWAZdnkvAhcr1RZvxABEwkU/8vbkhzSzrnc=; b=ahzBfWCqJcvvvJaCeJ0sBeSsFrdafCslYdtxF1DwW8/FWW7dbcrIN34kaBgiPZe1Ws jRKEyZou7QOvoI+4upx7NPRA8FCdUYi7KjxJeUXpCdNUPGQFYIvA8GEiZ+vx68wTdvNk mowPKQddxGW77q+pguBTZG2ceKF2C11uBA+jeIq3ZsfWAUUTrW8h3OJyPF8DZhiUk8LD DhG7aZXZE7Oa80PnbGLpNoEGCpVH2khVlNeEObak5/drt0ugG1aI7Q6iubsb23hmCEeV 4WO07eD7fHzWE3E2Bp2pEG5DFRM4zdNCakeaksuoUruvyCo7rlty7Q95+fEx8NLZHwrN yfEQ== 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=BFV6PpldPWAZdnkvAhcr1RZvxABEwkU/8vbkhzSzrnc=; b=ptMcGCG7GbOLyvB04PAFguUKgGtWZokq3g2fvPPUrUVgjvt6qaY5KOG+Td3/cV1q8j 3HKL8/1e5chtgwl1YVqU0coGMJx4tcMLVr6cLnSVeB9fahD4B+AiMv377orWT2DveRlo df8m+4QTsKcrTPVTmyFpv2KuW5202s9mJdlfTaOZTIGqpF9kaaNbnDPYpG9ikAp05NxB Mj4NnmXG7abH+joeLsokA6Da3sgMl+MsHUI4Wgr6AoDqe6FPLQ0SQHvyUzruZN157Re7 /hUuDrhQq/qEGLog19OgwoQTgnbUbY8bLAs6skAjjGXfUfF2wfP2ls3oVIpN1pgaTwwM 7I8A== X-Gm-Message-State: ALQs6tB4taLnJZqpiIYL8REXaf2NJI+OVCkcqoEV01kS0NKeAfuRKxKD 8kn7P6n5eWUYmWMz4dgxyYB0h9DLk4tpkUg9ZgW+TQ== X-Received: by 2002:aca:5d0b:: with SMTP id r11-v6mr1412127oib.290.1524837939900; Fri, 27 Apr 2018 07:05:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.138.0.213 with HTTP; Fri, 27 Apr 2018 07:05:39 -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 16:05:39 +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 14:40 GMT+02:00 Arnd Bergmann : > On Fri, Apr 27, 2018 at 1:53 PM, Bartosz Golaszewski wrote: >> 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: >>>> 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. > > Ok. > >>> 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? > > I think it's fine here, since we're just move it out of the way and > there are only very few drivers using it: > > drivers/clocksource/sh_cmt.c:early_platform_init("earlytimer", > &sh_cmt_device_driver); > drivers/clocksource/sh_mtu2.c:early_platform_init("earlytimer", > &sh_mtu2_device_driver); > drivers/clocksource/sh_tmu.c:early_platform_init("earlytimer", > &sh_tmu_device_driver); > drivers/clocksource/timer-ti-dm.c:early_platform_init("earlytimer", > &omap_dm_timer_driver); > drivers/tty/serial/sh-sci.c:early_platform_init_buffer("earlyprintk", > &sci_driver, > > For timer-ti-dm, it seems like a leftover from old times that can > be removed. The other four are shared between arch/sh and > arch/arm/mach-shmobile and already have some #ifdef > to handle those two cases. > I'm also seeing that we also call early_platform_cleanup() from platform_bus_init(). Any ideas for this one? >>> 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. > > I'd rather keep those separate and would prefer not to have > that many different ways of getting there instead. DT and > board files can already share most of the code through the > use of platform_device, especially when you start using > device properties instead of platform_data, and the other > two are rare corner cases and ideally left that way. > > The early boot code is always special and instead of making > it easier to use, we should focus on using it as little as > possible: every line of code that we call before even > initializing timers and consoles means it gets harder to > debug when something goes wrong. > I'm afraid I don't quite understand your reasoning. I fully agree that devices that need to be initialized that early are a rare corner case. We should limit any such uses to the absolute minimum. But when we do need to go this way, we should do it right. Having a unified mechanism for early devices will allow maintainers to enforce good practices (using resources for register mapping, devres, reusing driver code for reading/writing to registers). Having initialization code in machine code will make everybody use different APIs and duplicate solutions. I normally assume that code consolidation is always good. If we add a way for DT-based platform devices to be probed early - it would be based on platform device/driver structures anyway. Why would we even want to not convert the board code into a simple call to early_platform_device_register() if we'll already offer this API for device tree? Best regards, Bartosz Golaszewski