All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH (net.git) 2/6] stmmac: fix and better tune the default buffer sizes
  2014-02-25  9:58 [PATCH (net.git) 1/6] stmmac: disable at run-time the EEE if not supported Giuseppe Cavallaro
@ 2014-02-25  9:58 ` Giuseppe Cavallaro
  0 siblings, 0 replies; 10+ messages in thread
From: Giuseppe Cavallaro @ 2014-02-25  9:58 UTC (permalink / raw
  To: netdev; +Cc: Giuseppe Cavallaro

This patch is to fix and tune the default buffer sizes.
It reduces the default bufsize used by the driver from
2048 to 1518 (taking into account the extra 4 bytes in case of VLAN).

Patch has been tested on both ARM and SH4 platform based.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index dc89dc3..a50c8fc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -92,8 +92,12 @@ static int tc = TC_DEFAULT;
 module_param(tc, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(tc, "DMA threshold control value");
 
-#define DMA_BUFFER_SIZE	BUF_SIZE_4KiB
-static int buf_sz = DMA_BUFFER_SIZE;
+#ifdef STMMAC_VLAN_TAG_USED
+#define	DEFAULT_BUFSIZE	(VLAN_ETH_FRAME_LEN + ETH_FCS_LEN)
+#else
+#define	DEFAULT_BUFSIZE	(ETH_FRAME_LEN + ETH_FCS_LEN)
+#endif
+static int buf_sz = DEFAULT_BUFSIZE;
 module_param(buf_sz, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(buf_sz, "DMA buffer size");
 
@@ -136,8 +140,8 @@ static void stmmac_verify_args(void)
 		dma_rxsize = DMA_RX_SIZE;
 	if (unlikely(dma_txsize < 0))
 		dma_txsize = DMA_TX_SIZE;
-	if (unlikely((buf_sz < DMA_BUFFER_SIZE) || (buf_sz > BUF_SIZE_16KiB)))
-		buf_sz = DMA_BUFFER_SIZE;
+	if (unlikely((buf_sz < DEFAULT_BUFSIZE) || (buf_sz > BUF_SIZE_16KiB)))
+		buf_sz = DEFAULT_BUFSIZE;
 	if (unlikely(flow_ctrl > 1))
 		flow_ctrl = FLOW_AUTO;
 	else if (likely(flow_ctrl < 0))
@@ -901,10 +905,10 @@ static int stmmac_set_bfsize(int mtu, int bufsize)
 		ret = BUF_SIZE_8KiB;
 	else if (mtu >= BUF_SIZE_2KiB)
 		ret = BUF_SIZE_4KiB;
-	else if (mtu >= DMA_BUFFER_SIZE)
+	else if (mtu > DEFAULT_BUFSIZE)
 		ret = BUF_SIZE_2KiB;
 	else
-		ret = DMA_BUFFER_SIZE;
+		ret = DEFAULT_BUFSIZE;
 
 	return ret;
 }
-- 
1.7.4.4

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

* [PATCH (net.git) 0/6] stmmac: fix EEE and chained mode
@ 2014-02-26  8:01 Giuseppe Cavallaro
  2014-02-26  8:01 ` [PATCH (net.git) 1/6 (v2)] stmmac: disable at run-time the EEE if not supported Giuseppe Cavallaro
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Giuseppe Cavallaro @ 2014-02-26  8:01 UTC (permalink / raw
  To: netdev; +Cc: Giuseppe Cavallaro

These are some patches to fix some problem in the driver.
For example the EEE that needs to be disabled if not supported
and the chain mode that is broken and the kernel panics.

Also there are two patches to fix some minor issues in the STi glue-logic.

Giuseppe Cavallaro (6):
  stmmac: disable at run-time the EEE if not supported
  stmmac: fix and better tune the default buffer sizes
  stmmac: dwmac-sti: fix broken STiD127 compatibility
  stmmac: dwmac-sti: remove useless tx_retime_srcs
  stmmac: remove useless check in the stmmac_tx_clean
  stmmac: fix chained mode

 drivers/net/ethernet/stmicro/stmmac/chain_mode.c   |    2 +-
 drivers/net/ethernet/stmicro/stmmac/common.h       |   20 +---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c    |    8 --
 drivers/net/ethernet/stmicro/stmmac/ring_mode.c    |    9 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |  104 ++++++++++---------
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |    2 +-
 6 files changed, 67 insertions(+), 78 deletions(-)

-- 
1.7.4.4

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

* [PATCH (net.git) 1/6 (v2)] stmmac: disable at run-time the EEE if not supported
  2014-02-26  8:01 [PATCH (net.git) 0/6] stmmac: fix EEE and chained mode Giuseppe Cavallaro
@ 2014-02-26  8:01 ` Giuseppe Cavallaro
  2014-02-26  8:01 ` [PATCH (net.git) 2/6] stmmac: fix and better tune the default buffer sizes Giuseppe Cavallaro
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Giuseppe Cavallaro @ 2014-02-26  8:01 UTC (permalink / raw
  To: netdev; +Cc: Giuseppe Cavallaro

This patch is to disable the EEE (so HW and timers)
for example when the phy communicates that the EEE
can be supported anymore.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   23 +++++++++++++++++---
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 078ad0e..b418f94 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -286,10 +286,25 @@ bool stmmac_eee_init(struct stmmac_priv *priv)
 
 	/* MAC core supports the EEE feature. */
 	if (priv->dma_cap.eee) {
+		int tx_lpi_timer = priv->tx_lpi_timer;
+
 		/* Check if the PHY supports EEE */
-		if (phy_init_eee(priv->phydev, 1))
+		if (phy_init_eee(priv->phydev, 1)) {
+			/* To manage at run-time if the EEE cannot be supported
+			 * anymore (for example because the lp caps have been
+			 * changed).
+			 * In that case the driver disable own timers.
+			 */
+			if (priv->eee_active) {
+				pr_debug("stmmac: disable EEE\n");
+				del_timer_sync(&priv->eee_ctrl_timer);
+				priv->hw->mac->set_eee_timer(priv->ioaddr, 0,
+							     tx_lpi_timer);
+			}
+			priv->eee_active = 0;
 			goto out;
-
+		}
+		/* Activate the EEE and start timers */
 		if (!priv->eee_active) {
 			priv->eee_active = 1;
 			init_timer(&priv->eee_ctrl_timer);
@@ -300,13 +315,13 @@ bool stmmac_eee_init(struct stmmac_priv *priv)
 
 			priv->hw->mac->set_eee_timer(priv->ioaddr,
 						     STMMAC_DEFAULT_LIT_LS,
-						     priv->tx_lpi_timer);
+						     tx_lpi_timer);
 		} else
 			/* Set HW EEE according to the speed */
 			priv->hw->mac->set_eee_pls(priv->ioaddr,
 						   priv->phydev->link);
 
-		pr_info("stmmac: Energy-Efficient Ethernet initialized\n");
+		pr_debug("stmmac: Energy-Efficient Ethernet initialized\n");
 
 		ret = true;
 	}
-- 
1.7.4.4

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

* [PATCH (net.git) 2/6] stmmac: fix and better tune the default buffer sizes
  2014-02-26  8:01 [PATCH (net.git) 0/6] stmmac: fix EEE and chained mode Giuseppe Cavallaro
  2014-02-26  8:01 ` [PATCH (net.git) 1/6 (v2)] stmmac: disable at run-time the EEE if not supported Giuseppe Cavallaro
@ 2014-02-26  8:01 ` Giuseppe Cavallaro
  2014-02-26  8:01 ` [PATCH (net.git) 3/6] stmmac: dwmac-sti: fix broken STiD127 compatibility Giuseppe Cavallaro
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Giuseppe Cavallaro @ 2014-02-26  8:01 UTC (permalink / raw
  To: netdev; +Cc: Giuseppe Cavallaro

This patch is to fix and tune the default buffer sizes.
It reduces the default bufsize used by the driver from
2048 to 1518 (taking into account the extra 4 bytes in case of VLAN).

Patch has been tested on both ARM and SH4 platform based.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index b418f94..40d811d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -92,8 +92,12 @@ static int tc = TC_DEFAULT;
 module_param(tc, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(tc, "DMA threshold control value");
 
-#define DMA_BUFFER_SIZE	BUF_SIZE_4KiB
-static int buf_sz = DMA_BUFFER_SIZE;
+#ifdef STMMAC_VLAN_TAG_USED
+#define	DEFAULT_BUFSIZE	(VLAN_ETH_FRAME_LEN + ETH_FCS_LEN)
+#else
+#define	DEFAULT_BUFSIZE	(ETH_FRAME_LEN + ETH_FCS_LEN)
+#endif
+static int buf_sz = DEFAULT_BUFSIZE;
 module_param(buf_sz, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(buf_sz, "DMA buffer size");
 
@@ -136,8 +140,8 @@ static void stmmac_verify_args(void)
 		dma_rxsize = DMA_RX_SIZE;
 	if (unlikely(dma_txsize < 0))
 		dma_txsize = DMA_TX_SIZE;
-	if (unlikely((buf_sz < DMA_BUFFER_SIZE) || (buf_sz > BUF_SIZE_16KiB)))
-		buf_sz = DMA_BUFFER_SIZE;
+	if (unlikely((buf_sz < DEFAULT_BUFSIZE) || (buf_sz > BUF_SIZE_16KiB)))
+		buf_sz = DEFAULT_BUFSIZE;
 	if (unlikely(flow_ctrl > 1))
 		flow_ctrl = FLOW_AUTO;
 	else if (likely(flow_ctrl < 0))
@@ -901,10 +905,10 @@ static int stmmac_set_bfsize(int mtu, int bufsize)
 		ret = BUF_SIZE_8KiB;
 	else if (mtu >= BUF_SIZE_2KiB)
 		ret = BUF_SIZE_4KiB;
-	else if (mtu >= DMA_BUFFER_SIZE)
+	else if (mtu > DEFAULT_BUFSIZE)
 		ret = BUF_SIZE_2KiB;
 	else
-		ret = DMA_BUFFER_SIZE;
+		ret = DEFAULT_BUFSIZE;
 
 	return ret;
 }
-- 
1.7.4.4

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

* [PATCH (net.git) 3/6] stmmac: dwmac-sti: fix broken STiD127 compatibility
  2014-02-26  8:01 [PATCH (net.git) 0/6] stmmac: fix EEE and chained mode Giuseppe Cavallaro
  2014-02-26  8:01 ` [PATCH (net.git) 1/6 (v2)] stmmac: disable at run-time the EEE if not supported Giuseppe Cavallaro
  2014-02-26  8:01 ` [PATCH (net.git) 2/6] stmmac: fix and better tune the default buffer sizes Giuseppe Cavallaro
@ 2014-02-26  8:01 ` Giuseppe Cavallaro
  2014-02-26  8:01 ` [PATCH (net.git) 4/6] stmmac: dwmac-sti: remove useless tx_retime_srcs Giuseppe Cavallaro
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Giuseppe Cavallaro @ 2014-02-26  8:01 UTC (permalink / raw
  To: netdev; +Cc: Giuseppe Cavallaro, Srinivas Kandagatla

This is to fix the compatibility to the STiD127 SoC.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Srinivas Kandagatla <srinivas.kandagatla@st.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index c61bc72b..8fb32a8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -36,7 +36,7 @@ static const struct of_device_id stmmac_dt_ids[] = {
 #ifdef CONFIG_DWMAC_STI
 	{ .compatible = "st,stih415-dwmac", .data = &sti_gmac_data},
 	{ .compatible = "st,stih416-dwmac", .data = &sti_gmac_data},
-	{ .compatible = "st,stih127-dwmac", .data = &sti_gmac_data},
+	{ .compatible = "st,stid127-dwmac", .data = &sti_gmac_data},
 #endif
 	/* SoC specific glue layers should come before generic bindings */
 	{ .compatible = "st,spear600-gmac"},
-- 
1.7.4.4

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

* [PATCH (net.git) 4/6] stmmac: dwmac-sti: remove useless tx_retime_srcs
  2014-02-26  8:01 [PATCH (net.git) 0/6] stmmac: fix EEE and chained mode Giuseppe Cavallaro
                   ` (2 preceding siblings ...)
  2014-02-26  8:01 ` [PATCH (net.git) 3/6] stmmac: dwmac-sti: fix broken STiD127 compatibility Giuseppe Cavallaro
@ 2014-02-26  8:01 ` Giuseppe Cavallaro
  2014-02-26  8:01 ` [PATCH (net.git) 5/6] stmmac: remove useless check in the stmmac_tx_clean Giuseppe Cavallaro
  2014-02-26  8:01 ` [PATCH (net.git) 6/6] stmmac: fix chained mode Giuseppe Cavallaro
  5 siblings, 0 replies; 10+ messages in thread
From: Giuseppe Cavallaro @ 2014-02-26  8:01 UTC (permalink / raw
  To: netdev; +Cc: Giuseppe Cavallaro, Srinivas Kandagatla

This is to remove the useless tx_retime_srcs definition.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Srinivas Kandagatla <srinivas.kandagatla@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index 552bbc1..e5b366e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -162,14 +162,6 @@ enum {
 	TX_RETIME_SRC_CLKGEN,
 };
 
-static const char *const tx_retime_srcs[] = {
-	[TX_RETIME_SRC_NA] = "",
-	[TX_RETIME_SRC_TXCLK] = "txclk",
-	[TX_RETIME_SRC_CLK_125] = "clk_125",
-	[TX_RETIME_SRC_PHYCLK] = "phyclk",
-	[TX_RETIME_SRC_CLKGEN] = "clkgen",
-};
-
 static u32 tx_retime_val[] = {
 	[TX_RETIME_SRC_TXCLK] = ETH_SEL_TXCLK_NOT_CLK125,
 	[TX_RETIME_SRC_CLK_125] = 0x0,
-- 
1.7.4.4

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

* [PATCH (net.git) 5/6] stmmac: remove useless check in the stmmac_tx_clean
  2014-02-26  8:01 [PATCH (net.git) 0/6] stmmac: fix EEE and chained mode Giuseppe Cavallaro
                   ` (3 preceding siblings ...)
  2014-02-26  8:01 ` [PATCH (net.git) 4/6] stmmac: dwmac-sti: remove useless tx_retime_srcs Giuseppe Cavallaro
@ 2014-02-26  8:01 ` Giuseppe Cavallaro
  2014-02-26 21:14   ` David Miller
  2014-02-26  8:01 ` [PATCH (net.git) 6/6] stmmac: fix chained mode Giuseppe Cavallaro
  5 siblings, 1 reply; 10+ messages in thread
From: Giuseppe Cavallaro @ 2014-02-26  8:01 UTC (permalink / raw
  To: netdev; +Cc: Giuseppe Cavallaro

There is an useless if condition that this patch is removing
when the driver cleans the tx resources.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 40d811d..6ce85c3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1321,12 +1321,9 @@ static void stmmac_tx_clean(struct stmmac_priv *priv)
 	if (unlikely(netif_queue_stopped(priv->dev) &&
 		     stmmac_tx_avail(priv) > STMMAC_TX_THRESH(priv))) {
 		netif_tx_lock(priv->dev);
-		if (netif_queue_stopped(priv->dev) &&
-		    stmmac_tx_avail(priv) > STMMAC_TX_THRESH(priv)) {
-			if (netif_msg_tx_done(priv))
-				pr_debug("%s: restart transmit\n", __func__);
-			netif_wake_queue(priv->dev);
-		}
+		if (netif_msg_tx_done(priv))
+			pr_debug("%s: restart transmit\n", __func__);
+		netif_wake_queue(priv->dev);
 		netif_tx_unlock(priv->dev);
 	}
 
-- 
1.7.4.4

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

* [PATCH (net.git) 6/6] stmmac: fix chained mode
  2014-02-26  8:01 [PATCH (net.git) 0/6] stmmac: fix EEE and chained mode Giuseppe Cavallaro
                   ` (4 preceding siblings ...)
  2014-02-26  8:01 ` [PATCH (net.git) 5/6] stmmac: remove useless check in the stmmac_tx_clean Giuseppe Cavallaro
@ 2014-02-26  8:01 ` Giuseppe Cavallaro
  5 siblings, 0 replies; 10+ messages in thread
From: Giuseppe Cavallaro @ 2014-02-26  8:01 UTC (permalink / raw
  To: netdev; +Cc: Giuseppe Cavallaro

This patch is to fix the chain mode that was broken
and generated a panic. This patch reviews the chain/ring
modes now shaing the same structure and taking care
about the pointers and callbacks.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/ethernet/stmicro/stmmac/chain_mode.c  |    2 +-
 drivers/net/ethernet/stmicro/stmmac/common.h      |   20 ++-----
 drivers/net/ethernet/stmicro/stmmac/ring_mode.c   |    9 ++--
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   56 +++++++++------------
 4 files changed, 34 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c
index 72d282b..c553f6b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c
+++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c
@@ -151,7 +151,7 @@ static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p)
 					  sizeof(struct dma_desc)));
 }
 
