]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
staging: greybus: loopback: fix broken udelay
authorJohan Hovold <johan@kernel.org>
Thu, 26 Jan 2017 11:37:32 +0000 (12:37 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jan 2017 08:29:23 +0000 (09:29 +0100)
The loopback driver allows the user to set a minimum delay of up to one
second to be inserted between test iterations (i.e. request
submissions). The delay is currently specified in microseconds and is
implemented using udelay.

Busy looping for long periods is not just anti-social; udelay must not
be used for delays longer than a few milliseconds due to the risk of
integer overflow.

Replace the broken udelay with a usleep_range with a 100 us range for
short delays (< 20 ms) and otherwise revert to using msleep.

Fixes: b36f04fa9417 ("greybus: loopback: Convert thread delay to microseconds")
Signed-off-by: Johan Hovold <johan@kernel.org>
Cc: stable <stable@vger.kernel.org> # 4.9+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/greybus/loopback.c

index 6c2a41c638c3ea6201fc19a1eec038ea56494277..a8329daf1e57f225b1b661afbdab031c1d3d4744 100644 (file)
@@ -1061,8 +1061,13 @@ static int gb_loopback_fn(void *data)
                        gb_loopback_calculate_stats(gb, !!error);
                }
                gb->send_count++;
-               if (us_wait)
-                       udelay(us_wait);
+
+               if (us_wait) {
+                       if (us_wait < 20000)
+                               usleep_range(us_wait, us_wait + 100);
+                       else
+                               msleep(us_wait / 1000);
+               }
        }
 
        gb_pm_runtime_put_autosuspend(bundle);