From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Florian Fainelli <f.fainelli@gmail.com>,
netdev@vger.kernel.org,
Steve Glendinning <steve.glendinning@shawell.net>
Cc: opendmb@gmail.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>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net] net: phy: Warn about incorrect mdio_bus_phy_resume() state
Date: Fri, 12 Aug 2022 13:19:47 +0200 [thread overview]
Message-ID: <27016cc0-f228-748b-ea03-800dda4e5f0c@samsung.com> (raw)
In-Reply-To: <20220801233403.258871-1-f.fainelli@gmail.com>
Hi All,
On 02.08.2022 01:34, Florian Fainelli wrote:
> Calling mdio_bus_phy_resume() with neither the PHY state machine set to
> PHY_HALTED nor phydev->mac_managed_pm set to true is a good indication
> that we can produce a race condition looking like this:
>
> CPU0 CPU1
> bcmgenet_resume
> -> phy_resume
> -> phy_init_hw
> -> phy_start
> -> phy_resume
> phy_start_aneg()
> mdio_bus_phy_resume
> -> phy_resume
> -> phy_write(..., BMCR_RESET)
> -> usleep() -> phy_read()
>
> with the phy_resume() function triggering a PHY behavior that might have
> to be worked around with (see bf8bfc4336f7 ("net: phy: broadcom: Fix
> brcm_fet_config_init()") for instance) that ultimately leads to an error
> reading from the PHY.
>
> Fixes: fba863b81604 ("net: phy: make PHY PM ops a no-op if MAC driver manages PHY PM")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
This patch, as probably intended, triggers a warning during system
suspend/resume cycle in the SMSC911x driver. I've observed it on ARM
Juno R1 board on the kernel compiled from next-202208010:
------------[ cut here ]------------
WARNING: CPU: 1 PID: 398 at drivers/net/phy/phy_device.c:323
mdio_bus_phy_resume+0x34/0xc8
Modules linked in: smsc911x cpufreq_powersave cpufreq_conservative
crct10dif_ce ip_tables x_tables ipv6 [last unloaded: smsc911x]
CPU: 1 PID: 398 Comm: rtcwake Not tainted 5.19.0+ #940
Hardware name: ARM Juno development board (r1) (DT)
pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : mdio_bus_phy_resume+0x34/0xc8
lr : dpm_run_callback+0x74/0x350
...
Call trace:
mdio_bus_phy_resume+0x34/0xc8
dpm_run_callback+0x74/0x350
device_resume+0xb8/0x258
dpm_resume+0x120/0x4a8
dpm_resume_end+0x14/0x28
suspend_devices_and_enter+0x164/0xa60
pm_suspend+0x25c/0x3a8
state_store+0x84/0x108
kobj_attr_store+0x14/0x28
sysfs_kf_write+0x60/0x70
kernfs_fop_write_iter+0x124/0x1a8
new_sync_write+0xd0/0x190
vfs_write+0x208/0x478
ksys_write+0x64/0xf0
__arm64_sys_write+0x14/0x20
invoke_syscall+0x40/0xf8
el0_svc_common.constprop.3+0x8c/0x120
do_el0_svc+0x28/0xc8
el0_svc+0x48/0xd0
el0t_64_sync_handler+0x94/0xb8
el0t_64_sync+0x15c/0x160
irq event stamp: 24406
hardirqs last enabled at (24405): [<ffff8000090c4734>]
_raw_spin_unlock_irqrestore+0x8c/0x90
hardirqs last disabled at (24406): [<ffff8000090b3164>] el1_dbg+0x24/0x88
softirqs last enabled at (24144): [<ffff800008010488>] _stext+0x488/0x5cc
softirqs last disabled at (24139): [<ffff80000809bf98>]
irq_exit_rcu+0x168/0x1a8
---[ end trace 0000000000000000 ]---
I hope the above information will help fixing the driver.
> ---
> drivers/net/phy/phy_device.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 46acddd865a7..608de5a94165 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -316,6 +316,12 @@ static __maybe_unused int mdio_bus_phy_resume(struct device *dev)
>
> phydev->suspended_by_mdio_bus = 0;
>
> + /* If we managed to get here with the PHY state machine in a state other
> + * than PHY_HALTED this is an indication that something went wrong and
> + * we should most likely be using MAC managed PM and we are not.
> + */
> + WARN_ON(phydev->state != PHY_HALTED && !phydev->mac_managed_pm);
> +
> ret = phy_init_hw(phydev);
> if (ret < 0)
> return ret;
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
next prev parent reply other threads:[~2022-08-12 11:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-01 23:34 Florian Fainelli
2022-08-04 2:40 ` patchwork-bot+netdevbpf
[not found] ` <CGME20220812111948eucas1p2bf97e7f4558eb024f419346367a87b45@eucas1p2.samsung.com>
2022-08-12 11:19 ` Marek Szyprowski [this message]
2022-08-12 16:32 ` Florian Fainelli
2022-08-16 11:18 ` Marek Szyprowski
2022-08-16 13:20 ` Geert Uytterhoeven
2022-08-17 2:28 ` Florian Fainelli
2022-08-17 9:18 ` Geert Uytterhoeven
2022-08-17 11:32 ` Marek Szyprowski
2022-09-19 14:51 ` Geert Uytterhoeven
2022-09-22 12:31 ` Jakub Kicinski
2022-09-22 15:29 ` Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=27016cc0-f228-748b-ea03-800dda4e5f0c@samsung.com \
--to=m.szyprowski@samsung.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=opendmb@gmail.com \
--cc=pabeni@redhat.com \
--cc=steve.glendinning@shawell.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®