Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1080185ybt; Tue, 7 Jul 2020 07:22:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHSU9IYLI6qk36ufqxPE0wowUYGOMb8Vv6s8QJgUrME5epgU3+7jUQtdt/xm9ZdHZlj2Ad X-Received: by 2002:a17:906:c201:: with SMTP id d1mr40984187ejz.40.1594131742559; Tue, 07 Jul 2020 07:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594131742; cv=none; d=google.com; s=arc-20160816; b=DoRcNohrO2DU8Vhensuxr+8YyN5gwa3WeQROoD5ugF8qOyKw3a/AobN2h1xD5Qdlkc bo1YVJeYslYxFSoCSiYE2z8RPxX73Ivvw/hsQpQvIaZDZxBq1xxkby85QEKIfWXDW3re hQCKI5G8doAA1zDeFZ7Ws+g84F3iZeSW+Uon4G/xGqKY26SzrNKDfKU5RoQDROZOYc2H sPjE8dgouEVOybS0c7jqSotEbr3W3FShWjzhvGYLs7LUwZWGsQGlj8XGzz9j1uJ9kaRF cNaZ8k3sGuGQjr7qP7AdjbcUrAxoAg6Kn/MJSrZn6lNDageapm23zFz7Vml4i53+0hD7 xiQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=dYbaZ/Wrqjq9DfyL4B+C3WNQNVZv8ZpiR5uz1yeQJXU=; b=nNGvC6fuBqCvFUMLEyEf6In8F7TOrJ1Vv6DZf/hAOmLSKNcmrBLLbrAmRN9Ke4ISsZ 3yNx+IUaB/ItWRJbjm7FzMoYKL8cz/52Og9u6GTlndbNbimSeOcToiReKNQaEGevsK/C hqJW0EFvkB+YQTJ6EumieunezXKIeH2UWpcoBYboMEO9tjygSmJv3MCPt20tM6GOpjxA vulSSSxeijSjMldFlRkoqMVE7x6KXF+c7hAOKEEJyEJer6ZPpk0adpqtRKU+O4Xxb6JK 37Bg0j9loZDLL8HaA9Rd17/EMgGAqxGBgwBLLc4T8npic6+UVxc7uzWrXDnhAmJ0FkTP UACQ== 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 f15si14429787edt.552.2020.07.07.07.21.58; Tue, 07 Jul 2020 07:22:22 -0700 (PDT) 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 S1728366AbgGGOT3 (ORCPT + 99 others); Tue, 7 Jul 2020 10:19:29 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:51012 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728110AbgGGOT3 (ORCPT ); Tue, 7 Jul 2020 10:19:29 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1jsoRK-0041ut-8O; Tue, 07 Jul 2020 16:19:18 +0200 Date: Tue, 7 Jul 2020 16:19:18 +0200 From: Andrew Lunn To: Maxime Ripard Cc: Florian Fainelli , Heiner Kallweit , Russell King , Rob Herring , Frank Rowand , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Antoine =?iso-8859-1?Q?T=E9nart?= Subject: Re: PHY reset handling during DT parsing Message-ID: <20200707141918.GA928075@lunn.ch> References: <20200706181331.x2tn5cl5jn5kqmhx@gilmour.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200706181331.x2tn5cl5jn5kqmhx@gilmour.lan> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 06, 2020 at 08:13:31PM +0200, Maxime Ripard wrote: > Hi, > > I came across an issue today on an Allwinner board, but I believe it's a > core issue. > > That board is using the stmac driver together with a phy that happens to > have a reset GPIO, except that that GPIO will never be claimed, and the > PHY will thus never work. > > You can find an example of such a board here: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/sun6i-a31-hummingbird.dts#n195 > > It looks like when of_mdiobus_register() will parse the DT, it will then > call of_mdiobus_register_phy() for each PHY it encounters [1]. > of_mdiobus_register_phy() will then if the phy doesn't have an > ethernet-phy-id* compatible call get_phy_device() [2], and will later on > call phy_register_device [3]. > > get_phy_device() will then call get_phy_id() [4], that will try to > access the PHY through the MDIO bus [5]. > > The code that deals with the PHY reset line / GPIO is however only done > in mdiobus_device_register, called through phy_device_register. Since > this is happening way after the call to get_phy_device, our PHY might > still very well be in reset if the bootloader hasn't put it out of reset > and left it there. Hi Maxime If you look at the history of this code, commit bafbdd527d569c8200521f2f7579f65a044271be Author: Sergei Shtylyov Date: Mon Dec 4 13:35:05 2017 +0100 phylib: Add device reset GPIO support you will see there is an assumption the PHY can be detected while in reset. The reset was originally handled inside the at803x PHY driver probe function, before it got moved into the core. What you are asking for it reasonable, but you have some history to deal with, changing some assumptions as to what the reset is all about. Andrew