Re: [Issue report] drivers/ftgmac100: DHCP occasionally fails during boot up or link down/up

From: Andrew Lunn
Date: Mon Feb 21 2022 - 17:09:36 EST


> [   16.872475]  Possible unsafe locking scenario:
> [   16.872475]
> [   16.872478]        CPU0                    CPU1
> [   16.872482]        ----                    ----
> [   16.872485]   lock(&dev->lock);
> [   16.872495]                                lock(rtnl_mutex);
> [   16.872505] lock(&dev->lock);

It looks like the whitespace got messed up here, and it should
actually be:
> [   16.872505] lock(&dev->lock);

> [   16.872513]   lock(rtnl_mutex);

So if up calls open() which first takes rtnl and then the
phydev->lock.

adjust link is called with phydev->lock already held and it then takes
the rtnl. Deadlock.

During the adjust_list callback, the phydev lock is held so the
contents of phydev are consistent. What you could do is make a copy of
what you need and then release phydev lock. You can then take rtnl and
do the reset. Once the reset is finished, program MAC with the copy
you took from phydev. Then lock phydev again, and return.

Andrew