From 05f56ac92fe4bcb00be5bd01574991a50c548b8b Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sat, 10 Jul 2021 21:56:29 +0200 Subject: [PATCH] LinuxKPI: Force the usleep_range() function to sleep instead of spinning on the timer. This allows other threads to execute, typically during hardware waiting loops. This also maches how the function works in Linux. Reviewed by: kib MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/compat/linuxkpi/common/include/linux/delay.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/delay.h b/sys/compat/linuxkpi/common/include/linux/delay.h index 860d36368a8..1ed9dffed35 100644 --- a/sys/compat/linuxkpi/common/include/linux/delay.h +++ b/sys/compat/linuxkpi/common/include/linux/delay.h @@ -2,7 +2,7 @@ * Copyright (c) 2010 Isilon Systems, Inc. * Copyright (c) 2010 iX Systems, Inc. * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013-2015 Mellanox Technologies, Ltd. + * Copyright (c) 2013-2021 Mellanox Technologies, Ltd. * Copyright (c) 2014 François Tigeot * All rights reserved. * @@ -68,7 +68,10 @@ ndelay(unsigned long x) static inline void usleep_range(unsigned long min, unsigned long max) { - DELAY(min); + /* guard against invalid values */ + if (min == 0) + min = 1; + pause_sbt("lnxsleep", ustosbt(min), 0, C_HARDCLOCK); } extern unsigned int linux_msleep_interruptible(unsigned int ms);