Commit graph

42336 commits

Author SHA1 Message Date
Christos Margiolis
2c53a4bbcb sound: Convert pcm_chn_add() to void
It always returns 0.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44998

(cherry picked from commit 139bcec852cf2786ca839ca0bddbb2b78a23d6fa)
2024-05-17 21:30:34 +02:00
Christos Margiolis
e6e7bf7087 sound: Add __assert_unreachable() to default cases in pcm_chn_add() and pcm_chn_remove()
We should normally never enter these cases.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44994

(cherry picked from commit 76f95bae092b7353ff82b7a0056ca5801bb98f76)
2024-05-17 21:30:34 +02:00
Christos Margiolis
13ee4d7f33 sound: Merge pcm_chn_create() and chn_init()
Follow-up of b3ea087c05d8c75978a302cbb3fa92ce1afa3e49 ("sound: Merge
pcm_chn_destroy() and chn_kill()")

While here, add device_printf()'s to all failure points. Also fix an
existing bug where we'd unlock an already unlocked channel, in case we
went to "out" (now "out2") before locking the channel.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D44993

(cherry picked from commit 2e9962ef57044b191431fe9228841e1415574d82)
2024-05-17 21:30:34 +02:00
Christos Margiolis
0baaaf8543 sound: Remove chn_timeout check from chn_init()
This check is not related to channel initializion, but is also
unnecessary, since sysctl_hw_snd_timeout() takes care of checking if
chn_timeout is within bounds.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44992

(cherry picked from commit 7cc1afc5589000ac6ad7a908b07fad3401367bd1)
2024-05-17 21:30:34 +02:00
Christos Margiolis
930b5a3c07 sound: Move pcm_chnref() and pcm_chnrelease() to pcm/channel.c
Improve code layering. These are channel functions, and so they do not
belong in pcm/sound.c.

While here, assert in chn_ref() that new refcount won't be negative.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44985

(cherry picked from commit a24050e2b784e13561da3ab731a1db92f2e3366c)
2024-05-17 21:30:34 +02:00
Christos Margiolis
532b1efd2d sound: Merge pcm_chn_destroy() and chn_kill()
pcm_chn_destroy() acts like a wrapper around chn_kill(), and
additionally calls a few more functions that should in fact be part of
chn_kill()'s logic. Merge pcm_chn_destroy()'s functionality in
chn_kill() to improve readability, as well as code layering.

While here, convert chn_kill() to void as it currently always returns 0.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44984

(cherry picked from commit b3ea087c05d8c75978a302cbb3fa92ce1afa3e49)
2024-05-17 21:30:34 +02:00
Christos Margiolis
ad677fb457 sound: Retire unit.*
The unit.* code is largely obsolete and imposes limits that are no
longer needed nowadays.

- Capping the maximum allowed soundcards in a given machine. By default,
  the limit is 512 (snd_max_u() in unit.c), and the maximum possible is
  2048 (SND_UNIT_UMAX in unit.h). It can also be tuned through the
  hw.snd.maxunit loader(8) tunable. Even though these limits are large
  enough that they should never cause problems, there is no need for
  this limit to exist in the first place.
- Capping the available device/channel types. By default, this is 32
  (snd_max_d() in unit.c). However, these types are pre-defined in
  pcm/sound.h (see SND_DEV_*), so the cap is unnecessary when we know
  that their number is constant.
- Capping the number of channels per-device. By default, the limit 1024
  (snd_max_c() in unit.c). This is probably the most problematic of the
  limits mentioned, because this limit can never be reached, as the
  maximum is hard-capped at either hw.snd.maxautovchans (16 by default),
  or SND_MAXHWCHAN and SND_MAXVCHANS.

These limtits are encoded in masks (see SND_U_MASK, SND_D_MASK,
SND_C_MASK in unit.h) and are used to construct a bitfield of the form
[dsp_unit, type, channel_unit] in snd_mkunit() which is assigned to
pcm_channel->unit.

This patch gets rid of everything unit.*-related and makes a slightly
different use of the "unit" field to only contain the channel unit
number. The channel type is stored in a new pcm_channel->type field, and
the DSP unit number need not be stored at all, since we can fetch it
from device_get_unit(pcm_channel->dev). This change has the effect that
we no longer need to impose caps on the number of soundcards,
device/channel types and per-device channels. As a result the code is
noticeably simplified and more readable.

Apart from the fact that the hw.snd.maxunit loader(8) tunable is also
retired as a side-effect of this patch, sound(4)'s behavior remains the
same.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D44912

(cherry picked from commit 25723d66369fe6786e9e4f5f77381b944755f267)
2024-05-17 21:30:25 +02:00
Christos Margiolis
41dee63555 sound: Remove obsolete DV_F_* flags
The ISA sound drivers that used them are retired.

Last reference of DV_F_DRQ_MASK and DV_F_DUAL_DMA:
716924cb48 ("Retire snd_sbc ISA sound card
driver")

Last reference of DV_F_DEV_MASK and DV_F_DEV_SHIFT:
5126e5eeeb ("Retire snd_mss ISA sound card
driver")

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44858

(cherry picked from commit 1b82d425ec0ac155765bcdf706040534309e9c94)
2024-05-17 21:30:01 +02:00
Christos Margiolis
9815728172 sound: Simplify unit fetching in dsp_oss_audioinfo()
"i" keeps the value of the current unit, so we do not have to call
PCMUNIT() and device_get_unit() to fetch it.

In the mixer case, I think it is more correct to do it like this, since
mixer and DSP device units have a 1-1 relationship (i.e the mixer unit
is always the same as the corresponding DSP device one) and that way we
can make it more clear.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44855

(cherry picked from commit a44c45c7f597d67d37e09396b0778a2847a30981)
2024-05-17 21:30:01 +02:00
Christos Margiolis
decc224ab8 sound: Remove PCMMINOR()
It's a NO-OP.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44854

(cherry picked from commit 8b97dce6973ca1b6c3407c34c76d459f43ca1061)
2024-05-17 21:30:01 +02:00
Christos Margiolis
d27972ec91 sound: Get rid of snddev_info->devcount
snddev_info->devcount keeps track of the total number of channels for a
given device. However, it is redundant to have it, since it is only used
in sound_oss_sysinfo() to populate the "numaudios" field, and we also
keep track of the channel counts in the playcount, pvchancount, reccount
and rvchancount fields anyway. We can simply sum those fields together
instead of updating a separate variable upon every channel
addition/deletion.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44852

(cherry picked from commit 4d2be7be3837d66ba242a0a7fd51632c3f89285d)
2024-05-17 21:30:01 +02:00
Christos Margiolis
69707d9f50 sound: Call device_get_name() and device_get_unit() only once in mixer_init()
No functional change intended.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44840

(cherry picked from commit 41ab202ff74ea6af7e9125c9dfb430c729380f41)
2024-05-17 21:30:01 +02:00
Christos Margiolis
8771127d75 sound: Be more verbose with virtual channel descriptions
Non-virtual channel description denote "play" or "record", so do the
same for virtual ones as well.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44839

(cherry picked from commit d0032e6a9e6596302bf129d7f68a627a02c6cd0a)
2024-05-17 21:30:01 +02:00
Ed Maste
7309d72e14 ukswitch: fix non-debug build
PR:		278847
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2e0c027e69de66afc1157c76bd42ecd3737d54e1)
2024-05-14 10:47:00 -04:00
Ed Maste
e9a7be7def ip17x: fix non-debug build
PR:		278847
Reviewed by:	jhibbits
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45133

(cherry picked from commit 82f43db382cc4aea2a3f34f08da9a97ab023d5fb)
2024-05-14 10:47:00 -04:00
Konstantin Belousov
ddabe1d3c5 mlx5en: add diagnostic in one more case of failed eeprom read preparation
(cherry picked from commit c097967b9af946cf46246cce5adde53f7e955ecc)
2024-05-13 12:51:29 +03:00
Ed Maste
5e7de5daa9 smsc(4): update to mention Microchip
Microchip Technology acquired SMSC in 2012, and all current products
and datasheets refer to the devices supported by this driver as
Microchip parts.  Mention SMSC in a parenthetical comment to explain
the driver's name.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45115

(cherry picked from commit 7ef6ce51742d44a7375ccbaeda4cc64e034c4816)
2024-05-10 09:01:52 -04:00
Seth Hoffert
3f6515c20f bpf: Make BPF interop consistent with if_loop
The pseudo_AF_HDRCMPLT check is already being done in if_loop and
just needed to be ported over to if_ic, if_wg, if_disc, if_gif,
if_gre, if_me, if_tuntap and ng_iface.  This is needed in order to
allow these interfaces to work properly with e.g., tcpreplay.

PR:		256587
Reviewed by:	markj
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/876

(cherry picked from commit 2cb0fce24d64039090dc9243cdf0715ee80c91b1)
2024-05-08 09:06:15 -04:00
Mark Johnston
bff26fe7aa wg: uma_zcreate() does not fail
No functional change intended.

MFC after:	1 week

(cherry picked from commit b6a0ed7c78dd45937e404706620467bef61c308d)
2024-05-02 09:25:08 -04:00
Mark Johnston
4ee7b8e1ef dpaa: uma_zcreate() does not fail
No functional change intended.

MFC after:	1 week

(cherry picked from commit 964064937ea04519bd400668dc1ce38848d50901)
2024-05-02 09:25:08 -04:00
Christos Margiolis
a2b09fc4b8 sound: Add missing space in dev.pcm.X.mode description
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44990

(cherry picked from commit e56c8996fc437488686e7cdef18258f16c5ea74e)
2024-04-29 12:43:31 +02:00
Christos Margiolis
33e0f0cd6b sound: Assert that we do not enter chn_sleep() with CHN_F_SLEEPING
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44959

(cherry picked from commit fa284525499d75955525839074bf5968d0923e6b)
2024-04-29 12:43:31 +02:00
Christos Margiolis
d8d7907826 sound: Fix panic caused by sleeping-channel destruction during asynchronous detach
Currently we are force-destroying all channels unconditionally in
pcm_killchan(). However, since asynchronous audio device detach is
possible as of 44e128fe9d92, if we do not check whether the channel is
sleeping or not and forcefully kill it, we will get a panic from
cv_timedwait_sig() (called from chn_sleep()), because it will try to use
a freed lock/cv.

Modify pcm_killchan() (renamed to pcm_killchans() since that's a more
appropriate name now) to loop through the channel list and destroy only
the channels that are awake, otherwise wake up the sleeping thread and
try again. This loop is repeated until all channels are awakened and
destroyed.

To reduce code duplication, implement chn_shutdown() which wakes up the
channel and sets CHN_F_DEAD, and use it in pcm_unregister() and
pcm_killchans().

Reported by:	KASAN
Fixes:		44e128fe9d92 ("sound: Implement asynchronous device detach")
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44923

(cherry picked from commit 03614fcba25b9de99e69819bc4690f66a3d24438)
2024-04-29 12:43:30 +02:00
Christos Margiolis
9847c2497d sound: Wrap dsp_clone() and mixer_clone() with bus_topo_lock()
Make sure that the softc isn't freed in between the checks.

Sponsored by:	The FreeBSD Foundation
MFC after;	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44991

(cherry picked from commit b18b990d8e7b15d25243d85ea22374dfdde8a18b)
2024-04-29 12:43:30 +02:00
Christos Margiolis
cc72812c49 sound: Fix NULL dereference in dsp_clone() and mixer_clone()
If we only have a single soundcard attached and we detach it right
before entering [dsp|mixer]_clone(), there is a chance pcm_unregister()
will have returned already, meaning it will have set snd_unit to -1, and
thus devclass_get_softc() will return NULL here.

While here, 1) move the calls to dsp_destroy_dev() and mixer_uninit()
below the point where we unset SD_F_REGISTERED, and 2) follow what
mixer_clone() does and make sure we don't use a NULL d->dsp_dev in
dsp_clone().

