Thread (11 messages) flat view 11 messages, 2 authors, 2020-01-24

RE: [PATCH net v3 1/5] net: stmmac: Fix incorrect location to set real_num_rx|tx_queues

From: Ong, Boon Leong <hidden>
Date: 2020-01-24 08:56:33
Also in: lkml, netdev

-----Original Message-----
From: Jose Abreu <Jose.Abreu@synopsys.com>
Sent: Wednesday, January 22, 2020 5:56 PM
To: Ong, Boon Leong <redacted>; netdev@vger.kernel.org
Cc: Tan, Tee Min <redacted>; Voon, Weifeng
[off-list ref]; Giuseppe Cavallaro [off-list ref];
Alexandre TORGUE [off-list ref]; David S . Miller
[off-list ref]; Maxime Coquelin [off-list ref];
Joao Pinto [off-list ref]; Arnd Bergmann [off-list ref];
Alexandru Ardelean [off-list ref]; linux-stm32@st-md-
mailman.stormreply.com; linux-arm-kernel@lists.infradead.org; linux-
kernel@vger.kernel.org
Subject: RE: [PATCH net v3 1/5] net: stmmac: Fix incorrect location to set
real_num_rx|tx_queues

From: Ong Boon Leong <redacted>
Date: Jan/22/2020, 09:09:32 (UTC+00:00)
quoted
For driver open(), rtnl_lock is acquired by network stack but not in the
resume(). Therefore, we introduce lock_acquired boolean to control when
to use rtnl_lock|unlock() within stmmac_hw_setup().
Why not use rtnl_is_locked() instead of the boolean ?
We know that stmmac_open() is called with rtnl_mutex locked by caller.
And, stmmac_resume() is called without rtnl_mutex is locked by caller.
If we replace the boolean with rtnl_is_locked(), then we will have the
following logics in stmmac_hw_setup():-

     if (!rtnl_is_locked)   ---- (A)
         rtnl_lock();
     netif_set_real_num_rx_queues();
     netif_set_real_num_tx_queues();
     if (!rtnl_is_locked)   ---- (B)
         rtnl_unlock();

For stmmac_open(), (A) is false but (B) is true. 
So, the stmmac_open() exits with rtnl_mutex is released.
Here, the above logic does not perserve the original rtnl_mutex
is locked when stmmac_open() is called.

For stmmac_resume(), (A) is true, and (B) is also true.
So, the stmmac_resume() exits with rtnl_mutex is released.
Here, the above logic works well as the original rtnl_mutex is released
when stmmac_resume() is called.
 
So, as far as I can see, the proposed boolean approach works fine for both
stmmac_open() and stmmac_resume().

Do you agree? 
 


 
 

 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help