]> git.baikalelectronics.ru Git - kernel.git/commit
net: ocelot: fix wrong time_after usage
authorPavel Skripkin <paskripkin@gmail.com>
Wed, 6 Jul 2022 13:28:45 +0000 (16:28 +0300)
committerJakub Kicinski <kuba@kernel.org>
Fri, 8 Jul 2022 01:05:36 +0000 (18:05 -0700)
commitea21f0dfe050dba4c2125506ad6cd8be2a6fab73
tree64d8562125d0d478f85ef4eab65e8f28ce8678cd
parent6ad20ce1047b45e6cd5ca0aa52aafc58bf148a5c
net: ocelot: fix wrong time_after usage

Accidentally noticed, that this driver is the only user of
while (time_after(jiffies...)).

It looks like typo, because likely this while loop will finish after 1st
iteration, because time_after() returns true when 1st argument _is after_
2nd one.

There is one possible problem with this poll loop: the scheduler could put
the thread to sleep, and it does not get woken up for
OCELOT_FDMA_CH_SAFE_TIMEOUT_US. During that time, the hardware has done
its thing, but you exit the while loop and return -ETIMEDOUT.

Fix it by using sane poll API that avoids all problems described above

Fixes: 63f3021bd722 ("net: ocelot: add FDMA support")
Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20220706132845.27968-1-paskripkin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mscc/ocelot_fdma.c