* [v2, PATCH 1/4] net: stmmac: dwmac-mediatek: enable Ethernet power domain
2019-06-03 1:58 [v2, PATCH 0/4] complete dwmac-mediatek driver and fix flow control issue Biao Huang
@ 2019-06-03 1:58 ` Biao Huang
2019-06-03 1:58 ` [v2, PATCH 2/4] net: stmmac: dwmac-mediatek: disable rx watchdog Biao Huang
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Biao Huang @ 2019-06-03 1:58 UTC (permalink / raw)
To: davem, Jose Abreu, andrew
Cc: Giuseppe Cavallaro, Alexandre Torgue, Maxime Coquelin,
Matthias Brugger, netdev, linux-stm32, linux-arm-kernel,
linux-kernel, linux-mediatek, yt.shen, biao.huang, jianguo.zhang,
boon.leong.ong
add Ethernet power on/off operations in init/exit flow.
Signed-off-by: Biao Huang <biao.huang@mediatek.com>
---
.../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
index 126b66b..b84269e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
@@ -9,6 +9,7 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_net.h>
+#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/stmmac.h>
@@ -298,6 +299,9 @@ static int mediatek_dwmac_init(struct platform_device *pdev, void *priv)
return ret;
}
+ pm_runtime_enable(&pdev->dev);
+ pm_runtime_get_sync(&pdev->dev);
+
return 0;
}
@@ -307,6 +311,9 @@ static void mediatek_dwmac_exit(struct platform_device *pdev, void *priv)
const struct mediatek_dwmac_variant *variant = plat->variant;
clk_bulk_disable_unprepare(variant->num_clks, plat->clks);
+
+ pm_runtime_put_sync(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
}
static int mediatek_dwmac_probe(struct platform_device *pdev)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread* [v2, PATCH 2/4] net: stmmac: dwmac-mediatek: disable rx watchdog
2019-06-03 1:58 [v2, PATCH 0/4] complete dwmac-mediatek driver and fix flow control issue Biao Huang
2019-06-03 1:58 ` [v2, PATCH 1/4] net: stmmac: dwmac-mediatek: enable Ethernet power domain Biao Huang
@ 2019-06-03 1:58 ` Biao Huang
2019-06-03 1:58 ` [v2, PATCH 3/4] net: stmmac: modify default value of tx-frames Biao Huang
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Biao Huang @ 2019-06-03 1:58 UTC (permalink / raw)
To: davem, Jose Abreu, andrew
Cc: Giuseppe Cavallaro, Alexandre Torgue, Maxime Coquelin,
Matthias Brugger, netdev, linux-stm32, linux-arm-kernel,
linux-kernel, linux-mediatek, yt.shen, biao.huang, jianguo.zhang,
boon.leong.ong
disable rx watchdog for dwmac-mediatek, then the hw will
issue a rx interrupt once receiving a packet, so the responding time
for rx path will be reduced.
Signed-off-by: Biao Huang <biao.huang@mediatek.com>
---
.../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
index b84269e..79f2ee3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
@@ -356,6 +356,7 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)
plat_dat->has_gmac4 = 1;
plat_dat->has_gmac = 0;
plat_dat->pmt = 0;
+ plat_dat->riwt_off = 1;
plat_dat->maxmtu = ETH_DATA_LEN;
plat_dat->bsp_priv = priv_plat;
plat_dat->init = mediatek_dwmac_init;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread* [v2, PATCH 3/4] net: stmmac: modify default value of tx-frames
2019-06-03 1:58 [v2, PATCH 0/4] complete dwmac-mediatek driver and fix flow control issue Biao Huang
2019-06-03 1:58 ` [v2, PATCH 1/4] net: stmmac: dwmac-mediatek: enable Ethernet power domain Biao Huang
2019-06-03 1:58 ` [v2, PATCH 2/4] net: stmmac: dwmac-mediatek: disable rx watchdog Biao Huang
@ 2019-06-03 1:58 ` Biao Huang
2019-06-03 11:40 ` Jose Abreu
2019-06-03 1:58 ` [v2, PATCH 4/4] net: stmmac: dwmac4: fix flow control issue Biao Huang
2019-06-06 0:03 ` [v2, PATCH 0/4] complete dwmac-mediatek driver and " David Miller
4 siblings, 1 reply; 8+ messages in thread
From: Biao Huang @ 2019-06-03 1:58 UTC (permalink / raw)
To: davem, Jose Abreu, andrew
Cc: Giuseppe Cavallaro, Alexandre Torgue, Maxime Coquelin,
Matthias Brugger, netdev, linux-stm32, linux-arm-kernel,
linux-kernel, linux-mediatek, yt.shen, biao.huang, jianguo.zhang,
boon.leong.ong
the default value of tx-frames is 25, it's too late when
passing tstamp to stack, then the ptp4l will fail:
ptp4l -i eth0 -f gPTP.cfg -m
ptp4l: selected /dev/ptp0 as PTP clock
ptp4l: port 1: INITIALIZING to LISTENING on INITIALIZE
ptp4l: port 0: INITIALIZING to LISTENING on INITIALIZE
ptp4l: port 1: link up
ptp4l: timed out while polling for tx timestamp
ptp4l: increasing tx_timestamp_timeout may correct this issue,
but it is likely caused by a driver bug
ptp4l: port 1: send peer delay response failed
ptp4l: port 1: LISTENING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
ptp4l tests pass when changing the tx-frames from 25 to 1 with
ethtool -C option.
It should be fine to set tx-frames default value to 1, so ptp4l will pass
by default.
Signed-off-by: Biao Huang <biao.huang@mediatek.com>
---
drivers/net/ethernet/stmicro/stmmac/common.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 26bbcd8..6a08cec 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -261,7 +261,7 @@ struct stmmac_safety_stats {
#define STMMAC_COAL_TX_TIMER 1000
#define STMMAC_MAX_COAL_TX_TICK 100000
#define STMMAC_TX_MAX_FRAMES 256
-#define STMMAC_TX_FRAMES 25
+#define STMMAC_TX_FRAMES 1
/* Packets types */
enum packets_types {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread* RE: [v2, PATCH 3/4] net: stmmac: modify default value of tx-frames
2019-06-03 1:58 ` [v2, PATCH 3/4] net: stmmac: modify default value of tx-frames Biao Huang
@ 2019-06-03 11:40 ` Jose Abreu
2019-06-04 2:31 ` biao huang
0 siblings, 1 reply; 8+ messages in thread
From: Jose Abreu @ 2019-06-03 11:40 UTC (permalink / raw)
To: Biao Huang, davem@davemloft.net, andrew@lunn.ch
Cc: Giuseppe Cavallaro, Alexandre Torgue, Maxime Coquelin,
Matthias Brugger, netdev@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
yt.shen@mediatek.com, jianguo.zhang@mediatek.com,
boon.leong.ong@intel.com
From: Biao Huang <biao.huang@mediatek.com>
> the default value of tx-frames is 25, it's too late when
> passing tstamp to stack, then the ptp4l will fail:
>
> ptp4l -i eth0 -f gPTP.cfg -m
> ptp4l: selected /dev/ptp0 as PTP clock
> ptp4l: port 1: INITIALIZING to LISTENING on INITIALIZE
> ptp4l: port 0: INITIALIZING to LISTENING on INITIALIZE
> ptp4l: port 1: link up
> ptp4l: timed out while polling for tx timestamp
> ptp4l: increasing tx_timestamp_timeout may correct this issue,
> but it is likely caused by a driver bug
> ptp4l: port 1: send peer delay response failed
> ptp4l: port 1: LISTENING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
>
> ptp4l tests pass when changing the tx-frames from 25 to 1 with
> ethtool -C option.
> It should be fine to set tx-frames default value to 1, so ptp4l will pass
> by default.
I'm not sure if this is the right approach ... What's the timeout value
you have for TX Timestamp ?
Thanks,
Jose Miguel Abreu
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [v2, PATCH 3/4] net: stmmac: modify default value of tx-frames
2019-06-03 11:40 ` Jose Abreu
@ 2019-06-04 2:31 ` biao huang
0 siblings, 0 replies; 8+ messages in thread
From: biao huang @ 2019-06-04 2:31 UTC (permalink / raw)
To: Jose Abreu
Cc: davem@davemloft.net, andrew@lunn.ch, Giuseppe Cavallaro,
Alexandre Torgue, Maxime Coquelin, Matthias Brugger,
netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
yt.shen@mediatek.com, jianguo.zhang@mediatek.com,
boon.leong.ong@intel.com
On Mon, 2019-06-03 at 11:40 +0000, Jose Abreu wrote:
> From: Biao Huang <biao.huang@mediatek.com>
>
> > the default value of tx-frames is 25, it's too late when
> > passing tstamp to stack, then the ptp4l will fail:
> >
> > ptp4l -i eth0 -f gPTP.cfg -m
> > ptp4l: selected /dev/ptp0 as PTP clock
> > ptp4l: port 1: INITIALIZING to LISTENING on INITIALIZE
> > ptp4l: port 0: INITIALIZING to LISTENING on INITIALIZE
> > ptp4l: port 1: link up
> > ptp4l: timed out while polling for tx timestamp
> > ptp4l: increasing tx_timestamp_timeout may correct this issue,
> > but it is likely caused by a driver bug
> > ptp4l: port 1: send peer delay response failed
> > ptp4l: port 1: LISTENING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
> >
> > ptp4l tests pass when changing the tx-frames from 25 to 1 with
> > ethtool -C option.
> > It should be fine to set tx-frames default value to 1, so ptp4l will pass
> > by default.
>
> I'm not sure if this is the right approach ... What's the timeout value
> you have for TX Timestamp ?
I use the default tx_timestamp_timeout value 1, which represents 1ms.
do you try ptp4l on your side?
performance test is done in https://lkml.org/lkml/2019/5/30/1617
and seems no performance degradation.
>
> Thanks,
> Jose Miguel Abreu
^ permalink raw reply [flat|nested] 8+ messages in thread
* [v2, PATCH 4/4] net: stmmac: dwmac4: fix flow control issue
2019-06-03 1:58 [v2, PATCH 0/4] complete dwmac-mediatek driver and fix flow control issue Biao Huang
` (2 preceding siblings ...)
2019-06-03 1:58 ` [v2, PATCH 3/4] net: stmmac: modify default value of tx-frames Biao Huang
@ 2019-06-03 1:58 ` Biao Huang
2019-06-06 0:03 ` [v2, PATCH 0/4] complete dwmac-mediatek driver and " David Miller
4 siblings, 0 replies; 8+ messages in thread
From: Biao Huang @ 2019-06-03 1:58 UTC (permalink / raw)
To: davem, Jose Abreu, andrew
Cc: Giuseppe Cavallaro, Alexandre Torgue, Maxime Coquelin,
Matthias Brugger, netdev, linux-stm32, linux-arm-kernel,
linux-kernel, linux-mediatek, yt.shen, biao.huang, jianguo.zhang,
boon.leong.ong
Current dwmac4_flow_ctrl will not clear
GMAC_RX_FLOW_CTRL_RFE/GMAC_RX_FLOW_CTRL_RFE bits,
so MAC hw will keep flow control on although expecting
flow control off by ethtool. Add codes to fix it.
Fixes: 477286b53f55 ("stmmac: add GMAC4 core support")
Signed-off-by: Biao Huang <biao.huang@mediatek.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index 2544cff..9322b71 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -488,8 +488,9 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex,
if (fc & FLOW_RX) {
pr_debug("\tReceive Flow-Control ON\n");
flow |= GMAC_RX_FLOW_CTRL_RFE;
- writel(flow, ioaddr + GMAC_RX_FLOW_CTRL);
}
+ writel(flow, ioaddr + GMAC_RX_FLOW_CTRL);
+
if (fc & FLOW_TX) {
pr_debug("\tTransmit Flow-Control ON\n");
@@ -497,7 +498,7 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex,
pr_debug("\tduplex mode: PAUSE %d\n", pause_time);
for (queue = 0; queue < tx_cnt; queue++) {
- flow |= GMAC_TX_FLOW_CTRL_TFE;
+ flow = GMAC_TX_FLOW_CTRL_TFE;
if (duplex)
flow |=
@@ -505,6 +506,9 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex,
writel(flow, ioaddr + GMAC_QX_TX_FLOW_CTRL(queue));
}
+ } else {
+ for (queue = 0; queue < tx_cnt; queue++)
+ writel(0, ioaddr + GMAC_QX_TX_FLOW_CTRL(queue));
}
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [v2, PATCH 0/4] complete dwmac-mediatek driver and fix flow control issue
2019-06-03 1:58 [v2, PATCH 0/4] complete dwmac-mediatek driver and fix flow control issue Biao Huang
` (3 preceding siblings ...)
2019-06-03 1:58 ` [v2, PATCH 4/4] net: stmmac: dwmac4: fix flow control issue Biao Huang
@ 2019-06-06 0:03 ` David Miller
4 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2019-06-06 0:03 UTC (permalink / raw)
To: biao.huang
Cc: joabreu, andrew, peppe.cavallaro, alexandre.torgue,
mcoquelin.stm32, matthias.bgg, netdev, linux-stm32,
linux-arm-kernel, linux-kernel, linux-mediatek, yt.shen,
jianguo.zhang, boon.leong.ong
From: Biao Huang <biao.huang@mediatek.com>
Date: Mon, 3 Jun 2019 09:58:02 +0800
> Changes in v2:
> patch#1: there is no extra action in mediatek_dwmac_remove, remove it
>
> v1:
> This series mainly complete dwmac-mediatek driver:
> 1. add power on/off operations for dwmac-mediatek.
> 2. disable rx watchdog to reduce rx path reponding time.
> 3. change the default value of tx-frames from 25 to 1, so
> ptp4l will test pass by default.
>
> and also fix the issue that flow control won't be disabled any more
> once being enabled.
Series applied to net-next.
^ permalink raw reply [flat|nested] 8+ messages in thread