From owner-freebsd-arm@freebsd.org Wed Aug 9 21:59:28 2017 Return-Path: Delivered-To: freebsd-arm@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 B8154DD6E5C for ; Wed, 9 Aug 2017 21:59:28 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1a.eu.mailhop.org (outbound1a.eu.mailhop.org [52.58.109.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4907C30FE for ; Wed, 9 Aug 2017 21:59:27 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 01f06699-7d4e-11e7-b2f5-7fbc454a3a22 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.78.92.27 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.78.92.27]) by outbound1.eu.mailhop.org (Halon) with ESMTPSA id 01f06699-7d4e-11e7-b2f5-7fbc454a3a22; Wed, 09 Aug 2017 21:59:26 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id v79LxLEU001973 for ; Wed, 9 Aug 2017 15:59:21 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1502315961.50720.75.camel@freebsd.org> Subject: Re: devicetree vs. MODULE_DEPEND From: Ian Lepore To: freebsd-arm@freebsd.org Date: Wed, 09 Aug 2017 15:59:21 -0600 In-Reply-To: <20170809205919.GA62042@freebsd-t420.fritz.box> References: <20170809205919.GA62042@freebsd-t420.fritz.box> Content-Type: multipart/mixed; boundary="=-5K3xDeACkttgD5cSaPTU" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Aug 2017 21:59:28 -0000 --=-5K3xDeACkttgD5cSaPTU Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit On Wed, 2017-08-09 at 22:59 +0200, Manuel Stühn wrote: > Hi list, > > is it correct, that the sequence in the devicetree-blob defines the  > probing sequence without considering the MODULE_DEPEND-macro? > > I stumbled over an unexpected behavior during the ti_pruss-driver  > development. Because the ti-pruss is gone in the default devicetree, > I  > activate it via the overlay-framework and put it to the address  > "/ocp/pruss@4a300000".  The devicetree-blob contains the entry and > the  > driver gets probed, but it fails to enable its clock.  > This is quite obvious as according to dmesg the am335x_prcm0 is > probed  > _after_ the ti_pruss0 device. So I tried to handle this by adding an  > explicit dependency to ti_prcm into the ti_pruss driver like:  > MODULE_DEPEND(ti_pruss, ti_prcm, 1, 1, 1); > > It compiles cleanly, unfortunately this changes nothing. Only placing > it  > in the devicetree after the prcm-node or loading it as a module > after  > the OS booted up makes the device probe correctly. > > Any ideas? MODULE_DEPEND only affects the kernel linker.  It ensures that other modules you depend on automatically get loaded along with your module. Try the attached patch to ensure that the clocks driver is loaded earlier than drivers that might rely on it. -- Ian --=-5K3xDeACkttgD5cSaPTU Content-Disposition: inline; filename="am335x_prcm.c.diff" Content-Type: text/x-patch; name="am335x_prcm.c.diff"; charset="us-ascii" Content-Transfer-Encoding: 7bit Index: am335x/am335x_prcm.c =================================================================== --- am335x/am335x_prcm.c (revision 322019) +++ am335x/am335x_prcm.c (working copy) @@ -465,8 +465,8 @@ static driver_t am335x_prcm_driver = { static devclass_t am335x_prcm_devclass; -DRIVER_MODULE(am335x_prcm, simplebus, am335x_prcm_driver, - am335x_prcm_devclass, 0, 0); +EARLY_DRIVER_MODULE(am335x_prcm, simplebus, am335x_prcm_driver, + am335x_prcm_devclass, 0, 0, BUS_PASS_TIMER + BUS_PASS_ORDER_EARLY); MODULE_VERSION(am335x_prcm, 1); MODULE_DEPEND(am335x_prcm, ti_scm, 1, 1, 1); --=-5K3xDeACkttgD5cSaPTU--