lkml.org 
[lkml]   [2013]   [Dec]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] net: mvmdio: fix wait_event_timeout() being called with a 1 jiffy timeout.
Date
If a timer interrupt kicks right after the wait_event_timeout() call,
we may endup a reporting timeout before the timeout really occured.

Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
---
drivers/net/ethernet/marvell/mvmdio.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 7354960..2814bbc 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -76,9 +76,19 @@ static int orion_mdio_wait_ready(struct mii_bus *bus)
{
struct orion_mdio_dev *dev = bus->priv;
unsigned long timeout = usecs_to_jiffies(MVMDIO_SMI_TIMEOUT);
- unsigned long end = jiffies + timeout;
+ unsigned long end;
int timedout = 0;

+ /*
+ * make sure that we wait at least more than one
+ * jiffy. wait_event_timeout() with a timeout parameter of 1
+ * jiffy may return before the SMI access is done if a timer
+ * interrupt kicks immediately after.
+ */
+ if (timeout < 2)
+ timeout = 2;
+ end = jiffies + timeout;
+
while (1) {
if (orion_mdio_smi_is_done(dev))
return 0;
--
1.8.1.2


\
 
 \ /
  Last update: 2013-12-03 17:21    [W:0.078 / U:1.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site