linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Guillermo Rodríguez" <guille.rodriguez@gmail.com>
Cc: "Guillermo Rodríguez" <guille.rodriguez@gmail.com>,
	"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	linux-input@vger.kernel.org
Subject: [PATCH 1/1] Input: evdev - fix wrong timestamp after SYN_DROPPED event
Date: Mon,  2 Dec 2024 13:33:51 +0100	[thread overview]
Message-ID: <20241202123351.86957-2-guille.rodriguez@gmail.com> (raw)
In-Reply-To: <20241202123351.86957-1-guille.rodriguez@gmail.com>

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 --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)
-- 
2.25.1


  reply	other threads:[~2024-12-02 12:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02 12:33 [PATCH 0/1] Input: evdev - fix wrong timestamp after SYN_DROPPED Guillermo Rodríguez
2024-12-02 12:33 ` Guillermo Rodríguez [this message]
2024-12-02 12:42 ` [PATCH 1/1] Input: evdev - fix wrong timestamp after SYN_DROPPED event Guillermo Rodríguez
2025-02-24 16:19 ` [PATCH 0/1] Input: evdev - fix wrong timestamp after SYN_DROPPED Guillermo Rodriguez Garcia
2025-02-25  0:52 ` Dmitry Torokhov
2025-03-03  9:56   ` Guillermo Rodriguez Garcia
2025-04-12 10:01     ` Guillermo Rodriguez Garcia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241202123351.86957-2-guille.rodriguez@gmail.com \
    --to=guille.rodriguez@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).