History

ALSA: rawmidi: Work around false-positive mutex lockdep warning

When opening a legacy rawmidi device for a UMP, it may re-open an existing rawmidi device for appending to a substream, leading to a lockdep warning due to rmidi->open_mutex taken twice -- but the rawmidi devices are completely individual, hence it's a false-positive. For avoiding the warning, modify the helper to open a rawmidi instance with a proper locking subclass from the UMP legacy open. Unfortunately, there is no good way to achieve it with guard(), so reverted to the manual mutex calls again.

Takashi Iwai committed 3 months ago

Commit 9c047421 parent 02442d53 files · +24 −11Browse files

Showing the changes to include (1 of 3 files). Show all

Unified · Split

include/sound/rawmidi.h+12−2
@@ -176,8 +176,9 @@ int snd_rawmidi_proceed(struct snd_rawmidi_substream *substream); · 175 unmodified lines
176176 /* main midi functions */
177177
178178 int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info);
179−int snd_rawmidi_kernel_open(struct snd_rawmidi *rmidi, int subdevice,
180− int mode, struct snd_rawmidi_file *rfile);
179+int snd_rawmidi_kernel_open_nested(struct snd_rawmidi *rmidi, int subdevice,
180+ int mode, struct snd_rawmidi_file *rfile,
181+ int depth);
181182 int snd_rawmidi_kernel_release(struct snd_rawmidi_file *rfile);
182183 int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream,
183184 struct snd_rawmidi_params *params);
@@ -191,6 +192,15 @@ long snd_rawmidi_kernel_read(struct snd_rawmidi_substream *substream, · 7 unmodified lines
191192 long snd_rawmidi_kernel_write(struct snd_rawmidi_substream *substream,
192193 const unsigned char *buf, long count);
193194
195+/* non-nested version */
196+static inline int snd_rawmidi_kernel_open(struct snd_rawmidi *rmidi,
197+ int subdevice,
198+ int mode,
199+ struct snd_rawmidi_file *rfile)
200+{
201+ return snd_rawmidi_kernel_open_nested(rmidi, subdevice, mode, rfile, 0);
202+}
203+
194204 /* set up the tied devices */
195205 static inline void snd_rawmidi_tie_devices(struct snd_rawmidi *r1,
196206 struct snd_rawmidi *r2)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t