mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Input: atkbd - rate-limit unknown key warnings
@ 2026-09-21 13:19 Zhang Heng
  2026-09-21 16:40 ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang Heng @ 2026-09-21 13:19 UTC (permalink / raw)
  To: dmitry.torokhov, cryolitia.pukngae, kees+treewide, DongLin_Lyu
  Cc: linux-input, linux-kernel, Zhang Heng

Replace dev_warn() with dev_warn_ratelimited() for unmapped scancode
warnings, matching the existing rate-limited handling of spurious
ACK/NAK events in the same function. 

Link: https://bugzilla.kernel.org/show_bug.cgi?id=221214
Signed-off-by: Zhang Heng <zhangheng@kylinos.cn>
---
 drivers/input/keyboard/atkbd.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 93650c98206d..26523329040b 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -497,13 +497,11 @@ static void atkbd_receive_byte(struct ps2dev *ps2dev, u8 data)
 	case ATKBD_KEY_NULL:
 		break;
 	case ATKBD_KEY_UNKNOWN:
-		dev_warn(&serio->dev,
-			 "Unknown key %s (%s set %d, code %#x on %s).\n",
-			 atkbd->release ? "released" : "pressed",
-			 atkbd->translated ? "translated" : "raw",
-			 atkbd->set, code, serio->phys);
-		dev_warn(&serio->dev,
-			 "Use 'setkeycodes %s%02x <keycode>' to make it known.\n",
-			 code & 0x80 ? "e0" : "", code & 0x7f);
+		dev_warn_ratelimited(&serio->dev,
+				     "Unknown key %s (%s set %d, code %#x on %s); use 'setkeycodes %s%02x <keycode>' to make it known.\n",
+				     atkbd->release ? "released" : "pressed",
+				     atkbd->translated ? "translated" : "raw",
+				     atkbd->set, code, serio->phys,
+				     code & 0x80 ? "e0" : "", code & 0x7f);
 		input_sync(dev);
 		break;
-- 
2.25.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Input: atkbd - rate-limit unknown key warnings
  2026-09-21 13:19 [PATCH] Input: atkbd - rate-limit unknown key warnings Zhang Heng
@ 2026-09-21 16:40 ` Dmitry Torokhov
  2026-09-22  2:12   ` Zhang Heng
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2026-09-21 16:40 UTC (permalink / raw)
  To: Zhang Heng
  Cc: cryolitia.pukngae, kees+treewide, DongLin_Lyu, linux-input, linux-kernel

Hi Zhang,

On Mon, Sep 21, 2026 at 09:19:34PM +0800, Zhang Heng wrote:
> Replace dev_warn() with dev_warn_ratelimited() for unmapped scancode
> warnings, matching the existing rate-limited handling of spurious
> ACK/NAK events in the same function. 

I do not think this is needed. Unlike spurious NAK/ACKs pressing keys
are initiated by a person and events are naturally rate-limited.

The solution is to indeed map the key to do nothing:

	KEYBOARD_KEY_xx=unknown

Userspace ignores KEY_UNKNOWN events and there are no dmesg logs either.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Input: atkbd - rate-limit unknown key warnings
  2026-09-21 16:40 ` Dmitry Torokhov
@ 2026-09-22  2:12   ` Zhang Heng
  2026-09-22  3:38     ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang Heng @ 2026-09-22  2:12 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: cryolitia.pukngae, kees+treewide, DongLin_Lyu, linux-input, linux-kernel

Thanks for your reply. This fix should be handled in userspace. It’s 
just that for ordinary users, they see a lot of warning messages after 
pressing keys, so perhaps it would be better to limit the output. I also 
agree with you that this patch is not necessary—after all, the benefit 
of this patch is indeed limited. If the patch is not merged, I’m fine 
with that.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Input: atkbd - rate-limit unknown key warnings
  2026-09-22  2:12   ` Zhang Heng
@ 2026-09-22  3:38     ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2026-09-22  3:38 UTC (permalink / raw)
  To: Zhang Heng
  Cc: cryolitia.pukngae, kees+treewide, DongLin_Lyu, linux-input, linux-kernel

On Tue, Sep 22, 2026 at 10:12:15AM +0800, Zhang Heng wrote:
> Thanks for your reply. This fix should be handled in userspace. It’s just
> that for ordinary users, they see a lot of warning messages after pressing
> keys, so perhaps it would be better to limit the output. I also agree with
> you that this patch is not necessary—after all, the benefit of this patch is
> indeed limited. If the patch is not merged, I’m fine with that.

If you submit a patch to systemd's 60-keyboard.hwdb introducing the
mapping you will solve this issue for users.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-22  3:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-21 13:19 [PATCH] Input: atkbd - rate-limit unknown key warnings Zhang Heng
2026-09-21 16:40 ` Dmitry Torokhov
2026-09-22  2:12   ` Zhang Heng
2026-09-22  3:38     ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®