Received: by 10.192.165.148 with SMTP id m20csp2283021imm; Thu, 26 Apr 2018 08:32:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp8G5BeNvX55xP3Z7KBp0SMNu0p14apej/+FMeRj1H1vHbVZCfLChHklE9lnMkxcw++fEEH X-Received: by 10.99.3.69 with SMTP id 66mr4765480pgd.98.1524756756343; Thu, 26 Apr 2018 08:32:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524756756; cv=none; d=google.com; s=arc-20160816; b=dZpcSVGqHMHhkZ6RT3FvZZ56rIFfmEqO2Gpzqm3D/2xiLApbp1L+LG3b201m5yFkZ8 yWetY05vET1o64kQ+4N6TxtbOvYV4bZRVbg0g7pvVqRaurCdz8OjwgFB8I+QeKgP4qTS 3JduUpAhJvN8/NVm8s7/+EitL4kWnfN1UE6AKlJp0MFKUxmNE2LYy+YH4HHgqu4ar7xL Wmkgej98hfwFQr5BtBpSvWSvGNGotc1pceDrvtVuGoQ2ZnYcdglTmyVk8kTeFq1CCI6Y SfR7gCa7lBYNMQAFmnUIIjBiQkRK9TA+XCN9fYObc5FTjImW8At0aXwV7viB/6Arjh+r jYcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=psxLmNITlMYHCRdygaR0WxL86seus5FiYSOervPjrTw=; b=ZTl3kPnWiZVwwb7FTLIgEyZdp8U4Ti9aiJpGZYd8Brgsr3383xLxhActjlQYTHQc7I /4za1wsriV5EzKroQ6obuASZh96ZdmeZRAOKcioWtpBMIvG4bKQI50oO5Yt1dp2mkA3F rbeCLajTLIWxWlrZQYxvjiYPfPvy0S1MNehMPWSk2zDyXd86Qhu5GVSAkI89Afjd1Q5P IWfcvKsA48BzbwTtq7/HqradhtxZwrwEuitJ2vpCcZKi4wJm4ekuvohhBA7s0blI9ejY z5bLx8LKq3cSnTgiYG8tEbu5Kf2bmPPa5uh58v4N6B6b9GrJOuVWTRcCqwyOduW1a6rb daLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=fUAYMrEF; 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 n23si16375964pgc.359.2018.04.26.08.32.22; Thu, 26 Apr 2018 08:32:36 -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=fUAYMrEF; 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 S1756703AbeDZP3l (ORCPT + 99 others); Thu, 26 Apr 2018 11:29:41 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:51508 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756501AbeDZP3f (ORCPT ); Thu, 26 Apr 2018 11:29:35 -0400 Received: by mail-wm0-f65.google.com with SMTP id j4so13724315wme.1 for ; Thu, 26 Apr 2018 08:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=psxLmNITlMYHCRdygaR0WxL86seus5FiYSOervPjrTw=; b=fUAYMrEFUtv+QhKCw0VzsBUZOstSo26FlzcwOaPTr3x3C/V5M0r+HAUCo86rchBX4f OU1HVJGLyCyju+e4L9s0UCwMRu70Z51ocj8lAhiHcikkpW7ABfhxDtnoIYXUJX/KM+DG RFZZfiNQsmshfnmX1agyRtSwFU78+gdaihMjYFq2nMm9YY7cPPf07DHNPTWurCIA7Kfb RqBknG15kA90rsFNuf5PjG8I/7zLAkMfQ7CyThT2WqjOTsIwUgkE6/ctXHs4szFShy9d LRliH9uVXeUNRGM1S8M6np9kXSKgDTLQvvskK3Z/pjQL1KFwPV0oMQyqq9oQruwUOODs rUeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=psxLmNITlMYHCRdygaR0WxL86seus5FiYSOervPjrTw=; b=aCRQwYaBf2yQdta0LV9ezGF76Qsqr/DRFRlR5w+q4w2H7QZK8tj6HH+jwjZ0QvKwC2 Y6a1IYw1u8GNSAMHMCRofN6pqZSlOBkY2OeDfZgvhiSFklhro1llSnfznQnKNINDYkG4 PPKLTlwIPmntGhbWxOkrKtu9/Gm7PPMD/3pau8eQdpvtPSTSHhYkeIoyFkHCcMg/o2nR 6QyQK0KAOdvqss7CXOB2WvaRQ4mqry+ojFEF8+p5fuIsR6aT4SNVrt5YlVJK/uiBxyJW RzpK/4HOiEFaKtlMB+xaq0sF9rYP3xPd1+r3J3EkmKWdcLKNJwzYH1i5gIY3BxGDZ25b gRQg== X-Gm-Message-State: ALQs6tAcs/14giFxfC6QODMfEBgL6WZnFvUc6YUqqxrgYwKHVlCFFRuA cTTM1yrvezZtqx3D3Jx+GXGz1g== X-Received: by 10.28.74.133 with SMTP id n5mr20698207wmi.31.1524756574154; Thu, 26 Apr 2018 08:29:34 -0700 (PDT) Received: from brgl-bgdev.lan (LFbn-NIC-1-84-58.w2-15.abo.wanadoo.fr. [2.15.173.58]) by smtp.gmail.com with ESMTPSA id q2-v6sm2679355wrj.57.2018.04.26.08.29.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Apr 2018 08:29:33 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , David Lechner , Michael Turquette , Stephen Boyd , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Mark Rutland , Yoshinori Sato , Rich Felker , Frank Rowand , "Rafael J . Wysocki" , Jarkko Sakkinen , Dmitry Torokhov , Arend van Spriel , Heikki Krogerus , Michal Suchanek , Jan Kiszka , Andy Shevchenko , Marc Zyngier , Peter Rosin Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH RFC PoC 0/2] platform: different approach to early platform drivers Date: Thu, 26 Apr 2018 17:29:18 +0200 Message-Id: <20180426152920.21569-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski This is a follow to my series[1] the aim of which was to introduce device tree support for early platform devices. It was received rather negatively. Aside from using device tree to pass implementation specific details to the system, two important concerns were raised: no probe deferral support and the fact that currently the early devices never get converted to actual platform drivers. This series is a proof-of-concept that's trying to address those issues. The only user of the current version of early platform drivers is the SuperH architecture. If this series eventually gets merged, we could simply replace the other solution. The current implementation of early platform drivers is pretty much a hack built on top of the early_param mechanism. The devices only look like platform devices and use the same structures but never actually get registered with the driver model. The idea behind this series is to allow users to probe platform devices very early in the boot sequence and then switch the early devices to actual platform devices and the early drivers to platform drivers in during device_initcall. If any of the early registration functions is called after device_initcall, we'll just end up calling the normal platform_driver/device_register routines. The user can specify if he wants the device to be probed the second time after this conversion and the check if it's an early or a normal probe from the driver code. We also support a simple version of probe deferral: initially each new registered device is added to the head of the early devices list. If it matches an early driver, it will be probed. If probe return -EPROBE_DEFER, it will be moved to the tail of the list and reprobed the next time we match a device but after all other devices. This implementation has certain shortcomings that will be addressed if the feedback is at least somewhat positive. For instance: the driver registration happens in early_initcall(). This may be too late for certain clocksource or clk drivers. The solution for that would be defining a new section in which the init callbacks of the drivers would reside and let the architecture call the actual registration function whenever it's needed. I also need to figure out if any locking is needed. We don't support DT in this series either. The proposed approach would be to walk over the devices nodes early in the boot sequence and allocate and probe the matching early devices and then register them with the driver model later. [1] https://lkml.org/lkml/2018/4/24/937 Bartosz Golaszewski (2): earlydev: implement a new way to probe platform devices early misc: implement a dummy early platform driver drivers/base/Kconfig | 3 + drivers/base/Makefile | 1 + drivers/base/earlydev.c | 175 ++++++++++++++++++++++++++++++++ drivers/base/platform.c | 11 ++ drivers/misc/Kconfig | 8 ++ drivers/misc/Makefile | 1 + drivers/misc/dummy-early.c | 46 +++++++++ include/linux/earlydev.h | 63 ++++++++++++ include/linux/platform_device.h | 4 + 9 files changed, 312 insertions(+) create mode 100644 drivers/base/earlydev.c create mode 100644 drivers/misc/dummy-early.c create mode 100644 include/linux/earlydev.h -- 2.17.0