Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp366931ybt; Mon, 6 Jul 2020 11:14:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsPZSugRuHw4JN//SESoIGulsht8olmYLf0LiNcfDMLPUcoSW4gPBtZ646pA4Zck01vT/a X-Received: by 2002:aa7:cd50:: with SMTP id v16mr50345161edw.252.1594059253549; Mon, 06 Jul 2020 11:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594059253; cv=none; d=google.com; s=arc-20160816; b=RnRkfftubhJsmcz5XpCE0P4qHYcNaMOykU57LwEx9L6btxyMwzyWrRC6cLnQGy2RQ9 KExITAZQ0NgopzywrCbdwHwaqdSsXoIg4SIpDIN2Q/N4Hn8ut695Kwvi+8WHNXtK/V08 ln/pi4RiVAKireQLLBlgh8Pm/viqVJdQwDYox2FJJ+3KCPtZr3wvUyWrUpWIVCWBS6Jc z3pOH5il8/jj3+4PfiO3usperPFGvMtTXxFlHD1/wh/0HGTivdRXQnUZKsPqaMsDFyA1 AZ+gWPZxPKPVJ3XKmOomRAjy4DfvkuuLM1gYQEp9fOZnIUW3SjUQjRFHmMswDyXD8CQH wesw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature:dkim-signature; bh=+v/Te64vKu4e35ENQ/jK6ubbrXotygKRxSoJgsFaBMY=; b=g0O/DHER6orLZRMOkmSAH9k5F2QD6v84NtPqfjcu1tbjRG+7llszD8838SdaPpY94w LFQ43jfsOrYVQbQNnesirDFkNKVUKMZ6Pg8jjrBc45kOB+Nrsdu56KX33pdw4XEjzVhb taSQgYf4KJswuoBXNwss75xYcjW36nRPowbNC1bYIhcqCYQwwvaQwXOqWQIRR0yPlp5Y GBGdPTOkcthaAg/j+acmLMwTHirR2CuHHEDwCXaY5AJ6YEn0eCT7Oh2lV148JZ0Ib7we 89kT3/otsoQCQF7GsUJX+rtBGhh/gFibDsVQt1TK9uN0NtnaLAE2SFxFQ+BTP/TSs0wp K+3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=qSy7OzOH; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=qshJlZ0E; 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=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o3si13277562eje.601.2020.07.06.11.13.49; Mon, 06 Jul 2020 11:14:13 -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; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=qSy7OzOH; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=qshJlZ0E; 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=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729693AbgGFSNi (ORCPT + 99 others); Mon, 6 Jul 2020 14:13:38 -0400 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:53335 "EHLO new1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729622AbgGFSNi (ORCPT ); Mon, 6 Jul 2020 14:13:38 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id ED5E958023D; Mon, 6 Jul 2020 14:13:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 06 Jul 2020 14:13:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:mime-version:content-type; s= fm3; bh=+v/Te64vKu4e35ENQ/jK6ubbrXotygKRxSoJgsFaBMY=; b=qSy7OzOH skFlHeU9mi26Sma2rX0D/lgIfCCmui9NIvzQgMWug9tdsg6RIO1cZLqpjdwlhmzB 5KivDkYhKbmi+Wo0kEIvgJ7/u4ISd/JPSAz14cB63lEUXYhlQFEPJ1xuNSKnF/Y2 qpByMVOwDmJgXVa7CRM5SEf+GkyGBnslNoUoCqpSCMc9Qw8+1YLGN98sEL4jJ/VG uN7qMhfDu5+cDGOFlzqbTmXua69/vwUHB5cyE9ue9LlFDnYEWmL2G+ocDPAvFR8A gwbi8wMuLm5W/vQHq4alBcdWVKZuOBsNxCPrhPFIhTaA68X2q/0l6Uwcf5+GDJqy tbZw/+6MOKeI1w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=+v/Te64vKu4e35ENQ/jK6ubbrXoty gKRxSoJgsFaBMY=; b=qshJlZ0E5dHQkkrkVBROwDSY5Sgo3A2aErHKsBk4Qzhcr YwuFLcpq3tbOAjJDSQBmHDR6xZI/1CNCEffKHJUxCkzmx53vJLWlG1WdmkEXmPOD JfwLoYmaXaTcuR45TtB1ww+APCPkk8b6YtmvmF+w/VdCDOm1675nQNe0gWlxAK2m /Gd9KvUT4QKgNYiizc7yFmAfC52rbIbQVOKdX/S6Vor8Znp6GHXGU5Sq4jwTre1P FxtBFwbHScWLP1IFcoDIctKVuofwpIsDZ9BAn3TnMGziXoFlqCJ3z+uhNz3jMYsi DJ6Acx5FPad+2ZtZrUmjIPEXfcNXCVc/IRbnxdkEg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudefgdduvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggusehgtderredttddvnecuhfhrohhmpeforgigihhmvgcu tfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrthhtvg hrnhepkeeffefgffeijeffveehkeffleejgeefvefhkedtteegvdefjeduveehhfetveej necuffhomhgrihhnpehkvghrnhgvlhdrohhrghdpsghoohhtlhhinhdrtghomhenucfkph epledtrdekledrieekrdejieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 7C6193280064; Mon, 6 Jul 2020 14:13:33 -0400 (EDT) Date: Mon, 6 Jul 2020 20:13:31 +0200 From: Maxime Ripard To: Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King Cc: Rob Herring , Frank Rowand , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Antoine =?utf-8?Q?T=C3=A9nart?= Subject: PHY reset handling during DT parsing Message-ID: <20200706181331.x2tn5cl5jn5kqmhx@gilmour.lan> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2ftaacwvvl7mumne" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --2ftaacwvvl7mumne Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. I'm not entirely sure how to fix that though. I tried to fix it by splitting away the gpio / reset code away from mdiobus_device_register into a new function, and calling it before the first call to get_phy_id so that we can put our phy out of reset, but it looks like the device registration makes it more complicated than that. Any ideas? Thanks! Maxime 1: https://elixir.bootlin.com/linux/latest/source/drivers/of/of_mdio.c#L274 2: https://elixir.bootlin.com/linux/latest/source/drivers/of/of_mdio.c#L82 3: https://elixir.bootlin.com/linux/latest/source/drivers/of/of_mdio.c#L119 4: https://elixir.bootlin.com/linux/latest/source/drivers/net/phy/phy_device.c#L830 5: https://elixir.bootlin.com/linux/latest/source/drivers/net/phy/phy_device.c#L791 --2ftaacwvvl7mumne Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXwNpywAKCRDj7w1vZxhR xU1lAQCR+4X7EF6qEnFyxVCuaNV/g3Bjlk5krQv8tSUb3DmQ+AEA2WAuzE9iBzzg Awm1dmo/sBptpDkj+d3oPz4YqsFQvQw= =Gsc3 -----END PGP SIGNATURE----- --2ftaacwvvl7mumne--