[Development report #10] Audio Stack Improvements

From: Christos Margiolis <christos_at_freebsd.org>
Date: Tue, 16 Apr 2024 14:51:35 UTC
The first part of the week was spent doing some more debugging with
bapt@ (he experienced issues I could not reproduce on my machine).
Focused mostly on the DEVFS_CDEVPRIV(9) and asynchronous device detach
patches, in order to get them re-committed.

Re-committed DEVFS_CDEVPRIV(9) patch:
    - https://cgit.freebsd.org/src/commit/?id=e8c0d15a64fadb4a330f2da7244becaac161bb70
    - Apparently the patch introduced a regression where where
      dsp_[get|set]_flags() would fetch the flags of the wrong softc,
      resulting in generally strange behavior if the machine had more
      than 1 audio device attached (EBUSY's from dsp_open() etc).
      Eventually got rid of dsp_[get|set]_flags() altogether as they are
      no longer needed and used pcm_[get|set]_flags() directly.

Re-committed asynchronous device detach patch:
    - https://cgit.freebsd.org/src/commit/?id=44e128fe9d92c1a544b801cb56e907a66ef34691
    - Notified frustrated people:
	- https://www.davidschlachter.com/misc/freebsd-usb-audio
	- https://randomnixfix.wordpress.com/2021/10/23/why-the-freebsd-desktop-and-my-linux-rant/
	- https://forums.freebsd.org/threads/forcing-off-the-computer-endlessly-waiting-for-sound-application-to-exit-at-sleep-suspend-time.80412/
	- https://forums.freebsd.org/threads/not-entering-sleep-state-due-to-audio.82597/
	- https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194727
	- https://forums.freebsd.org/threads/anyone-here-uses-teams-on-freebsd.87150/page-2#post-651363
	- https://forums.freebsd.org/threads/freebsd-screen-shots.8877/page-89#post-651637
    - Sent wider call-for-testing on hackers@ and multimedia@:
      https://lists.freebsd.org/archives/freebsd-multimedia/2024-April/002306.html
    - Replied to feedback in the forums, IRC and mailing lists.
    - Closed duplicates of PR194727 and left it open until changes are
      MFC’d and we are sure it works properly.

Applied to co-mentor a GSOC project with Allan Jude.

MFC’d some patches to stable/14.

Opened a PR regarding filemon(4) crashing when building with KASAN
enabled: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278319

Spent some time researching the LOR in sound(4):
https://reviews.freebsd.org/P637
    - Found a reference that might be relevant to the bug:
      https://wiki.freebsd.org/RyanBeasley/Notes/snd_locking

Reviewed:
    - https://reviews.freebsd.org/D44777
    - https://reviews.freebsd.org/D44778

Minor patches:
    - https://cgit.freebsd.org/src/commit/?id=4f854658c5d6ca98c822491991052574d948617d
    - https://cgit.freebsd.org/src/commit/?id=068c675ca7aec11d3546c3f908e842a7eca2ccae

Christos