linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v3 0/9] net: stmmac: Fixes for -net
@ 2019-12-18 10:17 Jose Abreu
  2019-12-18 10:17 ` [PATCH net v3 1/9] net: stmmac: selftests: Needs to check the number of Multicast regs Jose Abreu
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Jose Abreu @ 2019-12-18 10:17 UTC (permalink / raw)
  To: netdev
  Cc: Joao Pinto, Jakub Kicinski, Jose Abreu, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin,
	linux-stm32, linux-arm-kernel, linux-kernel

Fixes for stmmac.

1) Fixes the filtering selftests (again) for cases when the number of multicast
filters are not enough.

2) Fixes SPH feature for MTU > default.

3) Fixes the behavior of accepting invalid MTU values.

4) Fixes FCS stripping for multi-descriptor packets.

5) Fixes the change of RX buffer size in XGMAC.

6) Fixes RX buffer size alignment.

7) Fixes the 16KB buffer alignment.

8) Fixes the enabling of 16KB buffer size feature.

9) Always arm the TX coalesce timer so that missed interrupts do not cause
a TX queue timeout.

---
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---

Jose Abreu (9):
  net: stmmac: selftests: Needs to check the number of Multicast regs
  net: stmmac: Determine earlier the size of RX buffer
  net: stmmac: Do not accept invalid MTU values
  net: stmmac: Only the last buffer has the FCS field
  net: stmmac: xgmac: Clear previous RX buffer size
  net: stmmac: RX buffer size must be 16 byte aligned
  net: stmmac: 16KB buffer must be 16 byte aligned
  net: stmmac: Enable 16KB buffer size
  net: stmmac: Always arm TX Timer at end of transmission start

 drivers/net/ethernet/stmicro/stmmac/common.h       |  5 +-
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h     |  2 +
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c |  3 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 53 +++++++++++++---------
 .../net/ethernet/stmicro/stmmac/stmmac_selftests.c |  4 ++
 5 files changed, 42 insertions(+), 25 deletions(-)

-- 
2.7.4


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

* [PATCH net v3 1/9] net: stmmac: selftests: Needs to check the number of Multicast regs
  2019-12-18 10:17 [PATCH net v3 0/9] net: stmmac: Fixes for -net Jose Abreu
@ 2019-12-18 10:17 ` Jose Abreu
  2019-12-18 10:17 ` [PATCH net v3 2/9] net: stmmac: Determine earlier the size of RX buffer Jose Abreu
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jose Abreu @ 2019-12-18 10:17 UTC (permalink / raw)
  To: netdev
  Cc: Joao Pinto, Jakub Kicinski, Jose Abreu, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin,
	linux-stm32, linux-arm-kernel, linux-kernel

When running the MC and UC filter tests we setup a multicast address
that its expected to be blocked. If the number of available multicast
registers is zero, driver will always pass the multicast packets which
will fail the test.

Check if available multicast addresses is enough before running the
tests.

Fixes: 091810dbded9 ("net: stmmac: Introduce selftests support")
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>

---
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
index f3d8b9336b8e..13227909287c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
@@ -624,6 +624,8 @@ static int stmmac_test_mcfilt(struct stmmac_priv *priv)
 		return -EOPNOTSUPP;
 	if (netdev_uc_count(priv->dev) >= priv->hw->unicast_filter_entries)
 		return -EOPNOTSUPP;
+	if (netdev_mc_count(priv->dev) >= priv->hw->multicast_filter_bins)
+		return -EOPNOTSUPP;
 
 	while (--tries) {
 		/* We only need to check the mc_addr for collisions */
@@ -666,6 +668,8 @@ static int stmmac_test_ucfilt(struct stmmac_priv *priv)
 
 	if (stmmac_filter_check(priv))
 		return -EOPNOTSUPP;
+	if (netdev_uc_count(priv->dev) >= priv->hw->unicast_filter_entries)
+		return -EOPNOTSUPP;
 	if (netdev_mc_count(priv->dev) >= priv->hw->multicast_filter_bins)
 		return -EOPNOTSUPP;
 
-- 
2.7.4


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

* [PATCH net v3 2/9] net: stmmac: Determine earlier the size of RX buffer
  2019-12-18 10:17 [PATCH net v3 0/9] net: stmmac: Fixes for -net Jose Abreu
  2019-12-18 10:17 ` [PATCH net v3 1/9] net: stmmac: selftests: Needs to check the number of Multicast regs Jose Abreu
