Hello! On 3/23/23 11:32 AM, Geert Uytterhoeven wrote: [...] >>> It had a purpose back in the days, but today we have a handy helper. >> >> Well, the is_opened flag doesn't get set/cleared at the same time as >> __LINK_STATE_START. I'm not sure they are interchangeable... >> >>> Reported-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> >>> Signed-off-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx> > >>> --- a/drivers/net/ethernet/renesas/sh_eth.c >>> +++ b/drivers/net/ethernet/renesas/sh_eth.c >>> @@ -2441,8 +2441,6 @@ static int sh_eth_open(struct net_device *ndev) >>> >>> netif_start_queue(ndev); >>> >>> - mdp->is_opened = 1; >>> - >> >> __LINK_STATE_START gets set before the ndo_open() method call, so >> before the RPM call that enbales the clocks... >> >>> return ret; >>> >>> out_free_irq: >>> @@ -2565,7 +2563,7 @@ static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev) >>> if (mdp->cd->no_tx_cntrs) >>> return &ndev->stats; >>> >>> - if (!mdp->is_opened) >>> + if (!netif_running(ndev)) >>> return &ndev->stats; >> >> I guess mdp->is_opened is checked here to avoid reading the counter >> regs when RPM hasn't been called yet to enable the clocks... > > Exactly, cfr. commit 7fa2955ff70ce453 ("sh_eth: Fix sleeping function > called from invalid context"). Yeah, pm_runtime_get_sync() couldn't be called in this case as netstat_show() invoked read_lock() that ensued calling preempt_disable()... > So you mean sh_eth_get_stats() can now be called after setting > __LINK_STATE_START, but before RPM has enabled the clocks? Yes, probably... > Is there some protection against parallel execution of ndo_open() > and get_stats()? Haven't seen it (yet?)... > Gr{oetje,eeting}s, > > Geert MBR, Sergey