Reported by:	KASAN
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44924

(cherry picked from commit 074d6fbebc160222cde6b726adcc7350881d7824)
2024-04-29 12:43:30 +02:00
Christos Margiolis
ac316062a7 sound: Remove obsolete chn_setvolume()
It is marked as obsolete and there are no consumers of it anymore.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44853

(cherry picked from commit 17969e696325273e250a1dc73f43de76c0836aae)
2024-04-29 12:43:30 +02:00
Gordon Bergling
770e03ac39 wtap: Fix typos in kernel messages
- s/cant/can't/

(cherry picked from commit 026520a5f2d2ec01e19494c37b87448df86ef21a)
2024-04-28 07:20:25 +02:00
Gordon Bergling
4f8ee76d2a ds1307(4): Fix a typo in a source code comment
- s/slighly/slightly/

(cherry picked from commit fa3b320668ba6068014337bbbb05dbd39ac8dfb6)
2024-04-27 07:49:47 +02:00
Kyle Evans
60a4a8532b ahc(4): resolve some minor nits
In ahc_init(), qoutfifo is already assigned to effectively the same
value a couple lines up, except in the first assignment it uses the
proper definition; keep the more descriptive assignment.

ahc_targetcmd_offset() gets the offset wrong entirely; as per the
area of ahc_init() this diff also touches, targetcmds is laid out first
in the shared map and it's followed by the qoutfifo.  As a result, we'd
generally be getting negative offsets here.  We can't actually do a
partial sync anyways, so there was no consequence to getting this wrong.

