| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: drm_wait_netbsd.h,v 1.1.2.5 2013/07/24 02:36:31 riastradh Exp $ */ | | 1 | /* $NetBSD: drm_wait_netbsd.h,v 1.1.2.6 2013/07/24 03:08:03 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -47,40 +47,54 @@ typedef kcondvar_t drm_waitqueue_t; | | | @@ -47,40 +47,54 @@ typedef kcondvar_t drm_waitqueue_t; |
47 | | | 47 | |
48 | static inline void | | 48 | static inline void |
49 | DRM_INIT_WAITQUEUE(drm_waitqueue_t *q, const char *name) | | 49 | DRM_INIT_WAITQUEUE(drm_waitqueue_t *q, const char *name) |
50 | { | | 50 | { |
51 | cv_init(q, name); | | 51 | cv_init(q, name); |
52 | } | | 52 | } |
53 | | | 53 | |
54 | static inline void | | 54 | static inline void |
55 | DRM_DESTROY_WAITQUEUE(drm_waitqueue_t *q) | | 55 | DRM_DESTROY_WAITQUEUE(drm_waitqueue_t *q) |
56 | { | | 56 | { |
57 | cv_destroy(q); | | 57 | cv_destroy(q); |
58 | } | | 58 | } |
59 | | | 59 | |
| | | 60 | static inline bool |
| | | 61 | DRM_WAITERS_P(drm_waitqueue_t *q, struct mutex *interlock) |
| | | 62 | { |
| | | 63 | KASSERT(mutex_is_locked(interlock)); |
| | | 64 | return cv_has_waiters(q); |
| | | 65 | } |
| | | 66 | |
60 | static inline void | | 67 | static inline void |
61 | DRM_WAKEUP_ONE(drm_waitqueue_t *q, struct mutex *interlock) | | 68 | DRM_WAKEUP_ONE(drm_waitqueue_t *q, struct mutex *interlock) |
62 | { | | 69 | { |
63 | KASSERT(mutex_is_locked(interlock)); | | 70 | KASSERT(mutex_is_locked(interlock)); |
64 | cv_signal(q); | | 71 | cv_signal(q); |
65 | } | | 72 | } |
66 | | | 73 | |
67 | static inline void | | 74 | static inline void |
68 | DRM_WAKEUP_ALL(drm_waitqueue_t *q, struct mutex *interlock) | | 75 | DRM_WAKEUP_ALL(drm_waitqueue_t *q, struct mutex *interlock) |
69 | { | | 76 | { |
70 | KASSERT(mutex_is_locked(interlock)); | | 77 | KASSERT(mutex_is_locked(interlock)); |
71 | cv_broadcast(q); | | 78 | cv_broadcast(q); |
72 | } | | 79 | } |
73 | | | 80 | |
| | | 81 | static inline bool |
| | | 82 | DRM_SPIN_WAITERS_P(drm_waitqueue_t *q, spinlock_t *interlock) |
| | | 83 | { |
| | | 84 | KASSERT(spin_is_locked(interlock)); |
| | | 85 | return cv_has_waiters(q); |
| | | 86 | } |
| | | 87 | |
74 | static inline void | | 88 | static inline void |
75 | DRM_SPIN_WAKEUP_ONE(drm_waitqueue_t *q, spinlock_t *interlock) | | 89 | DRM_SPIN_WAKEUP_ONE(drm_waitqueue_t *q, spinlock_t *interlock) |
76 | { | | 90 | { |
77 | KASSERT(spin_is_locked(interlock)); | | 91 | KASSERT(spin_is_locked(interlock)); |
78 | cv_signal(q); | | 92 | cv_signal(q); |
79 | } | | 93 | } |
80 | | | 94 | |
81 | static inline void | | 95 | static inline void |
82 | DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, spinlock_t *interlock) | | 96 | DRM_SPIN_WAKEUP_ALL(drm_waitqueue_t *q, spinlock_t *interlock) |
83 | { | | 97 | { |
84 | KASSERT(spin_is_locked(interlock)); | | 98 | KASSERT(spin_is_locked(interlock)); |
85 | cv_broadcast(q); | | 99 | cv_broadcast(q); |
86 | } | | 100 | } |