ntsync: Introduce NTSYNC_IOC_EVENT_PULSE.
authorElizabeth Figura <zfigura@codeweavers.com>
Fri, 13 Dec 2024 19:34:52 +0000 (13:34 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Jan 2025 12:18:11 +0000 (13:18 +0100)
This corresponds to the NT syscall NtPulseEvent().

This wakes up any waiters as if the event had been set, but does not set the
event, instead resetting it if it had been signalled. Thus, for a manual-reset
event, all waiters are woken, whereas for an auto-reset event, at most one
waiter is woken.

Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20241213193511.457338-12-zfigura@codeweavers.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/ntsync.c
include/uapi/linux/ntsync.h

index b31443aa9692b3ec076d867a0ebfda3815dfd239..141ebe8a7d4f0f56e220c2a5e6822ecd4c290899 100644 (file)
@@ -534,7 +534,7 @@ static int ntsync_mutex_kill(struct ntsync_obj *mutex, void __user *argp)
        return ret;
 }
 
-static int ntsync_event_set(struct ntsync_obj *event, void __user *argp)
+static int ntsync_event_set(struct ntsync_obj *event, void __user *argp, bool pulse)
 {
        struct ntsync_device *dev = event->dev;
        __u32 prev_state;
@@ -550,6 +550,8 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp)
        if (all)
                try_wake_all_obj(dev, event);
        try_wake_any_event(event);
+       if (pulse)
+               event->u.event.signaled = false;
 
        ntsync_unlock_obj(dev, event, all);
 
@@ -605,9 +607,11 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
        case NTSYNC_IOC_MUTEX_KILL:
                return ntsync_mutex_kill(obj, argp);
        case NTSYNC_IOC_EVENT_SET:
-               return ntsync_event_set(obj, argp);
+               return ntsync_event_set(obj, argp, false);
        case NTSYNC_IOC_EVENT_RESET:
                return ntsync_event_reset(obj, argp);
+       case NTSYNC_IOC_EVENT_PULSE:
+               return ntsync_event_set(obj, argp, true);
        default:
                return -ENOIOCTLCMD;
        }
index d74c4e4f93d8116a3a067726e39eb32021a943fb..9eab7666b8b99a565a6081c957d9bce9523cb08b 100644 (file)
@@ -50,5 +50,6 @@ struct ntsync_wait_args {
 #define NTSYNC_IOC_MUTEX_KILL          _IOW ('N', 0x86, __u32)
 #define NTSYNC_IOC_EVENT_SET           _IOR ('N', 0x88, __u32)
 #define NTSYNC_IOC_EVENT_RESET         _IOR ('N', 0x89, __u32)
+#define NTSYNC_IOC_EVENT_PULSE         _IOR ('N', 0x8a, __u32)
 
 #endif