Reviewed by:	imp, mav

(cherry picked from commit b5e0cc2fa44f52f16fc0b9c3f1709bc0f43fe2d0)
2024-04-24 22:59:03 -05:00
Kyle Evans
7c3092e343 ahc(4)/ahd(4): fix target mode on ARM
One of the comments in ahc_execute_scb() notes that the CAM direction is
actually w.r.t. the initiator.  As a consequence, all of our sync ops
end up being wrong because the direction is flipped from that of the
transfer.  Fix it to do proper invalidation and avoid spewing random
garbage out on the SCSI bus.

Reported and tested by:	HP van Braam <hp@tmm.cx>
Reviewed by:	imp, mav

(cherry picked from commit 9dcf39575efb2ff32f955d9e04e04af28d45d798)
2024-04-24 22:58:58 -05:00
Henrich Hartzer
c7a5881d7a Add support for Intel Atom S1200 UART
PR: 278316

Signed-off-by: Henrich Hartzer <henrichhartzer@tuta.io>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1164
(cherry picked from commit 1f2776e123603042944aad9f41ceb46b5b28d8ae)
2024-04-24 17:57:55 -06:00
Eric Joyner
f6de0a7c94
ice(4): Update to 1.39.13-k
- Adds mirror interface functionality
- Remove unused virtchnl headers

