Received: by 10.192.165.148 with SMTP id m20csp806081imm; Fri, 27 Apr 2018 07:49:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr/n7RgyAtnCLnI3vDLm0R3UNkX6meJFprExIW9X6dv6tRrXX7Rm0TepGvJUa0k7WQi6/Io X-Received: by 2002:a63:6dcb:: with SMTP id i194-v6mr2311195pgc.402.1524840566877; Fri, 27 Apr 2018 07:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524840566; cv=none; d=google.com; s=arc-20160816; b=BPMb5rvRENjnca+92agYzYnPpdguUp4jUnMrbYfzLJV+3+ME3da0Y9SgygUkugsOrV HFhQl5oNxJF6bMPWpOpPmyORHvPhml3jDf/3Zzex0FLNifdkvPi9XLV1t5wzAijdtThq RENSXoeMQvJXRXuucX9lkc9T+i67ziomFekRAhEd5hXgk/ekwIAVGwosnzWJFiQFn6Nx zXf7xlaiw50h0mjdvQJQZbupi1h72B0D37g7CVhzJnlH8EkZPs8WYfuh4uVjaw/u2fZ8 39VV3agY23CnDrOkvqxtnpbrzdl4xhArKVOk4/HUosqK3tKxh19+15JMLHHEOmnePZ8S 0xRg== 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=bu1uwr+o9/+PiAcZTDmirstuYOvrnXsyB5CJBiu+m0E=; b=FwfTNGqWu9p+NQPkXGApNB6j4zbQkuZjirGaiPQ7GfHkMS0cD7LrA0lEITpmYcWceP ImWEGBE+WVmKeCBWTG+HjZpce1ooEAZ6C24fs+iAdFNCv7Pgw7K7mY1nYpLDc8xRi3he LBuBPYl4xaAsqsfTD5N+QHGLpxI5jveL1By3EL1wzxhEAiKHDc2Ji5gD/2DmTBlVWN0z CApz07r1iBS51PKDgKj+DWP5nN2wM47OhcS7pTA497h1k0RNev0ZFxlwZn2EXgi4844k sAP9AVfvlrg++04OrepElfPkK1r2IOZLPXWJ9H96hk4fMmkIkOQhfYYL1guDOftuxd3f ioQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=uKPuRFB2; 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 h131si489439pfc.206.2018.04.27.07.49.12; Fri, 27 Apr 2018 07:49:26 -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=uKPuRFB2; 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 S934510AbeD0OsH (ORCPT + 99 others); Fri, 27 Apr 2018 10:48:07 -0400 Received: from mail-qk0-f179.google.com ([209.85.220.179]:41038 "EHLO mail-qk0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934461AbeD0OsC (ORCPT ); Fri, 27 Apr 2018 10:48:02 -0400 Received: by mail-qk0-f179.google.com with SMTP id d125so1559099qkb.8; Fri, 27 Apr 2018 07:48:01 -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=bu1uwr+o9/+PiAcZTDmirstuYOvrnXsyB5CJBiu+m0E=; b=uKPuRFB2mM+laRGDAywhp6cKbRppLqsPbWQ+RCLf2vJn8EVx63t4hPztQ5lHwIt0x3 cU3OE+fbaKx7zFaa0U9CPuprK1DUNkWvuhFCzPMozWg7hKr0gbEZScg0ugNiApio/3qW JmAm32gu7vWagv3XL72iLtavx8CEKTyayEFkx8zLRpNBCcoKl64r0Dgi2RgTJHT8oWMU BP3gOvOME45EG3cF7W/S6fmpAIA1lTC5FYRKXmbCX/1GIU0ssh6WAsqfv7Yx59gz4vAX 84Qm94GLgORAS4n+vZ2v5lWC8K6ojI198G3B4KS+5MG7LRHJl+5P0IgsXxJUCX56CYpd FbNw== 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=bu1uwr+o9/+PiAcZTDmirstuYOvrnXsyB5CJBiu+m0E=; b=oy4s3sbxpIXimIfndLxhKKO8h3Q0GZgjasfNZLlE0QhJlYfP9QRnzakw2SgoLzOylX 83IGizXsQIUiqFnAIFioV1pA3plFPD7uUW4MHxWtiyHaNI/MiqtXtroW4KmpYAiKqVll H6Fm+sljOs3dl4f+wZzt+Oua3weUd7GPqKY1bu0cPcVzFvLv6lBaKCC2XRL3D7D7LDdU yOQJWTQiuXNweJdNJXg9bgtgaUA+j0rrhXJmWJo97CorXCPUOolTbpCK6jlCZX4c8Iot bXvykiNIZdiE3cTpjuDZxOQGCbLsxf3e0T7RgKiv3LaDJS+5DpcNYjhzpnYrnpxufu0N O+8w== X-Gm-Message-State: ALQs6tD/VvIbSufDElr4O3GX3jlJ3ga5x2GDt3dt/sad5uQDz8nNbWGj YKkh2xZllSmOjriEY9x4qxIwNIvgIIugjSylkRNOcA== X-Received: by 10.55.124.198 with SMTP id x189mr2235429qkc.224.1524840481075; Fri, 27 Apr 2018 07:48:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.185.3 with HTTP; Fri, 27 Apr 2018 07:48:00 -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 16:48:00 +0200 X-Google-Sender-Auth: hacJzFUg1MCjUh5SkB5TPgccazw Message-ID: Subject: Re: [PATCH RFC PoC 0/2] platform: different approach to early platform drivers To: Bartosz Golaszewski 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 On Fri, Apr 27, 2018 at 4:05 PM, Bartosz Golaszewski wrote: > 2018-04-27 14:40 GMT+02:00 Arnd Bergmann : >> 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? My first idea would be to call it immediately after registering all devices and drivers. It looks like it's only needed to make all devm_ allocations persistent by removing them from the list, so we have to call early_platform_cleanup() before getting to the real platform code, but it could be done much earlier if we want to, at least after both setup_arch() and sh_late_time_init() are complete. >> 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? I think we first need to define what we really want to achieve here. It sounds like you still want to recreate a lot of what early_platform devices do, but it seems more important to me to add the missing functionality to the OF_DECLARE infrastructure. The most important pieces that seem to be missing are solved by finding a way to provide a platform_device pointer with the following properties: - allow being passed into dev_print() - allow using the pointer as a token for devres unwinding - access to device_private data that remains persistent until real a platform_driver gets loaded That can probably be done as an extension to the current infrastructure. However, I'd be very cautious about the resource portion: filling the platform resources (registers, irqs, ...) the way we do for regular devices is much harder and can introduce additional (or circular) dependencies on other devices. OTOH, not using those resources means you have a hard time passing information from board files. Arnd