linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups
@ 2018-02-19 17:11 Niklas Cassel
  2018-02-19 17:11 ` [PATCH net-next 1/7] net: stmmac: set MSS for each tx DMA channel Niklas Cassel
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Niklas Cassel @ 2018-02-19 17:11 UTC (permalink / raw)
  To: netdev; +Cc: Jose.Abreu, vbhadram, Niklas Cassel, linux-kernel

stmmac multi-queue fixes and cleanups

Niklas Cassel (7):
  net: stmmac: set MSS for each tx DMA channel
  net: stmmac: do not clear tx_skbuff entries in
    stmmac_xmit()/stmmac_tso_xmit()
  net: stmmac: WARN if tx_skbuff entries are reused before cleared
  net: stmmac: rename dwmac4_tx_queue_routing() to match reality
  net: stmmac: call correct function in
    stmmac_mac_config_rx_queues_routing()
  net: stmmac: add error handling in stmmac_mtl_setup()
  net: stmmac: honor error code from stmmac_dt_phy()

 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c  |  6 ++--
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       |  2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 23 +++++++--------
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 34 +++++++++++++++++-----
 4 files changed, 42 insertions(+), 23 deletions(-)

-- 
2.14.2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH net-next 1/7] net: stmmac: set MSS for each tx DMA channel
  2018-02-19 17:11 [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Niklas Cassel
@ 2018-02-19 17:11 ` Niklas Cassel
  2018-02-20  7:31   ` Giuseppe CAVALLARO
  2018-02-19 17:11 ` [PATCH net-next 2/7] net: stmmac: do not clear tx_skbuff entries in stmmac_xmit()/stmmac_tso_xmit() Niklas Cassel
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 11+ messages in thread
From: Niklas Cassel @ 2018-02-19 17:11 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue
  Cc: Jose.Abreu, vbhadram, Niklas Cassel, netdev, linux-kernel

The DMA engine in dwmac4 can segment a large TSO packet to several
smaller packets of (max) size Maximum Segment Size (MSS).

The DMA engine fetches and saves the MSS via a context descriptor.

This context decriptor has to be provided to each tx DMA channel.
To ensure that this is done, move struct member mss from stmmac_priv
to stmmac_tx_queue.

stmmac_reset_queues_param() now also resets mss, together with other
queue parameters, so reset of mss value can be removed from
stmmac_resume().

init_dma_tx_desc_rings() now also resets mss, together with other
queue parameters, so reset of mss value can be removed from
stmmac_open().

This fixes tx queue timeouts for dwmac4, with DT property
snps,tx-queues-to-use > 1, when running iperf3 with multiple threads.

Fixes: ce736788e8a9 ("net: stmmac: adding multiple buffers for TX")
Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h      |  2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 +++++--------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index a916e13624eb..75161e1b7e55 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -58,6 +58,7 @@ struct stmmac_tx_queue {
 	unsigned int dirty_tx;
 	dma_addr_t dma_tx_phy;
 	u32 tx_tail_addr;
+	u32 mss;
 };
 
 struct stmmac_rx_queue {
@@ -138,7 +139,6 @@ struct stmmac_priv {
 	spinlock_t ptp_lock;
 	void __iomem *mmcaddr;
 	void __iomem *ptpaddr;
-	u32 mss;
 
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *dbgfs_dir;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 7ad841434ec8..d38bf38f12f5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1355,6 +1355,7 @@ static int init_dma_tx_desc_rings(struct net_device *dev)
 
 		tx_q->dirty_tx = 0;
 		tx_q->cur_tx = 0;
+		tx_q->mss = 0;
 
 		netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue));
 	}
@@ -1946,6 +1947,7 @@ static void stmmac_tx_err(struct stmmac_priv *priv, u32 chan)
 						     (i == DMA_TX_SIZE - 1));
 	tx_q->dirty_tx = 0;
 	tx_q->cur_tx = 0;
+	tx_q->mss = 0;
 	netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, chan));
 	stmmac_start_tx_dma(priv, chan);
 
@@ -2632,7 +2634,6 @@ static int stmmac_open(struct net_device *dev)
 
 	priv->dma_buf_sz = STMMAC_ALIGN(buf_sz);
 	priv->rx_copybreak = STMMAC_RX_COPYBREAK;