Signed-off-by: Eric Joyner <erj@FreeBSD.org>

Sponsored by:	Intel Corporation
Tested by:	jeffrey.e.pieper@intel.com
Differential Revision:	https://reviews.freebsd.org/D44004

(cherry picked from commit 9e54973fc33aa44b77d1c851cb36fcd82dc44cda)
2024-04-24 15:14:48 -07:00
Eric Joyner
988dd5a1f3
ice(4): Update copyright year to 2024
Signed-off-by: Eric Joyner <erj@FreeBSD.org>

Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D44003

(cherry picked from commit 015f8cc5b0c10336a048f37a7071ea03516de242)
2024-04-24 15:14:48 -07:00
Gordon Bergling
0b396f0185 bhnd(4): Remove a double word in a source code comment
- s/of of/of/

(cherry picked from commit d2747968c068b8cfc890901f4955037bad7adb9a)
2024-04-23 07:23:21 +02:00
Gordon Bergling
1e17c11779 safe(4): Remove a double word in a source code comment
- s/of of/of/

(cherry picked from commit 1bbdcf62d3ac8fbea2d4c5b37ccd9ac2032d37d7)
2024-04-23 07:23:04 +02:00
Gordon Bergling
4a393999f3 usb(4): Remove a double word in a source code comment
- s/of of/of/

