From: Andrew Lunn <andrew@lunn.ch>
To: Russell King <rmk+kernel@armlinux.org.uk>
Cc: Florian Fainelli <f.fainelli@gmail.com>, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v2 5/7] net: phy: marvell: fix paged access races
Date: Tue, 2 Jan 2018 17:00:47 +0100 [thread overview]
Message-ID: <20180102160047.GD20986@lunn.ch> (raw)
In-Reply-To: <E1eWKHQ-0003io-8N@rmk-PC.armlinux.org.uk>
On Tue, Jan 02, 2018 at 10:58:48AM +0000, Russell King wrote:
> For paged accesses to be truely safe, we need to hold the bus lock to
> prevent anyone else gaining access to the registers while we modify
> them.
>
> The phydev->lock mutex does not do this: userspace via the MII ioctl
> can still sneak in and read or write any register while we are on a
> different page, and the suspend/resume methods can be called by a
> thread different to the thread polling the phy status.
>
> Races have been observed with mvneta on SolidRun Clearfog with phylink,
> particularly between the phylib worker reading the PHYs status, and
> the thread resuming mvneta, calling phy_start() which then calls
> through to m88e1121_config_aneg_rgmii_delays(), which tries to
> read-modify-write the MSCR register:
>
> CPU0 CPU1
> marvell_read_status_page()
> marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE)
> ...
> m88e1121_config_aneg_rgmii_delays()
> set_page(MII_MARVELL_MSCR_PAGE)
> phy_read(phydev, MII_88E1121_PHY_MSCR_REG)
> marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE);
> ...
> phy_write(phydev, MII_88E1121_PHY_MSCR_REG)
>
> The result of this is we end up writing the copper page register 21,
> which causes the copper PHY to be disabled, and the link partner sees
> the link immediately go down.
>
> Solve this by taking the bus lock instead of the PHY lock, thereby
> preventing other accesses to the PHY while we are accessing other PHY
> pages.
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
next prev parent reply other threads:[~2018-01-02 16:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-02 10:52 [PATCH net-next v2 0/7] Resolve races in phy accessors Russell King - ARM Linux
2018-01-02 10:58 ` [PATCH net-next v2 1/7] net: mdiobus: add unlocked accessors Russell King
2018-01-02 10:58 ` [PATCH net-next v2 2/7] net: phy: use unlocked accessors for indirect MMD accesses Russell King
2018-01-02 10:58 ` [PATCH net-next v2 3/7] net: phy: add unlocked accessors Russell King
2018-01-02 15:49 ` Andrew Lunn
2018-01-02 10:58 ` [PATCH net-next v2 4/7] net: phy: add paged phy register accessors Russell King
2018-01-02 15:52 ` Andrew Lunn
2018-01-02 10:58 ` [PATCH net-next v2 5/7] net: phy: marvell: fix paged access races Russell King
2018-01-02 16:00 ` Andrew Lunn [this message]
2018-01-02 10:58 ` [PATCH net-next v2 6/7] net: phy: add phy_modify() accessor Russell King
2018-01-02 16:01 ` Andrew Lunn
2018-01-02 10:58 ` [PATCH net-next v2 7/7] net: phy: convert read-modify-write to phy_modify() Russell King
2018-01-02 16:05 ` Andrew Lunn
2018-01-03 16:04 ` [PATCH net-next v2 0/7] Resolve races in phy accessors David Miller
2018-01-03 17:32 ` Russell King - ARM Linux
2018-01-03 18:38 ` David Miller
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=20180102160047.GD20986@lunn.ch \
--to=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
/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).