-const struct stmmac_chain_mode_ops chain_mode_ops = {
+const struct stmmac_mode_ops chain_mode_ops = {
 	.init = stmmac_init_dma_chain,
 	.is_jumbo_frm = stmmac_is_jumbo_frm,
 	.jumbo_frm = stmmac_jumbo_frm,
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 7834a39..74610f3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -419,20 +419,13 @@ struct mii_regs {
 	unsigned int data;	/* MII Data */
 };
 
-struct stmmac_ring_mode_ops {
-	unsigned int (*is_jumbo_frm) (int len, int ehn_desc);
-	unsigned int (*jumbo_frm) (void *priv, struct sk_buff *skb, int csum);
-	void (*refill_desc3) (void *priv, struct dma_desc *p);
-	void (*init_desc3) (struct dma_desc *p);
-	void (*clean_desc3) (void *priv, struct dma_desc *p);
-	int (*set_16kib_bfsize) (int mtu);
-};
-
-struct stmmac_chain_mode_ops {
+struct stmmac_mode_ops {
 	void (*init) (void *des, dma_addr_t phy_addr, unsigned int size,
 		      unsigned int extend_desc);
 	unsigned int (*is_jumbo_frm) (int len, int ehn_desc);
 	unsigned int (*jumbo_frm) (void *priv, struct sk_buff *skb, int csum);
+	int (*set_16kib_bfsize)(int mtu);
+	void (*init_desc3)(struct dma_desc *p);
 	void (*refill_desc3) (void *priv, struct dma_desc *p);
 	void (*clean_desc3) (void *priv, struct dma_desc *p);
 };
@@ -441,8 +434,7 @@ struct mac_device_info {
 	const struct stmmac_ops *mac;
 	const struct stmmac_desc_ops *desc;
 	const struct stmmac_dma_ops *dma;
-	const struct stmmac_ring_mode_ops *ring;
-	const struct stmmac_chain_mode_ops *chain;
+	const struct stmmac_mode_ops *mode;
 	const struct stmmac_hwtimestamp *ptp;
 	struct mii_regs mii;	/* MII register Addresses */
 	struct mac_link link;
@@ -460,7 +452,7 @@ void stmmac_get_mac_addr(void __iomem *ioaddr, unsigned char *addr,
 void stmmac_set_mac(void __iomem *ioaddr, bool enable);
 
 void dwmac_dma_flush_tx_fifo(void __iomem *ioaddr);
-extern const struct stmmac_ring_mode_ops ring_mode_ops;
-extern const struct stmmac_chain_mode_ops chain_mode_ops;
+extern const struct stmmac_mode_ops ring_mode_ops;
+extern const struct stmmac_mode_ops chain_mode_ops;
 
 #endif /* __COMMON_H__ */
diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
index a96c7c2..650a4be 100644
--- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
+++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
@@ -100,10 +100,9 @@ static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p)
 {
 	struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr;
 
-	if (unlikely(priv->plat->has_gmac))
-		/* Fill DES3 in case of RING mode */
-		if (priv->dma_buf_sz >= BUF_SIZE_8KiB)
-			p->des3 = p->des2 + BUF_SIZE_8KiB;
+	/* Fill DES3 in case of RING mode */
+	if (priv->dma_buf_sz >= BUF_SIZE_8KiB)
+		p->des3 = p->des2 + BUF_SIZE_8KiB;
 }
 
 /* In ring mode we need to fill the desc3 because it is used as buffer */
@@ -126,7 +125,7 @@ static int stmmac_set_16kib_bfsize(int mtu)
 	return ret;
 }
 
-const struct stmmac_ring_mode_ops ring_mode_ops = {
+const struct stmmac_mode_ops ring_mode_ops = {
 	.is_jumbo_frm = stmmac_is_jumbo_frm,
 	.jumbo_frm = stmmac_jumbo_frm,
 	.refill_desc3 = stmmac_refill_desc3,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 6ce85c3..4142aea 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -970,9 +970,9 @@ static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p,
 
 	p->des2 = priv->rx_skbuff_dma[i];
 
-	if ((priv->mode == STMMAC_RING_MODE) &&
+	if ((priv->hw->mode->init_desc3) &&
 	    (priv->dma_buf_sz == BUF_SIZE_16KiB))
-		priv->hw->ring->init_desc3(p);
+		priv->hw->mode->init_desc3(p);
 
 	return 0;
 }
@@ -1003,11 +1003,8 @@ static int init_dma_desc_rings(struct net_device *dev)
 	unsigned int bfsize = 0;
 	int ret = -ENOMEM;
 
-	/* Set the max buffer size according to the DESC mode
-	 * and the MTU. Note that RING mode allows 16KiB bsize.
-	 */
-	if (priv->mode == STMMAC_RING_MODE)
-		bfsize = priv->hw->ring->set_16kib_bfsize(dev->mtu);
+	if (priv->hw->mode->set_16kib_bfsize)
+		bfsize = priv->hw->mode->set_16kib_bfsize(dev->mtu);
 
 	if (bfsize < BUF_SIZE_16KiB)
 		bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_buf_sz);
@@ -1048,15 +1045,15 @@ static int init_dma_desc_rings(struct net_device *dev)
 	/* Setup the chained descriptor addresses */
 	if (priv->mode == STMMAC_CHAIN_MODE) {
 		if (priv->extend_desc) {
-			priv->hw->chain->init(priv->dma_erx, priv->dma_rx_phy,
-					      rxsize, 1);
-			priv->hw->chain->init(priv->dma_etx, priv->dma_tx_phy,
-					      txsize, 1);
+			priv->hw->mode->init(priv->dma_erx, priv->dma_rx_phy,
+					     rxsize, 1);
+			priv->hw->mode->init(priv->dma_etx, priv->dma_tx_phy,
+					     txsize, 1);
 		} else {
-			priv->hw->chain->init(priv->dma_rx, priv->dma_rx_phy,
-					      rxsize, 0);
-			priv->hw->chain->init(priv->dma_tx, priv->dma_tx_phy,
-					      txsize, 0);
+			priv->hw->mode->init(priv->dma_rx, priv->dma_rx_phy,
+					     rxsize, 0);
+			priv->hw->mode->init(priv->dma_tx, priv->dma_tx_phy,
+					     txsize, 0);
 		}
 	}
 
@@ -1307,7 +1304,7 @@ static void stmmac_tx_clean(struct stmmac_priv *priv)
 					 DMA_TO_DEVICE);
 			priv->tx_skbuff_dma[entry] = 0;
 		}
-		priv->hw->ring->clean_desc3(priv, p);
+		priv->hw->mode->clean_desc3(priv, p);
 
 		if (likely(skb != NULL)) {
 			dev_kfree_skb(skb);
@@ -1860,6 +1857,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 	int nfrags = skb_shinfo(skb)->nr_frags;
 	struct dma_desc *desc, *first;
 	unsigned int nopaged_len = skb_headlen(skb);
+	unsigned int enh_desc = priv->plat->enh_desc;
 
 	if (unlikely(stmmac_tx_avail(priv) < nfrags + 1)) {
 		if (!netif_queue_stopped(dev)) {
@@ -1887,27 +1885,19 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 	first = desc;
 
 	/* To program the descriptors according to the size of the frame */
-	if (priv->mode == STMMAC_RING_MODE) {
-		is_jumbo = priv->hw->ring->is_jumbo_frm(skb->len,
-							priv->plat->enh_desc);
-		if (unlikely(is_jumbo))
-			entry = priv->hw->ring->jumbo_frm(priv, skb,
-							  csum_insertion);
-	} else {
-		is_jumbo = priv->hw->chain->is_jumbo_frm(skb->len,
-							 priv->plat->enh_desc);
-		if (unlikely(is_jumbo))
-			entry = priv->hw->chain->jumbo_frm(priv, skb,
-							   csum_insertion);
-	}
+	if (enh_desc)
+		is_jumbo = priv->hw->mode->is_jumbo_frm(skb->len, enh_desc);
+
 	if (likely(!is_jumbo)) {
 		desc->des2 = dma_map_single(priv->device, skb->data,
 					    nopaged_len, DMA_TO_DEVICE);
 		priv->tx_skbuff_dma[entry] = desc->des2;
 		priv->hw->desc->prepare_tx_desc(desc, 1, nopaged_len,
 						csum_insertion, priv->mode);
-	} else
+	} else {
 		desc = first;
+		entry = priv->hw->mode->jumbo_frm(priv, skb, csum_insertion);
+	}
 
 	for (i = 0; i < nfrags; i++) {
 		const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
@@ -2045,7 +2035,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv)
 
 			p->des2 = priv->rx_skbuff_dma[entry];
 
-			priv->hw->ring->refill_desc3(priv, p);
+			priv->hw->mode->refill_desc3(priv, p);
 
 			if (netif_msg_rx_status(priv))
 				pr_debug("\trefill entry #%d\n", entry);
@@ -2649,11 +2639,11 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
 
 	/* To use the chained or ring mode */
 	if (chain_mode) {
-		priv->hw->chain = &chain_mode_ops;
+		priv->hw->mode = &chain_mode_ops;
 		pr_info(" Chain mode enabled\n");
 		priv->mode = STMMAC_CHAIN_MODE;
 	} else {
-		priv->hw->ring = &ring_mode_ops;
+		priv->hw->mode = &ring_mode_ops;
 		pr_info(" Ring mode enabled\n");
 		priv->mode = STMMAC_RING_MODE;
 	}
-- 
1.7.4.4

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

* Re: [PATCH (net.git) 5/6] stmmac: remove useless check in the stmmac_tx_clean
  2014-02-26  8:01 ` [PATCH (net.git) 5/6] stmmac: remove useless check in the stmmac_tx_clean Giuseppe Cavallaro
@ 2014-02-26 21:14   ` David Miller
  2014-02-27  9:59     ` Giuseppe CAVALLARO
  0 siblings, 1 reply; 10+ messages in thread
From: David Miller @ 2014-02-26 21:14 UTC (permalink / raw
  To: peppe.cavallaro; +Cc: netdev

From: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Date: Wed, 26 Feb 2014 09:01:06 +0100

> There is an useless if condition that this patch is removing
> when the driver cleans the tx resources.
> 
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

It is not useless, the first check is optimistic and lock free.

You must retest the condition under the lock in order to avoid
spurious wakeups.

Such a spurious wakeup could overlap another asynchronous context
filling the TX queue and sleeping it, resulting in corruption.

Furthermore, that cleanup patch in this series is absolutely not
appropriate for 'net' which is for real bug fixes only.  Specifically
I'm talking about patch #4.

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

* Re: [PATCH (net.git) 5/6] stmmac: remove useless check in the stmmac_tx_clean
  2014-02-26 21:14   ` David Miller
@ 2014-02-27  9:59     ` Giuseppe CAVALLARO
  0 siblings, 0 replies; 10+ messages in thread
From: Giuseppe CAVALLARO @ 2014-02-27  9:59 UTC (permalink / raw
  To: David Miller; +Cc: netdev

On 2/26/2014 10:14 PM, David Miller wrote:
> From: Giuseppe Cavallaro <peppe.cavallaro@st.com>
> Date: Wed, 26 Feb 2014 09:01:06 +0100
>
>> There is an useless if condition that this patch is removing
>> when the driver cleans the tx resources.
>>
>> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
>
> It is not useless, the first check is optimistic and lock free.
>
> You must retest the condition under the lock in order to avoid
> spurious wakeups.
>
> Such a spurious wakeup could overlap another asynchronous context
> filling the TX queue and sleeping it, resulting in corruption.
>
> Furthermore, that cleanup patch in this series is absolutely not
> appropriate for 'net' which is for real bug fixes only.  Specifically
> I'm talking about patch #4.
>
>

Ok  I will send the patches w/o the #4. Thx for your advice

peppe

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

end of thread, other threads:[~2014-02-27  9:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-26  8:01 [PATCH (net.git) 0/6] stmmac: fix EEE and chained mode Giuseppe Cavallaro
2014-02-26  8:01 ` [PATCH (net.git) 1/6 (v2)] stmmac: disable at run-time the EEE if not supported Giuseppe Cavallaro
2014-02-26  8:01 ` [PATCH (net.git) 2/6] stmmac: fix and better tune the default buffer sizes Giuseppe Cavallaro
2014-02-26  8:01 ` [PATCH (net.git) 3/6] stmmac: dwmac-sti: fix broken STiD127 compatibility Giuseppe Cavallaro
2014-02-26  8:01 ` [PATCH (net.git) 4/6] stmmac: dwmac-sti: remove useless tx_retime_srcs Giuseppe Cavallaro
2014-02-26  8:01 ` [PATCH (net.git) 5/6] stmmac: remove useless check in the stmmac_tx_clean Giuseppe Cavallaro
2014-02-26 21:14   ` David Miller
2014-02-27  9:59     ` Giuseppe CAVALLARO
2014-02-26  8:01 ` [PATCH (net.git) 6/6] stmmac: fix chained mode Giuseppe Cavallaro
  -- strict thread matches above, loose matches on Subject: below --
2014-02-25  9:58 [PATCH (net.git) 1/6] stmmac: disable at run-time the EEE if not supported Giuseppe Cavallaro
2014-02-25  9:58 ` [PATCH (net.git) 2/6] stmmac: fix and better tune the default buffer sizes Giuseppe Cavallaro

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.