Skip to contentSkip to conversation

ALSA: usb-audio: Don't use printk_ratelimit for debug prints

PATCH In review Sean Anderson 2 participants 2 messages Aug 1, 2025 – Aug 2, 2025 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: usb-audio: Don't use printk_ratelimit for debug prints

printk_ratelimit is deprecated, since it shares state with all other printk sites. Additionally, the suppression message is printed at warning level even though the actual messages are printed at debug and are (usually) invisible! This can result in thousands of messages like

retire_capture_urb: 4992 callbacks suppressed

in the console, and can inhibit debugging since it is unclear what the source of the suppressed callbacks is.

Switch to dev_dbg_ratelimited which doesn't print anything unless debug is enabled.

---

 sound/usb/pcm.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
sound/usb/pcm.c +4 -5
index 08bf535ed163..96339594dfd5 100644
@@ -1280,11 +1280,10 @@ static void retire_capture_urb(struct snd_usb_substream *subs,
 
 	for (i = 0; i < urb->number_of_packets; i++) {
 		cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset + subs->pkt_offset_adj;
-		if (urb->iso_frame_desc[i].status && printk_ratelimit()) {
-			dev_dbg(&subs->dev->dev, "frame %d active: %d\n",
-				i, urb->iso_frame_desc[i].status);
-			// continue;
-		}
+		if (urb->iso_frame_desc[i].status)
+			dev_dbg_ratelimited(&subs->dev->dev,
+					    "frame %d active: %d\n", i,
+					    urb->iso_frame_desc[i].status);
 		bytes = urb->iso_frame_desc[i].actual_length;
 		if (subs->stream_offset_adj > 0) {
 			unsigned int adj = min(subs->stream_offset_adj, bytes);
Signature · 1 line
2.35.1.1320.gc452695387.dirty
#1 lore raw
Quoted 8 lines · Sean Anderson

printk_ratelimit is deprecated, since it shares state with all other printk sites. Additionally, the suppression message is printed at warning level even though the actual messages are printed at debug and are (usually) invisible! This can result in thousands of messages like

retire_capture_urb: 4992 callbacks suppressed

Quoted 7 lines

in the console, and can inhibit debugging since it is unclear what the source of the suppressed callbacks is.

Switch to dev_dbg_ratelimited which doesn't print anything unless debug is enabled.

Applied now. Thanks.

Takashi