(cherry picked from commit 604511f84ae6378db25ae3080e9db2e3bc9e0811)
2024-04-23 07:21:45 +02:00
Gordon Bergling
2b343cd2d5 oce(4): Fix a typo in a source code comment
- s/addres/address/

(cherry picked from commit e991acd5d0f60fe3c57acb452003c551194a758b)
2024-04-21 09:33:52 +02:00
Gordon Bergling
04ab41437a muge(4): Fix a typo in a source code comment
- s/addres/address/

(cherry picked from commit 046fe202e76623988ac612b20047940b86dd373f)
2024-04-21 09:33:29 +02:00
Xin LI
e4d8fe76c5 amdsmn(4), amdtemp(4): add support for AMD Family 19h Models 10h-1Fh.
Tested on AMD Threadripper 7960X.

PR:		kern/278311
Tested by:	jbo

(cherry picked from commit 51c69c8682e8ab0e5d82ab3d6f2d16419d40bad4)
2024-04-20 20:15:52 -07:00
Michael Zhilin
2a66844f60 snd_hda: fix "duplicated free" on module unloading
This is trivial fix of hdacc_detach to avoid duplicated free on snd_hda
unloading.

The first try of detaching (kldunload) may results into "device busy" error,
but codec->fgs is freed by detach. Second try attempts to free codec->fgs again
and system panicks.

Here is example:

pcm0: unregister: channel pcm0:virtual:dsp0.vp0 busy (pid 3428)
pulseaudio[3428] [oss] module-oss.c: DSP shutdown.
pcm0: detached
hdaa0: detached
panic: Duplicate free of 0xfffff80412ee7d20 from zone 0xfffffe006bc0ba00
(malloc-32) slab 0xfffff80412ee7fc8(105)
cpuid = 6
time = 1712999565
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0202f859e0
vpanic() at vpanic+0x135/frame 0xfffffe0202f85b10
panic() at panic+0x43/frame 0xfffffe0202f85b70
uma_dbg_free() at uma_dbg_free+0x105/frame 0xfffffe0202f85b90
uma_zfree_arg() at uma_zfree_arg+0x95/frame 0xfffffe0202f85be0
free() at free+0xa1/frame 0xfffffe0202f85c20
hdacc_detach() at hdacc_detach+0x2f/frame 0xfffffe0202f85c40
device_detach() at device_detach+0x197/frame 0xfffffe0202f85c80
devclass_driver_deleted() at devclass_driver_deleted+0x66/frame 0xfffffe0202f85c
devclass_delete_driver() at devclass_delete_driver+0x81/frame 0xfffffe0202f85d00
driver_module_handler() at driver_module_handler+0xff/frame 0xfffffe0202f85d50
module_unload() at module_unload+0x32/frame 0xfffffe0202f85d70
linker_file_unload() at linker_file_unload+0x1eb/frame 0xfffffe0202f85db0
kern_kldunload() at kern_kldunload+0x18e/frame 0xfffffe0202f85e00
amd64_syscall() at amd64_syscall+0x153/frame 0xfffffe0202f85f30
fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe0202f85f30

MFC after:              3 days
Reviewed by:            markj, christos
Differential Revision:  https://reviews.freebsd.org/D44778
Sponsored by:           Postgres Professional