@ 2019-12-18 10:17 ` Jose Abreu
  2019-12-18 10:17 ` [PATCH net v3 3/9] net: stmmac: Do not accept invalid MTU values Jose Abreu
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jose Abreu @ 2019-12-18 10:17 UTC (permalink / raw)
  To: netdev
  Cc: Joao Pinto, Jakub Kicinski, Jose Abreu, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin,
	linux-stm32, linux-arm-kernel, linux-kernel

Split Header feature needs to know the size of RX buffer but current
code is determining it too late. Fix this by moving the RX buffer
computation to earlier stage.

Changes from v2:
- Do not try to align already aligned buffer size

Fixes: 67afd6d1cfdf ("net: stmmac: Add Split Header support and enable it in XGMAC cores")
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>

---
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 24 +++++++++++------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index bbc65bd332a8..eccbf5daf9ed 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1293,19 +1293,9 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags)
 	struct stmmac_priv *priv = netdev_priv(dev);
 	u32 rx_count = priv->plat->rx_queues_to_use;
 	int ret = -ENOMEM;
-	int bfsize = 0;
 	int queue;
 	int i;
 
-	bfsize = stmmac_set_16kib_bfsize(priv, dev->mtu);
-	if (bfsize < 0)
-		bfsize = 0;
-
-	if (bfsize < BUF_SIZE_16KiB)
-		bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_buf_sz);
-
-	priv->dma_buf_sz = bfsize;
-
 	/* RX INITIALIZATION */
 	netif_dbg(priv, probe, priv->dev,
 		  "SKB addresses:\nskb\t\tskb data\tdma data\n");
@@ -1347,8 +1337,6 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags)
 		}
 	}
 
-	buf_sz = bfsize;
-
 	return 0;
 
 err_init_rx_buffers:
@@ -2658,6 +2646,7 @@ static void stmmac_hw_teardown(struct net_device *dev)
 static int stmmac_open(struct net_device *dev)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
+	int bfsize = 0;
 	u32 chan;
 	int ret;
 
@@ -2677,7 +2666,16 @@ static int stmmac_open(struct net_device *dev)
 	memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats));
 	priv->xstats.threshold = tc;
 
-	priv->dma_buf_sz = STMMAC_ALIGN(buf_sz);
+	bfsize = stmmac_set_16kib_bfsize(priv, dev->mtu);
+	if (bfsize < 0)
+		bfsize = 0;
+
+	if (bfsize < BUF_SIZE_16KiB)
+		bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_buf_sz);
+
+	priv->dma_buf_sz = bfsize;
+	buf_sz = bfsize;
+
 	priv->rx_copybreak = STMMAC_RX_COPYBREAK;
 
 	ret = alloc_dma_desc_resources(priv);
-- 
2.7.4


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

* [PATCH net v3 3/9] net: stmmac: Do not accept invalid MTU values
  2019-12-18 10:17 [PATCH net v3 0/9] net: stmmac: Fixes for -net Jose Abreu
  2019-12-18 10:17 ` [PATCH net v3 1/9] net: stmmac: selftests: Needs to check the number of Multicast regs Jose Abreu
  2019-12-18 10:17 ` [PATCH net v3 2/9] net: stmmac: Determine earlier the size of RX buffer Jose Abreu
@ 2019-12-18 10:17 ` Jose Abreu
  2019-12-18 10:17 ` [PATCH net v3 4/9] net: stmmac: Only the last buffer has the FCS field Jose Abreu
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jose Abreu @ 2019-12-18 10:17 UTC (permalink / raw)
  To: netdev
  Cc: Joao Pinto, Jakub Kicinski, Jose Abreu, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin,
	linux-stm32, linux-arm-kernel, linux-kernel

