generic: mtk_eth_soc: fix PPE hanging issue
[openwrt/staging/stintel.git] / target / linux / generic / pending-6.6 / 736-net-ethernet-mtk_eth_soc-fix-PPE-hanging-issue.patch
1 From c8262ebbf7ca546dd5ead3c0383a89eb401627ff Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Wed, 13 Mar 2024 17:55:02 +0000
4 Subject: [PATCH] net: ethernet: mtk_eth_soc: fix PPE hanging issue
5
6 A patch to resolve an issue was found in MediaTek's GPL-licensed SDK:
7 In the mtk_ppe_stop() function, the PPE scan mode is not disabled before
8 disabling the PPE. This can potentially lead to a hang during the process
9 of disabling the PPE.
10
11 Without this patch, the PPE may experience a hang during the reboot test.
12
13 Reference: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/b40da332dfe763932a82f9f62a4709457a15dd6c
14
15 Suggested-by: Bc-bocun Chen <bc-bocun.chen@mediatek.com>
16 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
17 ---
18 drivers/net/ethernet/mediatek/mtk_ppe.c | 18 +++++++++++-------
19 1 file changed, 11 insertions(+), 7 deletions(-)
20
21 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
22 +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
23 @@ -1002,7 +1002,7 @@ void mtk_ppe_start(struct mtk_ppe *ppe)
24 MTK_PPE_KEEPALIVE_DISABLE) |
25 FIELD_PREP(MTK_PPE_TB_CFG_HASH_MODE, 1) |
26 FIELD_PREP(MTK_PPE_TB_CFG_SCAN_MODE,
27 - MTK_PPE_SCAN_MODE_KEEPALIVE_AGE) |
28 + MTK_PPE_SCAN_MODE_CHECK_AGE) |
29 FIELD_PREP(MTK_PPE_TB_CFG_ENTRY_NUM,
30 MTK_PPE_ENTRIES_SHIFT);
31 if (mtk_is_netsys_v2_or_greater(ppe->eth))
32 @@ -1098,17 +1098,21 @@ int mtk_ppe_stop(struct mtk_ppe *ppe)
33
34 mtk_ppe_cache_enable(ppe, false);
35
36 - /* disable offload engine */
37 - ppe_clear(ppe, MTK_PPE_GLO_CFG, MTK_PPE_GLO_CFG_EN);
38 - ppe_w32(ppe, MTK_PPE_FLOW_CFG, 0);
39 -
40 /* disable aging */
41 val = MTK_PPE_TB_CFG_AGE_NON_L4 |
42 MTK_PPE_TB_CFG_AGE_UNBIND |
43 MTK_PPE_TB_CFG_AGE_TCP |
44 MTK_PPE_TB_CFG_AGE_UDP |
45 - MTK_PPE_TB_CFG_AGE_TCP_FIN;
46 + MTK_PPE_TB_CFG_AGE_TCP_FIN |
47 + MTK_PPE_TB_CFG_SCAN_MODE;
48 ppe_clear(ppe, MTK_PPE_TB_CFG, val);
49
50 - return mtk_ppe_wait_busy(ppe);
51 + if (mtk_ppe_wait_busy(ppe))
52 + return -ETIMEDOUT;
53 +
54 + /* disable offload engine */
55 + ppe_clear(ppe, MTK_PPE_GLO_CFG, MTK_PPE_GLO_CFG_EN);
56 + ppe_w32(ppe, MTK_PPE_FLOW_CFG, 0);
57 +
58 + return 0;
59 }