From: Vladimir Oltean <olteanv@gmail.com>
To: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Cc: netdev@vger.kernel.org, andrew@lunn.ch,
Julian.FRIEDRICH@frequentis.com, f.fainelli@gmail.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, linux-kernel@vger.kernel.org,
upstream+netdev@sigma-star.at
Subject: Re: [PATCH v4] net: dsa: mv88e6xxx: propperly shutdown PPU re-enable timer on destroy
Date: Fri, 4 Apr 2025 00:44:37 +0300 [thread overview]
Message-ID: <20250403214437.fayvje56af3rbfrl@skbuf> (raw)
In-Reply-To: <20250401135705.92760-1-david.oberhollenzer@sigma-star.at> <20250401135705.92760-1-david.oberhollenzer@sigma-star.at>
Hi David,
On Tue, Apr 01, 2025 at 03:56:37PM +0200, David Oberhollenzer wrote:
> The mv88e6xxx has an internal PPU that polls PHY state. If we want to
> access the internal PHYs, we need to disable the PPU first. Because
> that is a slow operation, a 10ms timer is used to re-enable it,
> canceled with every access, so bulk operations effectively only
> disable it once and re-enable it some 10ms after the last access.
>
> If a PHY is accessed and then the mv88e6xxx module is removed before
> the 10ms are up, the PPU re-enable ends up accessing a dangling pointer.
>
> This especially affects probing during bootup. The MDIO bus and PHY
> registration may succeed, but registration with the DSA framework
> may fail later on (e.g. because the CPU port depends on another,
> very slow device that isn't done probing yet, returning -EPROBE_DEFER).
> In this case, probe() fails, but the MDIO subsystem may already have
> accessed the MIDO bus or PHYs, arming the timer.
>
> This is fixed as follows:
> - If probe fails after mv88e6xxx_phy_init(), make sure we also call
> mv88e6xxx_phy_destroy() before returning
> - In mv88e6xxx_remove(), make sure we do the teardown in the correct
> order, calling mv88e6xxx_phy_destroy() after unregistering the
> switch device.
> - In mv88e6xxx_phy_destroy(), destroy both the timer and the work item
> that the timer might schedule, synchronously waiting in case one of
> the callbacks already fired and destroying the timer first, before
> waiting for the work item.
> - Access to the PPU is guarded by a mutex, the worker acquires it
> with a mutex_trylock(), not proceeding with the expensive shutdown
> if that fails. We grab the mutex in mv88e6xxx_phy_destroy() to make
> sure the slow PPU shutdown is already done or won't even enter, when
> we wait for the work item.
>
> Fixes: 2e5f032095ff ("dsa: add support for the Marvell 88E6131 switch chip")
> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
> ---
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
next prev parent reply other threads:[~2025-04-03 21:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 13:56 [PATCH v4] net: dsa: mv88e6xxx: propperly shutdown PPU re-enable timer on destroy David Oberhollenzer
2025-04-03 21:44 ` Vladimir Oltean [this message]
2025-04-03 22:20 ` 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=20250403214437.fayvje56af3rbfrl@skbuf \
--to=olteanv@gmail.com \
--cc=Julian.FRIEDRICH@frequentis.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=david.oberhollenzer@sigma-star.at \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=upstream+netdev@sigma-star.at \
/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