From owner-freebsd-current@freebsd.org Wed Apr 20 00:49:33 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE9D7B1398D for ; Wed, 20 Apr 2016 00:49:33 +0000 (UTC) (envelope-from howard0su@gmail.com) Received: from mail-io0-x22c.google.com (mail-io0-x22c.google.com [IPv6:2607:f8b0:4001:c06::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7994B1976; Wed, 20 Apr 2016 00:49:33 +0000 (UTC) (envelope-from howard0su@gmail.com) Received: by mail-io0-x22c.google.com with SMTP id g185so37085712ioa.2; Tue, 19 Apr 2016 17:49:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6vphQgmHfnET+JyJ0TibVd/XsJ9VoxW8O+1jOzC8dfA=; b=UApYXrt4FUt0RvwbDbaG5VEr/07ciktgDab2tTUv0nZxxdH8uEPnVaw/DCqrU94v2p tll+Pyjh+NTnB0uVwaBqctmPW5GQIItoJsi6zQRCZi1Q3Xa40JtgnCaP4G3zyz7MOjRD j8N+kZdPgZE9Sgr1CEbvx3zTzM+/6auU7gsAjpmYIZkIVINPEVlPxd7QTe1RqvtvSneH yADewGl1ZvX5RB7BVM1QgUjvpNon5j7kaqmuWBa49xsAWFrym5aCYEVrbnfItv7ImSGh LYjlesl8xgDgM8b1vzxWTafyZWas8RpAETeWjeIH6AB3mz+aKtT+RLdDLJXCegMWNvEH o4xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6vphQgmHfnET+JyJ0TibVd/XsJ9VoxW8O+1jOzC8dfA=; b=G9yoqtqQnHPrN1VFJowakX237qoNz6S28x7DUKJL8MseMb3NZ254VoFfoQ93zMBN5n ggl9YXVWUJ03FPFgt6rekInvejpMPwOYY8DiWfp3MSkSOc/JhNtAMaagLPZCGM6MTV+2 +J+/Jr4Epl+2hvePUkCBHOViAd4KibS+RzG44NM25ajfjRxKa6QRRFX6f9by+HGC+xw9 VSMvVwfhCw7CF0OWeESY5fBW3wiSh5+SSngulXK/kcnzNYqpjwKg12vCeEQI/z+5w6fF ud4OI5MFvUzW2MKoEYEaoqs/fk6OZOeeSauofoEka0Ge0W1iIZ55iUIf4HAaWQv1xVxv GPrA== X-Gm-Message-State: AOPr4FX4uf4SnOKoRGlECnc/7fmdK9DR+d1FZMOBI+zdAzdn1OYGjYYzDBztL4p8N3+Hrnw6VwnOvxo/i5McSg== X-Received: by 10.107.132.202 with SMTP id o71mr6363575ioi.118.1461113372972; Tue, 19 Apr 2016 17:49:32 -0700 (PDT) MIME-Version: 1.0 References: <1611132.EbTME86UTe@ralph.baldwin.cx> <2291840.VrgKOUFVXv@ralph.baldwin.cx> In-Reply-To: <2291840.VrgKOUFVXv@ralph.baldwin.cx> From: Howard Su Date: Wed, 20 Apr 2016 00:49:23 +0000 Message-ID: Subject: Re: Mis-use of BUS_PASS_ORDER_MIDDLE To: John Baldwin Cc: freebsd-current@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2016 00:49:33 -0000 Can we only load the bus driver that is required by timer or pic? Then you don't need worry about acpi_pci or pcib. John Baldwin =E4=BA=8E2016=E5=B9=B44=E6=9C=8820=E6=97=A5= =E5=91=A8=E4=B8=89 =E4=B8=8A=E5=8D=883:26=E5=86=99=E9=81=93=EF=BC=9A > On Tuesday, April 19, 2016 03:42:40 PM Howard Su wrote: > > On Tue, Apr 19, 2016 at 2:53 AM John Baldwin wrote: > > > > > On Monday, April 18, 2016 11:10:12 PM Howard Su wrote: > > > > I noticed several places there are code like this, especially in > some arm > > > > low level drivers. > > > > EARLY_DRIVER_MODULE(aw_ccu, simplebus, aw_ccu_driver, > aw_ccu_devclass, > > > > 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); > > > > > > > > =E2=80=8BI feel the usage of BUS_PASS_ORDER_MIDDLE is misused. Ther= e are > another > > > > macro EARLY_DRIVER_MODULE_ORDERED, which take an additional paramet= er > > > > "order". I believe BUS_PASS_ORDER_xxx is used for that parameter. > > > > > > No, this is actually correct. The _ORDERED variants actually accept = a > > > SI_ORDER_* value to determine how drivers contained in a single .ko > file > > > are registered (in particular if you have several drivers in a .ko fi= le > > > you typically want the "top-most" driver to attach last so that all t= he > > > other drivers are ready once the actual device is attached). > > > > > Why not use _ORDERED here to achieve same thing? _ORDERED(...., > > SI_ORDER_LAST, BUS_PASS_BUS)? > > > > I am thinking to add some macro like BUS_DRIVER_MODULE, > INT_DRIVER_MODULE, > > TIMER_DRIVER_MODULE, so that the driver can declare itself in such way. > If > > we can avoid usage of BUS_PASS_ORDER_XXX, the macro is much cleaner. > > > > I am plan to do is: in autoconf phase, first load timer, int and some > bus, > > etc low level drivers first, then set cold=3D0, then load other driver = to > > work around the problem that driver needs special handling on cold whic= h > is > > not necessary. of course, this may depends on your change of ap_startup= . > > thoughts? > > I would like to get to that, but the path on x86 is a bit messier. Ideal= ly > the order looks something like this: > > - enumerate the tree (BUS_PASS_BUS) > - reserve fixed-resources (things like acpi_sysres) (BUS_PASS_RESOURCE) > - reserve existing resources that could be moved or disabled if > their is a conflict (think PCI BARs programmed by firmware and/or > doing an initial pass of BARs) > - interrupt controllers (may need resources) (BUS_PASS_INTR) > - timers (probably need resources, need interrupts) (BUS_PASS_TIMER) > > Then all the rest. > > However, it ends up a bit messier on x86 at least. I have a WIP to at > least start doing BUS_PASS_BUS for x86, but I found that I really need > some ACPI bits to probe before the ACPI 'pcib' driver, so I've ended > up with a kind of 'BUS_PASS_PREBUS' for acpi0, and even then it turns out > that in some cases we need more granularity than just 'BUS_PASS_xxx'. > > SI_ORDER_* with ORDERED will not help as all the drivers are registered > at SI_SUB_DRIVERS during boot (which is when the SI_ORDER_* applies), > but the device tree is enumerated and attached at SI_SUB_CONFIGURE. > > And yes, the AP startup stuff is a precursor for this. > > -- > John Baldwin > --=20 -Howard