[PATCH] HID: playstation: ratelimit input CRC check failed messages

DORMANTno replies

From: Mauricio Faria de Oliveira <hidden>
Date: 2026-10-28 00:35:53
Also in: lkml
Subsystem: hid core layer, hid playstation driver, the rest · Maintainers: Jiri Kosina, Benjamin Tissoires, Roderick Colenbrander, Linus Torvalds

The kernel log of a Steam Deck was mostly filled with CRC check errors
from what is apparently a bogus controller, with 8174 messages in <200
seconds, averaging ~43 messages/second:

    $ cat dmesg-pstore.202610250608-0 \
      | grep -c "input CRC's check failed"
    8174

    $ cat dmesg-pstore.202610250608-0 \
      | grep -m1 "input CRC's check failed"
    <3>[    8.715455] playstation 0005:054C:05C4.0006:
                      DualShock4 input CRC's check failed

    $ tac dmesg-pstore.202610250608-0 \
      | grep -m1 "input CRC's check failed"
    <3>[  196.187459] playstation 0005:054C:05C4.0006:
                      DualShock4 input CRC's check failed

    $ echo $((8174 / (196-8)))
    43

Let's ratelimit the input CRC check failed messages for the exceptional,
high-frequency error case, which doesn't impact the occasional, low-freq
error case (as ratelimiting does not trigger) or the non-error case.

CRC check failed messages for driver-initiated requests are kept as is.

Testing with a UHID driver to synthetically reproduce input CRC check
errors (generated by an LLM) shows that it reduces the duplicate lines
and still provides useful information (number of errors/same message).

For example, triggering such error every 25ms (40 times/second), prints
10 messages and silently counts another 187 in 5 seconds, ie, 197 / 5 =
39.4 times/second (aligned with the synthetic reproducer's rate):

    [    9.554184] playstation ...: Registered DualShock4 controller ...
    [   10.053936] playstation ...: DualShock4 input CRC's check failed
    [   10.078162] playstation ...: DualShock4 input CRC's check failed
    [   10.103447] playstation ...: DualShock4 input CRC's check failed
    [   10.128739] playstation ...: DualShock4 input CRC's check failed
    [   10.154016] playstation ...: DualShock4 input CRC's check failed
    [   10.179198] playstation ...: DualShock4 input CRC's check failed
    [   10.204474] playstation ...: DualShock4 input CRC's check failed
    [   10.229762] playstation ...: DualShock4 input CRC's check failed
    [   10.254904] playstation ...: DualShock4 input CRC's check failed
    [   10.280441] playstation ...: DualShock4 input CRC's check failed
    [   15.070695] dualshock4_parse_report: 187 callbacks suppressed
    ...

This reduces the space consumed in the kernel log during 5 seconds from
~200 lines to only 11 lines (5.5%).

Signed-off-by: Mauricio Faria de Oliveira <redacted>
---
 drivers/hid/hid-playstation.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
index f9dc9378cf777d33aab3cdb87302c6e48f406d2f..b053037a3f0b95b6986c7e53e787e005676ed565 100644
--- a/drivers/hid/hid-playstation.c
+++ b/drivers/hid/hid-playstation.c
@@ -824,6 +824,7 @@ static int ps_get_report(struct hid_device *hdev, u8 report_id, u8 *buf,
 		u32 report_crc = get_unaligned_le32(&buf[crc_offset]);
 
 		if (!ps_check_crc32(PS_FEATURE_CRC32_SEED, buf, crc_offset, report_crc)) {
+			/* hid_err_ratelimited() not used on driver-initiated requests */
 			hid_err(hdev, "CRC check failed for reportID=%d\n", report_id);
 			return -EILSEQ;
 		}
@@ -1459,7 +1460,7 @@ static int dualsense_parse_report(struct ps_device *ps_dev, struct hid_report *r
 		u32 report_crc = get_unaligned_le32(&data[size - 4]);
 
 		if (!ps_check_crc32(PS_INPUT_CRC32_SEED, data, size - 4, report_crc)) {
-			hid_err(hdev, "DualSense input CRC's check failed\n");
+			hid_err_ratelimited(hdev, "DualSense input CRC's check failed\n");
 			return -EILSEQ;
 		}
 
@@ -2425,7 +2426,7 @@ static int dualshock4_parse_report(struct ps_device *ps_dev, struct hid_report *
 
 		/* Last 4 bytes of input report contains CRC. */
 		if (!ps_check_crc32(PS_INPUT_CRC32_SEED, data, size - 4, report_crc)) {
-			hid_err(hdev, "DualShock4 input CRC's check failed\n");
+			hid_err_ratelimited(hdev, "DualShock4 input CRC's check failed\n");
 			return -EILSEQ;
 		}
 
---
base-commit: 83f32c773255720a661aa45d83e36278135f23f5
change-id: 20261027-hid-playstation-ratelimit-input-crc-error-26f871f1c9d2

Best regards,
-- 
Mauricio Faria de Oliveira [off-list ref]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help