(cherry picked from commit bed0b2146faa2e9a445d9f9196c7b46f50034631)
2024-04-19 09:37:08 +03:00
Michael Zhilin
0a902d7561 snd_hda: Add the full Intel Meteor/Arrow/Lunar Lake HD Audio PCI IDs
This is based off the Linux file sound/hda/intel-dsp-config.c.

Tested on:              Lenovo Thinkbook 16 G6+ IMH
MFC after:              3 days
Reviewed by:            markj, christos
Differential Revision:  https://reviews.freebsd.org/D44777
Sponsored by:           Postgres Professional

(cherry picked from commit 1dd1a696c58fb275aa0e01666d57861eeb51878d)
2024-04-19 09:37:07 +03:00
Josef 'Jeff' Sipek
788987e034 acpi_battery: avoid divide-by-zero when no devices have capacity info
On laptops with builtin batteries, disconnecting the battery may show up
as a battery without any capacity information. (The theory is that one
is disconnecting the cells but the electronics identifying the battery
are still connected.) As a result, the loop over all batteries in
acpi_battery_get_battinfo results in total_lfcap == 0.

So, just check that total_lfcap is non-zero to avoid a division by zero
(triggerable by sysctl hw.acpi.battery).

Reported by:	Stefano Marinelli
Tested by:	Stefano Marinelli
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D44818

(cherry picked from commit 2e850b832f5d2adb9b230d191277d67c00caaab9)
2024-04-19 03:16:52 +00:00
Mitchell Horne
9319a8a11a simple_mfd: don't attach children twice
Trying to probe+attach the child device at the point it is added comes
before the syscon handle is set up (if relevant). It will therefore be
unavailable to the attach method which is expecting it, and the first
attempt to attach the device will fail.

Just rely on the call to bus_generic_attach() at the end of the function
to perform probe+attach of dev's children.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44268

(cherry picked from commit accda781531788a814bc438e1e96ef544c12aeaf)
2024-04-18 15:11:31 -03:00
Mitchell Horne
29701960b3 clk_fixed: call clkdom_dump() for verbose boot
This is standard practice for clock drivers that register clocks
dynamically. Nothing else uses the CLK_DEBUG macro.

The result is that the name and frequency of the fixed clock is printed
for a verbose boot, which may aid in debugging.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44265

(cherry picked from commit 6e66bb9fc3d026765113fa1258cd12292da9309a)
2024-04-18 15:11:31 -03:00
Mitchell Horne
5eb27a0d68 clk_fixed: quiet by default
We may attach several of these devices, but there is no meaningful
information added to dmesg. For example:

  ofwbus0: <Open Firmware Device Tree>
  clk_fixed0: <Fixed clock> on ofwbus0
  clk_fixed1: <Fixed clock> on ofwbus0
  clk_fixed2: <Fixed clock> on ofwbus0
  clk_fixed3: <Fixed clock> on ofwbus0
  clk_fixed4: <Fixed clock> on ofwbus0
  clk_fixed5: <Fixed clock> on ofwbus0
  clk_fixed6: <Fixed clock> on ofwbus0
  clk_fixed7: <Fixed clock> on ofwbus0
  clk_fixed8: <Fixed clock> on ofwbus0
  clk_fixed9: <Fixed clock> on ofwbus0
  clk_fixed10: <Fixed clock> on ofwbus0
  clk_fixed11: <Fixed clock> on ofwbus0

To reduce this noise, quiet the devices for by default. For verbose
boot, the message will be emitted.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44266

(cherry picked from commit 1cb9f6f6413e9d242de47e730ec7d4ce3e5688fe)
2024-04-18 15:11:31 -03:00
Mitchell Horne
327987597b clkdom_dump(): improve output text
If the call to clknode_get_freq() returns an error (unlikely), report
this, rather than printing the error code as the clock frequency.

If the clock has no parent (e.g. a fixed reference clock), print "none"
rather than "(NULL)(-1)". This is a more human-legible presentation of the
same information.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44267