-	priv->mss = 0;
 
 	ret = alloc_dma_desc_resources(priv);
 	if (ret < 0) {
@@ -2872,10 +2873,10 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
 	mss = skb_shinfo(skb)->gso_size;
 
 	/* set new MSS value if needed */
-	if (mss != priv->mss) {
+	if (mss != tx_q->mss) {
 		mss_desc = tx_q->dma_tx + tx_q->cur_tx;
 		priv->hw->desc->set_mss(mss_desc, mss);
-		priv->mss = mss;
+		tx_q->mss = mss;
 		tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, DMA_TX_SIZE);
 	}
 
@@ -4436,6 +4437,7 @@ static void stmmac_reset_queues_param(struct stmmac_priv *priv)
 
 		tx_q->cur_tx = 0;
 		tx_q->dirty_tx = 0;
+		tx_q->mss = 0;
 	}
 }
 
@@ -4481,11 +4483,6 @@ int stmmac_resume(struct device *dev)
 
 	stmmac_reset_queues_param(priv);
 
-	/* reset private mss value to force mss context settings at
-	 * next tso xmit (only used for gmac4).
-	 */
-	priv->mss = 0;
-
 	stmmac_clear_descriptors(priv);
 
 	stmmac_hw_setup(ndev, false);
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 2/7] net: stmmac: do not clear tx_skbuff entries in stmmac_xmit()/stmmac_tso_xmit()
  2018-02-19 17:11 [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Niklas Cassel
  2018-02-19 17:11 ` [PATCH net-next 1/7] net: stmmac: set MSS for each tx DMA channel Niklas Cassel
@ 2018-02-19 17:11 ` Niklas Cassel
  2018-02-19 17:11 ` [PATCH net-next 3/7] net: stmmac: WARN if tx_skbuff entries are reused before cleared Niklas Cassel
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Niklas Cassel @ 2018-02-19 17:11 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue
  Cc: Jose.Abreu, vbhadram, Niklas Cassel, netdev, linux-kernel

tx_skbuff is initialized to NULL in init_dma_tx_desc_rings(), which is
called from ndo_open().

stmmac_tx_clean() frees any non-NULL skb, and sets the tx_skbuff
entry to NULL. Hence, there is no need to set skbuff entries to NULL
in stmmac_xmit()/stmmac_tso_xmit(), and doing so falsely gives the
reader the impression that it is needed.
Do not clear tx_skbuff entries in stmmac_xmit()/stmmac_tso_xmit().

Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index d38bf38f12f5..24afe7733cde 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2927,7 +2927,6 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
 
 		tx_q->tx_skbuff_dma[tx_q->cur_tx].buf = des;
 		tx_q->tx_skbuff_dma[tx_q->cur_tx].len = skb_frag_size(frag);
-		tx_q->tx_skbuff[tx_q->cur_tx] = NULL;
 		tx_q->tx_skbuff_dma[tx_q->cur_tx].map_as_page = true;
 	}
 
@@ -3102,8 +3101,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 		if (dma_mapping_error(priv->device, des))
 			goto dma_map_err; /* should reuse desc w/o issues */
 
-		tx_q->tx_skbuff[entry] = NULL;
-
 		tx_q->tx_skbuff_dma[entry].buf = des;
 		if (unlikely(priv->synopsys_id >= DWMAC_CORE_4_00))
 			desc->des0 = cpu_to_le32(des);
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 3/7] net: stmmac: WARN if tx_skbuff entries are reused before cleared
  2018-02-19 17:11 [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Niklas Cassel
  2018-02-19 17:11 ` [PATCH net-next 1/7] net: stmmac: set MSS for each tx DMA channel Niklas Cassel
  2018-02-19 17:11 ` [PATCH net-next 2/7] net: stmmac: do not clear tx_skbuff entries in stmmac_xmit()/stmmac_tso_xmit() Niklas Cassel
@ 2018-02-19 17:11 ` Niklas Cassel
  2018-02-19 17:11 ` [PATCH net-next 4/7] net: stmmac: rename dwmac4_tx_queue_routing() to match reality Niklas Cassel
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Niklas Cassel @ 2018-02-19 17:11 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue
  Cc: Jose.Abreu, vbhadram, Niklas Cassel, netdev, linux-kernel

The current code assumes that a tx_skbuff entry has been cleared
by stmmac_tx_clean() before stmmac_xmit()/stmmac_tso_xmit()
assigns a new skb to that entry. However, since we never check
the current value before overwriting it, it is theoretically
possible that a non-NULL value is overwritten.

Add WARN_ONs to verify that each entry in tx_skbuff is NULL
before it is assigned a new value.

Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 24afe7733cde..9881df126227 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2794,6 +2794,7 @@ static void stmmac_tso_allocator(struct stmmac_priv *priv, unsigned int des,
 
 	while (tmp_len > 0) {
 		tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, DMA_TX_SIZE);
+		WARN_ON(tx_q->tx_skbuff[tx_q->cur_tx]);
 		desc = tx_q->dma_tx + tx_q->cur_tx;
 
 		desc->des0 = cpu_to_le32(des + (total_len - tmp_len));
@@ -2878,6 +2879,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
 		priv->hw->desc->set_mss(mss_desc, mss);
 		tx_q->mss = mss;
 		tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, DMA_TX_SIZE);
+		WARN_ON(tx_q->tx_skbuff[tx_q->cur_tx]);
 	}
 
 	if (netif_msg_tx_queued(priv)) {
@@ -2888,6 +2890,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	first_entry = tx_q->cur_tx;
+	WARN_ON(tx_q->tx_skbuff[first_entry]);
 
 	desc = tx_q->dma_tx + first_entry;
 	first = desc;
@@ -3062,6 +3065,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	entry = tx_q->cur_tx;
 	first_entry = entry;
+	WARN_ON(tx_q->tx_skbuff[first_entry]);
 
 	csum_insertion = (skb->ip_summed == CHECKSUM_PARTIAL);
 
@@ -3090,6 +3094,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 		bool last_segment = (i == (nfrags - 1));
 
 		entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE);
+		WARN_ON(tx_q->tx_skbuff[entry]);
 
 		if (likely(priv->extend_desc))
 			desc = (struct dma_desc *)(tx_q->dma_etx + entry);
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 4/7] net: stmmac: rename dwmac4_tx_queue_routing() to match reality
  2018-02-19 17:11 [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Niklas Cassel
                   ` (2 preceding siblings ...)
  2018-02-19 17:11 ` [PATCH net-next 3/7] net: stmmac: WARN if tx_skbuff entries are reused before cleared Niklas Cassel
@ 2018-02-19 17:11 ` Niklas Cassel
  2018-02-19 17:11 ` [PATCH net-next 5/7] net: stmmac: call correct function in stmmac_mac_config_rx_queues_routing() Niklas Cassel
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Niklas Cassel @ 2018-02-19 17:11 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue
  Cc: Jose.Abreu, vbhadram, Niklas Cassel, netdev, linux-kernel

Looking at dwmac4_tx_queue_routing(), it is obvious that it
sets up rx queue routing.

Rename dwmac4_tx_queue_routing() to dwmac4_rx_queue_routing()
to better match reality.

Fixes: abe80fdc6ee6 ("net: stmmac: RX queue routing configuration")
Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index 63795ecafc8d..46b9ae20ff6c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -120,7 +120,7 @@ static void dwmac4_tx_queue_priority(struct mac_device_info *hw,
 	writel(value, ioaddr + base_register);
 }
 
-static void dwmac4_tx_queue_routing(struct mac_device_info *hw,
+static void dwmac4_rx_queue_routing(struct mac_device_info *hw,
 				    u8 packet, u32 queue)
 {
 	void __iomem *ioaddr = hw->pcsr;
@@ -713,7 +713,7 @@ static const struct stmmac_ops dwmac4_ops = {
 	.rx_queue_enable = dwmac4_rx_queue_enable,
 	.rx_queue_prio = dwmac4_rx_queue_priority,
 	.tx_queue_prio = dwmac4_tx_queue_priority,
-	.rx_queue_routing = dwmac4_tx_queue_routing,
+	.rx_queue_routing = dwmac4_rx_queue_routing,
 	.prog_mtl_rx_algorithms = dwmac4_prog_mtl_rx_algorithms,
 	.prog_mtl_tx_algorithms = dwmac4_prog_mtl_tx_algorithms,
 	.set_mtl_tx_queue_weight = dwmac4_set_mtl_tx_queue_weight,
@@ -744,7 +744,7 @@ static const struct stmmac_ops dwmac410_ops = {
 	.rx_queue_enable = dwmac4_rx_queue_enable,
 	.rx_queue_prio = dwmac4_rx_queue_priority,
 	.tx_queue_prio = dwmac4_tx_queue_priority,
-	.rx_queue_routing = dwmac4_tx_queue_routing,
+	.rx_queue_routing = dwmac4_rx_queue_routing,
 	.prog_mtl_rx_algorithms = dwmac4_prog_mtl_rx_algorithms,
 	.prog_mtl_tx_algorithms = dwmac4_prog_mtl_tx_algorithms,
 	.set_mtl_tx_queue_weight = dwmac4_set_mtl_tx_queue_weight,
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 5/7] net: stmmac: call correct function in stmmac_mac_config_rx_queues_routing()
  2018-02-19 17:11 [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Niklas Cassel
                   ` (3 preceding siblings ...)
  2018-02-19 17:11 ` [PATCH net-next 4/7] net: stmmac: rename dwmac4_tx_queue_routing() to match reality Niklas Cassel
@ 2018-02-19 17:11 ` Niklas Cassel
  2018-02-19 17:11 ` [PATCH net-next 6/7] net: stmmac: add error handling in stmmac_mtl_setup() Niklas Cassel
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Niklas Cassel @ 2018-02-19 17:11 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue
  Cc: Jose.Abreu, vbhadram, Niklas Cassel, netdev, linux-kernel

stmmac_mac_config_rx_queues_routing() incorrectly calls rx_queue_prio()
instead of rx_queue_routing().

This looks like a copy paste issue, since
stmmac_mac_config_rx_queues_prio() already calls rx_queue_prio(),
and both stmmac_mac_config_rx_queues_routing() and
stmmac_mac_config_rx_queues_prio() are very similar in structure.

Fixes: abe80fdc6ee6 ("net: stmmac: RX queue routing configuration")
Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 9881df126227..c8d86d77e03d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2432,7 +2432,7 @@ static void stmmac_mac_config_rx_queues_routing(struct stmmac_priv *priv)
 			continue;
 
 		packet = priv->plat->rx_queues_cfg[queue].pkt_route;
-		priv->hw->mac->rx_queue_prio(priv->hw, packet, queue);
+		priv->hw->mac->rx_queue_routing(priv->hw, packet, queue);
 	}
 }
 
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 6/7] net: stmmac: add error handling in stmmac_mtl_setup()
  2018-02-19 17:11 [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Niklas Cassel
                   ` (4 preceding siblings ...)
  2018-02-19 17:11 ` [PATCH net-next 5/7] net: stmmac: call correct function in stmmac_mac_config_rx_queues_routing() Niklas Cassel
@ 2018-02-19 17:11 ` Niklas Cassel
  2018-02-19 17:11 ` [PATCH net-next 7/7] net: stmmac: honor error code from stmmac_dt_phy() Niklas Cassel
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Niklas Cassel @ 2018-02-19 17:11 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue
  Cc: Jose.Abreu, vbhadram, Niklas Cassel, netdev, linux-kernel

The device tree binding for stmmac says:

- Multiple TX Queues parameters: below the list of all the parameters to
                                 configure the multiple TX queues:
        - snps,tx-queues-to-use: number of TX queues to be used in the driver
	[...]
        - For each TX queue
		[...]

However, if one specifies snps,tx-queues-to-use = 2,
but omits the queue subnodes, or defines just one queue subnode,
since the driver appears to initialize queues with sane default
values, we will get tx queue timeouts.

This is because the initialization code only initializes
as many queues as it finds subnodes. Potentially leaving
some queues uninitialized.

To avoid hard to debug issues, return an error if the number
of subnodes differ from snps,tx-queues-to-use/snps,rx-queues-to-use.

Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 29 ++++++++++++++++++----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 05f122b8424a..bcfac84cf6fb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -135,13 +135,14 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
  * stmmac_mtl_setup - parse DT parameters for multiple queues configuration
  * @pdev: platform device
  */
-static void stmmac_mtl_setup(struct platform_device *pdev,
-			     struct plat_stmmacenet_data *plat)
+static int stmmac_mtl_setup(struct platform_device *pdev,
+			    struct plat_stmmacenet_data *plat)
 {
 	struct device_node *q_node;
 	struct device_node *rx_node;
 	struct device_node *tx_node;
 	u8 queue = 0;
+	int ret = 0;
 
 	/* For backwards-compatibility with device trees that don't have any
 	 * snps,mtl-rx-config or snps,mtl-tx-config properties, we fall back
@@ -159,12 +160,12 @@ static void stmmac_mtl_setup(struct platform_device *pdev,
 
 	rx_node = of_parse_phandle(pdev->dev.of_node, "snps,mtl-rx-config", 0);
 	if (!rx_node)
-		return;
+		return ret;
 
 	tx_node = of_parse_phandle(pdev->dev.of_node, "snps,mtl-tx-config", 0);
 	if (!tx_node) {
 		of_node_put(rx_node);
-		return;
+		return ret;
 	}
 
 	/* Processing RX queues common config */
@@ -220,6 +221,11 @@ static void stmmac_mtl_setup(struct platform_device *pdev,
 
 		queue++;
 	}
+	if (queue != plat->rx_queues_to_use) {
+		ret = -EINVAL;
+		dev_err(&pdev->dev, "Not all RX queues were configured\n");
+		goto out;
+	}
 
 	/* Processing TX queues common config */
 	if (of_property_read_u32(tx_node, "snps,tx-queues-to-use",
@@ -281,10 +287,18 @@ static void stmmac_mtl_setup(struct platform_device *pdev,
 
 		queue++;
 	}
+	if (queue != plat->tx_queues_to_use) {
+		ret = -EINVAL;
+		dev_err(&pdev->dev, "Not all TX queues were configured\n");
+		goto out;
+	}
 
+out:
 	of_node_put(rx_node);
 	of_node_put(tx_node);
 	of_node_put(q_node);
+
+	return ret;
 }
 
 /**
@@ -376,6 +390,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 	struct device_node *np = pdev->dev.of_node;
 	struct plat_stmmacenet_data *plat;
 	struct stmmac_dma_cfg *dma_cfg;
+	int rc;
 
 	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
 	if (!plat)
@@ -499,7 +514,11 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 
 	plat->axi = stmmac_axi_setup(pdev);
 
-	stmmac_mtl_setup(pdev, plat);
+	rc = stmmac_mtl_setup(pdev, plat);
+	if (rc) {
+		stmmac_remove_config_dt(pdev, plat);
+		return ERR_PTR(rc);
+	}
 
 	/* clock setup */
 	plat->stmmac_clk = devm_clk_get(&pdev->dev,
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 7/7] net: stmmac: honor error code from stmmac_dt_phy()
  2018-02-19 17:11 [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Niklas Cassel
                   ` (5 preceding siblings ...)
  2018-02-19 17:11 ` [PATCH net-next 6/7] net: stmmac: add error handling in stmmac_mtl_setup() Niklas Cassel
@ 2018-02-19 17:11 ` Niklas Cassel
  2018-02-19 18:12 ` [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Jose Abreu
  2018-02-20 19:14 ` David Miller
  8 siblings, 0 replies; 11+ messages in thread
From: Niklas Cassel @ 2018-02-19 17:11 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue
  Cc: Jose.Abreu, vbhadram, Niklas Cassel, netdev, linux-kernel

Honor error code from stmmac_dt_phy() instead of always
returning -ENODEV.

No functional change intended.

Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index bcfac84cf6fb..ebd3e5ffa73c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -417,8 +417,9 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 		dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n");
 
 	/* To Configure PHY by using all device-tree supported properties */
-	if (stmmac_dt_phy(plat, np, &pdev->dev))
-		return ERR_PTR(-ENODEV);
+	rc = stmmac_dt_phy(plat, np, &pdev->dev);
+	if (rc)
+		return ERR_PTR(rc);
 
 	of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size);
 
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups
  2018-02-19 17:11 [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Niklas Cassel
                   ` (6 preceding siblings ...)
  2018-02-19 17:11 ` [PATCH net-next 7/7] net: stmmac: honor error code from stmmac_dt_phy() Niklas Cassel
@ 2018-02-19 18:12 ` Jose Abreu
  2018-02-20 19:14 ` David Miller
  8 siblings, 0 replies; 11+ messages in thread
From: Jose Abreu @ 2018-02-19 18:12 UTC (permalink / raw)
  To: Niklas Cassel, netdev; +Cc: Jose.Abreu, vbhadram, Niklas Cassel, linux-kernel

Hi Niklas,

On 19-02-2018 17:11, Niklas Cassel wrote:
> stmmac multi-queue fixes and cleanups
>
> Niklas Cassel (7):
>   net: stmmac: set MSS for each tx DMA channel
>   net: stmmac: do not clear tx_skbuff entries in
>     stmmac_xmit()/stmmac_tso_xmit()
>   net: stmmac: WARN if tx_skbuff entries are reused before cleared
>   net: stmmac: rename dwmac4_tx_queue_routing() to match reality
>   net: stmmac: call correct function in
>     stmmac_mac_config_rx_queues_routing()
>   net: stmmac: add error handling in stmmac_mtl_setup()
>   net: stmmac: honor error code from stmmac_dt_phy()

Thanks! The whole series is:

Reviewed-by: Jose Abreu <joabreu@synopsys.com>

Best Regards,
Jose Miguel Abreu

>
>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c  |  6 ++--
>  drivers/net/ethernet/stmicro/stmmac/stmmac.h       |  2 +-
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 23 +++++++--------
>  .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 34 +++++++++++++++++-----
>  4 files changed, 42 insertions(+), 23 deletions(-)
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 1/7] net: stmmac: set MSS for each tx DMA channel
  2018-02-19 17:11 ` [PATCH net-next 1/7] net: stmmac: set MSS for each tx DMA channel Niklas Cassel
@ 2018-02-20  7:31   ` Giuseppe CAVALLARO
  0 siblings, 0 replies; 11+ messages in thread
