[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241103113539.7b44e4f3@kernel.org>
Date: Sun, 3 Nov 2024 11:35:39 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: David Oberhollenzer <david.oberhollenzer@...ma-star.at>
Cc: netdev@...r.kernel.org, andrew@...n.ch, Julian.FRIEDRICH@...quentis.com,
f.fainelli@...il.com, olteanv@...il.com, davem@...emloft.net,
edumazet@...gle.com, pabeni@...hat.com, linux-kernel@...r.kernel.org,
upstream+netdev@...ma-star.at
Subject: Re: [PATCH] net: dsa: mv88e6xxx: properly shutdown PPU re-enable
timer on destroy
On Tue, 29 Oct 2024 13:42:45 +0100 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 it. Because enable/disable
> of the PPU 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 is easily triggered by deferred probing during boot-up. MDIO bus
> and PHY registration may succeed, but switch registration fails later
> on, because the CPU port depends on a very slow device. In this case,
> probe() fails, but the MDIO subsystem may already have accessed bus
> or the PHYs, arming 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_phy_destroy(), grab the ppu_mutex to make sure the work
> function either has already exited, or (should it run) cannot do
> anything, fails to grab the mutex and returns.
> - In addition to destroying the timer, also destroy the work item, in
> case the timer has already fired.
> - Do all of this synchronously, to make sure timer & work item are
> destroyed and none of the callbacks are running.
Looks good, AFAICT. Could you repost with a Fixes tag added?
To make the job of the stable team easier?
Powered by blists - more mailing lists