diff mbox series

[1/1] Input: evdev - fix wrong timestamp after SYN_DROPPED event

Message ID 20241202124220.87481-1-guille.rodriguez@gmail.com
State Superseded
Headers show
Series Input: evdev - fix wrong timestamp after SYN_DROPPED | expand

Commit Message

Guillermo Rodríguez Dec. 2, 2024, 12:42 p.m. UTC
Reset the input device's timestamp after generating a SYN_DROPPED
event, otherwise the next real event will use the same timestamp as
the SYN_DROPPED event itself.

Fixes: 3b51c44bd693 ("Input: allow drivers specify timestamp for input events")

Signed-off-by: Guillermo Rodríguez <guille.rodriguez@gmail.com>
---
 drivers/input/evdev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index b5cbb57ee5f6..6ab38a611321 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -142,7 +142,8 @@  static void __evdev_flush_queue(struct evdev_client *client, unsigned int type)
 
 static void __evdev_queue_syn_dropped(struct evdev_client *client)
 {
-	ktime_t *ev_time = input_get_timestamp(client->evdev->handle.dev);
+	struct input_dev *input_dev = client->evdev->handle.dev;
+	ktime_t *ev_time = input_get_timestamp(input_dev);
 	struct timespec64 ts = ktime_to_timespec64(ev_time[client->clk_type]);
 	struct input_event ev;
 
@@ -160,6 +161,13 @@  static void __evdev_queue_syn_dropped(struct evdev_client *client)
 		client->tail = (client->head - 1) & (client->bufsize - 1);
 		client->packet_head = client->tail;
 	}
+
+	/*
+	 * Reset the timestamp; otherwise the next event will
+	 * have the same timestamp as this SYN_DROPPED event.
+	 * See input_handle_event.
+	 */
+	input_dev->timestamp[INPUT_CLK_MONO] = ktime_set(0, 0);
 }
 
 static void evdev_queue_syn_dropped(struct evdev_client *client)