The maximum MTU value is determined by the maximum size of TX FIFO so
that a full packet can fit in the FIFO. Add a check for this in the MTU
change callback.

Also check if provided and rounded MTU does not passes the maximum limit
of 16K.

Changes from v2:
- Align MTU before checking if its valid

Fixes: 7ac6653a085b ("stmmac: Move the STMicroelectronics driver")
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>

---
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index eccbf5daf9ed..8b7861909ef9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3827,12 +3827,24 @@ static void stmmac_set_rx_mode(struct net_device *dev)
 static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
+	int txfifosz = priv->plat->tx_fifo_size;
+
+	if (txfifosz == 0)
+		txfifosz = priv->dma_cap.tx_fifo_size;
+
+	txfifosz /= priv->plat->tx_queues_to_use;
 
 	if (netif_running(dev)) {
 		netdev_err(priv->dev, "must be stopped to change its MTU\n");
 		return -EBUSY;
 	}
 
+	new_mtu = STMMAC_ALIGN(new_mtu);
+
+	/* If condition true, FIFO is too small or MTU too large */
+	if ((txfifosz < new_mtu) || (new_mtu > BUF_SIZE_16KiB))
+		return -EINVAL;
+
 	dev->mtu = new_mtu;
 
 	netdev_update_features(dev);
-- 
2.7.4


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

* [PATCH net v3 4/9] net: stmmac: Only the last buffer has the FCS field
  2019-12-18 10:17 [PATCH net v3 0/9] net: stmmac: Fixes for -net Jose Abreu
                   ` (2 preceding siblings ...)
  2019-12-18 10:17 ` [PATCH net v3 3/9] net: stmmac: Do not accept invalid MTU values Jose Abreu
@ 2019-12-18 10:17 ` Jose Abreu
  2019-12-18 10:17 ` [PATCH net v3 5/9] net: stmmac: xgmac: Clear previous RX buffer size Jose Abreu
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jose Abreu @ 2019-12-18 10:17 UTC (permalink / raw)
  To: netdev
  Cc: Joao Pinto, Jakub Kicinski, Jose Abreu, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin,
	linux-stm32, linux-arm-kernel, linux-kernel

Only the last received buffer contains the FCS field. Check for end of
packet before trying to strip the FCS field.

Fixes: 88ebe2cf7f3f ("net: stmmac: Rework stmmac_rx()")
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>

---
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 8b7861909ef9..acb14a96243e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3644,8 +3644,9 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
 		 * feature is always disabled and packets need to be
 		 * stripped manually.
 		 */
