1. Build vanilla kernel
I use a vanilla kernel from kernel.org and omit packages. To avoid name collision I use kernel 6.4.11. As a base I used the config from Ubuntu kernel config-6.2.0-26-generic. It led to a build error, which I could resolve by following this guide: https://phoenixnap.com/kb/build-linux-kernel.
This halves the build time to about 12 min. make localmodconfig
would be even better, but the kernel was already built.
$ cd linux-6.4.11-presonus1810
$ cp /boot/config-6.2.0-26-generic .config
$ make oldconfig
$ make -j$(nproc) 2>&1 | tee make.log
$ scripts/config --disable SYSTEM_TRUSTED_KEYS
$ scripts/config --disable SYSTEM_REVOCATION_KEYS
$ make -j$(nproc) 2>&1 | tee make2.log
$ sudo make modules_install
goes to /lib/modules/6.4.11
$ sudo make install
$ sudo ~/sysadmin/virtualization/vfio/initramfs_without_vfio-pci.sh 6.4.11
Although it is a vanilla kernel, dkms is started automatically and failed to build the nvidia.ko module. I know already that 6.4 is too far ahead for this to happen at the moment. Furthermore, GRUB configuration is updated automatically. A pleasant surprise.
2. Reduce boot/test time
Because I can use aplay/arecord/amixer for testing, I do not need gdm. Runlevel 3 is enough.
The GRUB command line is minimal: usbcore.autosuspend=-1 3
I use the usbcore
configuration because of my Android smartphone to avoid disconnect during USB usage. Not a proper solution, but this is another issue. For tinkering with a USB driver it is not bad to keep it, for as long as this aspect is not in focus of testing.
I have two graphics cards and cannot set the big one as secondary GPU. To avoid input switch on my monitor and reduce turnaround time further, I disabled vfio-pci
for just this kernel. Since 6.2 vfio-pci
is built as a module (like Arch Linux), so it is not enough to change the kernel command line to disable it. I have to tinker with initramfs configuration:
initramfs_without_vfio-pci.sh:
#!/bin/bash
# to be run as root
if [ $# -ne 1 ]; then
echo "Usage: $0 <kernel name>, i. e. $0 6.4.11"
exit 1
fi
kernel=$1
if ! [ -d "/lib/modules/$kernel" ]; then
echo kernel $kernel not found
exit 2
fi
echo "disable vfio module"
chmod a-x /etc/initramfs-tools/scripts/init-top/vfio.sh
sed -i 's/vfio/#vfio/' /etc/initramfs-tools/modules
echo "update initramfs without vfio for $kernel"
update-initramfs -u -k $kernel
echo "enable vfio module"
sed -i 's/#vfio/vfio/' /etc/initramfs-tools/modules
chmod a+x /etc/initramfs-tools/scripts/init-top/vfio.sh
exit 0
GRUB is not cooperative either, with the all-or-nothing approach. I only want kernel 6.4.11 to run with virtualization support disabled. It was quite a bit of tweaking to let GRUB make an exception.
Added to /etc/default/grub
:
export GRUB_CMDLINE_LINUX_2="usbcore.autosuspend=-1 3"
export KERNEL_RUNLVL_3="6.4.11"
Changed parts of /etc/grub.d/10_linux
:
if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then
if [ "${version}" != "${KERNEL_RUNLVL_3}" ]; then
linux_entry "${OS}" "${version}" simple \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
else
linux_entry "${OS} text" "${version}" simple \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_2}"
fi
and copying the code to the advanced section (important to remember!):
if [ "${version}" != "${KERNEL_RUNLVL_3}" ]; then
linux_entry "${OS}" "${version}" advanced \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
else
linux_entry "${OS} text" "${version}" advanced \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_2}"
fi
A look at /boot/grub/grub.cfg
shows that everything is fine.
3. Test vanilla kernel
Aug 25 22:29:50 malah kernel: [ 133.573922] usb 1-2: 1:3: usb_set_interface failed (-32)
This is called repeatedly, for whatever reason. Printing once “USB Audio: Presonus 1810 is not supported” would be better than freezing the system. Such messages could be shown as notification so that the user can switch the device off to save power when running Linux.
4. Patch kernel
But I want to see what happens if I let USB device 194f:0106
accepted:
diff -ru linux-6.4.11/sound/usb/format.c linux-6.4.11-presonus1810/sound/usb/format.c
--- linux-6.4.11/sound/usb/format.c 2023-08-16 18:32:31.000000000 +0200
+++ linux-6.4.11-presonus1810/sound/usb/format.c 2023-08-26 00:02:32.284648039 +0200
@@ -378,8 +378,8 @@
for (rate = min; rate <= max; rate += res) {
- /* Filter out invalid rates on Presonus Studio 1810c */
- if (chip->usb_id == USB_ID(0x194f, 0x010c) &&
+ /* Filter out invalid rates on Presonus Studio 1810 and 1810c */
+ if ((chip->usb_id == USB_ID(0x194f, 0x0106) || chip->usb_id == USB_ID(0x194f, 0x010c)) &&
!s1810c_valid_sample_rate(fp, rate))
goto skip_rate;
diff -ru linux-6.4.11/sound/usb/mixer_quirks.c linux-6.4.11-presonus1810/sound/usb/mixer_quirks.c
--- linux-6.4.11/sound/usb/mixer_quirks.c 2023-08-16 18:32:31.000000000 +0200
+++ linux-6.4.11-presonus1810/sound/usb/mixer_quirks.c 2023-08-26 00:09:52.699114926 +0200
@@ -3440,6 +3440,9 @@
err = snd_rme_controls_create(mixer);
break;
+ case USB_ID(0x194f, 0x0106): /* Presonus Studio 1810 */
+ err = snd_sc1810_init_mixer(mixer);
+ break;
case USB_ID(0x194f, 0x010c): /* Presonus Studio 1810c */
err = snd_sc1810_init_mixer(mixer);
break;
diff -ru linux-6.4.11/sound/usb/mixer_s1810c.c linux-6.4.11-presonus1810/sound/usb/mixer_s1810c.c
--- linux-6.4.11/sound/usb/mixer_s1810c.c 2023-08-16 18:32:31.000000000 +0200
+++ linux-6.4.11-presonus1810/sound/usb/mixer_s1810c.c 2023-08-26 00:12:00.547596670 +0200
@@ -552,7 +552,7 @@
return 0;
dev_info(&dev->dev,
- "Presonus Studio 1810c, device_setup: %u\n", chip->setup);
+ "Presonus Studio 1810/1810c, device_setup: %u\n", chip->setup);
if (chip->setup == 1)
dev_info(&dev->dev, "(8out/18in @ 48kHz)\n");
else if (chip->setup == 2)
diff -ru linux-6.4.11/sound/usb/quirks.c linux-6.4.11-presonus1810/sound/usb/quirks.c
--- linux-6.4.11/sound/usb/quirks.c 2023-08-16 18:32:31.000000000 +0200
+++ linux-6.4.11-presonus1810/sound/usb/quirks.c 2023-08-26 00:04:22.261206796 +0200
@@ -1549,8 +1549,8 @@
/* fasttrackpro usb: skip altsets incompatible with device_setup */
if (chip->usb_id == USB_ID(0x0763, 0x2012))
return fasttrackpro_skip_setting_quirk(chip, iface, altno);
- /* presonus studio 1810c: skip altsets incompatible with device_setup */
- if (chip->usb_id == USB_ID(0x194f, 0x010c))
+ /* presonus studio 1810/1810c: skip altsets incompatible with device_setup */
+ if (chip->usb_id == USB_ID(0x194f, 0x0106) || chip->usb_id == USB_ID(0x194f, 0x010c))
return s1810c_skip_setting_quirk(chip, iface, altno);
5. Rebuild and install module
$ make scripts prepare modules_prepare
[...]
$ make -C . M=sound/usb
CC [M] sound/usb/format.o
CC [M] sound/usb/mixer_quirks.o
CC [M] sound/usb/mixer_s1810c.o
CC [M] sound/usb/quirks.o
LD [M] sound/usb/snd-usb-audio.o
MODPOST sound/usb/Module.symvers
CC [M] sound/usb/snd-usb-audio.mod.o
LD [M] sound/usb/snd-usb-audio.ko
BTF [M] sound/usb/snd-usb-audio.ko
CC [M] sound/usb/snd-usbmidi-lib.mod.o
LD [M] sound/usb/snd-usbmidi-lib.ko
BTF [M] sound/usb/snd-usbmidi-lib.ko
[...]
$ sudo cp -a --no-preserve=ownership sound/usb/snd-usb-audio.ko sound/usb/snd-usbmidi-lib.ko /lib/modules/6.4.11/kernel/sound/usb/
6. Test modified kernel
I have switched on the audio interface, nothing else.
Aug 26 00:45:42 malah kernel: [ 30.464783] usb 1-2: new high-speed USB device number 2 using xhci_hcd
Aug 26 00:45:42 malah kernel: [ 30.615563] usb 1-2: New USB device found, idVendor=194f, idProduct=0106, bcdDevice= 2.5
1
Aug 26 00:45:42 malah kernel: [ 30.615571] usb 1-2: New USB device strings: Mfr=1, Product=3, SerialNumber=2
Aug 26 00:45:42 malah kernel: [ 30.615574] usb 1-2: Product: Studio 1810
Aug 26 00:45:42 malah kernel: [ 30.615578] usb 1-2: Manufacturer: PreSonus
Aug 26 00:45:42 malah kernel: [ 30.615581] usb 1-2: SerialNumber: <hidden>
Aug 26 00:45:42 malah kernel: [ 30.974956] usb 1-2: Presonus Studio 1810/1810c, device_setup: 0
Aug 26 00:45:42 malah kernel: [ 30.974963] usb 1-2: (8out/14in @ 96kHz)
Looks fine so far.
Aug 26 00:45:43 malah kernel: [ 31.555187] ------------[ cut here ]------------
Aug 26 00:45:43 malah kernel: [ 31.555191] usb 1-2: BOGUS control dir, pipe 80000280 doesn't match bRequestType 40
Aug 26 00:45:43 malah kernel: [ 31.555199] WARNING: CPU: 1 PID: 1872 at drivers/usb/core/urb.c:411 usb_submit_urb+0x64b
/0x700
Aug 26 00:45:43 malah kernel: [ 31.555207] Modules linked in: xt_CHECKSUM xt_MASQUERADE nft_chain_nat nf_nat bridge stp
llc ip6t_REJECT nf_reject_ipv6 xt_hl ip6t_rt ipt_REJECT nf_reject_ipv4 xt_LOG nf_log_syslog xt_comment xt_multiport nft_
limit xt_limit xt_addrtype xt_tcpudp xt_conntrack nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nft_compat nf_tables intel_r
apl_msr intel_rapl_common amd64_edac edac_mce_amd kvm_amd snd_hda_codec_hdmi libcrc32c nfnetlink binfmt_misc snd_usb_audi
o(OE) snd_hda_intel kvm snd_intel_dspcfg snd_intel_sdw_acpi snd_hda_codec snd_hda_core snd_virtuoso snd_oxygen_lib snd_us
bmidi_lib(OE) snd_hwdep snd_mpu401_uart uvcvideo nls_iso8859_1 snd_pcm videobuf2_vmalloc uvc snd_seq_midi videobuf2_memop
s snd_seq_midi_event videobuf2_v4l2 nfsd snd_rawmidi videodev irqbypass crct10dif_pclmul polyval_clmulni snd_seq polyval_
generic ghash_clmulni_intel sha512_ssse3 asus_nb_wmi eeepc_wmi aesni_intel asus_wmi snd_seq_device snd_timer crypto_simd
ledtrig_audio videobuf2_common cryptd sparse_keymap platform_profile asus_ec_sensors mc rapl
Aug 26 00:45:43 malah kernel: [ 31.555300] auth_rpcgss ccp input_leds joydev snd video wmi_bmof k10temp soundcore nfs_
acl lockd mac_hid grace sch_fq_codel drm sunrpc msr parport_pc ppdev lp parport ramoops reed_solomon pstore_blk pstore_zo
ne efi_pstore ip_tables x_tables autofs4 hid_microsoft ff_memless hid_generic usbhid hid ucsi_ccg typec_ucsi nvme typec i
gc crc32_pclmul nvme_core ahci i2c_piix4 i2c_nvidia_gpu xhci_pci libahci i2c_ccgx_ucsi xhci_pci_renesas nvme_common wmi
Aug 26 00:45:43 malah kernel: [ 31.555356] CPU: 1 PID: 1872 Comm: pulseaudio Tainted: G OE 6.4.11 #1
Aug 26 00:45:43 malah kernel: [ 31.555360] Hardware name: ASUS System Product Name/ProArt X570-CREATOR WIFI, BIOS 1201
04/19/2023
Aug 26 00:45:43 malah kernel: [ 31.555361] RIP: 0010:usb_submit_urb+0x64b/0x700
Aug 26 00:45:43 malah kernel: [ 31.555365] Code: 48 89 55 b8 89 4d c0 44 89 45 d0 e8 9f 1d ec ff 44 8b 45 d0 8b 4d c0 4
8 c7 c7 58 4f 5e 8a 48 8b 55 b8 48 89 c6 e8 85 66 50 ff <0f> 0b 44 8b 5d b4 e9 59 fc ff ff 0f b6 1d 88 85 9d 01 80 fb 01
0f
Aug 26 00:45:43 malah kernel: [ 31.555368] RSP: 0018:ffffb1e3c30ef9d8 EFLAGS: 00010292
Aug 26 00:45:43 malah kernel: [ 31.555371] RAX: 0000000000000000 RBX: ffff95f73b585550 RCX: 0000000000000000
Aug 26 00:45:43 malah kernel: [ 31.555373] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
Aug 26 00:45:43 malah kernel: [ 31.555374] RBP: ffffb1e3c30efa28 R08: 0000000000000000 R09: 0000000000000000
Aug 26 00:45:43 malah kernel: [ 31.555376] R10: 0000000000000000 R11: 0000000000000000 R12: ffff95f73fe7c858
Aug 26 00:45:43 malah kernel: [ 31.555378] R13: ffff95f73fe7c800 R14: ffff95f6c6f29440 R15: 0000000000000000
Aug 26 00:45:43 malah kernel: [ 31.555380] FS: 00007f9d26bf8080(0000) GS:ffff9605aea40000(0000) knlGS:0000000000000000
Aug 26 00:45:43 malah kernel: [ 31.555382] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Aug 26 00:45:43 malah kernel: [ 31.555384] CR2: 00005618fe3ff578 CR3: 000000017b0b0000 CR4: 0000000000750ee0
Aug 26 00:45:43 malah kernel: [ 31.555386] PKRU: 55555554
Aug 26 00:45:43 malah kernel: [ 31.555387] Call Trace:
Aug 26 00:45:43 malah kernel: [ 31.555389] <TASK>
Aug 26 00:45:43 malah kernel: [ 31.555393] ? show_regs+0x72/0x90
Aug 26 00:45:43 malah kernel: [ 31.555398] ? usb_submit_urb+0x64b/0x700
Aug 26 00:45:43 malah kernel: [ 31.555402] ? __warn+0x8d/0x160
Aug 26 00:45:43 malah kernel: [ 31.555406] ? usb_submit_urb+0x64b/0x700
Aug 26 00:45:43 malah kernel: [ 31.555410] ? report_bug+0x1bb/0x1d0
Aug 26 00:45:43 malah kernel: [ 31.555415] ? handle_bug+0x46/0x90
Aug 26 00:45:43 malah kernel: [ 31.555420] ? exc_invalid_op+0x19/0x80
Aug 26 00:45:43 malah kernel: [ 31.555424] ? asm_exc_invalid_op+0x1b/0x20
Aug 26 00:45:43 malah kernel: [ 31.555431] ? usb_submit_urb+0x64b/0x700
Aug 26 00:45:43 malah kernel: [ 31.555435] ? usb_submit_urb+0x64b/0x700
Aug 26 00:45:43 malah kernel: [ 31.555440] usb_start_wait_urb+0x71/0x190
Aug 26 00:45:43 malah kernel: [ 31.555445] usb_control_msg+0xe3/0x160
Aug 26 00:45:43 malah kernel: [ 31.555452] snd_usb_ctl_msg+0xb5/0x190 [snd_usb_audio]
Aug 26 00:45:43 malah kernel: [ 31.555471] snd_sc1810c_get_status_field.constprop.0+0xbe/0x1b0 [snd_usb_audio]
Aug 26 00:45:43 malah kernel: [ 31.555500] snd_s1810c_switch_get+0x86/0x110 [snd_usb_audio]
Aug 26 00:45:43 malah kernel: [ 31.555515] snd_ctl_elem_read+0xef/0x160 [snd]
Aug 26 00:45:43 malah kernel: [ 31.555526] snd_ctl_ioctl+0x527/0x7f0 [snd]
Aug 26 00:45:43 malah kernel: [ 31.555536] ? __x86_return_thunk+0x5/0x10
Aug 26 00:45:43 malah kernel: [ 31.555540] ? __fget_light+0xb5/0x160
Aug 26 00:45:43 malah kernel: [ 31.555546] __x64_sys_ioctl+0x9d/0xe0
Aug 26 00:45:43 malah kernel: [ 31.555552] do_syscall_64+0x5c/0x90
Aug 26 00:45:43 malah kernel: [ 31.555555] ? do_syscall_64+0x69/0x90
Aug 26 00:45:43 malah kernel: [ 31.555558] entry_SYSCALL_64_after_hwframe+0x77/0xe1
Aug 26 00:45:43 malah kernel: [ 31.555562] RIP: 0033:0x7f9d2771aaff
Aug 26 00:45:43 malah kernel: [ 31.555584] Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <41> 89 c0 3d 00 f0 ff ff 77 1f 48 8b 44 24 18 64 48 2b 04 25 28 00
Aug 26 00:45:43 malah kernel: [ 31.555586] RSP: 002b:00007ffe0f815640 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
Aug 26 00:45:43 malah kernel: [ 31.555589] RAX: ffffffffffffffda RBX: 00005618fe3d6aa0 RCX: 00007f9d2771aaff
Aug 26 00:45:43 malah kernel: [ 31.555591] RDX: 00007ffe0f8156b0 RSI: 00000000c4c85512 RDI: 0000000000000009
Aug 26 00:45:43 malah kernel: [ 31.555593] RBP: 00005618fe3d6aa0 R08: 0000000000000000 R09: 0000000000000000
Aug 26 00:45:43 malah kernel: [ 31.555594] R10: 0000000000000000 R11: 0000000000000246 R12: 00005618fe3d6ac8
Aug 26 00:45:43 malah kernel: [ 31.555596] R13: 00007ffe0f8156b0 R14: 00005618fe3d6e40 R15: 00005618fe3e79fa
Aug 26 00:45:43 malah kernel: [ 31.555602] </TASK>
Aug 26 00:45:43 malah kernel: [ 31.555603] ---[ end trace 0000000000000000 ]---
Outside of tolerance, I would say
Maybe I shall get a 1810c so that I have both models and can verify that the USB interface is different. There are no complains about 1810c Linux support, the newer model shall work. Default setting is better than with the Windows driver, because the mixer is disabled/bypassed (and unsupported). On Windows, I wanted to use a virtual instrument (VST) and heard the stage piano at the same time because of the mixer, which I had to figure out as a newbie to this interface. It is said that the newer USB-C variant still uses USB 2.0 bus protocol, but obviously with updated firmware and driver. The original driver author used usbmon on Windows for reverse engineering. As far as I know, it is part of Wireshark. I will see what I can do.
7. Alternative: Using virtual machine
Another approach would be a Linux guest system as a virtual machine, with USB port passthrough, similar to PCIe passthrough for the graphics card. A minimal Linux distribution would be sufficient for this approach, the smaller the better. No X/Wayland/Gnome/KDE.
For production audio systems, it is not recommended to use a virtual machine, but this system is just for functional testing.
8. Epilog
I apologize for the lengthy comment, but it may help someone else to keep going and contribute in one way or the other.