Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/include/linux drm: Timeout audit -- li...



details:   https://anonhg.NetBSD.org/src/rev/22a21ed35710
branches:  trunk
changeset: 1028965:22a21ed35710
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 12:35:54 2021 +0000

description:
drm: Timeout audit -- linux/sched.h.

diffstat:

 sys/external/bsd/drm2/include/linux/sched.h |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (43 lines):

diff -r 8af51e148e73 -r 22a21ed35710 sys/external/bsd/drm2/include/linux/sched.h
--- a/sys/external/bsd/drm2/include/linux/sched.h       Sun Dec 19 12:35:45 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/sched.h       Sun Dec 19 12:35:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sched.h,v 1.20 2021/12/19 12:23:17 riastradh Exp $     */
+/*     $NetBSD: sched.h,v 1.21 2021/12/19 12:35:54 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -66,14 +66,16 @@
 static inline long
 schedule_timeout_uninterruptible(long timeout)
 {
-       long remain;
-       int start, end;
+       unsigned start, end;
+
+       KASSERT(timeout >= 0);
+       KASSERT(timeout < MAX_SCHEDULE_TIMEOUT);
 
        if (cold) {
                unsigned us;
                if (hz <= 1000) {
                        unsigned ms = hztoms(MIN((unsigned long)timeout,
-                           mstohz(INT_MAX)));
+                           mstohz(INT_MAX/2)));
                        us = MIN(ms, INT_MAX/1000)*1000;
                } else if (hz <= 1000000) {
                        us = MIN(timeout, (INT_MAX/1000000)/hz)*hz*1000000;
@@ -86,11 +88,10 @@
 
        start = getticks();
        /* Caller is expected to loop anyway, so no harm in truncating.  */
-       (void)kpause("loonix", false /*!intr*/, MIN(timeout, INT_MAX), NULL);
+       (void)kpause("loonix", /*intr*/false, MIN(timeout, INT_MAX/2), NULL);
        end = getticks();
 
-       remain = timeout - (end - start);
-       return remain > 0 ? remain : 0;
+       return timeout - MIN(timeout, (end - start));
 }
 
 static inline bool



Home | Main Index | Thread Index | Old Index