(cherry picked from commit 08635c51d1e34f8a3e42c7cf35dc7264a5b68118)
2024-04-18 15:11:31 -03:00
Christos Margiolis
5abbbb7c64 sound: Remove leftover references to snd_clone
The snd_clone framework does not exist as of
e8c0d15a64fadb4a330f2da7244becaac161bb70 ("sound: Get rid of snd_clone
and use DEVFS_CDEVPRIV(9)"), so remove leftover references to it from
unit.c.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 months
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44758

(cherry picked from commit 068c675ca7aec11d3546c3f908e842a7eca2ccae)
2024-04-18 14:39:41 +02:00
Christos Margiolis
51abcd0c47 sound: Update some LICENSE headers
The following commits introduced substantial changes to pcm/dsp.c,
pcm/sndstat.c and pcm/sound.c.

9da3b645dbaaad724d524727d003fed7be05ff7c ("sound: Move
sndstat_prepare_pcm() to pcm/sndstat.c and remove
sndstat_entry->handler")
e8c0d15a64fadb4a330f2da7244becaac161bb70 ("sound: Get rid of snd_clone
and use DEVFS_CDEVPRIV(9)")

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44757

(cherry picked from commit 4f854658c5d6ca98c822491991052574d948617d)
2024-04-18 14:39:36 +02:00
Christos Margiolis
d692c314d2 sound: Implement asynchronous device detach
Hot-unplugging a sound device, such as a USB sound card, whilst being
consumed by an application, results in an infinite loop until either the
application closes the device's file descriptor, or the channel
automatically times out after hw.snd.timeout seconds. In the case of a
detach however, the timeout approach is still not ideal, since we want
all resources to be released immediatelly, without waiting for N seconds
until we can use the bus again.

The timeout mechanism works by calling chn_sleep() in chn_read() and
chn_write() (see pcm/channel.c) in order to send the thread to sleep,
using cv_timedwait_sig(). Since chn_sleep() sets the CHN_F_SLEEPING flag
while waiting for cv_timedwait_sig() to return, we can test this flag in
pcm_unregister() (called during detach) and wakeup the sleeping
thread(s) to immediately kill the channel(s) being consumed.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 months
PR:		194727
Reviewed by:	dev_submerge.ch, bapt, markj
Differential Revision:	https://reviews.freebsd.org/D43545

(cherry picked from commit 44e128fe9d92c1a544b801cb56e907a66ef34691)
2024-04-18 14:39:31 +02:00
Christos Margiolis
e6c51f6db8 sound: Get rid of snd_clone and use DEVFS_CDEVPRIV(9)
Currently the snd_clone framework creates device nodes on-demand for
every channel, through the dsp_clone() callback, and is responsible for
routing audio to the appropriate channel(s). This patch gets rid of the
whole snd_clone framework (including any related sysctls) and instead
uses DEVFS_CDEVPRIV(9) to handle device opening, channel allocation and
audio routing. This results in a significant reduction in code size as
well as complexity.

Behavior that is preserved:

- hw.snd.basename_clone.
- Exclusive access of an audio device (i.e VCHANs disabled).
- Multiple processes can read from/write to the device.
- A device can only be opened as many times as the maximum allowed
  channel number (see SND_MAXHWCHAN in pcm/sound.h).
- OSSv4 compatibility aliases are preserved.

Behavior changes:

Only one /dev/dspX device node is created (on attach) for each audio
device, as opposed to the current /dev/dspX.Y devices created by
snd_clone. According to the sound(4) man page, devices are not meant to
be opened through /dev/dspX.Y anyway, so it is best if we do not create
device nodes for them in the first place. As a result of this, modify
dsp_oss_audioinfo() to print /dev/dspX in the "ai->devnode", instead of
/dev/dspX.Y.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 months
Reviewed by:	dev_submerge.ch, bapt, markj
Differential Revision:	https://reviews.freebsd.org/D44411

(cherry picked from commit e8c0d15a64fadb4a330f2da7244becaac161bb70)
2024-04-18 14:39:26 +02:00