Message ID | 20230223070519.2211-1-wsa+renesas@sang-engineering.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp183237wrd; Wed, 22 Feb 2023 23:35:41 -0800 (PST) X-Google-Smtp-Source: AK7set80GKsENSvz41PRT5roGNveVFZEUdyyR+GZNSuHXv3nnO4/j/Pf9gbUVq334vaJMinWF4hc X-Received: by 2002:a05:6402:268e:b0:4ac:d21b:2a44 with SMTP id w14-20020a056402268e00b004acd21b2a44mr11443147edd.0.1677137741223; Wed, 22 Feb 2023 23:35:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677137741; cv=none; d=google.com; s=arc-20160816; b=dQIxP8zSTBVtV9w5cEH7yK/+Vcbe9S2741ne58vLeDZ0wWJSkWfjuateVX2eCBSB3z CmxXFMd7g4476Sy7JJvZdORJuzo2LBTUrqhO4zAAGYhHyezxqn9BjdRnCKaWAtdWZaKM QIvdvYf5YCrmmtuC0QuRlC2bxAgjKvPdEHSUdRNwFpGg0vvB5SC23RdnW7GOX5GddPmg yY/fFfFJ7uDcSgcz7YIJXgsgAI8eO6IwF8ZWQXzFMyMJixXmWjBQ6mmZY9SvtrMhqrFP /xr8jB1h3ezxSa8sgYMZ6kXzsScdVw3vsT2mLO3btJ1xXOlJPRbd5EfkTOWhnaXNziw1 yR6w== 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=Bj2feb9exyJ82U3UGSUWjJkxzFD23W4uUwEyRJrWQkM=; b=pPugjM8iMiyg0xrMpY3xjG+AVHd3IrQA/zdZp0RtDPAeVD2OtGcdQ0tXW9chmP2yrB xj/yjXBCaibHm2WfJEAd+UQs3smjmNyJGUHCaA94iBUvd3z5oYxOJkvDQXPSDMFiMW4L I1oqiqRZFTP0IIq6S9Z4exTkh37zDZUEylPUnk4oxwTLTIhi/D6vhykULihlFghRTx2M 4tCsqIT3U1nvFuXBn2pk4JtAfaUC/uHaUxG6YGY1KXAW/E4z4eqwMC2oy5C2R9IXGVyc aj2ORQG41JX96clLqSL60H0+dJqTc6SYhPXLkYYsBv733SSTpbyjRiq5/j8s2PInqx0j xscw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=MxxxE1GA; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k17-20020aa7d8d1000000b004acb85b9c41si1606470eds.328.2023.02.22.23.35.18; Wed, 22 Feb 2023 23:35:41 -0800 (PST) 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=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=MxxxE1GA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233296AbjBWHFh (ORCPT <rfc822;cambridge8321@gmail.com> + 99 others); Thu, 23 Feb 2023 02:05:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233320AbjBWHFf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 23 Feb 2023 02:05:35 -0500 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C6157698 for <linux-kernel@vger.kernel.org>; Wed, 22 Feb 2023 23:05:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=k1; bh=OIOomp7cpAJjsuC0dN7moT40lIm w7FjKpciZCFaEvBE=; b=MxxxE1GA5YlhSuMFni3q8w57S5/1NfReO2W82rAEdhK gIywXuwwBh1hNR6Wx2PnrEtijLodgJqlWpbwSw1lV1Bys3V6m6wfHTdfNGY/m3TE HSpZbD0ZMf2B3AqMUXmxS2TmpxTmtllSEzcNBcNcid71wU25xIUQSTt+FSt0Q7LI = Received: (qmail 829236 invoked from network); 23 Feb 2023 08:05:28 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 23 Feb 2023 08:05:28 +0100 X-UD-Smtp-Session: l3s3148p1@Bx5Eo1j1XuJehh92 From: Wolfram Sang <wsa+renesas@sang-engineering.com> To: linux-renesas-soc@vger.kernel.org Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>, Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [REGRESSION PATCH RFC] net: phy: don't resume PHY via MDIO when iface is not up Date: Thu, 23 Feb 2023 08:05:19 +0100 Message-Id: <20230223070519.2211-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE autolearn=no 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?1758606383719460967?= X-GMAIL-MSGID: =?utf-8?q?1758606383719460967?= |
Series |
[REGRESSION,RFC] net: phy: don't resume PHY via MDIO when iface is not up
|
|
Commit Message
Wolfram Sang
Feb. 23, 2023, 7:05 a.m. UTC
TLDR; Commit 96fb2077a517 ("net: phy: consider that suspend2ram may cut
off PHY power") caused regressions for us when resuming an interface
which is not up. It turns out the problem is another one, the above
commit only makes it visible. The attached patch is probably not the
right fix, but at least is proving my assumptions AFAICS.
Setup: I used Renesas boards for my tests, namely Salvator-XS and Ebisu.
They both use RAVB driver (drivers/net/ethernet/renesas/ravb_main.c) and
a Micrel KSZ9031 PHY (drivers/net/phy/micrel.c). I think the problems
are generic, though.
Long text: After the above commit, we could see various resume failures
on our boards, like timeouts when resetting the MDIO bus, or warning
about skew values in non-RGMII mode, although RGMII was used. All of
these happened, because phy_init_hw() was now called in
mdio_bus_phy_resume() which wasn't the case before. But the interface
was not up yet, e.g. phydev->interface was still the default and not
RGMII, so the initialization didn't work properly. phy_attach_direct()
pays attention to this:
1504 /* Do initial configuration here, now that
1505 * we have certain key parameters
1506 * (dev_flags and interface)
1507 */
1508 err = phy_init_hw(phydev);
But phy_init_hw() doesn't if the interface is not up, AFAICS.
This may be a problem in itself, but I then wondered why
mdio_bus_phy_resume() gets called anyhow because the RAVB driver sets
'phydev->mac_managed_pm = true' so once the interface is up
mdio_bus_phy_resume() never gets called. But again, the interface was
not up yet, so mac_managed_pm was not set yet.
So, in my quest to avoid mdio_bus_phy_resume() being called, I tried
this patch declaring the PHY being in suspend state when being probed.
The KSZ9031 has a soft_reset() callback, so phy_init_hw() will reset the
suspended flag when the PHY is attached. It works for me(tm),
suspend/resume now works independently of the interface being up or not.
I don't think this is the proper solution, though. It will e.g. fail if
some PHY is not using the soft_reset() callback. And I am missing the
experience in this subsystem to decide if we can clear the resume flag
in phy_init_hw() unconditionally. My gut feeling is that we can't.
So, this patch mostly demonstrates the issues we have and the things I
found out. I'd be happy if someone could point me to a proper solution,
or more information that I am missing here. Thank you in advance and
happy hacking!
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/net/phy/phy_device.c | 1 +
1 file changed, 1 insertion(+)
Comments
Hi Wolfram, Thanks for your report! On Thu, Feb 23, 2023 at 8:36 AM Wolfram Sang <wsa+renesas@sang-engineering.com> wrote: > TLDR; Commit 96fb2077a517 ("net: phy: consider that suspend2ram may cut > off PHY power") caused regressions for us when resuming an interface That is actually an LTS commit. Upstream is commit 4c0d2e96ba055bd8 ("net: phy: consider that suspend2ram may cut off PHY power") in v5.12-rc1. Gr{oetje,eeting}s, Geert
Hi Geert, > > TLDR; Commit 96fb2077a517 ("net: phy: consider that suspend2ram may cut > > off PHY power") caused regressions for us when resuming an interface > > That is actually an LTS commit. Upstream is commit 4c0d2e96ba055bd8 > ("net: phy: consider that suspend2ram may cut off PHY power") in > v5.12-rc1. Oh, thank you for correcting me! All the best, Wolfram
On 23.02.2023 08:05, Wolfram Sang wrote: > TLDR; Commit 96fb2077a517 ("net: phy: consider that suspend2ram may cut > off PHY power") caused regressions for us when resuming an interface > which is not up. It turns out the problem is another one, the above > commit only makes it visible. The attached patch is probably not the > right fix, but at least is proving my assumptions AFAICS. > > Setup: I used Renesas boards for my tests, namely Salvator-XS and Ebisu. > They both use RAVB driver (drivers/net/ethernet/renesas/ravb_main.c) and > a Micrel KSZ9031 PHY (drivers/net/phy/micrel.c). I think the problems > are generic, though. > > Long text: After the above commit, we could see various resume failures > on our boards, like timeouts when resetting the MDIO bus, or warning > about skew values in non-RGMII mode, although RGMII was used. All of > these happened, because phy_init_hw() was now called in > mdio_bus_phy_resume() which wasn't the case before. But the interface > was not up yet, e.g. phydev->interface was still the default and not > RGMII, so the initialization didn't work properly. phy_attach_direct() > pays attention to this: > > 1504 /* Do initial configuration here, now that > 1505 * we have certain key parameters > 1506 * (dev_flags and interface) > 1507 */ > 1508 err = phy_init_hw(phydev); > > But phy_init_hw() doesn't if the interface is not up, AFAICS. > > This may be a problem in itself, but I then wondered why > mdio_bus_phy_resume() gets called anyhow because the RAVB driver sets > 'phydev->mac_managed_pm = true' so once the interface is up > mdio_bus_phy_resume() never gets called. But again, the interface was > not up yet, so mac_managed_pm was not set yet. > Setting phydev->mac_managed_pm in the open() callback is too late. It should be set as soon as the phydev is created. That's in ravb_mdio_init() after the call to of_mdiobus_register(). It should be possible to get the phydev with: pn = of_parse_phandle(np, "phy-handle", 0); phy = of_phy_find_device(pn); > So, in my quest to avoid mdio_bus_phy_resume() being called, I tried > this patch declaring the PHY being in suspend state when being probed. > The KSZ9031 has a soft_reset() callback, so phy_init_hw() will reset the > suspended flag when the PHY is attached. It works for me(tm), > suspend/resume now works independently of the interface being up or not. > > I don't think this is the proper solution, though. It will e.g. fail if > some PHY is not using the soft_reset() callback. And I am missing the > experience in this subsystem to decide if we can clear the resume flag > in phy_init_hw() unconditionally. My gut feeling is that we can't. > > So, this patch mostly demonstrates the issues we have and the things I > found out. I'd be happy if someone could point me to a proper solution, > or more information that I am missing here. Thank you in advance and > happy hacking! > > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> > --- > drivers/net/phy/phy_device.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > index 8cff61dbc4b5..5cbb471700a8 100644 > --- a/drivers/net/phy/phy_device.c > +++ b/drivers/net/phy/phy_device.c > @@ -3108,6 +3108,7 @@ static int phy_probe(struct device *dev) > > /* Set the state to READY by default */ > phydev->state = PHY_READY; > + phydev->suspended = 1; > > out: > /* Assert the reset signal */
Hello Heiner, > > This may be a problem in itself, but I then wondered why > > mdio_bus_phy_resume() gets called anyhow because the RAVB driver sets > > 'phydev->mac_managed_pm = true' so once the interface is up > > mdio_bus_phy_resume() never gets called. But again, the interface was > > not up yet, so mac_managed_pm was not set yet. > > > Setting phydev->mac_managed_pm in the open() callback is too late. > It should be set as soon as the phydev is created. That's in > ravb_mdio_init() after the call to of_mdiobus_register(). > > It should be possible to get the phydev with: > pn = of_parse_phandle(np, "phy-handle", 0); > phy = of_phy_find_device(pn); Awesome, thank you very much for the pointer. I applied setting 'mac_managed_pm' at probe time, and now I can resume successfully. Sadly, this is only the first part of the problem. I still can't get the interface up after resuming, but I still need to debug this further. At least, the problem with mdiobus_resume getting called is fixed now. Thank you for your help! Wolfram
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 8cff61dbc4b5..5cbb471700a8 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3108,6 +3108,7 @@ static int phy_probe(struct device *dev) /* Set the state to READY by default */ phydev->state = PHY_READY; + phydev->suspended = 1; out: /* Assert the reset signal */