Skip to contentSkip to conversation

net: stmmac: Misc fixes

PATCH In review Jose Abreu 4 participants 8 messages Jan 30, 2019 – Feb 6, 2019

Subsystems (4)
lore
Share & tools
lore

Jose Abreu

author
#0 lore raw

cover net: stmmac: Misc fixes

Some misc fixes for stmmac targeting -net.

Cc Joao Pinto <[email protected]>
Cc David S. Miller <[email protected]>
Cc Giuseppe Cavallaro <[email protected]>
Cc Alexandre Torgue <[email protected]>

Jose Abreu (3):
net: stmmac: Fallback to Platform Data clock in Watchdog conversion
net: stmmac: Send TSO packets always from Queue 0
net: stmmac: Disable EEE mode earlier in XMIT callback

 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 14 ++++++++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    | 17 +++++++++++++----
 include/linux/stmmac.h                               |  1 +
 3 files changed, 24 insertions(+), 8 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/3 net: stmmac: Fallback to Platform Data clock in Watchdog conversion

If we don't have DT then stmmac_clk will not be available. Let's add a new Platform Data field so that we can specify the refclk by this mean.

This way we can still use the coalesce command in PCI based setups.

Cc Joao Pinto <[email protected]>
Cc David S. Miller <[email protected]>
Cc Giuseppe Cavallaro <[email protected]>
Cc Alexandre Torgue <[email protected]>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 14 ++++++++++----
 include/linux/stmmac.h                               |  1 +
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +10 -4
index d1f61c25d82b..5d85742a2be0 100644
@@ -721,8 +721,11 @@ static u32 stmmac_usec2riwt(u32 usec, struct stmmac_priv *priv)
 {
 	unsigned long clk = clk_get_rate(priv->plat->stmmac_clk);
 
-	if (!clk)
-		return 0;
+	if (!clk) {
+		clk = priv->plat->clk_ref_rate;
+		if (!clk)
+			return 0;
+	}
 
 	return (usec * (clk / 1000000)) / 256;
 }
@@ -731,8 +734,11 @@ static u32 stmmac_riwt2usec(u32 riwt, struct stmmac_priv *priv)
 {
 	unsigned long clk = clk_get_rate(priv->plat->stmmac_clk);
 
-	if (!clk)
-		return 0;
+	if (!clk) {
+		clk = priv->plat->clk_ref_rate;
+		if (!clk)
+			return 0;
+	}
 
 	return (riwt * 256) / (clk / 1000000);
 }
