From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
chenhao418@huawei.com, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Jijie Shao <shaojijie@huawei.com>,
lanhao@huawei.com, liuyonglong@huawei.com,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
shenjian15@huawei.com, wangjie125@huawei.com,
wangpeiyang1@huawei.com
Subject: Re: [PATCH net-next 1/7] net: phy: always call phy_process_state_change() under lock
Date: Mon, 18 Sep 2023 14:06:26 +0100 [thread overview]
Message-ID: <ZQhLUlw452Ewu7yi@shell.armlinux.org.uk> (raw)
In-Reply-To: <42ef8c8f-2fc0-a210-969b-7b0d648d8226@samsung.com>
On Mon, Sep 18, 2023 at 02:33:04PM +0200, Marek Szyprowski wrote:
> Hi Russell,
>
> On 14.09.2023 17:35, Russell King (Oracle) wrote:
> > phy_stop() calls phy_process_state_change() while holding the phydev
> > lock, so also arrange for phy_state_machine() to do the same, so that
> > this function is called with consistent locking.
> >
> > Tested-by: Jijie Shao <shaojijie@huawei.com>
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
>
> This change, merged to linux-next as commit 8da77df649c4 ("net: phy:
> always call phy_process_state_change() under lock") introduces the
> following deadlock with ASIX AX8817X USB driver:
Yay, latent bug found...
I guess this is asix_ax88772a_link_change_notify() which is causing
the problem, and yes, that phy_start_aneg() needs to be the unlocked
version (which we'll have to export.)
This should fix it.
diff --git a/drivers/net/phy/ax88796b.c b/drivers/net/phy/ax88796b.c
index 0f1e617a26c9..eb74a8cf8df1 100644
--- a/drivers/net/phy/ax88796b.c
+++ b/drivers/net/phy/ax88796b.c
@@ -90,7 +90,7 @@ static void asix_ax88772a_link_change_notify(struct phy_device *phydev)
*/
if (phydev->state == PHY_NOLINK) {
phy_init_hw(phydev);
- phy_start_aneg(phydev);
+ _phy_start_aneg(phydev);
}
}
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 93a8676dd8d8..a5fa077650e8 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -981,7 +981,7 @@ static int phy_check_link_status(struct phy_device *phydev)
* If the PHYCONTROL Layer is operating, we change the state to
* reflect the beginning of Auto-negotiation or forcing.
*/
-static int _phy_start_aneg(struct phy_device *phydev)
+int _phy_start_aneg(struct phy_device *phydev)
{
int err;
@@ -1002,6 +1002,7 @@ static int _phy_start_aneg(struct phy_device *phydev)
return err;
}
+EXPORT_SYMBOL(_phy_start_aneg);
/**
* phy_start_aneg - start auto-negotiation for this PHY device
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 1351b802ffcf..3cc52826f18e 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1736,6 +1736,7 @@ void phy_detach(struct phy_device *phydev);
void phy_start(struct phy_device *phydev);
void phy_stop(struct phy_device *phydev);
int phy_config_aneg(struct phy_device *phydev);
+int _phy_start_aneg(struct phy_device *phydev);
int phy_start_aneg(struct phy_device *phydev);
int phy_aneg_done(struct phy_device *phydev);
int phy_speed_down(struct phy_device *phydev, bool sync);
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2023-09-18 16:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-14 15:34 [PATCH net-next 0/7] net: phy: avoid race when erroring stopping PHY Russell King (Oracle)
2023-09-14 15:35 ` [PATCH net-next 1/7] net: phy: always call phy_process_state_change() under lock Russell King (Oracle)
2023-09-14 18:21 ` Florian Fainelli
2023-09-18 12:33 ` Marek Szyprowski
2023-09-18 12:55 ` Andrew Lunn
2023-09-18 13:05 ` Marek Szyprowski
2023-09-18 13:07 ` Russell King (Oracle)
2023-09-18 13:06 ` Russell King (Oracle) [this message]
2023-09-18 13:15 ` Marek Szyprowski
2023-09-14 15:35 ` [PATCH net-next 2/7] net: phy: call phy_error_precise() while holding the lock Russell King (Oracle)
2023-09-14 18:21 ` Florian Fainelli
2023-09-14 15:35 ` [PATCH net-next 3/7] net: phy: move call to start aneg Russell King (Oracle)
2023-09-14 18:22 ` Florian Fainelli
2023-09-14 15:35 ` [PATCH net-next 4/7] net: phy: move phy_suspend() to end of phy_state_machine() Russell King (Oracle)
2023-09-14 18:22 ` Florian Fainelli
2023-09-14 15:35 ` [PATCH net-next 5/7] net: phy: move phy_state_machine() Russell King (Oracle)
2023-09-14 18:22 ` Florian Fainelli
2023-09-14 15:35 ` [PATCH net-next 6/7] net: phy: split locked and unlocked section of phy_state_machine() Russell King (Oracle)
2023-09-14 18:39 ` Florian Fainelli
2023-09-14 15:36 ` [PATCH net-next 7/7] net: phy: convert phy_stop() to use split state machine Russell King (Oracle)
2023-09-14 18:39 ` Florian Fainelli
2023-09-17 13:40 ` [PATCH net-next 0/7] net: phy: avoid race when erroring stopping PHY patchwork-bot+netdevbpf
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=ZQhLUlw452Ewu7yi@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=chenhao418@huawei.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=lanhao@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=m.szyprowski@samsung.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shaojijie@huawei.com \
--cc=shenjian15@huawei.com \
--cc=wangjie125@huawei.com \
--cc=wangpeiyang1@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).