Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4235088imm; Mon, 14 May 2018 04:47:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqmvjj/ckwned9+AX5l6HRq70h1PowYt7SA1p/C7VkmSDVd4jHBbiqT/qrsYBiHMHxJSK6p X-Received: by 2002:a63:7315:: with SMTP id o21-v6mr8196732pgc.360.1526298432280; Mon, 14 May 2018 04:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526298432; cv=none; d=google.com; s=arc-20160816; b=lDlweE70KucwnDXu7LKtH6wL29PoXQjp5e6O2kkffLK7iYm5s1VmCeADtcKNcK2AF2 SuNFgBOFU4MGPYClSj5OPUUrimfVpZmwZnvyCfGb0DILoIrf1VVbAo1SSOtkMwjI6Ls1 wLbHY91ImaUu6Pbt6U8oM1Qa14Bv3CSMPBVdgjNbVGOamXrrgcyX4+LL8c7G2WYaZJ++ leCNZMblCFYq9+KxhGz6NeLGR8ObwD8U9zUTmLrA51PuWpBJjXVsk9v4kq+SnSUdeLfu CzDi5QuX1WJ/xIAZUDeFizUyh1yl5s0KgJeGvEyQ2U4anEoVYf8+1ZVHDuYbF28CUWFM HwWA== 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=Aym6qTP1VAcyYMXvqQMmDpjKygFNBfMKFJV1b0PqcVA=; b=C3Zpn7U1JR0zy816vwjAtQQGaNJsLek8ehH3ttud2x7J/rdR9+LXvZM428Rlq8ZE2f CqIoDzb02zfL9iV/y94UUBGoCm42CWrBR4C1bkYHernOx6E6uCsUhErn/2aD4LHJ/ooa uK1FvLCKsnTcHuMgKsr0oW2kokqTRBlVsmzMCyFV0llrGa77Hy6iG/ce60bEjqpPP/Q5 lsjQ36ZOWNA9a81orU47tuWdgf6aQMcZpe3sZr1v1ESWB5g7MtUhe6wletHmmCSzKABT XdHiqSfZWQ0z7IRipu0+mNamoFm5ZVHolXt62JtxjIyhW3IuBSkbY8yUk6d39JOX2e9U y7Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=yaEt3m6O; 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 b35-v6si9290875plh.36.2018.05.14.04.46.55; Mon, 14 May 2018 04:47:12 -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=yaEt3m6O; 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 S1752259AbeENLiU (ORCPT + 99 others); Mon, 14 May 2018 07:38:20 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:44094 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752066AbeENLiR (ORCPT ); Mon, 14 May 2018 07:38:17 -0400 Received: by mail-io0-f170.google.com with SMTP id d11-v6so14767367iof.11 for ; Mon, 14 May 2018 04:38: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=Aym6qTP1VAcyYMXvqQMmDpjKygFNBfMKFJV1b0PqcVA=; b=yaEt3m6OzsPje/6D3msxxoAi+Yv/+fuGhKSVefWf46lirFVTPrS+WBL0pGfiZ4g477 WcKYFEwQjFuwVY+r0YPRJMwyYm/ZCf/cAduE1/49an3hxDdJKCI8McWe+Ufnij/iFoZX Wz7JoEIxH450Qny1G5zYOHUoz+sq7Mxu1iUNxFiBqr0SUzS0MK4hydM/J+msqQhETgY8 JACrxR7Klr6aRQ7eO/Jnbmfp3EjENbM79j7ch/J2CV6G+FESzY70g6B3fmxOraTF1JS/ /abzJeLCFeXXUpfIl+QAXxXYamwy6L7g7xgIAUjXhazFszTqBFlAyGGAh/ZKyAeVcjSh +wVw== 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=Aym6qTP1VAcyYMXvqQMmDpjKygFNBfMKFJV1b0PqcVA=; b=C4SXnWiSpaTkh0KXvViw8EXJkZDdBg2DGHi6UcD439iHu84UWPGgBpd/PRYC6kenBV 0FEGePp9sumbSsIpfyJdTBnwOte93SPA57jflaImaY2+o9T1rSdKNoFYYPEFEYkLkctF 66yySsUYy9fipjUljTHLDgUw1KjAiPjUk3xV5VVkL2DNCqPKQcFUlLOnBLktdcwwjr+7 h/ux/x8yWdN8r0UUARSODctPGf42J2T8czlFJDZx1gIS6ZJ/DlyIeCaJtm9m5iDxAm8x cveA0r21MkoasTKnAKFZ85QLj5pHEDKGaSjlO527S78Ks2jOfshNqC/yYa4q1hZ/LE+/ yKbQ== X-Gm-Message-State: ALKqPwfhtQ6V/K4/ra2aD+3y4KlD8T9oDc5gY5OxAHt3iNN/w0GxIDtW Ws6Zb13AK0O4uw45FWGjWHvrglAkplMmrclpDc4bSQ== X-Received: by 2002:a6b:93c6:: with SMTP id v189-v6mr10152056iod.84.1526297896696; Mon, 14 May 2018 04:38:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.181.1 with HTTP; Mon, 14 May 2018 04:38:16 -0700 (PDT) In-Reply-To: References: <20180511162028.20616-1-brgl@bgdev.pl> From: Bartosz Golaszewski Date: Mon, 14 May 2018 13:38:16 +0200 Message-ID: Subject: Re: [PATCH 00/12] introduce support for early platform drivers To: Rob Herring Cc: Sekhar Nori , Kevin Hilman , David Lechner , Michael Turquette , Stephen Boyd , Arnd Bergmann , Greg Kroah-Hartman , Mark Rutland , Yoshinori Sato , Rich Felker , Andy Shevchenko , Marc Zyngier , "Rafael J . Wysocki" , Peter Rosin , Jiri Slaby , Thomas Gleixner , Daniel Lezcano , Geert Uytterhoeven , Magnus Damm , Johan Hovold , Frank Rowand , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , "linux-kernel@vger.kernel.org" , devicetree , "open list:GENERIC INCLUDE/ASM HEADER FILES" 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-05-11 22:13 GMT+02:00 Rob Herring : > On Fri, May 11, 2018 at 11:20 AM, Bartosz Golaszewski wrote: >> This series is a follow-up to the RFC[1] posted a couple days ago. >> >> NOTE: this series applies on top of my recent patches[2] that move the previous >> implementation of early platform devices to arch/sh. >> >> Problem: >> >> Certain class of devices, such as timers, certain clock drivers and irq chip >> drivers need to be probed early in the boot sequence. The currently preferred >> approach is using one of the OF_DECLARE() macros. This however does not create >> a platform device which has many drawbacks - such as not being able to use >> devres routines, dev_ log functions or no way of deferring the init OF function >> if some other resources are missing. > > I skimmed though this and it doesn't look horrible (how's that for > positive feedback? ;) ). But before going into the details, I think > first there needs to be agreement this is the right direction. > > The question does remain though as to whether this class of devices > should be platform drivers. They can't be modules. They can't be > hotplugged. Can they be runtime-pm enabled? So the advantage is ... > The main (but not the only) advantage for drivers that can both be platform drivers and OF_DECLARE drivers is that we get a single entry point and can reuse code without resorting to checking if (!dev). It results in more consistent code base. Another big advantage is consolidation of device tree and machine code for SoC drivers used in different boards of which some are still using board files and others are defined in DT (see: DaVinci). > I assume that the clock maintainers had some reason to move clocks to > be platform drivers. It's just not clear to me what that was. > >> For drivers that use both platform drivers and OF_DECLARE the situation is even >> more complicated as the code needs to take into account that there can possibly >> be no struct device present. For a specific use case that we're having problems >> with, please refer to the recent DaVinci common-clock conversion patches and >> the nasty workaround that this problem implies[3]. > > So devm_kzalloc will work with this solution? Why did we need > devm_kzalloc in the first place? The clocks can never be removed and > cleaning up on error paths is kind of pointless. The system would be > hosed, right? > It depends - not all clocks are necessary for system to boot. >> We also used to have an early platform drivers implementation but they were not >> integrated with the linux device model at all - they merely used the same data >> structures. The users could not use devres, defer probe and the early devices >> never became actual platform devices later on. >> >> Proposed solution: >> >> This series aims at solving this problem by (re-)introducing the concept of >> early platform drivers and devices - this time however in a way that seamlessly >> integrates with the existing platform drivers and also offers device-tree >> support. >> >> The idea is to provide a way for users to probe devices early, while already >> being able to use devres, devices resources and properties and also deferred >> probing. >> >> New structures are introduced: the early platform driver contains the >> early_probe callback which has the same signature as regular platform_device >> probe. This callback is called early on. The user can have both the early and >> regular probe speficied or only one of them and they both receive the same >> platform device object as argument. Any device data allocated early will be >> carried over to the normal probe. >> >> The architecture code is responsible for calling early_platform_start() in >> which the early drivers will be registered and devices populated from DT. > > Can we really do this in one spot for different devices (clk, timers, > irq). The sequence is all very carefully crafted. Platform specific > hooks is another thing to consider. > This is why I added support for early probe deferral - so that we can stop caring for the order as long as the drivers are aware of other resources they need and we call early_platform_start() the moment the earliest of the early devices is needed. >> Once the device and kobject mechanisms are ready, all early drivers and devices >> will be converted into real platform drivers and devices. Also: if any of the >> early platform registration functions will be called once early initialization >> is done, these functions will work like regular platform_device/driver ones. > > This could leave devices in a weird state. They've successfully probed > early, but then are on the deferred list for normal probe for example. > It's not really a weird state - once we're past the 'early' stage, the drivers' "earlyness" no longer plays any role. An early deferred device wouldn't be any different from other deferred devices. It's possible that we enabled some crucial resources in the early stage and then failed to fully probe the device later. I don't see a problem with that. Best regards, Bartosz Golaszewski