include/linux/stmmac.h +1 -0
index 7ddfc65586b0..4335bd771ce5 100644
@@ -184,6 +184,7 @@ struct plat_stmmacenet_data {
 	struct clk *pclk;
 	struct clk *clk_ptp_ref;
 	unsigned int clk_ptp_rate;
+	unsigned int clk_ref_rate;
 	struct reset_control *stmmac_rst;
 	struct stmmac_axi *axi;
 	int has_gmac4;
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 2/3 net: stmmac: Send TSO packets always from Queue 0

In reply to Jose Abreu

The number of TSO enabled channels in HW can be different than the number of total channels. There is no way to determined, at runtime, the number of TSO capable channels and its safe to assume that if TSO is enabled then at least channel 0 will be TSO capable.

Lets always send TSO packets from Queue 0.

Cc Joao Pinto <[email protected]>
Cc David S. Miller <[email protected]>
Cc Giuseppe Cavallaro <[email protected]>
Cc Alexandre Torgue <[email protected]>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10 -1
index 5afba69981cf..6656008068de 100644
@@ -3025,8 +3025,17 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	/* Manage oversized TCP frames for GMAC4 device */
 	if (skb_is_gso(skb) && priv->tso) {
-		if (skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))
+		if (skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) {
+			/*
+			 * There is no way to determine the number of TSO
+			 * capable Queues. Let's use always the Queue 0
+			 * because if TSO is supported then at least this
+			 * one will be capable.
+			 */
+			skb_set_queue_mapping(skb, 0);
+
 			return stmmac_tso_xmit(skb, dev);
+		}
 	}
 
 	if (unlikely(stmmac_tx_avail(priv, queue) < nfrags + 1)) {
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH 3/3 net: stmmac: Disable EEE mode earlier in XMIT callback

In reply to Jose Abreu

In stmmac xmit callback we use a different flow for TSO packets but TSO xmit callback is not disabling the EEE mode.

Fix this by disabling earlier the EEE mode, i.e. before calling the TSO xmit callback.

Cc Joao Pinto <[email protected]>
Cc David S. Miller <[email protected]>
Cc Giuseppe Cavallaro <[email protected]>
Cc Alexandre Torgue <[email protected]>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -3
index 6656008068de..685d20472358 100644
@@ -3023,6 +3023,9 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	tx_q = &priv->tx_queue[queue];
 
+	if (priv->tx_path_in_lpi_mode)
+		stmmac_disable_eee_mode(priv);
+
 	/* Manage oversized TCP frames for GMAC4 device */
 	if (skb_is_gso(skb) && priv->tso) {
 		if (skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) {
@@ -3050,9 +3053,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 		return NETDEV_TX_BUSY;
 	}
 
-	if (priv->tx_path_in_lpi_mode)
-		stmmac_disable_eee_mode(priv);
-
 	entry = tx_q->cur_tx;
 	first_entry = entry;
 	WARN_ON(tx_q->tx_skbuff[first_entry]);
Signature · 1 line
2.7.4
#4 lore raw
In reply to Jose Abreu
Quoted 12 lines · Jose Abreu

Some misc fixes for stmmac targeting -net.

Cc Joao Pinto <[email protected]>
Cc David S. Miller <[email protected]>
Cc Giuseppe Cavallaro <[email protected]>
Cc Alexandre Torgue <[email protected]>

Jose Abreu (3):
net: stmmac: Fallback to Platform Data clock in Watchdog conversion
net: stmmac: Send TSO packets always from Queue 0
net: stmmac: Disable EEE mode earlier in XMIT callback

Quoted 8 lines
 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 14 ++++++++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    | 17 +++++++++++++----
 include/linux/stmmac.h                               |  1 +
 3 files changed, 24 insertions(+), 8 deletions(-)
Signature · 1 line
2.7.4

Hello

Could you CC [email protected] when you send patch. (as asked by get_maintainer.pl) By avoiding it, your patchset is not stored on lore nor is handled by all checkbots reading lkml.

Thanks
Regards

#6 lore raw
In reply to Jose Abreu
Quoted 8 lines · Jose Abreu

Some misc fixes for stmmac targeting -net.

Cc Joao Pinto <[email protected]>
Cc David S. Miller <[email protected]>
Cc Giuseppe Cavallaro <[email protected]>
Cc Alexandre Torgue <[email protected]>
Quoted 4 lines

Jose Abreu (3):
net: stmmac: Fallback to Platform Data clock in Watchdog conversion
net: stmmac: Send TSO packets always from Queue 0
net: stmmac: Disable EEE mode earlier in XMIT callback

Hello Jose,

Thanks for your great work of improving the stmmac driver.

Unfortunately, I'm seeing that a lot of important stmmac fixes aren't getting backported to stable kernels.

I think that the problem is that a lot of stmmac commit messages do not clearly indicate what happens if these patches are not included.

See netdev FAQ:

Q: I have created a network patch and I think it should be backported to
stable. Should I add a "Cc: [email protected]" like the references in the kernel's Documentation/ directory say?

A: No. See above answer. In short, if you think it really belongs in
stable, then ensure you write a decent commit log that describes who gets impacted by the bugfix and how it manifests itself, and when the bug was introduced. If you do that properly, then the commit will get handled appropriately and most likely get put in the patchworks stable queue if it really warrants it.

Could you please tell me what happens if I don't include "net: stmmac: Disable EEE mode earlier in XMIT callback" ?

likewise if I don't include "net: stmmac: Send TSO packets always from Queue 0" ?

I assume that I will get a TX timeout if I try to send a TSO packet from a queue that does not support it?

Also, we already define the TX queues in the snps,mtl-tx-config:
Documentation/devicetree/bindings/net/stmmac.txt

Wouldn't it be possible to add a snps,tso-capable property for each tx queue node that supports tso?

Kind regards,
Niklas

Quoted 9 lines
 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 14 ++++++++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    | 17 +++++++++++++----
 include/linux/stmmac.h                               |  1 +
 3 files changed, 24 insertions(+), 8 deletions(-)
Signature · 1 line
2.7.4
author
#7 lore raw

Hi Niklas,

Quoted 31 lines · Niklas Cassel
Quoted 8 lines · Jose Abreu

Some misc fixes for stmmac targeting -net.

Cc Joao Pinto <[email protected]>
Cc David S. Miller <[email protected]>
Cc Giuseppe Cavallaro <[email protected]>
Cc Alexandre Torgue <[email protected]>
Quoted 4 lines

Jose Abreu (3):
net: stmmac: Fallback to Platform Data clock in Watchdog conversion
net: stmmac: Send TSO packets always from Queue 0
net: stmmac: Disable EEE mode earlier in XMIT callback

Hello Jose,

Thanks for your great work of improving the stmmac driver.

Unfortunately, I'm seeing that a lot of important stmmac fixes aren't getting backported to stable kernels.

I think that the problem is that a lot of stmmac commit messages do not clearly indicate what happens if these patches are not included.

See netdev FAQ:

Q: I have created a network patch and I think it should be backported to
stable. Should I add a "Cc: [email protected]" like the references in the kernel's Documentation/ directory say?

Quoted 6 lines

A: No. See above answer. In short, if you think it really belongs in
stable, then ensure you write a decent commit log that describes who gets impacted by the bugfix and how it manifests itself, and when the bug was introduced. If you do that properly, then the commit will get handled appropriately and most likely get put in the patchworks stable queue if it really warrants it.

I will try to add a Fixes tag and explain more carefully the next time. Sorry.

Quoted 5 lines

Could you please tell me what happens if I don't include "net: stmmac: Disable EEE mode earlier in XMIT callback" ?

Probably a drop in performance. Not critical though.

Quoted 4 lines

likewise if I don't include "net: stmmac: Send TSO packets always from Queue 0" ?

In my tests I get a drop in performance also.

Quoted 3 lines

I assume that I will get a TX timeout if I try to send a TSO packet from a queue that does not support it?

No. Packets will still be sent but they will not be TSO packets.

Quoted 6 lines

Also, we already define the TX queues in the snps,mtl-tx-config:
Documentation/devicetree/bindings/net/stmmac.txt

Wouldn't it be possible to add a snps,tso-capable property for each tx queue node that supports tso?

Yes but that would be more like a -next improvement.

Thanks,
Jose Miguel Abreu

Quoted 14 lines

Kind regards,
Niklas

Quoted 9 lines
 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 14 ++++++++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    | 17 +++++++++++++----
 include/linux/stmmac.h                               |  1 +
 3 files changed, 24 insertions(+), 8 deletions(-)
Signature · 1 line
2.7.4