Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3649921pxj; Mon, 21 Jun 2021 03:36:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymeLNSjks8oy1tIvUHAhRKskirDNSlVRqFsRJuSvP7kKAnaEFT5qixkDEYtPm/JBeRo25J X-Received: by 2002:a05:6e02:1c85:: with SMTP id w5mr4469360ill.285.1624271801758; Mon, 21 Jun 2021 03:36:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624271801; cv=none; d=google.com; s=arc-20160816; b=u995RxBcngb5Ag7kaRoTHMUJwkNJ71SjRx96tub1hlv9UpU8hEVyQ8iFXZNbeQ2+E7 YAa/krqFYfMXxhLqkU4/5UajCr7HBd7Cfph1EruFZEg3ZMDbHs/lRCv3K8StDZq+1ryu 0J8mkv9DnG1oSlyt3s4hzKkQo88VF1Q1z6kcu/sT7EaLJQvc4nIhJFqSyKp8uektXBeD TZBb4tN8jdSJd7tb9zejWzQ6bblY+WH/inJ4jCPBn56Wu09kGydDW67l5VkE4o6n2jI7 DVui6ph3JHRtBecbDcLluGjpNBYBm8bhM0xf7QYvanhblIDx4fokAzw0SpJlHWoyRW3F Mo/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=qACWu+bnbyPKnWsJHtA+hAZdpnvZk5bHIEy1Pug1Wwg=; b=HZWZwK4zhLp7mFCDbaXbM+TXmEImxSMRbNbfq5LMOplQsbmv+qQsbwtVTTD1L4fzhQ 1LwihbzSZZ78OS1ahukXWkM1n1aSykqcTrNA0dbtvkXOnm7TXkt3Lw6GoXfJpZA4cTAo EDX1IjY7TP2VFz4PYyPB6oX8fz3xU95NrnNf1MKaxAjkBdRlcwJX+019r2HobmGu+Il/ YA2Ak3ZTbuqPh+zjOvEZG8MrKoBsZN1xfJ3WSHzJ8mF1TkmVdhIZAa9fJjNUciz/T/g9 Du5rT3RMCtnMKvDuIA/Q2WXRB1NPhe2reQ1MfM+MaFjBODvnKHhZKGrJskk/coQxji4w oeeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@endlessos.org header.s=google header.b=AgvtY9XF; 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=endlessos.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s13si19437236jat.111.2021.06.21.03.36.26; Mon, 21 Jun 2021 03:36:41 -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=@endlessos.org header.s=google header.b=AgvtY9XF; 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=endlessos.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229747AbhFUKiH (ORCPT + 99 others); Mon, 21 Jun 2021 06:38:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbhFUKiH (ORCPT ); Mon, 21 Jun 2021 06:38:07 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10144C061756 for ; Mon, 21 Jun 2021 03:35:52 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id h16so9704969pjv.2 for ; Mon, 21 Jun 2021 03:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessos.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qACWu+bnbyPKnWsJHtA+hAZdpnvZk5bHIEy1Pug1Wwg=; b=AgvtY9XFqTFRZZMKYLON5qKVKzGP/iBwCiNh2pmuTSvbMRH6lrQt7MwjVsStzRgDh6 40lvAhPLLEJQ174u7dpwDasEbgJbSVrCy10X4Dyw70FG5vwWiMZJi8CM9H3A/g3Y4Q9l 1bW3hcQVsOS/xN4MGlUfO2tc1jKpdYv+89m1dmk3ZgqnYHvUOqvVqR/la5SjNs0ELTXb dKESFFgD4IaKZ3V9c0mwpIm7v66ECYTc/pR9Ce3ThbQmMSywCBbuxt88w+qgjey3npho j0+WEMpRTo/IdF+j6EOC0CX5Ao450J3k93rfEi6nMg4c+wAUWubaXRwiur9rgAeFAOje 6nXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qACWu+bnbyPKnWsJHtA+hAZdpnvZk5bHIEy1Pug1Wwg=; b=RYsy20FwOb3EE0WFq4dptYuyv31+RcaWgGPigUKj7Ecnoi9JKtPE6Ur8xx4M0ahATv 9pRTW37TH/fmRc1MOphYtR7wxDuICSkW6k0J6ccioDY3IGaAQHSRcXn8Ot5g2t3SoIFb OC+u52tU4gYC9WDjVyfn1OQgaTcim33Lcx+d+5oaXg4MWtJAfNHCruNv4lWptYIDMYLx q5j6+UKLtO/u87IMfEsvmtp8BxtRc+Qq0xFk2jmIK3ACiv82mm1YMridMGlQrQupQ0U/ IiNy26EZ0VT/uVJ9yfJTG7ifNS3s9c/oP+4bVUnEwsSatpzoSKlBSP8oMgiLZxpeexa/ OgaQ== X-Gm-Message-State: AOAM533GepPs/LfUhnXRzCJ41fATLIQplDs2NnssqQ1BaYKtH0xb31A5 pLreHn7MfD10KN0zr0o4+ASIsQ== X-Received: by 2002:a17:90a:7381:: with SMTP id j1mr14004550pjg.29.1624271751494; Mon, 21 Jun 2021 03:35:51 -0700 (PDT) Received: from starnight.local ([150.116.242.79]) by smtp.googlemail.com with ESMTPSA id ml5sm1124159pjb.3.2021.06.21.03.35.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 03:35:51 -0700 (PDT) From: Jian-Hong Pan To: Doug Berger , Florian Fainelli , Stefan Wahren Cc: bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessos.org, linux-rpi-kernel@lists.infradead.org, Jian-Hong Pan Subject: [PATCH] net: bcmgenet: Fix attaching to PYH failed on RPi 4B Date: Mon, 21 Jun 2021 18:33:11 +0800 Message-Id: <20210621103310.186334-1-jhp@endlessos.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Broadcom UniMAC MDIO bus comes too late. So, GENET cannot find the ethernet PHY on UniMAC MDIO bus. This leads GENET fail to attach the PHY. bcmgenet fd580000.ethernet: GENET 5.0 EPHY: 0x0000 ... could not attach to PHY bcmgenet fd580000.ethernet eth0: failed to connect to PHY uart-pl011 fe201000.serial: no DMA platform data libphy: bcmgenet MII bus: probed ... unimac-mdio unimac-mdio.-19: Broadcom UniMAC MDIO bus This patch makes GENET try to connect the PHY up to 3 times. Also, waits a while between each time for mdio-bcm-unimac module's loading and probing. Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=213485 Signed-off-by: Jian-Hong Pan --- drivers/net/ethernet/broadcom/genet/bcmmii.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index 5335244e4577..64f244471fd3 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -289,6 +289,7 @@ int bcmgenet_mii_probe(struct net_device *dev) struct phy_device *phydev; u32 phy_flags = 0; int ret; + int i; /* Communicate the integrated PHY revision */ if (priv->internal_phy) @@ -301,8 +302,22 @@ int bcmgenet_mii_probe(struct net_device *dev) priv->old_pause = -1; if (dn) { - phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup, - phy_flags, priv->phy_interface); + /* Try to connect the PHY on UniMAC DMIO bus up to 3 times. + * Wait a while between each time for mdio-bcm-unimac module's + * loading and probing. + */ + phydev = NULL; + for (i = 1; i < 4 && !phydev; i++) { + netdev_info(dev, + "connect %s on UniMAC MDIO bus %d time", + priv->phy_dn->full_name, i); + phydev = of_phy_connect(dev, priv->phy_dn, + bcmgenet_mii_setup, + phy_flags, priv->phy_interface); + if (!phydev && i < 3) + msleep(500); + } + if (!phydev) { pr_err("could not attach to PHY\n"); return -ENODEV; -- 2.32.0