Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1241214imm; Fri, 11 May 2018 13:14:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoMYlyOnF6O0crvmnoUTHu02KyjwaKFGP5BeufvrVEfo10lsoB7O//VCMHqxw/EY4i31TRw X-Received: by 2002:aa7:8492:: with SMTP id u18-v6mr182459pfn.225.1526069698415; Fri, 11 May 2018 13:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526069698; cv=none; d=google.com; s=arc-20160816; b=cvg/1ckILFURdV3/fMUWWke6xSFRhAOhFsFKf++y2LZVFzl3yGkF2m0VY0cI5M7dX9 kylQxOl8eO973kI2DBDRU0v8S88wnpUmnjp2WbmmQbETPf5YexhiAZgLoRRnofklTiMO v/CA0zSI6WwcWlpQx3/5+4z5DeJdR+hTusJnT3nxQuUrRNdRHw2H306IEsJqaWAgyq3l K+zPew0/QoaCNmOnS4hgpEqj+zoOyEseOLM671Gx7zeM8KrJNO9XVJ5X978Q3GCfufFA k3Auc0GbSJPEwG8qZF211xLCOAgSlAU1AqlkglVT8oDyNS7ycQtBAW3kdEJLyLIReY37 b8lw== 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=sHVGFlxUPjcLvUIxzBGA00plkGej4krqqdbnEt4M4Cc=; b=vgJNKLugJ364stUUGkXT1ed0p1JNuGsJwAYh3HSYDum4PNKZ4Jx3si15vaDqv1ULMp ZFFRLyLdvXd7mt1IZen0IK2+Mf7hBN9iVD+vpO7f0VxYstVgGwRIW37NO3YnRQnNTNRf 4cypkJ/yMAhDguNy0NWdFZy/CGpRA7RzhrJzW8HywpWkRRfwZENhEtOAHrhfYjh2oN3d xYJZkyn9ywGy5xDNf55CEBORqClezwExxHOFvlPdq/qC5J2S2jZUn6gSrSZfgwNuvrVA T9XAysVt5tX8xfQ7NrP7EPFr0O1woESMqC955LtdigLrOEdtRFabqO4QDdAWte+kSoXj YTdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uGu9o82L; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w21-v6si3249636pgm.433.2018.05.11.13.14.43; Fri, 11 May 2018 13:14:58 -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=@kernel.org header.s=default header.b=uGu9o82L; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752014AbeEKUOS (ORCPT + 99 others); Fri, 11 May 2018 16:14:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:49648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751859AbeEKUN6 (ORCPT ); Fri, 11 May 2018 16:13:58 -0400 Received: from mail-qt0-f172.google.com (mail-qt0-f172.google.com [209.85.216.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5BE9021842; Fri, 11 May 2018 20:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526069637; bh=sHVGFlxUPjcLvUIxzBGA00plkGej4krqqdbnEt4M4Cc=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=uGu9o82LKuwga7FTX/CFj880U69FCkgXO0AqCsqI/YSakvCIEOqm10VVrumCLkawu 1H/4I3dCGQ+BkK8BUylJa5keqo7z4ecJvctl5Tk5pD/rfX3bRJ/4rfY7bUyQUlLm43 BFN3gKVvUCrlIJjbExWvC7V+mXSCbYoE7iqMm5VY= Received: by mail-qt0-f172.google.com with SMTP id m9-v6so8685601qtb.5; Fri, 11 May 2018 13:13:57 -0700 (PDT) X-Gm-Message-State: ALKqPwfsmZXNfJMRPYWHA8c4juhqhJ12QbpCwtro91NXYs0/7cRJxd4F kQTldXSCg6ByuQMZOV42G7bcmptJuu0zT9v2dA== X-Received: by 2002:aed:3a46:: with SMTP id n64-v6mr7175228qte.118.1526069636344; Fri, 11 May 2018 13:13:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.155.2 with HTTP; Fri, 11 May 2018 13:13:35 -0700 (PDT) In-Reply-To: <20180511162028.20616-1-brgl@bgdev.pl> References: <20180511162028.20616-1-brgl@bgdev.pl> From: Rob Herring Date: Fri, 11 May 2018 15:13:35 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 00/12] introduce support for early platform drivers To: Bartosz Golaszewski 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@vger.kernel.org, "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 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 ... 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? > 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. > 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. Rob