User Details
- User Since
- Nov 25 2021, 6:20 PM (157 w, 1 m)
Apr 6 2024
Hacked it into the sosso test executable to exercise this ioctl, I'm still not convinced of its utility. This lets every application of all users set the device description globally. I think it's useful on a system level (mixer or similar tool), but I'd be wary to use it in an application. For the purposes mentioned in OSSv4, something like virtual_oss can set the description of the pcm devices it creates in a different way.
Apr 1 2024
Mar 31 2024
Do you have a particular interest in this ioctl? I didn't find any software using it on github, just example code from the 4Front OSS docs. Maybe it's a good opportunity to add an OSS API test executable now? Otherwise I have to hack it into sosso or something to run it.
Did another test drive with all patches together, works fine now. Sorry for the long "test cycle", I really have to get a USB expansion card for bhyve passthrough, so I don't have to reboot into CURRENT all the time.
Mar 29 2024
"Good news", I can reproduce the lock order reversal on the main branch, without this patch - it's not related to the changes here. How should we proceed with that?
Mar 28 2024
This is definitely more readable, but my main concern would be that this form of output is quite lengthy and not very grep-friendly. Imagine 8 pcm devices with 4 channels each (when idle). Ideally, we could easily grep for the whole output of a single device, or check which output is used by an application (cat /dev/sndstat | grep mpv). Would be handy for both personal use and bug reports from users. Or maybe we can integrate these selective queries into a user space tool?
Mar 27 2024
The mmap'ed tests worked fine in general, but I hit the following while starting two instances simultaneously:
lock order reversal: 1st 0xfffff8012e17e0a0 pcm7:virtual:dsp7.vr0 (pcm virtual record channel, sleep mutex) @ /usr/src/sys/dev/sound/pcm/dsp.c:2617 2nd 0xfffff8012e17e120 pcm7 (sound cdev, sleep mutex) @ /usr/src/sys/dev/sound/pcm/channel.c:2214 lock order sound cdev -> pcm virtual record channel established at: #0 0xffffffff80bc7b7a at witness_checkorder+0x2fa #1 0xffffffff80b2d200 at __mtx_lock_flags+0x90 #2 0xffffffff808e6b7d at sound_oss_sysinfo+0x1ed #3 0xffffffff808cf810 at dsp_ioctl+0x960 #4 0xffffffff809db8f2 at devfs_ioctl+0xd2 #5 0xffffffff80c63092 at vn_ioctl+0xc2 #6 0xffffffff809dbfce at devfs_ioctl_f+0x1e #7 0xffffffff80bce186 at kern_ioctl+0x286 #8 0xffffffff80bcde93 at sys_ioctl+0x143 #9 0xffffffff8105b473 at amd64_syscall+0x153 #10 0xffffffff8102d10b at fast_syscall_common+0xf8 lock order pcm virtual record channel -> sound cdev attempted at: #0 0xffffffff80bc83e3 at witness_checkorder+0xb63 #1 0xffffffff80b2d200 at __mtx_lock_flags+0x90 #2 0xffffffff808c949a at chn_trigger+0x26a #3 0xffffffff808e9c6c at vchan_trigger+0x12c #4 0xffffffff808c9321 at chn_trigger+0xf1 #5 0xffffffff808d5acb at dsp_oss_syncstart+0x1bb #6 0xffffffff808d0b40 at dsp_ioctl+0x1c90 #7 0xffffffff809db8f2 at devfs_ioctl+0xd2 #8 0xffffffff80c63092 at vn_ioctl+0xc2 #9 0xffffffff809dbfce at devfs_ioctl_f+0x1e #10 0xffffffff80bce186 at kern_ioctl+0x286 #11 0xffffffff80bcde93 at sys_ioctl+0x143 #12 0xffffffff8105b473 at amd64_syscall+0x153 #13 0xffffffff8102d10b at fast_syscall_common+0xf8
I was able to reproduce this a second time, with some "luck" in timing.
My first round of tests was all good, no regressions so far. I still have to test mmap'ed operation, probably tomorrow.
Mar 21 2024
Mar 19 2024
Mar 16 2024
Feb 26 2024
I'm still testing this, but I haven't found any problems in the last few days. It's hard to tell whether this approach is robust against missed interrupts, because I never encountered any.
Feb 25 2024
Feb 24 2024
This passed some manual tests, setting hw.usb.uaudio.default_rate to different values, re-plug the uaudio device and try various sample rates (vchans disabled).
Feb 17 2024
Correct man page regarding number of channels for HDSPe AIO cards.
Feb 14 2024
Thanks for the article, Olivier - now that I know the extent of your project, I suspect it won't be MFC'd?
If that's the case it may be worth to get this minimal fix in right now, and MFC it to STABLE. The earlier this issue is fixed in all supported releases, the less workarounds in ports.
Feb 13 2024
Feb 11 2024
Taken here from PR 276962.
Feb 10 2024
Definitely an improvement, the previous behavior was confusing.
Feb 9 2024
One last thing, sorry for the mess of inline comments.
Just some random testing, with no pcm devices I get:
# mixer -a mixer: mixer_get_nmixers(): No error: 0 # mixer mixer: mixer_open((null)): No error: 0
This case could be handled with a less cryptic message.
This was tested with a HDSPe RayDAT. @br, could you at least test the analog outputs of the AIO? You probably need audio/jack or audio/virtual_oss to handle that many channels. Just ask me if you need help with the setup.
Ok, hopefully last round of comments from my side :-)
Feb 7 2024
Feb 6 2024
Integrated into D43679. The parameter iteration shouldn't produce duplicate entries anymore.
Moved the special treatment of USB 1.1 devices up to where the USB bus speed is
queried. This should clarify the intent to only detect more than 4 channels if
the default_channels is set to a higher value.
Sorry this took some time, but here is a list of info I'd want to have in the man page if I was an end user.
Be specific about when these settings are helpful. We don't want users to set them unnecessarily, due to possible side effects on other uaudio devices.
The only case here is a duplicate sample rate, right? I'm uneasy to do this in the descriptor loop (why?).
Not opposed to this, just note that it may be of limited value. The sample rate can effectively change at runtime, see uaudio_chan_set_param_speed().
Feb 4 2024
Jan 31 2024
Have a look at D43679 - that should make documentation of default_bits and default_channels easier.
Not very elegant, but the whole iteration method here is somewhat crude. The default_rate sysctl already acts like a default, and does not prevent other sample rates from the list. Leave it unchanged.
As communicated in private, the latest update to this change fixes all kernel panics and witness complaints.
Jan 30 2024
Unfortunately I still get the kernel panic when I pull the USB plug, see inline comments.
The case without pulling the plug first: When I stop Jack, there's no kernel panic now, but I get the following messages:
Jan 30 13:59:09 current kernel: exclusive sleep mutex clone lock (clone manager) r = 0 (0xfffff8011ac4d2e0) locked @ /usr/src/sys/dev/sound/clone.c:390 Jan 30 13:59:09 current kernel: stack backtrace: Jan 30 13:59:09 current kernel: #0 0xffffffff80bc7c15 at witness_debugger+0x65 Jan 30 13:59:09 current kernel: #1 0xffffffff80bc8d79 at witness_warn+0x3e9 Jan 30 13:59:09 current kernel: #2 0xffffffff80adf0fe at destroy_dev+0x1e Jan 30 13:59:09 current kernel: #3 0xffffffff80885823 at snd_clone_gc+0x223 Jan 30 13:59:09 current kernel: #4 0xffffffff80885b82 at snd_clone_unref+0x52 Jan 30 13:59:09 current kernel: #5 0xffffffff808cf44b at dsp_close+0x73b Jan 30 13:59:09 current kernel: #6 0xffffffff809db9bf at devfs_close+0x48f Jan 30 13:59:09 current kernel: #7 0xffffffff8112e002 at VOP_CLOSE_APV+0x32 Jan 30 13:59:09 current kernel: #8 0xffffffff80c640a0 at vn_close1+0x100 Jan 30 13:59:09 current kernel: #9 0xffffffff80c626af at vn_closefile+0x3f Jan 30 13:59:09 current kernel: #10 0xffffffff809dc37b at devfs_close_f+0x2b Jan 30 13:59:09 current kernel: #11 0xffffffff80aece5b at _fdrop+0x1b Jan 30 13:59:09 current kernel: #12 0xffffffff80af06c3 at closef+0x1e3 Jan 30 13:59:09 current kernel: #13 0xffffffff80af45e6 at closefp_impl+0x76 Jan 30 13:59:09 current kernel: #14 0xffffffff81058463 at amd64_syscall+0x153 Jan 30 13:59:09 current kernel: #15 0xffffffff8102ab1b at fast_syscall_common+0xf8
Thanks for picking this up, @christos.
Jan 29 2024
Jan 28 2024
FYI, if I disable vchans on the device, the mutex clone kernel panic also occurs when I just stop Jack as usual. Without forcing a device detach by pulling the USB plug. It seems like the mutex owner assertions in snd_clone_wakeup() are violated even without running the pcm_unregister() code first. Hope this helps.
Jan 27 2024
Could you commit it if there are no other issues? Thank you!
Jan 25 2024
Jackpot again! ;-)
This time it's a different problem, see inline comment.
Jan 24 2024
Jackpot! Kernel panic on the first attempt! ;-)
See inline comment, don't have an explanation yet why this happens there.
Jan 22 2024
Meka, according to USB descriptor your audio interface is fine with 1ms intervals (bInterval = 0x0004). So that's not the problem. And the latency doesn't even change without this patch, we know that worked before. Did you replug the device after you changed the buffer_ms sysctl? New buffer_ms values may not become effective immediately, depending on your settings.
Jan 21 2024
Thanks for all the measurements, Meka! It seems like the buffer_ms sysctl doesn't have any effect at all. I suspect your audio interface to demand a longer interval in its USB descriptor. Could you
Jan 20 2024
@br I changed the default period from 128 to 256, compared to the port version of snd_hdspe_alt. That should be closer to the playback blocksize given by the pcm latency settings by default. Could you please test this in your HDSPe AIO setup and make sure the system defaults (vchanformat=s16le:2.0, vchanrate=48000, latency=2, latency_profile=1) work fine?
Hi Meka, sorry to hear, hope you are well now.
Your measurements seem to be accurate. Unfortunately they do not match my expectations, as I would have estimated more like a ~12ms reduction in this scenario.
I'll try to verify my own tests, but could you measure the new default of buffer_ms=4 in your setup? And a period of 768 in addition to 512 and 1024? Thanks!
I may have to check with the version of Jack in ports, I did my measurements with the new sosso backend which does mmap io.
Jan 19 2024
Clarified buffer_ms sysctl description as suggested by @emaste.
Jan 18 2024
@meka_tilda.center Any comment on your test results?
Introduced UAUDIO_BUFFER_MS_MIN and UAUDIO_BUFFER_MS_MAX as constants.
Intentionally left the comments that mention 8 ms max buffer length. It
gives some understandable context and that value will probably never change
as long as current USB audio standards are supported.
Jan 17 2024
Please note that this commit depends on rGd7fde2c9eccf, and thus also on rGb6052c10fb4ad. These were not marked for MFC. Don't know much about MFC procedures, but cherry-picking this commit without the others will probably fail. Feel free to MFC them as well if needed.
Looks good to me, /dev/sndstat output is
Jan 14 2024
Fixed various style(9) issues.
Jan 12 2024
Thanks. I'll fix the style(9) issues you mentioned and some more that I just spotted now - probably tomorrow.
Jan 11 2024
Regarding future support of additional RME cards, I looked briefly into that when I decided for the bitset approach on physical ports. Obviously there's a limit to that (32 bits). But physical ports on the AIO Pro look like the same as AIO, MADI FX has 5 ports and the others have even less. Thus I wouldn't worry too much about this limit, we may have to adapt more aspects of the driver anyway. The linux driver for example handles MADI and AES in separate files from AIO and RayDAT.
Jan 10 2024
Tested on 15.0-CURRENT as of 2024-01-09, on amd64 with an RME HDSPe RayDAT card. I have this code in use for several months now, as a separate kernel module from ports.
Jan 4 2024
- Should be all tabs now between #define and macros.
- Table lookup instead of magic number 15 for clock_source sysctl.
- Moved clock source setting register value creation to tables in hdspe.c.
- Simplified and cleaned up clock source related macros.
- Removed unused and invalid HDSPM_CLOCK_MODE_MASTER macro.
Jan 2 2024
I'll fix up the patches tomorrow, see inline comments.
Dec 31 2023
Fix minor readability and style(9) issues.
Dec 30 2023
This is part of the improvements developed on github as an alternative kernel module for HDSPe sound cards. I built that separately as a local port / package. As such these changes have been tested extensively with a HDSPe RayDAT card, and are in use for several months now.
Thanks for testing, Meka! Could you elaborate on how you did the latency measurements?
Because jack_iodelay reports a decrease of only ~2ms in total roundtrip latency, whereas the extra loopback latency decreases by ~300 frames (~6ms at 48kHz). Any other changes in the setup or Jack settings?
Nov 24 2023
Ping! Also, patch briefly tested on 15.0-CURRENT as of today. No regressions, works as expected.
Sep 23 2023
@mav I hope it's ok to add you as a reviewer / committer here? Or should I ask someone else instead?
Sep 22 2023
FYI, my patch is here D41942: snd_uaudio(4): Adapt buffer length to buffer_ms tunable. for review. I'll add more info this weekend.
Sep 12 2023
Update: Looks like the current snd_uaudio implementation actually does transfers according to USB standard, it spreads the isochronous frames over the whole transfer interval. I was misled by parts of the code, and the fact that usbdump(8) only shows the first millisecond of longer transfers. Sorry for the noise.
Sep 4 2023
I didn't promise it to be easy, but I think USB transfer size should be as close to sound(4) fragment size, if it can't be equal, as for other sound cards.
Sep 3 2023
Well, these are three different topics then:
After some thought I have a different proposal:
Sep 1 2023
Chiming in here as I have some experience with the snd_uaudio module and its code. I do support this change, but I think the title is a bit misleading.