Re: [PATCH net-next] net: phy: Add driver for Motorcomm yt8531 gigabit ethernet phy

From: Andrew Lunn
Date: Wed Nov 30 2022 - 13:21:33 EST


On Wed, Nov 30, 2022 at 05:33:15PM +0000, Russell King (Oracle) wrote:
> Hi Andrew,
>
> On Wed, Nov 30, 2022 at 06:10:42PM +0100, Andrew Lunn wrote:
> > This is not the first time Russell has pointed out your locking is
> > wrong.
> >
> > How about adding a check in functions which should be called with the
> > lock taken really do have the lock taken?
>
> They already do:
>
> lockdep_assert_held_once(&bus->mdio_lock);
>
> but I guess people just aren't testing their code with lockdep enabled.
>
> The only other thing I can think of trying is to use mutex_trylock():
>
> if (WARN_ON_ONCE(mutex_trylock(&bus->mdio_lock)))
> mutex_unlock(&bus->mdio_lock);
>
> scattered throughout.

The ASSERT_RTNL() macro does this, it does not depend on lockdep.

And given the persistent sort of problems we have seen, you are
probably correct, lockdep is not being enabled by some developers. I
guess they don't even know what it is.

Andrew