* [RESEND, PATCH 1/4] net: stmmac: dwmac-mediatek: enable Ethernet power domain
2019-05-30 9:43 [RESEND, PATCH 0/4] complete dwmac-mediatek driver and fix flow control issue Biao Huang
@ 2019-05-30 9:43 ` Biao Huang
2019-06-02 20:01 ` David Miller
2019-05-30 9:43 ` [RESEND, PATCH 2/4] net: stmmac: dwmac-mediatek: disable rx watchdog Biao Huang
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Biao Huang @ 2019-05-30 9:43 UTC (permalink / raw)
To: davem, Jose Abreu
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, andrew
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 | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
index 126b66b..3c7a60f 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)
@@ -364,6 +371,15 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)
return 0;
}
+static int mediatek_dwmac_remove(struct platform_device *pdev)
+{
+ int ret;
+
+ ret = stmmac_pltfr_remove(pdev);
+
+ return ret;
+}
+
static const struct of_device_id mediatek_dwmac_match[] = {
{ .compatible = "mediatek,mt2712-gmac",
.data = &mt2712_gmac_variant },
@@ -374,7 +390,7 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)
static struct platform_driver mediatek_dwmac_driver = {
.probe = mediatek_dwmac_probe,
- .remove = stmmac_pltfr_remove,
+ .remove = mediatek_dwmac_remove,
.driver = {
.name = "dwmac-mediatek",
.pm = &stmmac_pltfr_pm_ops,
--
1.7.9.5
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [RESEND, PATCH 1/4] net: stmmac: dwmac-mediatek: enable Ethernet power domain
2019-05-30 9:43 ` [RESEND, PATCH 1/4] net: stmmac: dwmac-mediatek: enable Ethernet power domain Biao Huang
@ 2019-06-02 20:01 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-06-02 20:01 UTC (permalink / raw)
To: biao.huang
Cc: joabreu, 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, andrew
From: Biao Huang <biao.huang@mediatek.com>
Date: Thu, 30 May 2019 17:43:15 +0800
> @@ -364,6 +371,15 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)
> return 0;
> }
>
> +static int mediatek_dwmac_remove(struct platform_device *pdev)
> +{
> + int ret;
> +
> + ret = stmmac_pltfr_remove(pdev);
> +
> + return ret;
> +}
> +
> static const struct of_device_id mediatek_dwmac_match[] = {
> { .compatible = "mediatek,mt2712-gmac",
> .data = &mt2712_gmac_variant },
> @@ -374,7 +390,7 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)
>
> static struct platform_driver mediatek_dwmac_driver = {
> .probe = mediatek_dwmac_probe,
> - .remove = stmmac_pltfr_remove,
> + .remove = mediatek_dwmac_remove,
> .driver = {
> .name = "dwmac-mediatek",
> .pm = &stmmac_pltfr_pm_ops,
This half of your patch has no effect and seems completely unnecessary.
Please remove it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RESEND, PATCH 2/4] net: stmmac: dwmac-mediatek: disable rx watchdog
2019-05-30 9:43 [RESEND, PATCH 0/4] complete dwmac-mediatek driver and fix flow control issue Biao Huang
2019-05-30 9:43 ` [RESEND, PATCH 1/4] net: stmmac: dwmac-mediatek: enable Ethernet power domain Biao Huang
@ 2019-05-30 9:43 ` Biao Huang
2019-05-30 9:43 ` [RESEND, PATCH 3/4] net: stmmac: modify default value of tx-frames Biao Huang
2019-05-30 9:43 ` [RESEND, PATCH 4/4] net: stmmac: dwmac4: fix flow control issue Biao Huang
3 siblings, 0 replies; 6+ messages in thread
From: Biao Huang @ 2019-05-30 9:43 UTC (permalink / raw)
To: davem, Jose Abreu
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, andrew
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 3c7a60f..38cd054 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 [flat|nested] 6+ messages in thread
* [RESEND, PATCH 3/4] net: stmmac: modify default value of tx-frames
2019-05-30 9:43 [RESEND, PATCH 0/4] complete dwmac-mediatek driver and fix flow control issue Biao Huang
2019-05-30 9:43 ` [RESEND, PATCH 1/4] net: stmmac: dwmac-mediatek: enable Ethernet power domain Biao Huang
2019-05-30 9:43 ` [RESEND, PATCH 2/4] net: stmmac: dwmac-mediatek: disable rx watchdog Biao Huang
@ 2019-05-30 9:43 ` Biao Huang
2019-05-30 9:43 ` [RESEND, PATCH 4/4] net: stmmac: dwmac4: fix flow control issue Biao Huang
3 siblings, 0 replies; 6+ messages in thread
From: Biao Huang @ 2019-05-30 9:43 UTC (permalink / raw)
To: davem, Jose Abreu
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, andrew
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 [flat|nested] 6+ messages in thread* [RESEND, PATCH 4/4] net: stmmac: dwmac4: fix flow control issue
2019-05-30 9:43 [RESEND, PATCH 0/4] complete dwmac-mediatek driver and fix flow control issue Biao Huang
` (2 preceding siblings ...)
2019-05-30 9:43 ` [RESEND, PATCH 3/4] net: stmmac: modify default value of tx-frames Biao Huang
@ 2019-05-30 9:43 ` Biao Huang
3 siblings, 0 replies; 6+ messages in thread
From: Biao Huang @ 2019-05-30 9:43 UTC (permalink / raw)
To: davem, Jose Abreu
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, andrew
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 [flat|nested] 6+ messages in thread