Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1727111pxb; Wed, 10 Feb 2021 15:34:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzky7L1Q0aYfMvsyIuTOlpv5TyRAhg3dWlZBerdwmQN4nnFkcBOX4ejH48yCek9dgO+MWIN X-Received: by 2002:a17:906:16c6:: with SMTP id t6mr5269945ejd.102.1613000082523; Wed, 10 Feb 2021 15:34:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613000082; cv=none; d=google.com; s=arc-20160816; b=QH161WjKKpbgScDl78mZi8etUT1f3pZJiUiXcWKeiEivfny0RsWxgg/H9WMNrBmW63 ujwwDpn4gQbfyPmo7bjM+0dX7sAhNpt1mptRdqc+ffmjtbKgJxRJ5I8iw/hSTSHTrtbe +NBYd2lDslv0e4pHHJme4YM4ueZhL9ytVMUsaIrTniSUDG062zrtE9IoQwFE1g2fx5QM kKB8d/DTW8hcfRFqLXfNeOAfBYNjJmJ6+bHK2neygbx9wyCmZPoUfsdSXwJ0lbK8zOC0 cEpOrQa5A/OS0yYnPxLsw71a9ID+bt/iRifD1mjL8USoWMbVGDD8lkmC39YnATlTO2w7 8DBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=MfvAlJS6MDThBR93eBM8Kuwg+g9RRXOQOpVXLQT/p8w=; b=FOgzjJzZgCIjumvKkq+oV3LtB/lEN5F0UAmDgF9EhLzA61+kcwso3G3SONjL3M0Hcz B6Xnvo0SB+E4CjRjnJz2lr9IbgBBgH+LYHcAEfn0CKQKvpdyUXF9eotJYCmigkt1Afn6 g2sg0olTWnwDIOiARJ9cYhBysPcrraSGUedafa3oTM8pZs4+tUPEZO4r1HcEDs5iHEBc iknYG0+l/7/obVrw4FHVQvuvswR8DP7RzirM6e+Hf6K+6DorTjNCSrcU2pxNAPJ4Z77N nPA6M1jPGiy59SOZEaORvR8++wBD5JiIhozof/2gzj90EM6PmQzYuVUpQzYOcGB0Z+Sw f++w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=AO0rWQGl; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j17si2419229edf.464.2021.02.10.15.34.04; Wed, 10 Feb 2021 15:34:42 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=AO0rWQGl; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233741AbhBJXau (ORCPT + 99 others); Wed, 10 Feb 2021 18:30:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233454AbhBJXaj (ORCPT ); Wed, 10 Feb 2021 18:30:39 -0500 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AED7AC0613D6 for ; Wed, 10 Feb 2021 15:29:59 -0800 (PST) Received: by mail-yb1-xb2f.google.com with SMTP id p186so3811397ybg.2 for ; Wed, 10 Feb 2021 15:29:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MfvAlJS6MDThBR93eBM8Kuwg+g9RRXOQOpVXLQT/p8w=; b=AO0rWQGlUWpJkMZF2QG+N2z6oIAl+/5IN78xVvptElOJ4vH3pLlxXzRojB1+486zPN JpqhNhH7o1roOSEhRKJP8+ltwQ9gSUHqHYNQS652gDPbi3ocThUSL984qg6xrqqLk2py zRgDZdkofpBDcgcW27d2nS/Ksh0X3qMob+Jh0T4M+SWXkugv/xt9yZsX+lDCmUds4FQd bP7ryeqZpbgA04rUVzHq50jwS35GzMHjFIk2ws1TiY1yQRGuko6VrNWmLwRKJo9oSIpJ GGvvLmJeqS6nC+LfpaPUImUZh4iJqN5oAeRkq9ywHN2TH4pu8uxdnp7QpdlnUVO1TnRS 7bZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MfvAlJS6MDThBR93eBM8Kuwg+g9RRXOQOpVXLQT/p8w=; b=YaJv4V6T6rABeN9l3n+zZg0kqHvNN495iRqqzKeLAx5X86TgA0Bdp3+P1Ur9vfQpVY ZnKjpz7aqOk/HeOJ2QQ8reOvwuvDBs/9B9tUgl43Hj2RFVufS1wbpPoxV0HD4YjOwL1e 1XXpyRCx8Kl7hy6bJTR3irh/dFiFrnFFuKcqePXhpAgD/LjrpJxJhAMiBh9L7Pxx/7/P YyEGsvHKleKwrvDJTHbAtroMEST4aDfINUjbTKNVR+2HqoKECOqbecXBo38dRZiNkBPH ucO+LPCNc7IfLkqD7oBpdMcP7SpRZD9c15rejHfoFXPEGDt/8IihgPOwy3S56cAMLqVv Aebg== X-Gm-Message-State: AOAM53360XEfxgahvf3w69aFlyfvwvyhaOUHdQuTSQjNldjWxxcJUVEb cHe+3VoPP/RjNKFaVMejo0TysR7lbEmdnDEEtQwV6A== X-Received: by 2002:a25:af0b:: with SMTP id a11mr7449292ybh.228.1612999798394; Wed, 10 Feb 2021 15:29:58 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Saravana Kannan Date: Wed, 10 Feb 2021 15:29:22 -0800 Message-ID: Subject: Re: phy_attach_direct()'s use of device_bind_driver() To: Andrew Lunn Cc: Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Android Kernel Team , netdev , LKML , Jon Hunter Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 10, 2021 at 2:52 PM Andrew Lunn wrote: > > 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. Thanks for the detailed answer Andrew! I think it gives me enough info/context to come up with a proper fix. > 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. I'm not sure if I can control what driver they use. If I can fix this warning, I'll probably try to do that. -Saravana