Message ID | 20230330091404.3293431-3-michael.wei.hong.sit@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp995552vqo; Thu, 30 Mar 2023 02:32:30 -0700 (PDT) X-Google-Smtp-Source: AKy350ZDeIMgEIToOpbj9zA6rz9cxVYb4jeAtzNx13qvZOFOZkJF45/szH3Bu/4kkhd8PI1L4y5H X-Received: by 2002:a17:907:c788:b0:922:446b:105a with SMTP id tz8-20020a170907c78800b00922446b105amr6503570ejc.19.1680168750364; Thu, 30 Mar 2023 02:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680168750; cv=none; d=google.com; s=arc-20160816; b=wMuvNyWHvr6HkMpy26oQsKgmE8oxcDTlS0BV1FhbmCz4bRuqTG9XRrCuzd6GbV1ndG Cqa1Ze/T4lYoqZ4J8E8uyr0FwfpT6vnSSzawyXcQ+meQ4kaESyycP2N51yG0VO8xDWX3 mp9RqAy185/gQiW35MJFYFqSh5QXnOEtrGxKec2Nwn8Q4AcbVa3Er36hG6qA5n9rYyPC WbkRp2zAPjtrZtWK53xXE5m8/dj5raY/IyQ+u+pfOjOfyvKpqFu31Ie/mG8zNXgR6MTt PcgxCnGDyPjlNm84VZKbnFXsQVz6eomHazlFN9skV4gkzRetTSKtAnE3h9mdHVGvnHY6 YhkQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XhG+QY03aph/EtJ/DGwDMKQnpUE78yOrQ3THTyFaJjs=; b=yWH8A7oIePSbqm/zuAiMHPFrTJ37tliqIjnVez4c16KFqMoC9IxzDb5NYa9Tc2CH8E tdXD4UYWWXicHAiujkT9+sBKJ9Kj1MmGlG0ULsZ3U+EjoT3W8Q4/OdX35qKGx5KgMt5n iigkgrw5ykTezJieZTq4jIbqLE7hGfNHgZGQZIsz7v91++hVC22qUau/gywtQiqp3Nhh gIFVkkXDvcVbGTsonpMayNCA7FX2oJ6b3W2TapJmChbua1/M7xLh7J6CyTUFEYH8qGAh HGD3iyeNZ2O3AEVN+OjutlJ6Vi4s932Gd5DEIE1TruaK+AZgDpmN9519v2WJ3LxpRZqB NvfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JuIE2QXD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y14-20020a170906914e00b0093331b35aaasi27152567ejw.813.2023.03.30.02.32.06; Thu, 30 Mar 2023 02:32:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JuIE2QXD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230060AbjC3JPW (ORCPT <rfc822;rua109.linux@gmail.com> + 99 others); Thu, 30 Mar 2023 05:15:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229724AbjC3JPI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 30 Mar 2023 05:15:08 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3CDF4680; Thu, 30 Mar 2023 02:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680167706; x=1711703706; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h7HA31Ype249VhePLWHGaLt81vSRMT92v7O/eTwjq3g=; b=JuIE2QXD6Wm59qjDoFr4Z+PiaJZo6vRF0R3ll/hnC7qjtAblu9wqfGOu 5Db5f+cQ6RTX//VmgtQ3zRcA+qfT8HItcxtxcaCHwAgaykKoua0QlhEHS hNWz3f4mUpi8UEzEKVThg/Kr3m0r0Kd+AGCWG35WuTYiG+LxP6dpxJFKM F/ivrGoD5iz018EHvYXSE3phkBNHasxl+4XC/k+LpFilr140MBEbHQVmM EzpjetgwQsZPtT3L6/Z8ZZVo8LM5YBLXHHAtMDRbHDXgVkkaj3W5qbs84 noCyGd3y9+mpAE+3slwgSG4XGkQexvrV7PVvMHZWd/XVIUcT93IribXpE w==; X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="325038889" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="325038889" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 02:15:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="678125420" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="678125420" Received: from mike-ilbpg1.png.intel.com ([10.88.227.76]) by orsmga007.jf.intel.com with ESMTP; 30 Mar 2023 02:14:57 -0700 From: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> To: Giuseppe Cavallaro <peppe.cavallaro@st.com>, Alexandre Torgue <alexandre.torgue@foss.st.com>, Jose Abreu <joabreu@synopsys.com>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Ong Boon Leong <boon.leong.ong@intel.com>, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux@armlinux.org.uk, hkallweit1@gmail.com, andrew@lunn.ch Cc: Looi Hong Aun <hong.aun.looi@intel.com>, Voon Weifeng <weifeng.voon@intel.com>, Lai Peter Jun Ann <peter.jun.ann.lai@intel.com> Subject: [PATCH net v5 2/3] net: stmmac: check if MAC needs to attach to a PHY Date: Thu, 30 Mar 2023 17:14:03 +0800 Message-Id: <20230330091404.3293431-3-michael.wei.hong.sit@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230330091404.3293431-1-michael.wei.hong.sit@intel.com> References: <20230330091404.3293431-1-michael.wei.hong.sit@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761784627410199610?= X-GMAIL-MSGID: =?utf-8?q?1761784627410199610?= |
Series |
Fix PHY handle no longer parsing
|
|
Commit Message
Sit, Michael Wei Hong
March 30, 2023, 9:14 a.m. UTC
After the introduction of the fixed-link support, the MAC driver no longer attempt to scan for a PHY to attach to. This causes the non fixed-link setups to stop working. Using the phylink_expects_phy() to check and determine if the MAC should expect and attach a PHY. Fixes: ab21cf920928 ("net: stmmac: make mdio register skips PHY scanning for fixed-link") Signed-off-by: Michael Sit Wei Hong <michael.wei.hong.sit@intel.com> Signed-off-by: Lai Peter Jun Ann <peter.jun.ann.lai@intel.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Comments
Hello, [...] > @@ -1144,10 +1145,11 @@ static int stmmac_init_phy(struct net_device *dev) > if (fwnode) > ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, 0); > > + phy_needed = phylink_expects_phy(priv->phylink); > /* Some DT bindings do not set-up the PHY handle. Let's try to > * manually parse it > */ > - if (!fwnode || ret) { > + if (!fwnode || phy_needed || ret) { Unfortunately this breaks Ethernet on my X96 Air board (the .dts file can be found upstream in: arch/arm64/boot/dts/amlogic/meson-sm1-x96-air-gbit.dts) Working boot-log: # dmesg | grep dwmac [ 3.699961] meson8b-dwmac ff3f0000.ethernet: IRQ eth_wake_irq not found [ 3.700944] meson8b-dwmac ff3f0000.ethernet: IRQ eth_lpi not found [ 3.707196] meson8b-dwmac ff3f0000.ethernet: PTP uses main clock [ 3.713688] meson8b-dwmac ff3f0000.ethernet: User ID: 0x11, Synopsys ID: 0x37 [ 3.720201] meson8b-dwmac ff3f0000.ethernet: DWMAC1000 [ 3.725387] meson8b-dwmac ff3f0000.ethernet: DMA HW capability register supported [ 3.732832] meson8b-dwmac ff3f0000.ethernet: RX Checksum Offload Engine supported [ 3.740301] meson8b-dwmac ff3f0000.ethernet: COE Type 2 [ 3.745491] meson8b-dwmac ff3f0000.ethernet: TX Checksum insertion supported [ 3.752504] meson8b-dwmac ff3f0000.ethernet: Wake-Up On Lan supported [ 3.758993] meson8b-dwmac ff3f0000.ethernet: Normal descriptors [ 3.764813] meson8b-dwmac ff3f0000.ethernet: Ring mode enabled [ 3.770629] meson8b-dwmac ff3f0000.ethernet: Enable RX Mitigation via HW Watchdog Timer [ 13.565781] meson8b-dwmac ff3f0000.ethernet end0: renamed from eth0 [ 14.036061] meson8b-dwmac ff3f0000.ethernet end0: Register MEM_TYPE_PAGE_POOL RxQ-0 [ 14.255617] meson8b-dwmac ff3f0000.ethernet end0: PHY [mdio_mux-0.0:00] driver [RTL8211F Gigabit Ethernet] (irq=33) [ 14.265404] meson8b-dwmac ff3f0000.ethernet end0: No Safety Features support found [ 14.267977] meson8b-dwmac ff3f0000.ethernet end0: PTP not supported by HW [ 14.275723] meson8b-dwmac ff3f0000.ethernet end0: configuring for phy/rgmii-txid link mode [ 17.394262] meson8b-dwmac ff3f0000.ethernet end0: Link is Up - 1Gbps/Full - flow control rx/tx Non-working boot-log: # dmesg | grep dwmac [ 3.730072] meson8b-dwmac ff3f0000.ethernet: IRQ eth_wake_irq not found [ 3.731053] meson8b-dwmac ff3f0000.ethernet: IRQ eth_lpi not found [ 3.737303] meson8b-dwmac ff3f0000.ethernet: PTP uses main clock [ 3.743795] meson8b-dwmac ff3f0000.ethernet: User ID: 0x11, Synopsys ID: 0x37 [ 3.750311] meson8b-dwmac ff3f0000.ethernet: DWMAC1000 [ 3.755498] meson8b-dwmac ff3f0000.ethernet: DMA HW capability register supported [ 3.762944] meson8b-dwmac ff3f0000.ethernet: RX Checksum Offload Engine supported [ 3.770412] meson8b-dwmac ff3f0000.ethernet: COE Type 2 [ 3.775603] meson8b-dwmac ff3f0000.ethernet: TX Checksum insertion supported [ 3.782615] meson8b-dwmac ff3f0000.ethernet: Wake-Up On Lan supported [ 3.789106] meson8b-dwmac ff3f0000.ethernet: Normal descriptors [ 3.794924] meson8b-dwmac ff3f0000.ethernet: Ring mode enabled [ 3.800738] meson8b-dwmac ff3f0000.ethernet: Enable RX Mitigation via HW Watchdog Timer [ 13.052942] meson8b-dwmac ff3f0000.ethernet end0: renamed from eth0 [ 13.594285] meson8b-dwmac ff3f0000.ethernet end0: Register MEM_TYPE_PAGE_POOL RxQ-0 [ 13.825578] meson8b-dwmac ff3f0000.ethernet end0: PHY [mdio_mux-0.0:00] driver [RTL8211F Gigabit Ethernet] (irq=33) [ 13.831358] meson8b-dwmac ff3f0000.ethernet end0: no phy found [ 13.836229] meson8b-dwmac ff3f0000.ethernet end0: __stmmac_open: Cannot attach to PHY (error: -19) Reverting this patch fixes that problem. I think the reason is a logic error in the patch: As you can see the PHY is found and attached (my understanding is that this happens through phylink_fwnode_phy_connect()). But we now also go to that if block below even fwnode != NULL && ret == 0 (which indicates that phylink_fwnode_phy_connect() was successful). Inside that if block priv->plat->phy_addr then has the default value (-1) that was set in stmmac_probe_config_dt(). I am running out of time for today. Could you please look into this and follow up with a patch (on top of this one, as this one has already been applied) that considers your original issues as well as the case of my board (I suspect that all Amlogic boards that are supported upstream are affected)? Please keep me Cc'ed so I can test your additional patch and then add my Tested-by. Thank you! Martin
Same happens on ARC HSDK [1]: # dmesg | grep stmmaceth stmmaceth f0008000.ethernet: use coherent DMA ops stmmaceth f0008000.ethernet: IRQ eth_wake_irq not found stmmaceth f0008000.ethernet: IRQ eth_lpi not found stmmaceth f0008000.ethernet: PTP uses main clock stmmaceth f0008000.ethernet: User ID: 0x10, Synopsys ID: 0x37 stmmaceth f0008000.ethernet: DWMAC1000 stmmaceth f0008000.ethernet: DMA HW capability register supported stmmaceth f0008000.ethernet: RX Checksum Offload Engine supported stmmaceth f0008000.ethernet: COE Type 2 stmmaceth f0008000.ethernet: TX Checksum insertion supported stmmaceth f0008000.ethernet: Normal descriptors stmmaceth f0008000.ethernet: Ring mode enabled stmmaceth f0008000.ethernet: Enable RX Mitigation via HW Watchdog Timer stmmaceth f0008000.ethernet: device MAC address 7e:14:df:5f:b8:78 stmmaceth f0008000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0 stmmaceth f0008000.ethernet eth0: PHY [stmmac-0:00] driver [Micrel KSZ9031 Gigabit PHY] (irq=POLL) stmmaceth f0008000.ethernet eth0: no phy found stmmaceth f0008000.ethernet eth0: __stmmac_open: Cannot attach to PHY (error: -19) After reverting this patch: # dmesg | grep stmmaceth stmmaceth f0008000.ethernet: use coherent DMA ops stmmaceth f0008000.ethernet: IRQ eth_wake_irq not found stmmaceth f0008000.ethernet: IRQ eth_lpi not found stmmaceth f0008000.ethernet: PTP uses main clock stmmaceth f0008000.ethernet: User ID: 0x10, Synopsys ID: 0x37 stmmaceth f0008000.ethernet: DWMAC1000 stmmaceth f0008000.ethernet: DMA HW capability register supported stmmaceth f0008000.ethernet: RX Checksum Offload Engine supported stmmaceth f0008000.ethernet: COE Type 2 stmmaceth f0008000.ethernet: TX Checksum insertion supported stmmaceth f0008000.ethernet: Normal descriptors stmmaceth f0008000.ethernet: Ring mode enabled stmmaceth f0008000.ethernet: Enable RX Mitigation via HW Watchdog Timer stmmaceth f0008000.ethernet: device MAC address 26:05:ea:c0:66:16 stmmaceth f0008000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0 stmmaceth f0008000.ethernet eth0: PHY [stmmac-0:00] driver [Micrel KSZ9031 Gigabit PHY] (irq=POLL) stmmaceth f0008000.ethernet eth0: No Safety Features support found stmmaceth f0008000.ethernet eth0: PTP not supported by HW stmmaceth f0008000.ethernet eth0: configuring for phy/rgmii-id link mode stmmaceth f0008000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off [1] arch/arc/boot/dts/hsdk.dts -- Shahab
Fixing the CC header. Apologies for the inconvenience. ------ Same happens on ARC HSDK [1]: # dmesg | grep stmmaceth stmmaceth f0008000.ethernet: use coherent DMA ops stmmaceth f0008000.ethernet: IRQ eth_wake_irq not found stmmaceth f0008000.ethernet: IRQ eth_lpi not found stmmaceth f0008000.ethernet: PTP uses main clock stmmaceth f0008000.ethernet: User ID: 0x10, Synopsys ID: 0x37 stmmaceth f0008000.ethernet: DWMAC1000 stmmaceth f0008000.ethernet: DMA HW capability register supported stmmaceth f0008000.ethernet: RX Checksum Offload Engine supported stmmaceth f0008000.ethernet: COE Type 2 stmmaceth f0008000.ethernet: TX Checksum insertion supported stmmaceth f0008000.ethernet: Normal descriptors stmmaceth f0008000.ethernet: Ring mode enabled stmmaceth f0008000.ethernet: Enable RX Mitigation via HW Watchdog Timer stmmaceth f0008000.ethernet: device MAC address 7e:14:df:5f:b8:78 stmmaceth f0008000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0 stmmaceth f0008000.ethernet eth0: PHY [stmmac-0:00] driver [Micrel KSZ9031 Gigabit PHY] (irq=POLL) stmmaceth f0008000.ethernet eth0: no phy found stmmaceth f0008000.ethernet eth0: __stmmac_open: Cannot attach to PHY (error: -19) After reverting this patch: # dmesg | grep stmmaceth stmmaceth f0008000.ethernet: use coherent DMA ops stmmaceth f0008000.ethernet: IRQ eth_wake_irq not found stmmaceth f0008000.ethernet: IRQ eth_lpi not found stmmaceth f0008000.ethernet: PTP uses main clock stmmaceth f0008000.ethernet: User ID: 0x10, Synopsys ID: 0x37 stmmaceth f0008000.ethernet: DWMAC1000 stmmaceth f0008000.ethernet: DMA HW capability register supported stmmaceth f0008000.ethernet: RX Checksum Offload Engine supported stmmaceth f0008000.ethernet: COE Type 2 stmmaceth f0008000.ethernet: TX Checksum insertion supported stmmaceth f0008000.ethernet: Normal descriptors stmmaceth f0008000.ethernet: Ring mode enabled stmmaceth f0008000.ethernet: Enable RX Mitigation via HW Watchdog Timer stmmaceth f0008000.ethernet: device MAC address 26:05:ea:c0:66:16 stmmaceth f0008000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0 stmmaceth f0008000.ethernet eth0: PHY [stmmac-0:00] driver [Micrel KSZ9031 Gigabit PHY] (irq=POLL) stmmaceth f0008000.ethernet eth0: No Safety Features support found stmmaceth f0008000.ethernet eth0: PTP not supported by HW stmmaceth f0008000.ethernet eth0: configuring for phy/rgmii-id link mode stmmaceth f0008000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off [1] arch/arc/boot/dts/hsdk.dts -- Shahab
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 8f543c3ab5c5..41f0f3b74933 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1135,6 +1135,7 @@ static int stmmac_init_phy(struct net_device *dev) { struct stmmac_priv *priv = netdev_priv(dev); struct fwnode_handle *fwnode; + bool phy_needed; int ret; fwnode = of_fwnode_handle(priv->plat->phylink_node); @@ -1144,10 +1145,11 @@ static int stmmac_init_phy(struct net_device *dev) if (fwnode) ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, 0); + phy_needed = phylink_expects_phy(priv->phylink); /* Some DT bindings do not set-up the PHY handle. Let's try to * manually parse it */ - if (!fwnode || ret) { + if (!fwnode || phy_needed || ret) { int addr = priv->plat->phy_addr; struct phy_device *phydev;