-		if (unlikely(priv->synopsys_id >= DWMAC_CORE_4_00) ||
-		    unlikely(status != llc_snap)) {
+		if (likely(!(status & rx_not_ls)) &&
+		    (likely(priv->synopsys_id >= DWMAC_CORE_4_00) ||
+		     unlikely(status != llc_snap))) {
 			if (buf2_len)
 				buf2_len -= ETH_FCS_LEN;
 			else
-- 
2.7.4


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

* [PATCH net v3 5/9] net: stmmac: xgmac: Clear previous RX buffer size
  2019-12-18 10:17 [PATCH net v3 0/9] net: stmmac: Fixes for -net Jose Abreu
                   ` (3 preceding siblings ...)
  2019-12-18 10:17 ` [PATCH net v3 4/9] net: stmmac: Only the last buffer has the FCS field Jose Abreu
@ 2019-12-18 10:17 ` Jose Abreu
  2019-12-18 10:17 ` [PATCH net v3 6/9] net: stmmac: RX buffer size must be 16 byte aligned Jose Abreu
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jose Abreu @ 2019-12-18 10:17 UTC (permalink / raw)
  To: netdev
  Cc: Joao Pinto, Jakub Kicinski, Jose Abreu, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin,
	linux-stm32, linux-arm-kernel, linux-kernel

When switching between buffer sizes we need to clear the previous value.

Fixes: d6ddfacd95c7 ("net: stmmac: Add DMA related callbacks for XGMAC2")
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>

---
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h     | 2 ++
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
index 3b6e559aa0b9..ef8a07c68ca7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
@@ -343,6 +343,8 @@
 #define XGMAC_DMA_CH_RX_CONTROL(x)	(0x00003108 + (0x80 * (x)))
 #define XGMAC_RxPBL			GENMASK(21, 16)
 #define XGMAC_RxPBL_SHIFT		16
+#define XGMAC_RBSZ			GENMASK(14, 1)
+#define XGMAC_RBSZ_SHIFT		1
 #define XGMAC_RXST			BIT(0)
 #define XGMAC_DMA_CH_TxDESC_HADDR(x)	(0x00003110 + (0x80 * (x)))
 #define XGMAC_DMA_CH_TxDESC_LADDR(x)	(0x00003114 + (0x80 * (x)))
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
index 22a7f0cc1b90..f3f08ccc379b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
@@ -482,7 +482,8 @@ static void dwxgmac2_set_bfsize(void __iomem *ioaddr, int bfsize, u32 chan)
 	u32 value;
 
 	value = readl(ioaddr + XGMAC_DMA_CH_RX_CONTROL(chan));
-	value |= bfsize << 1;
+	value &= ~XGMAC_RBSZ;
+	value |= bfsize << XGMAC_RBSZ_SHIFT;
 	writel(value, ioaddr + XGMAC_DMA_CH_RX_CONTROL(chan));
 }
 
-- 
2.7.4


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

* [PATCH net v3 6/9] net: stmmac: RX buffer size must be 16 byte aligned
  2019-12-18 10:17 [PATCH net v3 0/9] net: stmmac: Fixes for -net Jose Abreu
                   ` (4 preceding siblings ...)
  2019-12-18 10:17 ` [PATCH net v3 5/9] net: stmmac: xgmac: Clear previous RX buffer size Jose Abreu
@ 2019-12-18 10:17 ` Jose Abreu
  2019-12-18 10:17 ` [PATCH net v3 7/9] net: stmmac: 16KB buffer " Jose Abreu
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jose Abreu @ 2019-12-18 10:17 UTC (permalink / raw)
  To: netdev
  Cc: Joao Pinto, Jakub Kicinski, Jose Abreu, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin,
	linux-stm32, linux-arm-kernel, linux-kernel

We need to align the RX buffer size to at least 16 byte so that IP
doesn't mis-behave. This is required by HW.

Changes from v2:
- Align UP and not DOWN (David)

Fixes: 7ac6653a085b ("stmmac: Move the STMicroelectronics driver")
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>

---
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 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 acb14a96243e..f507a9bee15b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -46,7 +46,7 @@
 #include "dwxgmac2.h"
 #include "hwif.h"
 
-#define	STMMAC_ALIGN(x)		__ALIGN_KERNEL(x, SMP_CACHE_BYTES)
+#define	STMMAC_ALIGN(x)		ALIGN(ALIGN(x, SMP_CACHE_BYTES), 16)
 #define	TSO_MAX_BUFF_SIZE	(SZ_16K - 1)
 
 /* Module parameters */
-- 
2.7.4


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

* [PATCH net v3 7/9] net: stmmac: 16KB buffer must be 16 byte aligned
  2019-12-18 10:17 [PATCH net v3 0/9] net: stmmac: Fixes for -net Jose Abreu
                   ` (5 preceding siblings ...)
  2019-12-18 10:17 ` [PATCH net v3 6/9] net: stmmac: RX buffer size must be 16 byte aligned Jose Abreu
@ 2019-12-18 10:17 ` Jose Abreu
  2019-12-18 10:17 ` [PATCH net v3 8/9] net: stmmac: Enable 16KB buffer size Jose Abreu
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jose Abreu @ 2019-12-18 10:17 UTC (permalink / raw)
  To: netdev
  Cc: Joao Pinto, Jakub Kicinski, Jose Abreu, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin,
	linux-stm32, linux-arm-kernel, linux-kernel

The 16KB RX Buffer must also be 16 byte aligned. Fix it.

Fixes: 7ac6653a085b ("stmmac: Move the STMicroelectronics driver")
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>

---
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/stmicro/stmmac/common.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index b210e987a1db..94f94686cf7d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -365,9 +365,8 @@ struct dma_features {
 	unsigned int arpoffsel;
 };
 
-/* GMAC TX FIFO is 8K, Rx FIFO is 16K */
-#define BUF_SIZE_16KiB 16384
-/* RX Buffer size must be < 8191 and multiple of 4/8/16 bytes */
+/* RX Buffer size must be multiple of 4/8/16 bytes */
+#define BUF_SIZE_16KiB 16368
 #define BUF_SIZE_8KiB 8188
 #define BUF_SIZE_4KiB 4096
 #define BUF_SIZE_2KiB 2048
-- 
2.7.4


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

* [PATCH net v3 8/9] net: stmmac: Enable 16KB buffer size
  2019-12-18 10:17 [PATCH net v3 0/9] net: stmmac: Fixes for -net Jose Abreu
                   ` (6 preceding siblings ...)
  2019-12-18 10:17 ` [PATCH net v3 7/9] net: stmmac: 16KB buffer " Jose Abreu
@ 2019-12-18 10:17 ` Jose Abreu
  2019-12-18 10:17 ` [PATCH net v3 9/9] net: stmmac: Always arm TX Timer at end of transmission start Jose Abreu
  2019-12-18 20:06 ` [PATCH net v3 0/9] net: stmmac: Fixes for -net David Miller
  9 siblings, 0 replies; 11+ messages in thread
From: Jose Abreu @ 2019-12-18 10:17 UTC (permalink / raw)
  To: netdev
  Cc: Joao Pinto, Jakub Kicinski, Jose Abreu, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin,
	linux-stm32, linux-arm-kernel, linux-kernel

XGMAC supports maximum MTU that can go to 16KB. Lets add this check in
the calculation of RX buffer size.

Fixes: 7ac6653a085b ("stmmac: Move the STMicroelectronics driver")
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>

---
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f507a9bee15b..1cb466dd5b3f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1109,7 +1109,9 @@ static int stmmac_set_bfsize(int mtu, int bufsize)
 {
 	int ret = bufsize;
 
-	if (mtu >= BUF_SIZE_4KiB)
+	if (mtu >= BUF_SIZE_8KiB)
+		ret = BUF_SIZE_16KiB;
+	else if (mtu >= BUF_SIZE_4KiB)
 		ret = BUF_SIZE_8KiB;
 	else if (mtu >= BUF_SIZE_2KiB)
 		ret = BUF_SIZE_4KiB;
-- 
2.7.4


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

* [PATCH net v3 9/9] net: stmmac: Always arm TX Timer at end of transmission start
  2019-12-18 10:17 [PATCH net v3 0/9] net: stmmac: Fixes for -net Jose Abreu
                   ` (7 preceding siblings ...)
  2019-12-18 10:17 ` [PATCH net v3 8/9] net: stmmac: Enable 16KB buffer size Jose Abreu
@ 2019-12-18 10:17 ` Jose Abreu
  2019-12-18 20:06 ` [PATCH net v3 0/9] net: stmmac: Fixes for -net David Miller
  9 siblings, 0 replies; 11+ messages in thread
From: Jose Abreu @ 2019-12-18 10:17 UTC (permalink / raw)
  To: netdev
  Cc: Joao Pinto, Jakub Kicinski, Jose Abreu, Giuseppe Cavallaro,
	Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin,
	linux-stm32, linux-arm-kernel, linux-kernel

If TX Coalesce timer is enabled we should always arm it, otherwise we
may hit the case where an interrupt is missed and the TX Queue will
timeout.

Arming the timer does not necessarly mean it will run the tx_clean()
because this function is wrapped around NAPI launcher.

Fixes: 9125cdd1be11 ("stmmac: add the initial tx coalesce schema")
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>

---
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Jose Abreu <joabreu@synopsys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 1cb466dd5b3f..6f51a265459d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3053,8 +3053,6 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
 		tx_q->tx_count_frames = 0;
 		stmmac_set_tx_ic(priv, desc);
 		priv->xstats.tx_set_ic_bit++;
-	} else {
-		stmmac_tx_timer_arm(priv, queue);
 	}
 
 	/* We've used all descriptors we need for this skb, however,
@@ -3125,6 +3123,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc));
 	stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue);
+	stmmac_tx_timer_arm(priv, queue);
 
 	return NETDEV_TX_OK;
 
@@ -3276,8 +3275,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 		tx_q->tx_count_frames = 0;
 		stmmac_set_tx_ic(priv, desc);
 		priv->xstats.tx_set_ic_bit++;
-	} else {
-		stmmac_tx_timer_arm(priv, queue);
 	}
 
 	/* We've used all descriptors we need for this skb, however,
@@ -3366,6 +3363,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc));
 	stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue);
+	stmmac_tx_timer_arm(priv, queue);
 
 	return NETDEV_TX_OK;
 
-- 
2.7.4


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

* Re: [PATCH net v3 0/9] net: stmmac: Fixes for -net
  2019-12-18 10:17 [PATCH net v3 0/9] net: stmmac: Fixes for -net Jose Abreu
                   ` (8 preceding siblings ...)
  2019-12-18 10:17 ` [PATCH net v3 9/9] net: stmmac: Always arm TX Timer at end of transmission start Jose Abreu
@ 2019-12-18 20:06 ` David Miller
  9 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2019-12-18 20:06 UTC (permalink / raw)
  To: Jose.Abreu
  Cc: netdev, Joao.Pinto, jakub.kicinski, peppe.cavallaro,
	alexandre.torgue, mcoquelin.stm32, linux-stm32, linux-arm-kernel,
	linux-kernel

From: Jose Abreu <Jose.Abreu@synopsys.com>
Date: Wed, 18 Dec 2019 11:17:34 +0100

> Fixes for stmmac.

Series applied.

But realistically I doubt you'll ever find a configuration where
SMP_CACHE_BYTES is less than 16 (seriously, it is so non-sensible to
build a cpu like that).  So you could have done something like:

#if SMP_CACHE_BYTES < 16
#error SMP_CACHE_BYTES too small
#endif

and then add the funky double alignment code if that ever triggered.

But again it never will.

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

end of thread, other threads:[~2019-12-18 20:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18 10:17 [PATCH net v3 0/9] net: stmmac: Fixes for -net Jose Abreu
2019-12-18 10:17 ` [PATCH net v3 1/9] net: stmmac: selftests: Needs to check the number of Multicast regs Jose Abreu
2019-12-18 10:17 ` [PATCH net v3 2/9] net: stmmac: Determine earlier the size of RX buffer Jose Abreu
2019-12-18 10:17 ` [PATCH net v3 3/9] net: stmmac: Do not accept invalid MTU values Jose Abreu
2019-12-18 10:17 ` [PATCH net v3 4/9] net: stmmac: Only the last buffer has the FCS field Jose Abreu
2019-12-18 10:17 ` [PATCH net v3 5/9] net: stmmac: xgmac: Clear previous RX buffer size Jose Abreu
2019-12-18 10:17 ` [PATCH net v3 6/9] net: stmmac: RX buffer size must be 16 byte aligned Jose Abreu
2019-12-18 10:17 ` [PATCH net v3 7/9] net: stmmac: 16KB buffer " Jose Abreu
2019-12-18 10:17 ` [PATCH net v3 8/9] net: stmmac: Enable 16KB buffer size Jose Abreu
2019-12-18 10:17 ` [PATCH net v3 9/9] net: stmmac: Always arm TX Timer at end of transmission start Jose Abreu
2019-12-18 20:06 ` [PATCH net v3 0/9] net: stmmac: Fixes for -net 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).