From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754680AbYLJOrL (ORCPT ); Wed, 10 Dec 2008 09:47:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751228AbYLJOq5 (ORCPT ); Wed, 10 Dec 2008 09:46:57 -0500 Received: from yx-out-2324.google.com ([74.125.44.29]:43932 "EHLO yx-out-2324.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751169AbYLJOq4 (ORCPT ); Wed, 10 Dec 2008 09:46:56 -0500 Message-ID: Date: Wed, 10 Dec 2008 07:46:54 -0700 From: "Grant Likely" To: "Dave Hylands" Subject: Re: How to handle device drivers depending on another device. Cc: linux-embedded@vger.kernel.org, "Linux Kernel Mailing List" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 9, 2008 at 11:09 PM, Dave Hylands wrote: > Hi Grant, > >> Problem: There are no guarantees that the MDIO bus controller will be >> probed before the Ethernet device. > > I believe that what you're supposed to do is to have "bus" controllers > initilize themselves using subsys_initcall rather than module_init. If > you look in include/linux/init.h you can see the various initcall > definitions. module_init is at the same level as device_initcall. All > of the initcalls at one "level" are completed before moving onto the > next level. Even so the problem still exists. There is 1 bus and 3 devices involved. The 'bus' infrastructure is the MDIO bus (drivers/net/phy), and it does indeed use subsys_initcall(). But then there is the Ethernet device, the MDIO controller device, and the PHY device. Both the Ethernet device and the MDIO controller device are probed via the of_platform bus. The PHY device is attached to the MDIO controller. So, while the MDIO bus infrastructure is guaranteed to be initialized first; there is no guarantee that the MDIO bus controller will be probed before the Ethernet device. Secondly, even if the MDIO controller is probed before the Ethernet device, there is no guarantee that the PHY device will get registered onto the MDIO bus before the Ethernet device is probed. There remains the uncertainty of which of the two devices will get registered first and the Ethernet driver needs a mechanism to defer initialization until the PHY device is ready. > Of course, if you're using loadable modules, then the dependencies > should take care of things for you. For the bus infrastructure, yes, but not for the bus instances. g. -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.