Thread (11 messages) flat view 11 messages, 4 authors, 2021-11-23

Re: [PATCH] phy: fix possible double lock calling link changed handler

From: Alessandro B Maurici <hidden>
Date: 2021-11-23 04:49:57

On Tue, 23 Nov 2021 05:18:14 +0100
Andrew Lunn [off-list ref] wrote:
On Mon, Nov 22, 2021 at 11:55:48PM -0300, Alessandro B Maurici wrote:
quoted
From: Alessandro B Maurici <redacted>

Releases the phy lock before calling phy_link_change to avoid any worker
thread lockup. Some network drivers(eg Microchip's LAN743x), make a call to
phy_ethtool_get_link_ksettings inside the link change handler  
I think we need to take a step back here and answer the question, why
does it call phy_ethtool_get_link_ksettings in the link change
handler. I'm not aware of any other MAC driver which does this.

	 Andrew
I agree, the use in the lan743x seems related to the PTP, that driver seems
to be the only one using it, at least in the Linus tree. 
I think that driver could be patched as there are other ways to do it,
but my take on the problem itself is that the PHY device interface opens
a way to break the flow and this behavior does not seem to be documented,
so, instead of documenting a possible harmful interface while in the callback,
we should just get rid of the problem itself, and calling a callback without
any locks held seems to be a good alternative.
This is also a non critical performance path and the additional code
would not impact much, of course it makes the stuff less nice to look at.
The patch also has an additional check for the lock, since there is a 
function that is not calling the lock explicitly and has a warn if the lock
is not held at the start, so I put it there to be extra safe.

Alessandro
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help