Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1989888pxb; Thu, 11 Feb 2021 01:05:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKX07YAk5+cGum4FFEo5sr2z/DqNDEOD7qnrIkh1qr0kmWZIdhinPG5M/kK+lQJ68qFaWZ X-Received: by 2002:a17:906:3c0f:: with SMTP id h15mr6698600ejg.295.1613034355451; Thu, 11 Feb 2021 01:05:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613034355; cv=none; d=google.com; s=arc-20160816; b=a4seELlpHw6g5XfDgpaZ2/4E7Nonp80VJDa7MmBkWeQV4Gvfg4TzD7qAHRPA2VODF8 uYfqCxgdaUvjlw8usbs2H3jxkRbE9fQXor1hWuT1FJqJognEqJRuKQkt2ZlqAgKiM7GH UNPsrfFeBT4msPH6OZ6KuKROOX1cIMCv+MBUizsUkXgynIQffb5h4KDWj7FAZe7rrcgD mV6qxqJtpvVBuUUMK4fSAdwJTMog7YoYLjolOWhuZrHc2xj++WPxYK207UYCukKkK2qV pj6nbGR7zfwMy6/eENV6Fqf67OqJ8ijdDua52KdPS7Zn9MISrY9FZ/v+1vnyiq9F4KPg U0lA== 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=q7UX8xRAUx3NEYdZGJAbsbrxAPMirbP6gw872O+KA8o=; b=K2T3Y/IeBfS8k9tel+o4SIjcbTSZIj+FtQlDv4m+x7ukfXrVrh4ovV0cq8GDu60Pq5 mYI6N+VmCZx7p0OrCBVH8vEDWYbMlsHHR1ZoVrxy+09EB0OilpUurpXCaKlKGEzLQHN1 N917okP1/WR14F7n52NJk3mtCpeCUdf8nA3JUrR32BNmwLLhSuITNawphjRfydXw0VFU B3TPcZ5lTM4zoPrAK5hnDVmux2nuRj2dqVtCAOxGm77bu4qzaixZbkRL1ip9NoeGhwQ0 /FR2FdFMgSKdvRJ7Zs7Y6ZeWe74OKZ5dAfaOJPwzO7bNCKiCUHUu9GDFDgq1OWX3bx03 /m7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Xg3FjLP2; 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 a1si3559268edb.294.2021.02.11.01.04.39; Thu, 11 Feb 2021 01:05:55 -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=Xg3FjLP2; 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 S229927AbhBKJBH (ORCPT + 99 others); Thu, 11 Feb 2021 04:01:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbhBKI5p (ORCPT ); Thu, 11 Feb 2021 03:57:45 -0500 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73B74C061756 for ; Thu, 11 Feb 2021 00:58:31 -0800 (PST) Received: by mail-yb1-xb2a.google.com with SMTP id p186so4866968ybg.2 for ; Thu, 11 Feb 2021 00:58:31 -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=q7UX8xRAUx3NEYdZGJAbsbrxAPMirbP6gw872O+KA8o=; b=Xg3FjLP2YzkiPDJPOpJk+hijX0k6WHa6l2qtY8JyPZARLj2WfedEyqy11NQp6ZsaF3 kiXd6917qhcGTwXnB2HWyMontdMQtTaw3/G6XrT+26/K9v8X8wLQF/ax9h1S9fv8RbBT ExAKfRgtRXW9R2xzYSdrBrs73dCenkh6f2MyH3CkKpIGAy9gPQpNS6l5ARf+zZ+GppND oFvb6KwR7VEd28/JLBEs5MLqeXkSLkJklsxF1ULRrdoxb8ckZ16lD/NZwrukBvMX62GC usI/X3IiCQSxORNledNjo3cJb/pWxARqMhdZzpI6RwMzbwvZWecfr5qv19/SC2H0hYmL T7XQ== 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=q7UX8xRAUx3NEYdZGJAbsbrxAPMirbP6gw872O+KA8o=; b=o+lL9rHM1rZOgJ3yMl4g8migdMdiobVfh62tRCzgMLySjGR6qeWh2NvKFZMrqDqLZ5 roT/GxKzRmYig/UQRx/JSzD+PqCnTefmDQETg+IrqyWStlGjw7Rifrt71v2jKbxoJXpZ BLRwGp8oQEnZX7NA1dA/99Kkzxo17pkQnnZAwryoC7ThmzRePJywFQi72/vuI7wbgsmi p58wC+G6+jRy1PwyhDFwFcRO/yrXxids+FjOrKM434hLlnx8KmZ4sk+ZZ+PgaohbYk82 2P0wiJDry0SVJcQGewMjiIirbdvhgNQuCDU2bAmNK3U/v/qSoY8bM40SybLBa+JuxWCg SqWQ== X-Gm-Message-State: AOAM531uV11Enbwd6/hCRPHepkunhATgSsnNN1YESLkeQZ7qZwUP1ACX bWl6TNils4P79Q55nx2ZabfAWKIrEjxqNz0NE0+PNg== X-Received: by 2002:a25:8b8b:: with SMTP id j11mr9412475ybl.310.1613033910135; Thu, 11 Feb 2021 00:58:30 -0800 (PST) MIME-Version: 1.0 References: <4f0086ad-1258-063d-0ace-fe4c6c114991@gmail.com> In-Reply-To: <4f0086ad-1258-063d-0ace-fe4c6c114991@gmail.com> From: Saravana Kannan Date: Thu, 11 Feb 2021 00:57:54 -0800 Message-ID: Subject: Re: phy_attach_direct()'s use of device_bind_driver() To: Heiner Kallweit Cc: Andrew Lunn , 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 11:31 PM Heiner Kallweit wrote: > > On 11.02.2021 00:29, Saravana Kannan wrote: > > 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. > > > The genphy driver is a last resort, at least they lose functionality like > downshift detection and control. Therefore they should go with the > dedicated Marvell PHY driver. > > But right, this avoids the warning, but the underlying issue (probably > in device_bind_driver()) still exists. Would be good if you can fix it. Yeah, I plan to fix this. So I have a few more questions. In the example I gave, what should happen if the gpios listed in the phy's DT node aren't ready yet? The generic phy driver itself probably isn't using any GPIO? But will the phy work without the GPIO hardware being initialized? The reason I'm asking this question is, if the phy is linked to a supplier and the supplier is not ready, should the device_bind_driver() succeed or not? -Saravana