Thread (21 messages) 21 messages, 3 authors, 2024-09-04

Re: [PATCH net-next v2 3/7] net: ethernet: fs_enet: drop the .adjust_link custom fs_ops

From: Maxime Chevallier <maxime.chevallier@bootlin.com>
Date: 2024-09-04 15:50:47
Also in: lkml, netdev

On Wed, 4 Sep 2024 14:36:58 +0200
Andrew Lunn [off-list ref] wrote:
On Wed, Sep 04, 2024 at 10:27:11AM +0200, Maxime Chevallier wrote:
quoted
Hi Andrew,

On Fri, 30 Aug 2024 23:06:08 +0200
Andrew Lunn [off-list ref] wrote:
  
quoted
quoted
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -649,12 +649,7 @@ static void fs_adjust_link(struct net_device *dev)
 	unsigned long flags;
 
 	spin_lock_irqsave(&fep->lock, flags);
-
-	if (fep->ops->adjust_link)
-		fep->ops->adjust_link(dev);
-	else
-		generic_adjust_link(dev);
-
+	generic_adjust_link(dev);
 	spin_unlock_irqrestore(&fep->lock, flags);    
Holding a spinlock is pretty unusual. We are in thread context, and
the phydev mutex is held. Looking at generic_adjust_link, do any of
the fep->foo variables actually need protecting, particularly from
changes in interrupts context?  
Yes there are, the interrupt mask/event registers are being accessed
from the interrupt handler and the ->restart() hook. I can try to
rework this a bit for a cleaner interrupt handling, but I don't have
means to test this on all mac flavors (fec/fcc/scc) :(  
As far as i can see, none of the fep->old* members are accessed
outside of fs_enet-main.c. There values are not important for the
restart call. So the spinlock has nothing to do with adjust_link as
such, but restart. So maybe narrow down the lock to just the restart
call? But it is not a big issues, just unusual.
I agree with you on that, and this is actually what end-up happening in
the final phylink conversion patch (only the restart() call gets called
wthin the spinlock).

I'll however include a patch that does exactly what you suggest as part
of the phylink conversion, both to make the big port-to-phylink patch
smaller, but also to better document why we only need to care about the
restart() part, if that's ok :)

Thanks,

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