Hi *!
The HDSPM MADI driver seems to have an issue with its MIDI implementation. It is rock-solid for audio under Jack at 64 frames/period, but as soon as I start using the MIDI over MADI interface (to remote-control my Micstasy preamps), I'm getting xruns every ten seconds or so.
I've tried to debug the issue with the help of faberman, and he came up with a midi drain() implementation for the driver, but it didn't help with the xrun issue. It did help with busy MIDI programs in that they are no longer stuck in D state almost all the time, but sleeping, like any good program should.
This is a 2.6.39-rc7 kernel, and faberman has confirmed the issue with .39.
The attached test program rawmiditest.c (build with -lasound) will reproducibly cause xruns as soon as there is a mictasy on the MADI ring so that there's actual traffic. With no-one listening, there will be no xruns. (Might that be a hint that the problem is at the receiving end?)
This is really totally over my head, but I found one place in the driver (snd_hdspm_midi_input_trigger) where a midi routine locks the entire hdspm structure. it's flushing the midi input with the hdspm spinlock held - could this be taking so long as to cause xruns?
I'm waiting for a MIDI cable to arrive so that I can test if the same problem occurs when using the normal MIDI interfaces of the card (i.e. not the MIDI over MADI one)...
For the record, faberman suspected that there is a bit too much locking going on wrt the hmidi struct. OTOH, when we removed all hmidi spinlocks, I was able to lock up the machine twice... maybe there is some middle ground?
Meanwhile, any insights would be appreciated.
Best,
Jörn