Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2655810pxb; Thu, 11 Feb 2021 19:46:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoO/ae1ag23zazMet+hfd3tSnYFSerVcoW/tHeNZCHjEOyyVIb731rsQPw7DNldCANaP6f X-Received: by 2002:a17:906:688e:: with SMTP id n14mr667297ejr.205.1613101615157; Thu, 11 Feb 2021 19:46:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613101615; cv=none; d=google.com; s=arc-20160816; b=oeQQcibTO6Zut/x7ep8PPSWGor6NO4gPg+b+GIpGWOrbSVUCOFERm2KIN2eU5gGFyr 06pe52lpw0IS2/bs6K2ARCx6Gp4eg95K/5S53BOH0IqAsVNv4ljut84eLP0BHNk/i96D S35+/fUxfbqi6vUrGl9sHH6j+mq0W3z9JGo7R+bGpK9+5LsweBbhnDqpDMCnjq5NU/qa clu3uZ7qx4vPg6L6LXWzyXmB6hL+z7kE5KPBcSF/YpphCMe5ZrXDL6UPIUatN8EuKrQt Njsr9VRuGGEgN5I0mD6qQqWOulMfGy/XzkoiaPs/Dd7HLL1edNgInI3WS+T0cgmFkofC wkxQ== 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=fO2dAUD/g2FJ6JkizhIC2grkl0fhoTQPAOqI9IcmjlU=; b=08vrefW2QNLWS3yNhjhLjoe8dDPqqvjmnNd5a76/R8IPdqetkF5l43S+q2xrDJ4zNY B465JR4H3iV3nVy8xhtL44p4xvnsemqvnDLunmBKwjPUrHqRz4oPJYoHIENniy7M+aqP IC1EZfHysJavwBr3YPkt/amCBRgI9ufVAItTSZcICy+r5n8P74Ox/0T6+3YrlQmPUI7y JuNAf89fmhn7asGzQkFABreoe+oa4jXzJdyd2DO5A7q++s4UNhXoY5NwdrwJuGnx6ZF8 oiRYohHcpKUVWYIOv51KXXe3QxMqdoUSrlNbz1FDSILxd9m6ppmY/8rJ2IaKh3ceGU19 Vm1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jGZB9cZE; 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 a23si5783635eda.386.2021.02.11.19.46.31; Thu, 11 Feb 2021 19:46: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=jGZB9cZE; 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 S229832AbhBLDoF (ORCPT + 99 others); Thu, 11 Feb 2021 22:44:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbhBLDoA (ORCPT ); Thu, 11 Feb 2021 22:44:00 -0500 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B461BC0613D6 for ; Thu, 11 Feb 2021 19:43:14 -0800 (PST) Received: by mail-yb1-xb31.google.com with SMTP id r2so7776441ybk.11 for ; Thu, 11 Feb 2021 19:43:14 -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=fO2dAUD/g2FJ6JkizhIC2grkl0fhoTQPAOqI9IcmjlU=; b=jGZB9cZEdWkKlfqSRphqDwh6vCabGoYHMqfUPXnOXwPxnZn+P3pTBuM8LNv2Hlcl0E BQatBRHsk7w2yWo/lbqu6zd7zgrOdAi0mwrA2FuWQrpP0LQSrVDHerf7CAc4VjhLkrRV Iq1n1cwnxkPGFzVsgjAGEmXYls+XHlFBL5bdNj538svSk/oyAwfrVsq2Y9sPoyH/F4Hz bNtizHFOb51gDpgYqCBz4413nrM5x48xThiqjRPhQNcXaLfAvASGuHWv1EljOtOK3jxS 1XnamgtZvs7xOx22kAl7JSL4IqK+M89+80YaZkU8Izfpw7aDB/ogPHe3p7JotC+76c/x 30kA== 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=fO2dAUD/g2FJ6JkizhIC2grkl0fhoTQPAOqI9IcmjlU=; b=W3srMyWv2fZwwlVI0AoX3zeoFtxA/r2idqqi8oSX1OngTfLgSukNBHU/2h8UL90ewA 4i/8jXJy08rUSf7iRZM6XYZ/S4u7eyhj40CIgq8tFaiV2d5QYMhPpRDaqfcwd34YX6mD r9peFmbXkEDV00wTRnjOUfnkOonK/fix1VmfV8VLpk+CPtmXhgblggtVA/4S6o1ChnhH TFe+zsiHEVN30WOAjtnm6kd875j9fpJIcD9mUdXqIW61bmxsbXprKr5q7uLCOrMD/hUt VGKu/IPAx/cNheQQwQZZRILihV/WVt3c1gpXqqYThyhqdX2unCob8x+8KMgdX6UrzfCC GgcA== X-Gm-Message-State: AOAM532ywIbn82i7nvOTx6LhQekZdNFnu7145apyM9/92M9YxoL+Y1WB JkFDn1RA8pRtevSjWAvmvLhaZkLQyaGyIaPWRwsboA== X-Received: by 2002:a25:cc89:: with SMTP id l131mr1459522ybf.346.1613101392785; Thu, 11 Feb 2021 19:43:12 -0800 (PST) MIME-Version: 1.0 References: <4f0086ad-1258-063d-0ace-fe4c6c114991@gmail.com> In-Reply-To: From: Saravana Kannan Date: Thu, 11 Feb 2021 19:42:36 -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 Thu, Feb 11, 2021 at 5:57 AM Andrew Lunn wrote: > > > 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? > > There are four different use cases for GPIO. > > 1) The GPIO is used to reset all devices on the MDIO bus. When the bus > is registered with the core, the core will try to get this GPIO. If we > get EPROBE_DEFER, the registration of the bus is deferred and tried > again later. If the MAC driver tries to get the PHY device before the > MDIO bus is enumerated, it should also get EPROBE_DEFER, and in the > end everything should work. > > 2) The GPIO is for a specific PHY. Here we have an oddity in the > code. If the PHY responds to bus enumeration, before we start doing > anything with the reset GPIO, it will be discovered on the bus. At > this point, we try to get the GPIO. If that fails with EPROBE_DEFER, > all the PHYs on the bus are unregistered, and the bus registration > process fails with EPROBE_DEFER. > > 3) The GPIO is for a specific PHY. However, the device does not > respond to enumeration, because it is held in reset. You can get > around this by placing the ID values into device tree. The bus is > first enumerated in the normal way. And then devices which are listed > in DT, but have not been found, and have ID registers are registered > to the bus. This follows pretty much the same path as for a device > which is discovered. Before the device is registered with the device > core, we get the GPIOs, and handle the EPROBE_DEFER, unwinding > everything. > > 4) The GPIO does not use the normal name in DT. Or the PHY has some > other resource, which phylib does nothing with. The driver specific to > the hardware has code to handle the resource. It should try to get > those resources during probe. If probe returns EPROBE_DEFER, the probe > will be retried later. And when the MAC driver tries to find the PHY, > it should also get EPROBE_DEFER. > > In case 4, the fallback driver has no idea about these PHY devices > specific properties. They are not part of 802.3 clause 22. So it will > ignore them. Probably the PHY will not work, because it is missing a > reset, or a clock, or a regulator. But we don't really care about > that. In order that the DT was accepted into the kernel, there must be > a device specific driver which uses those properties. So the kernel > installation is broken, that hardware specific driver is missing. Thanks! I don't know anything about mdio (other than the generic bus stuff) or "MAC driver" (except for "MAC address"). So I had to read this multiple times and I think I finally got it at a high level. So, to summarize it and ignoring case 4, the phy device would never get added to driver core before all it's required resources are available just because of how it's part of an ethernet controller/mdio bus. So by the time we force bind a PHY to the generic driver, all the required resources should already be set up and work with the generic driver. So the plan to fix this warning is, when device_bind_driver() is called: 1. Delete all device links from the device (in this case, the PHY) to suppliers that haven't probed yet because there's no probe function that can defer at this point. 2. Then call the usual device link status update code so that it updates the status of the remaining device links correctly. This will avoid the warning. This seems like a generic solution that works for PHY and for any device that is force bound. Thanks for the help! -Saravana