devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
To: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: "nicolas.pitre-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
	<nicolas.pitre-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Lorenzo Pieralisi
	<lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>,
	Pawel Moll <Pawel.Moll-5wv7dgnIgG8@public.gmane.org>,
	devicetree-discuss
	<devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>,
	Magnus Damm <magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Hiroshi Doyu <hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Subject: Re: [RFC] early init and DT platform devices allocation/registration
Date: Tue, 25 Jun 2013 08:56:22 -0600	[thread overview]
Message-ID: <51C9AF96.3040107@wwwdotorg.org> (raw)
In-Reply-To: <CACxGe6sPaV-sBz=SF46KdUexjAhWKGrMpG_ty+K26f6ZU5iKdg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On 06/25/2013 05:45 AM, Grant Likely wrote:
> On Mon, Jun 24, 2013 at 5:33 PM, Lorenzo Pieralisi
> <lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org> wrote:
>> Hi all,
>>
>> I am dealing with a lingering problem related to init and probing of platform
>> devices early (before initcalls) in the kernel boot process. The problem,
>> which is nothing new, is related to how platform devices are created in the
>> kernel from DT and when they become available. Platform devices are created
>> through (assuming any legacy static initialization is removed from the kernel)
>>
>> of_platform_populate()
>>
>> at arch_initcall time on ARM. This is a problem for drivers that need to be
>> probed and initialized before arch_initcall (ie early_initcall) because
>> the corresponding platform_device has not been created yet.

What's the use-case here; why does the driver /have/ to be
allocated/probed so early? Can't drivers all be allocated from DT in the
usual fashion, and any dependencies resolved using deferred probe? In
almost all cases, that should work.

...
>> How this problem is supposed to be solved in the kernel ?
>>
>> 1- drivers that are to be up and running at early_initcall time must not
>>    rely on the device/driver model (but then they cannot use any API that
>>    requires a struct device to function (eg regmap))
>> 2- the driver should allocate a platform device at early initcall from
>>    a DT compatible node. Do not know how to deal with platform device
>>    duplication though, since of_platform_populate() will create another
>>    platform device when the node is parsed
> 
> While I've resisted it in the past, I would be okay with adding struct
> device pointer in the device_node structure. I've resisted because I
> don't want drivers following the device_node pointer and making an
> assumption about what /kind/ of device is pointed to by it. However,
> this is an important use case and it makes it feasible to use an early
> platform device with of_platform_populate.

Hiroshi (who I have CC'd here) has also been asking about this same
issue downstream. The issue for us is that we need to initialize an SMMU
driver before any devices that are translated by the SMMU. One option is
to force the register/probe of the SMMU driver explicitly, early in the
machine's .init_machine() callback, before of_platform_populate(), to
ensure the ordering. Then, we run into the same duplicate device issue,
and the change Grant mentions above would help solve this.

  parent reply	other threads:[~2013-06-25 14:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-24 16:33 [RFC] early init and DT platform devices allocation/registration Lorenzo Pieralisi
     [not found] ` <20130624163340.GB26084-7AyDDHkRsp3ZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2013-06-25 11:45   ` Grant Likely
     [not found]     ` <CACxGe6sPaV-sBz=SF46KdUexjAhWKGrMpG_ty+K26f6ZU5iKdg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-25 14:56       ` Stephen Warren [this message]
     [not found]         ` <51C9AF96.3040107-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-06-25 16:36           ` Hiroshi Doyu
     [not found]             ` <20130625.193628.2143557800560690024.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-06-25 17:52               ` Grant Likely
     [not found]                 ` <CACxGe6t9ifg9VRfXKypuhie3pXVPneZqcBy+J1bFpUaUx32P7g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-26  6:00                   ` Hiroshi Doyu
     [not found]                     ` <20130626.090030.1519009485651154440.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-06-26 10:03                       ` Grant Likely
     [not found]                         ` <CACxGe6te2RzFb6nkSZQFrzVX4fkQo4pyzLJ1D7Lf=440mE+jyg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-26 10:31                           ` Thierry Reding
2013-06-26 11:04                             ` Grant Likely
2013-06-26 12:44                           ` Sebastian Hesselbarth
     [not found]                             ` <51CAE235.1000807-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-06-26 13:12                               ` Grant Likely
     [not found]                                 ` <CACxGe6u=BfnbwmS=7X5eYqKuSkmGdu9v-StAx+m7fLd+8C69pA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-27  9:26                                   ` Thierry Reding
2013-06-28  8:49                           ` Hiroshi Doyu
     [not found]                             ` <20130628.114915.1341075505557760886.hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-06-28 10:38                               ` Thierry Reding
2013-06-28 12:27                                 ` Grant Likely
     [not found]                                   ` <CACxGe6vkM+awN94kU2GYfbXPdR=MgYwr=PbqmtD+=i5vmuVSnA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-15 14:23                                     ` Thierry Reding
2013-06-25 17:07           ` Lorenzo Pieralisi
     [not found]             ` <20130625170700.GB28654-7AyDDHkRsp3ZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2013-06-26  6:20               ` Magnus Damm
     [not found]                 ` <CANqRtoTVoLHLvhknpKW4th6wDM1EgY4GTx96OrM-yA42+Sm1aw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-26  9:32                   ` Lorenzo Pieralisi
2013-06-25 16:53       ` Lorenzo Pieralisi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51C9AF96.3040107@wwwdotorg.org \
    --to=swarren-3lzwwm7+weoh9zmkesr00q@public.gmane.org \
    --cc=Pawel.Moll-5wv7dgnIgG8@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org \
    --cc=magnus.damm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=nicolas.pitre-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).