kernel: fix busy wait loop in mediatek PPE code
authorIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Mon, 8 Feb 2021 04:17:12 +0000 (20:17 -0800)
committerFelix Fietkau <nbd@nbd.name>
Mon, 15 Feb 2021 07:13:16 +0000 (08:13 +0100)
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.

time_is_after_jiffies(timeout) will return true until timeout is less
than jiffies, which is the intended behavior here.

Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
target/linux/generic/pending-5.4/770-15-net-ethernet-mediatek-mtk_eth_soc-add-support-for-in.patch

index d679e30bea657e5c4100d49fcfb0d0e120c19af7..2614502f5ac418302d9c2f72ce7a7edc733329d7 100644 (file)
@@ -183,7 +183,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 +{
 +      unsigned long timeout = jiffies + HZ;
 +
-+      while (time_is_before_jiffies(timeout)) {
++      while (time_is_after_jiffies(timeout)) {
 +              if (!(ppe_r32(ppe, MTK_PPE_GLO_CFG) & MTK_PPE_GLO_CFG_BUSY))
 +                      return 0;
 +