From: Ong Boon Leong <hidden> Date: 2020-02-05 08:55:34
Thanks to all feedbacks from community.
We updated the patch-series to below:-
1/6: It ensures that the real_num_rx|tx_queues are set in both driver
probe() and resume(). So, move the netif_set_real_num_rx|tx_queues()
into stmmac_hw_setup(). Use rtnl_lock() and rtnl_unlock() for
stmmac_hw_setup() called inside stmmac_resume().
2/6: It ensures that the previous value of GMAC_VLAN_TAG register is
read first before for updating the register.
3/6: Similar to 2/6 patch but it is a fix for XGMAC_VLAN_TAG register
as requested by Jose Abreu.
4/6: It ensures the GMAC IP v4.xx and above behaves correctly to:-
ip link set <devname> multicast off|on
5/6: Added similar IFF_MULTICAST flag for xgmac2, similar to 4/6.
6/6: It ensures PCI platform data is using plat->phy_interface.
Rgds,
Boon Leong
Changes from v3:-
patch 1/6 - add rtnl_lock() and rtnl_unlock() for stmmac_hw_setup()
called inside stmmac_resume()
patch 3/6 - Added new patch to fix XGMAC_VLAN_TAG register writting
v2:-
patch 1/5 - added control for rtnl_lock() & rtnl_unlock() to ensure
they are used forstmmac_resume()
patch 4/5 - added IFF_MULTICAST flag check for xgmac to ensure
multicast works correctly.
v1:-
- Drop v1 patches (1/7, 3/7 & 4/7) that are not valid.
Aashish Verma (1):
net: stmmac: Fix incorrect location to set real_num_rx|tx_queues
Ong Boon Leong (1):
net: stmmac: xgmac: fix incorrect XGMAC_VLAN_TAG register writting
Tan, Tee Min (2):
net: stmmac: fix incorrect GMAC_VLAN_TAG register writting in GMAC4+
net: stmmac: xgmac: fix missing IFF_MULTICAST checki in
dwxgmac2_set_filter
Verma, Aashish (1):
net: stmmac: fix missing IFF_MULTICAST check in dwmac4_set_filter
Voon Weifeng (1):
net: stmmac: update pci platform data to use phy_interface
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 9 +++++----
.../net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 10 +++++++---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++++----
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 14 ++++++++------
4 files changed, 26 insertions(+), 17 deletions(-)
--
2.17.1
From: Ong Boon Leong <hidden> Date: 2020-02-05 08:55:37
From: Aashish Verma <redacted>
netif_set_real_num_tx_queues() & netif_set_real_num_rx_queues() should be
used to inform network stack about the real Tx & Rx queue (active) number
in both stmmac_open() and stmmac_resume(), therefore, we move the code
from stmmac_dvr_probe() to stmmac_hw_setup().
For driver open(), rtnl_lock is acquired by network stack but not in the
resume(). Therefore, we need to rtnl_lock() and rtnl_unlock() when
calling stmmac_hw_setup() within resume(). Thanks Jose Abreu for input.
Fixes: c02b7a914551 ("net: stmmac: use netif_set_real_num_{rx,tx}_queues")
Signed-off-by: Aashish Verma <redacted>
Tested-by: Tan, Tee Min <redacted>
Signed-off-by: Ong Boon Leong <redacted>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
@@ -2657,6 +2657,10 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)stmmac_enable_tbs(priv,priv->ioaddr,enable,chan);}+/* Configure real RX and TX queues */+netif_set_real_num_rx_queues(dev,priv->plat->rx_queues_to_use);+netif_set_real_num_tx_queues(dev,priv->plat->tx_queues_to_use);+/* Start the ball rolling... */stmmac_start_all_dma(priv);
@@ -4738,10 +4742,6 @@ int stmmac_dvr_probe(struct device *device,stmmac_check_ether_addr(priv);-/* Configure real RX and TX queues */-netif_set_real_num_rx_queues(ndev,priv->plat->rx_queues_to_use);-netif_set_real_num_tx_queues(ndev,priv->plat->tx_queues_to_use);-ndev->netdev_ops=&stmmac_netdev_ops;ndev->hw_features=NETIF_F_SG|NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM|
@@ -5091,7 +5091,9 @@ int stmmac_resume(struct device *dev)stmmac_clear_descriptors(priv);+rtnl_lock();stmmac_hw_setup(ndev,false);+rtnl_unlock();stmmac_init_coalesce(priv);stmmac_set_rx_mode(ndev);
From: Ong Boon Leong <hidden> Date: 2020-02-05 08:55:41
From: "Tan, Tee Min" <redacted>
It should always do a read of current value of GMAC_VLAN_TAG instead of
directly overwriting the register value.
Fixes: c1be0022df0d ("net: stmmac: Add VLAN HASH filtering support in GMAC4+")
Signed-off-by: Tan, Tee Min <redacted>
Signed-off-by: Ong Boon Leong <redacted>
---
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
From: Ong Boon Leong <hidden> Date: 2020-02-05 08:55:44
We should always do a read of current value of XGMAC_VLAN_TAG instead of
directly overwriting the register value.
Fixes: 3cd1cfcba26e2 ("net: stmmac: Implement VLAN Hash Filtering in XGMAC")
Signed-off-by: Ong Boon Leong <redacted>
---
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
From: Ong Boon Leong <hidden> Date: 2020-02-05 08:55:48
From: "Verma, Aashish" <redacted>
Without checking for IFF_MULTICAST flag, it is wrong to assume multicast
filtering is always enabled. By checking against IFF_MULTICAST, now
the driver behaves correctly when the multicast support is toggled by below
command:-
ip link set <devname> multicast off|on
Fixes: 477286b53f55 ("stmmac: add GMAC4 core support")
Signed-off-by: Verma, Aashish <redacted>
Tested-by: Tan, Tee Min <redacted>
Signed-off-by: Ong Boon Leong <redacted>
---
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -420,7 +420,7 @@ static void dwmac4_set_filter(struct mac_device_info *hw,value|=GMAC_PACKET_FILTER_PM;/* Set all the bits of the HASH tab */memset(mc_filter,0xff,sizeof(mc_filter));-}elseif(!netdev_mc_empty(dev)){+}elseif(!netdev_mc_empty(dev)&&(dev->flags&IFF_MULTICAST)){structnetdev_hw_addr*ha;/* Hash filter for multicast */
From: Ong Boon Leong <hidden> Date: 2020-02-05 08:55:52
From: "Tan, Tee Min" <redacted>
Without checking for IFF_MULTICAST flag, it is wrong to assume multicast
filtering is always enabled. By checking against IFF_MULTICAST, now
the driver behaves correctly when the multicast support is toggled by below
command:-
ip link set <devname> multicast off|on
Fixes: 0efedbf11f07a ("net: stmmac: xgmac: Fix XGMAC selftests")
Signed-off-by: Tan, Tee Min <redacted>
Signed-off-by: Ong Boon Leong <redacted>
---
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Ong Boon Leong <hidden> Date: 2020-02-05 08:55:54
From: Voon Weifeng <redacted>
The recent patch to support passive mode converter did not take care the
phy interface configuration in PCI platform data. Hence, converting all
the PCI platform data from plat->interface to plat->phy_interface as the
default mode is meant for PHY.
Fixes: 0060c8783330 ("net: stmmac: implement support for passive mode converters via dt")
Signed-off-by: Voon Weifeng <redacted>
Tested-by: Tan, Tee Min <redacted>
Signed-off-by: Ong Boon Leong <redacted>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
@@ -2657,6 +2657,10 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)stmmac_enable_tbs(priv,priv->ioaddr,enable,chan);}+/* Configure real RX and TX queues */+netif_set_real_num_rx_queues(dev,priv->plat->rx_queues_to_use);+netif_set_real_num_tx_queues(dev,priv->plat->tx_queues_to_use);+/* Start the ball rolling... */stmmac_start_all_dma(priv);
It is only safe to ignore the return values from
netif_set_real_num_{rx,tx}_queues() if you call them before the
network device is registered. Because only in that case are these
functions guaranteed to succeed.
But now that you have moved these calls here, they can fail.
Therefore you must check the return value and unwind the state
completely upon failures.
Honestly, I think this change will have several undesirable side effects:
1) Lots of added new code complexity
2) A new failure mode when resuming the device, users will find this
very hard to diagnose and recover from
What real value do you get from doing these calls after probe?
If you can't come up with a suitable answer to that question, you
should reconsider this change.
Thanks.
@@ -2657,6 +2657,10 @@ static int stmmac_hw_setup(struct net_device
*dev, bool init_ptp)
quoted
>--->-------stmmac_enable_tbs(priv, priv->ioaddr, enable, chan);
>---}
+>---/* Configure real RX and TX queues */
+>---netif_set_real_num_rx_queues(dev, priv->plat->rx_queues_to_use);
+>---netif_set_real_num_tx_queues(dev, priv->plat->tx_queues_to_use);
+
>---/* Start the ball rolling... */
>---stmmac_start_all_dma(priv);
It is only safe to ignore the return values from
netif_set_real_num_{rx,tx}_queues() if you call them before the
network device is registered. Because only in that case are these
functions guaranteed to succeed.
But now that you have moved these calls here, they can fail.
Therefore you must check the return value and unwind the state
completely upon failures.
Honestly, I think this change will have several undesirable side effects:
1) Lots of added new code complexity
2) A new failure mode when resuming the device, users will find this
very hard to diagnose and recover from
What real value do you get from doing these calls after probe?
If you can't come up with a suitable answer to that question, you
should reconsider this change.
Thanks.
We have patch that implements get|set_channels() that depends on this fix.
Anyway, we understand your insight and perspective now. So, we will drop
this patch in v5 series.
Thanks