From: Giuseppe CAVALLARO @ 2018-02-20  7:31 UTC (permalink / raw)
  To: Niklas Cassel, Alexandre Torgue
  Cc: Jose.Abreu, vbhadram, Niklas Cassel, netdev, linux-kernel

Hi Niklas

I had a look at this series that looks ok for me.

Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

On 2/19/2018 6:11 PM, Niklas Cassel wrote:
> The DMA engine in dwmac4 can segment a large TSO packet to several
> smaller packets of (max) size Maximum Segment Size (MSS).
>
> The DMA engine fetches and saves the MSS via a context descriptor.
>
> This context decriptor has to be provided to each tx DMA channel.
> To ensure that this is done, move struct member mss from stmmac_priv
> to stmmac_tx_queue.
>
> stmmac_reset_queues_param() now also resets mss, together with other
> queue parameters, so reset of mss value can be removed from
> stmmac_resume().
>
> init_dma_tx_desc_rings() now also resets mss, together with other
> queue parameters, so reset of mss value can be removed from
> stmmac_open().
>
> This fixes tx queue timeouts for dwmac4, with DT property
> snps,tx-queues-to-use > 1, when running iperf3 with multiple threads.
>
> Fixes: ce736788e8a9 ("net: stmmac: adding multiple buffers for TX")
> Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
> ---
>   drivers/net/ethernet/stmicro/stmmac/stmmac.h      |  2 +-
>   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 +++++--------
>   2 files changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> index a916e13624eb..75161e1b7e55 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> @@ -58,6 +58,7 @@ struct stmmac_tx_queue {
>   	unsigned int dirty_tx;
>   	dma_addr_t dma_tx_phy;
>   	u32 tx_tail_addr;
> +	u32 mss;
>   };
>   
>   struct stmmac_rx_queue {
> @@ -138,7 +139,6 @@ struct stmmac_priv {
>   	spinlock_t ptp_lock;
>   	void __iomem *mmcaddr;
>   	void __iomem *ptpaddr;
> -	u32 mss;
>   
>   #ifdef CONFIG_DEBUG_FS
>   	struct dentry *dbgfs_dir;
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 7ad841434ec8..d38bf38f12f5 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -1355,6 +1355,7 @@ static int init_dma_tx_desc_rings(struct net_device *dev)
>   
>   		tx_q->dirty_tx = 0;
>   		tx_q->cur_tx = 0;
> +		tx_q->mss = 0;
>   
>   		netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue));
>   	}
> @@ -1946,6 +1947,7 @@ static void stmmac_tx_err(struct stmmac_priv *priv, u32 chan)
>   						     (i == DMA_TX_SIZE - 1));
>   	tx_q->dirty_tx = 0;
>   	tx_q->cur_tx = 0;
> +	tx_q->mss = 0;
>   	netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, chan));
>   	stmmac_start_tx_dma(priv, chan);
>   
> @@ -2632,7 +2634,6 @@ static int stmmac_open(struct net_device *dev)
>   
>   	priv->dma_buf_sz = STMMAC_ALIGN(buf_sz);
>   	priv->rx_copybreak = STMMAC_RX_COPYBREAK;
> -	priv->mss = 0;
>   
>   	ret = alloc_dma_desc_resources(priv);
>   	if (ret < 0) {
> @@ -2872,10 +2873,10 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
>   	mss = skb_shinfo(skb)->gso_size;
>   
>   	/* set new MSS value if needed */
> -	if (mss != priv->mss) {
> +	if (mss != tx_q->mss) {
>   		mss_desc = tx_q->dma_tx + tx_q->cur_tx;
>   		priv->hw->desc->set_mss(mss_desc, mss);
> -		priv->mss = mss;
> +		tx_q->mss = mss;
>   		tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, DMA_TX_SIZE);
>   	}
>   
> @@ -4436,6 +4437,7 @@ static void stmmac_reset_queues_param(struct stmmac_priv *priv)
>   
>   		tx_q->cur_tx = 0;
>   		tx_q->dirty_tx = 0;
> +		tx_q->mss = 0;
>   	}
>   }
>   
> @@ -4481,11 +4483,6 @@ int stmmac_resume(struct device *dev)
>   
>   	stmmac_reset_queues_param(priv);
>   
> -	/* reset private mss value to force mss context settings at
> -	 * next tso xmit (only used for gmac4).
> -	 */
> -	priv->mss = 0;
> -
>   	stmmac_clear_descriptors(priv);
>   
>   	stmmac_hw_setup(ndev, false);

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups
  2018-02-19 17:11 [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Niklas Cassel
                   ` (7 preceding siblings ...)
  2018-02-19 18:12 ` [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Jose Abreu
@ 2018-02-20 19:14 ` David Miller
  8 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2018-02-20 19:14 UTC (permalink / raw)
  To: niklas.cassel; +Cc: netdev, Jose.Abreu, vbhadram, niklass, linux-kernel

From: Niklas Cassel <niklas.cassel@axis.com>
Date: Mon, 19 Feb 2018 18:11:08 +0100

> stmmac multi-queue fixes and cleanups

Looks good to me, series applied, thanks Niklas.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-02-20 19:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-19 17:11 [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Niklas Cassel
2018-02-19 17:11 ` [PATCH net-next 1/7] net: stmmac: set MSS for each tx DMA channel Niklas Cassel
2018-02-20  7:31   ` Giuseppe CAVALLARO
2018-02-19 17:11 ` [PATCH net-next 2/7] net: stmmac: do not clear tx_skbuff entries in stmmac_xmit()/stmmac_tso_xmit() Niklas Cassel
2018-02-19 17:11 ` [PATCH net-next 3/7] net: stmmac: WARN if tx_skbuff entries are reused before cleared Niklas Cassel
2018-02-19 17:11 ` [PATCH net-next 4/7] net: stmmac: rename dwmac4_tx_queue_routing() to match reality Niklas Cassel
2018-02-19 17:11 ` [PATCH net-next 5/7] net: stmmac: call correct function in stmmac_mac_config_rx_queues_routing() Niklas Cassel
2018-02-19 17:11 ` [PATCH net-next 6/7] net: stmmac: add error handling in stmmac_mtl_setup() Niklas Cassel
2018-02-19 17:11 ` [PATCH net-next 7/7] net: stmmac: honor error code from stmmac_dt_phy() Niklas Cassel
2018-02-19 18:12 ` [PATCH net-next 0/7] stmmac multi-queue fixes and cleanups Jose Abreu
2018-02-20 19:14 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).