Page MenuHomeFreeBSD

D48755.id152835.diff
No OneTemporary

D48755.id152835.diff

diff --git a/sys/compat/linuxkpi/common/include/linux/wait.h b/sys/compat/linuxkpi/common/include/linux/wait.h
--- a/sys/compat/linuxkpi/common/include/linux/wait.h
+++ b/sys/compat/linuxkpi/common/include/linux/wait.h
@@ -61,12 +61,14 @@
typedef int wait_queue_func_t(wait_queue_t *, unsigned int, int, void *);
+#define WQ_FLAG_WOKEN 0x02
+
/*
* Many API consumers directly reference these fields and those of
* wait_queue_head.
*/
struct wait_queue {
- unsigned int flags; /* always 0 */
+ unsigned int flags;
void *private;
wait_queue_func_t *func;
union {
@@ -87,8 +89,14 @@
* This function is referenced by at least one DRM driver, so it may not be
* renamed and furthermore must be the default wait queue callback.
*/
-extern wait_queue_func_t autoremove_wake_function;
-extern wait_queue_func_t default_wake_function;
+wait_queue_func_t autoremove_wake_function;
+wait_queue_func_t default_wake_function;
+wait_queue_func_t woken_wake_function;
+
+long linux_wait_woken(wait_queue_t *wq, unsigned state, long timeout);
+
+#define wait_woken(wq, state, timeout) \
+ linux_wait_woken((wq), (state), (timeout))
#define DEFINE_WAIT_FUNC(name, function) \
wait_queue_t name = { \
diff --git a/sys/compat/linuxkpi/common/src/linux_schedule.c b/sys/compat/linuxkpi/common/src/linux_schedule.c
--- a/sys/compat/linuxkpi/common/src/linux_schedule.c
+++ b/sys/compat/linuxkpi/common/src/linux_schedule.c
@@ -182,6 +182,38 @@
return (wake_up_task(wq->private, state));
}
+long
+linux_wait_woken(wait_queue_t *wq, unsigned state, long timeout)
+{
+ void *wchan = wq->private;
+
+ sleepq_lock(wchan);
+ set_task_state(current, state);
+ if (!(wq->flags & WQ_FLAG_WOKEN))
+ timeout = linux_schedule_timeout(timeout);
+ else
+ set_task_state(current, TASK_RUNNING);
+
+ wq->flags &= ~WQ_FLAG_WOKEN;
+ sleepq_release(wchan);
+
+ return (timeout);
+}
+
+int
+woken_wake_function(wait_queue_t *wq, unsigned int state,
+ int flags __unused, void *key __unused)
+{
+ void *wchan = wq->private;
+
+ sleepq_lock(wchan);
+ wq->flags |= WQ_FLAG_WOKEN;
+ sleepq_signal(wchan, SLEEPQ_SLEEP, 0, 0);
+ sleepq_release(wchan);
+
+ return (1);
+}
+
void
linux_init_wait_entry(wait_queue_t *wq, int flags)
{

File Metadata

Mime Type
text/plain
Expires
Wed, Jul 22, 8:06 PM (2 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35380763
Default Alt Text
D48755.id152835.diff (2 KB)

Event Timeline