hi everybody, testing a serial midi synth (Yamaha QY70) with alsa-0.9.0rc6, linux-2.4.18, and pmidi-1.5.5, and I noticed that the first notes of score where lost/jammed, whereas the rest sounded ok
After a couple of printk in snd-serialmidi.o, it seems that serialmidi::tx_loop happens to be executed by 2 concurent threads, one on behalf of the serial driver via its line discipline, the other called by snd_serialmidi_output_trigger (I assume it has to do with applicative snd_seq_drain_output). The preemption probably occurs in the write function of the tty driver these concurent threads both peek the same block of data from rawmidi, and write it to the tty driver (that could be not that serious if the block matches exactly an atomic midi event: its is simply sent twice, for example the same note), but both as well ack the writing, removing the sent event and the next to send (even if it has not been submited yet!) I fixed this problem with a coarse hack in tx_loop, calling snd_rawmidi_transmit_ack BEFORE tty->driver.write (that is not that risky, as far as the upper layer (rawmidi) and the lower layer (tty driver) already agreed on count), but I think a spinlock or whatever kernel artefact would be more appropriate to avoid concurency in the first place I join 4 files: - a midi file containing an arpeggio: C3/E3/G3/C4, 120bpm, each half note - a version of tx_loop crowded with printk - a run of the arpeggio with pmidi, dumped from /var/log/messages - a dump of the same run of pmidi, with the hack best regards
MThd ÀMTrk Z ÿ? ÿX ÿQ¡ ?<? ÿ?? ?<