Skip to content

Commit

Permalink
ALSA: usb-audio: Rate limit usb_set_interface error reporting
Browse files Browse the repository at this point in the history
When an error occurs during USB disconnection sometimes things can go
wrong as endpoint_set_interface may end up being called repeatedly. For
example:

% dmesg --notime | grep 'usb 3-7.1.4' | sort | uniq -c | head -2
   3069 usb 3-7.1.4: 1:1: usb_set_interface failed (-19)
    908 usb 3-7.1.4: 1:1: usb_set_interface failed (-71)

In my case, there sometimes are hundreds of these usb_set_interface
failure messages a second when I disconnect the hub that has my USB
audio device.

These messages can take a huge amount of the kmsg ringbuffer and don't
provide any extra information over the previous ones, so ratelimit them.

Signed-off-by: Chris Down <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
cdown authored and tiwai committed Apr 21, 2023
1 parent 4d421ee commit 2db2be5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sound/usb/endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,9 @@ static int endpoint_set_interface(struct snd_usb_audio *chip,
ep->iface, altset, ep->ep_num);
err = usb_set_interface(chip->dev, ep->iface, altset);
if (err < 0) {
usb_audio_err(chip, "%d:%d: usb_set_interface failed (%d)\n",
ep->iface, altset, err);
usb_audio_err_ratelimited(
chip, "%d:%d: usb_set_interface failed (%d)\n",
ep->iface, altset, err);
return err;
}

Expand Down
2 changes: 2 additions & 0 deletions sound/usb/usbaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ struct snd_usb_audio {

#define usb_audio_err(chip, fmt, args...) \
dev_err(&(chip)->dev->dev, fmt, ##args)
#define usb_audio_err_ratelimited(chip, fmt, args...) \
dev_err_ratelimited(&(chip)->dev->dev, fmt, ##args)
#define usb_audio_warn(chip, fmt, args...) \
dev_warn(&(chip)->dev->dev, fmt, ##args)
#define usb_audio_info(chip, fmt, args...) \
Expand Down

0 comments on commit 2db2be5

Please sign in to comment.