diff options
author | Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> | 2021-04-17 15:33:39 -0700 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2021-04-29 11:28:43 +0200 |
commit | 0e3c31c14c4fb4d818e1cc8edc898a146f501942 (patch) | |
tree | 8addaa3be85121f8a2a0344bb2109800da7a1f5c | |
parent | d1f1e5269ed992e6fc30d575b43b0913c9e58ca2 (diff) | |
download | upstream-0e3c31c14c4fb4d818e1cc8edc898a146f501942.tar.gz upstream-0e3c31c14c4fb4d818e1cc8edc898a146f501942.tar.bz2 upstream-0e3c31c14c4fb4d818e1cc8edc898a146f501942.zip |
kernel: backport mtk_ppe busy-wait loop fix
Fixes logic that leads to this error when booting mt7621 and other
devices that use the mediatek ethernet driver:
[ 23.144378] mtk_soc_eth 1e100000.ethernet: PPE table busy
Link: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=c5d66587b8900201e1530b7c18d41e87bd5812f4
Fixes: f07fe36f22fc ("kernel: update flow offload patches to upstream version")
Cc: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
-rw-r--r-- | target/linux/generic/backport-5.10/610-v5.13-35-net-ethernet-mediatek-ppe-fix-busy-wait-loop.patch | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/target/linux/generic/backport-5.10/610-v5.13-35-net-ethernet-mediatek-ppe-fix-busy-wait-loop.patch b/target/linux/generic/backport-5.10/610-v5.13-35-net-ethernet-mediatek-ppe-fix-busy-wait-loop.patch new file mode 100644 index 0000000000..66cd053cd1 --- /dev/null +++ b/target/linux/generic/backport-5.10/610-v5.13-35-net-ethernet-mediatek-ppe-fix-busy-wait-loop.patch @@ -0,0 +1,72 @@ +From c5d66587b8900201e1530b7c18d41e87bd5812f4 Mon Sep 17 00:00:00 2001 +From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> +Date: Thu, 15 Apr 2021 17:37:48 -0700 +Subject: [PATCH] net: ethernet: mediatek: ppe: fix busy wait loop + +The intention is for the loop to timeout if the body does not succeed. +The current logic calls time_is_before_jiffies(timeout) which is false +until after the timeout, so the loop body never executes. + +Fix by using readl_poll_timeout as a more standard and less error-prone +solution. + +Fixes: ba37b7caf1ed ("net: ethernet: mtk_eth_soc: add support for initializing the PPE") +Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> +Cc: Felix Fietkau <nbd@nbd.name> +Reviewed-by: Andrew Lunn <andrew@lunn.ch> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/ethernet/mediatek/mtk_ppe.c | 20 +++++++++----------- + drivers/net/ethernet/mediatek/mtk_ppe.h | 1 + + 2 files changed, 10 insertions(+), 11 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_ppe.c ++++ b/drivers/net/ethernet/mediatek/mtk_ppe.c +@@ -2,9 +2,8 @@ + /* Copyright (C) 2020 Felix Fietkau <nbd@nbd.name> */ + + #include <linux/kernel.h> +-#include <linux/jiffies.h> +-#include <linux/delay.h> + #include <linux/io.h> ++#include <linux/iopoll.h> + #include <linux/etherdevice.h> + #include <linux/platform_device.h> + #include "mtk_ppe.h" +@@ -44,18 +43,17 @@ static u32 ppe_clear(struct mtk_ppe *ppe + + static int mtk_ppe_wait_busy(struct mtk_ppe *ppe) + { +- unsigned long timeout = jiffies + HZ; +- +- while (time_is_before_jiffies(timeout)) { +- if (!(ppe_r32(ppe, MTK_PPE_GLO_CFG) & MTK_PPE_GLO_CFG_BUSY)) +- return 0; ++ int ret; ++ u32 val; + +- usleep_range(10, 20); +- } ++ ret = readl_poll_timeout(ppe->base + MTK_PPE_GLO_CFG, val, ++ !(val & MTK_PPE_GLO_CFG_BUSY), ++ 20, MTK_PPE_WAIT_TIMEOUT_US); + +- dev_err(ppe->dev, "PPE table busy"); ++ if (ret) ++ dev_err(ppe->dev, "PPE table busy"); + +- return -ETIMEDOUT; ++ return ret; + } + + static void mtk_ppe_cache_clear(struct mtk_ppe *ppe) +--- a/drivers/net/ethernet/mediatek/mtk_ppe.h ++++ b/drivers/net/ethernet/mediatek/mtk_ppe.h +@@ -12,6 +12,7 @@ + #define MTK_PPE_ENTRIES_SHIFT 3 + #define MTK_PPE_ENTRIES (1024 << MTK_PPE_ENTRIES_SHIFT) + #define MTK_PPE_HASH_MASK (MTK_PPE_ENTRIES - 1) ++#define MTK_PPE_WAIT_TIMEOUT_US 1000000 + + #define MTK_FOE_IB1_UNBIND_TIMESTAMP GENMASK(7, 0) + #define MTK_FOE_IB1_UNBIND_PACKETS GENMASK(23, 8) |