Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1704193pxb; Wed, 10 Feb 2021 14:54:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGCSIiA5XT/4E1mjvwv+vTpW3TXfTpsTh18mDKmzkj56TbRJyq4x7lBOJjT+v/bIVmRciz X-Received: by 2002:a05:6402:501:: with SMTP id m1mr5392336edv.58.1612997681569; Wed, 10 Feb 2021 14:54:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612997681; cv=none; d=google.com; s=arc-20160816; b=fhQw7uD6wjg7B0nwWPKnuYdm76gvmEiLsk2b3Mb10LZdxWAZr8w0eNZx98ZqW0zjNe ISK4CF6ogoaSEfP9Y4SDuHrBQ1zhkA6LPYurR29hruCp2czUEWMSb+Uh7zWSE5O7HdY1 wK1u9MqwMyQmVJPXgMvu6wOuoGuxG/lMqRVG2rc/3ZMUp4PCzgNB6WDmLGkDk2Xctgwb EWX5wauAUUqPxG2xCHcC5J4Fmt3ptQCAlVGr++bN97K1p9BBepnTu+sH3RmuDJVWvyhk 5QyDQ0SoJbFYUdhfhCWgSlH8gj21Umm4YoECWCwyrRONaeCqcQeFIuaxywJ32yAPVh7J 0U7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=mQzibTT54aXE/TGw8jusqG9YS0Zu+H8JNr+aM/KKL+A=; b=qpag1eNT+Loe/ldBTdFj2jhgWhj9LdNXwV+sbZMuxrUBAqNZ/xUN7yWCcbU2IYR4d+ ndJX+EdA0ukQ2CEGnXQJRlliPUxmzqeBgxVD6gSXMw5S2a5sJAuvYrCCQI17IIz+v71d U4/b6rp4vFF7iTkIelm8Dibnla5J4S7mcdEPgG90ybzULrIv6wVCnx9YnrMkDzAlmPcQ s2bMNm8P3DhSGmLqaT+XeehsHJVhWdpz45H9H+wd/te5Y4jrJrP3NS/8zc4DInrqYa5f GukSbfUEbPV5+zGp7pG6jBZU2H2NmlXXE4+suvzbpIaft20cKHGShaMCAItVjdPEr5FO aIoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si2647290edq.174.2021.02.10.14.54.15; Wed, 10 Feb 2021 14:54:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233641AbhBJWw6 (ORCPT + 99 others); Wed, 10 Feb 2021 17:52:58 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:33634 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233516AbhBJWw5 (ORCPT ); Wed, 10 Feb 2021 17:52:57 -0500 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1l9yLC-005Pl9-0r; Wed, 10 Feb 2021 23:52:10 +0100 Date: Wed, 10 Feb 2021 23:52:10 +0100 From: Andrew Lunn To: Saravana Kannan Cc: Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Android Kernel Team , netdev , LKML , Jon Hunter Subject: Re: phy_attach_direct()'s use of device_bind_driver() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 10, 2021 at 02:13:48PM -0800, Saravana Kannan wrote: > Hi, > > This email was triggered by this other email[1]. > > Why is phy_attach_direct() directly calling device_bind_driver() > instead of using bus_probe_device()? Hi Saravana So this is to do with the generic PHY, which is a special case. First the normal case. The MDIO bus driver registers an MDIO bus using mdiobus_register(). This will enumerate the bus, finding PHYs on it. Each PHY device is registered with the device core, using the usual device_add(). The core will go through the registered PHY drivers and see if one can drive this hardware, based on the ID registers the PHY has at address 2 and 3. If a match is found, the driver probes the device, all in the usual way. Sometime later, the MAC driver wants to make use of the PHY device. This is often in the open() call of the MAC driver, when the interface is configured up. The MAC driver asks phylib to associate a PHY devices to the MAC device. In the normal case, the PHY has been probed, and everything is good to go. However, sometimes, there is no driver for the PHY. There is no driver for that hardware. Or the driver has not been built, or it is not on the disk, etc. So the device core has not been able to probe it. However, IEEE 802.3 clause 22 defines a minimum set of registers a PHY should support. And most PHY devices have this minimum. So there is a fall back driver, the generic PHY driver. It assumes the minimum registers are available, and does its best to drive the hardware. It often works, but not always. So if the MAC asks phylib to connect to a PHY which does not have a driver, we forcefully bind the generic driver to the device, and hope for the best. We don't actually recommend using the generic driver. Use the specific driver for the hardware. But the generic driver can at least get you going, allow you to scp the correct driver onto the system, etc. Andrew