Commit graph

42383 commits

Author SHA1 Message Date
Emmanuel Vadot
183b64dfd8 linuxkpi: spinlock: Simplify code
Just use a typedef for spinlock_t, no need to create a useless
structure.

Reviewed by:		bz, emaste
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D45205

(cherry picked from commit ae38a1a1bfdf320089c254e4dbffdf4769d89110)

linuxkpi: Fix spin_lock_init

Some linux code re-init some spinlock so add MTX_NEW to mtx_init.

Reported by:	David Wolfskill <david@catwhisker.org>
Fixes:		ae38a1a1bfdf ("linuxkpi: spinlock: Simplify code")

(cherry picked from commit cff79fd02636f34010d8b835cc9e55401fa76e74)
2024-06-04 13:22:40 +02:00
Mark Johnston
54478f4b7e bnxt_re: Explicitly cast pointer-to-integer conversions
Reported by:	Jenkins
Fixes:	acd884dec99a ("RDMA/bnxt_re: Add bnxt_re RoCE driver")

(cherry picked from commit bbe42332e5b2cbe16a885360fad4462d13c7b357)
2024-06-03 13:23:15 -06:00
Sumit Saxena
93265fb21c RDMA/bnxt_re: Add bnxt_re RoCE driver
This patch introduces the RoCE driver for the
Broadcom NetXtreme-E 10/25/50/100/200G RoCE HCAs.

The RoCE driver is a two part driver that relies
on the bnxt_en NIC driver to operate. The changes
needed in the bnxt_en driver is included through
another patch "L2-RoCE driver communication interface"
in this set.

Presently, There is no user space support, Hence
recommendation to use the krping kernel module for
testing. User space support will be incorporated in
subsequent patch submissions.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45011

(cherry picked from commit acd884dec99adcf8c4cdd0aa8a50be79c216f8e8)
2024-06-03 13:23:15 -06:00
Chandrakanth patil
7a63abf952 bnxt_en: Driver version update to 230.0.133.0
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45010

(cherry picked from commit 862af86f4b7d2aec0623d19796e79cf96b4c7af6)
2024-06-03 13:23:14 -06:00
Chandrakanth patil
7f352c7d5f bnxt_en: Firmware header version update to 1.10.3.42
This file is automatically generated from the firmware code to
export the driver interfaces.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45009

(cherry picked from commit 3d8bbe001115f3e9742c128716335e654729ce1a)
2024-06-03 13:23:14 -06:00
Chandrakanth patil
9464f91b31 bnxt_en: Firmware error recovery support
Implement firmware error recovery support for Thor adapters.
This entails enabling the capability for the firmware to initiate
error recovery. Specifically, the firmware will send the reset notify
asynchronous event to notify the driver of an error and impending reset.
Subsequently, the driver will queue a task to execute the following steps.

1. Deactivate the allocated resources.
2. Await completion of the firmware's recovery process.
3. Configure the resources and reactivate the network interface.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45008

(cherry picked from commit c9965974a52b5dfad1737706b7f2623d999fb569)
2024-06-03 13:23:14 -06:00
Chandrakanth patil
fba2468e16 bnxt_en: Added support for priority queues extended stats
Below priority queues extended stats are exposed to sysctl:

tx_bytes_pri{0-7}
rx_bytes_pri{0-7}
tx_packets_pri{0-7}
rx_packets_pri{0-7}

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45007

(cherry picked from commit 032899b59c25389e60a0a092a0dad347102a6edc)
2024-06-03 13:23:14 -06:00
Chandrakanth patil
107e02d706 bnxt_en: L2-RoCE driver communication interface
- Added Aux bus support for RoCE.
- Implemented the ulp ops that are required by RoCE driver.
- Restructure context memory data structures
- DBR pacing support

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45006

(cherry picked from commit 050d28e13cdede7528944c0abf8d0455729c63fd)
2024-06-03 13:23:14 -06:00
Chandrakanth patil
ac940a8b92 bnxt_en: Add PFC, ETS & App TLVs protocols support
Created new directory "bnxt_en" in /dev/bnxt and /modules/bnxt
and moved source files and Makefile into respective directory.

ETS support:

   - Added new files bnxt_dcb.c & bnxt_dcb.h
   - Added sysctl node 'dcb' and created handlers 'ets' and
     'dcbx_cap'
   - Add logic to validate user input and configure ETS in
     the firmware
   - Updated makefile to include bnxt_dcb.c & bnxt_dcb.h

PFC support:

   - Created sysctl handlers 'pfc' under node 'dcb'
   - Added logic to validate user input and configure PFC in
     the firmware.

App TLV support:

   - Created 3 new sysctl handlers under node 'dcb'
       - set_apptlv (write only): Sets a specified TLV
       - del_apptlv (write only): Deletes a specified TLV
       - list_apptlv (read only): Lists all APP TLVs configured
   - Added logic to validate user input and configure APP TLVs
     in the firmware.

Added Below DCB ops for management interface:

   - Set PFC, Get PFC, Set ETS, Get ETS, Add App_TLV, Del App_TLV
     Lst App_TLV

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45005

(cherry picked from commit 35b53f8c989f62286aad075ef2e97bba358144f8)
2024-06-03 13:23:14 -06:00
Chandrakanth Patil
e7b0af020c if_bnxt: Set 1G/10G baseT force speed as auto speeds
The firmware lacks support for manually setting 1G and 10G baseT speeds.
However, the driver can enable auto speed masks to achieve automatic configuration
at these speeds.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42960

(cherry picked from commit 770e7ba3ebe87ba7ffc872c87de72707757b4e25)
2024-06-03 13:23:14 -06:00
Chandrakanth Patil
def6e32283 if_bnxt: 50G, 100G and 200G PAM4 support
Add support for 50G, 100G and 200G PAM4 support

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42959

(cherry picked from commit c63d67e137f353f4bc4d0d56bd793f83204a3e1e)
2024-06-03 13:23:13 -06:00
Sumit Saxena
43d9017a2f if_bnxt: Pluggable Module Display Support
This update enables the display of pluggable module information
to users via the ifconfig utility.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42958

(cherry picked from commit 3320f0f69f06df5c36daa8ff71e0c07908ff0f1a)
2024-06-03 13:23:13 -06:00
Chandrakanth Patil
9b5383c53e if_bnxt: Implementation of Extended Port Hardware Stats Support for THOR Controller
The newly added port extended hardware statistics are now accessible to
users through the sysctl interface. Also, Few obsolete stats are removed
and few stats are renamed.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42957

(cherry picked from commit d36b36621a9c0f785ebea495c57e975b8a526b67)
2024-06-03 13:23:13 -06:00
Chandrakanth Patil
1b5ff4b14d if_bnxt: Integrate AOC Cable Support into Current 40G PHY Speed
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D429506

(cherry picked from commit 816abba22efcf1ba51f61b1d89320ca8b576274e)
2024-06-03 13:23:13 -06:00
Chandrakanth Patil
51f6f533ba if_bnxt: Update Firmware Header to Latest Version 1.10.2.136
Update Firmware Header to Latest Version 1.10.2.136.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42955

(cherry picked from commit 25f38d09907fdfcc473fdc53c17b7c2d8c7c09a1)
2024-06-03 13:23:13 -06:00
Chandrakanth Patil
baa7cf2524 if_bnxt: Update Maximum Configurable MTU from 9000 to 9600
Increasing the maximum configurable MTU from 9000 to 9600 to
align with the firmware's capability of handling an MTU up to 9600.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42954

(cherry picked from commit 8a3aab53e335dadb3c95c0eb0664143a955f1ab7)
2024-06-03 13:23:13 -06:00
Chandrakanth Patil
c75f0a568e if_bnxt: Enabled support for 1G SX, CX, and LX forced speed settings
Enabled User Configuration of 1G Speed on Wh+ SFP28 Port with AOC
cable.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42953

(cherry picked from commit 0f8d1a9e0cd26bf4dd0b2fe2d28c1ab15d03cce4)
2024-06-03 13:23:13 -06:00
Chandrakanth Patil
30ae347bc1 if_bnxt: Incorrect Labeling of Supported Medium in ifconfig -m <inf> Command
The 1G speed on DAC medium is incorrectly labeled as 1000baseT, it
should be 1000baseCX. Updated the label accordingly.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42952

(cherry picked from commit c5108e37fbf93a538c76325766b8a3d76a72f119)
2024-06-03 13:23:12 -06:00
Chandrakanth Patil
6288beb31e if_bnxt: Fix media speed update issue in "ifconfig -m" during PHY hot plug
Currently, if a media type (e.g., DAC) is hot-plugged out and another type
(e.g., optical cable) is hot-plugged in, the new speed is not reflected in
ifconfig. This occurs when the driver fails to update speeds with unchanged
tx and rx flow control.

To fix, a phy_type check ensures update of phy speeds upon detecting the new
phy.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42951

(cherry picked from commit 7cbffbfcd9a5185be61bec65790674159bb7c0a8)
2024-06-03 13:23:12 -06:00
Sumit Saxena
4083c62d69 if_bnxt: Correcting the firmware package version parsing logic
The firmware package version currently appears as "Unknown" through
the sysctl interface. The parsing logic for extracting the firmware
package version from the package log has been modified to ensure
compatibility with all controllers.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D42950

(cherry picked from commit e436cb79666db3c8bb167d47ca9803c36013e32c)
2024-06-03 13:23:12 -06:00
Brooks Davis
38286d9f68 pcm: centralize 32-bit ioctl compat
Move all handlng of struct sndstioc_nv_arg(32) to sndstat_ioctl() and
make the functions that actually do the work take a buffer and size or
size pointer.  The 32-bit compat work is minimal so just inline it.

Remove checks that we've got a 32-bit process for 32-bit ioctls.  We
don't check that default ioctls are from 64-bit processes on 64-bit
systems.

Reviewed by:	christos
Differential Revision:	https://reviews.freebsd.org/D45307

(cherry picked from commit fb9013f215211f013eccc54786f299e39a1f8773)
2024-05-26 15:51:33 +02:00
Christos Margiolis
0aa767021c sound: Fix minchn, maxchn and fmts in sndstat_get_caps()
The current implementation (incorrectly) passes the channel encoding
value to AFMT_CHANNEL(), which will always return 0, since the channel
number bits are masked out by AFMT_ENCODING().

Also add missing fmts initialization and aggregate encoding formats into
it directly.

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

(cherry picked from commit 425a7bc465d4a6393c88c2e79c5ad77befda2a97)
2024-05-25 21:31:26 +02:00
Christos Margiolis
ab7c894154 sound: Handle unavailable devices in various OSS IOCTLs
mixer(8)'s -a option is used to print information about all mixer
devices in the system. To do this, it loops from 0 to
mixer_get_nmixers(), and tries to open "/dev/mixer%d". However, this
approach doesn't work when there are disabled/unregistered mixers in the
system, or when an audio device simply doesn't have a mixer.

mixer_get_nmixers() calls SNDCTL_SYSINFO and returns
oss_sysinfo->nummixers, whose value is the number of currently _enabled_
mixers only. Taking the bug report mentioned below (277615) as an
example, suppose a system with 8 mixer devices total, but 3 of them are
either disabled or non-existent, which means they will not show up under
/dev, meaning we have 5 enabled mixer devices, which is also what the
value of oss_sysinfo->nummixers will be. What mixer(8) will do is loop
from 0 to 5 (instead of 8), and start calling mixer_open() on
/dev/mixer0, up to /dev/mixer4, and as is expected, the first call will
fail right away, hence the error shown in the bug report.

To fix this, modify oss_sysinfo->nummixers to hold the value of the
maximum unit in the system, which, although not necessarily "correct",
is more intuitive for applications that will want to use this value to
loop through all mixer devices.

Additionally, notify applications that a device is
unavailable/unregistered instead of skipping it. The current
implementations of SNDCTL_AUDIOINFO, SNDCTL_MIXERINFO and
SNDCTL_CARDINFO break applications that expect to get information about
a device that is skipped. Related discussion can be found here:
https://reviews.freebsd.org/D45135#1029526

It has to be noted, that other applications, apart from mixer(8), suffer
from this.

PR:		277615
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45256

(cherry picked from commit 5d980fadf73df64a1e0eda40a93170ed76ce6f14)
2024-05-25 21:30:40 +02:00
Christos Margiolis
e8a80b4e50 sound: Separate implementations for SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO
FreeBSD's implementation of SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO
does not exactly work as intended. The problem is essentially that both
IOCTLs return the same information, while in fact the information
returned currently by dsp_oss_audioinfo() is what _only_
SNDCTL_ENGINEINFO is meant to return.

This behavior is also noted in the OSS manual [1] (see bold paragraph in
"Audio engines and device files" section), but since e8c0d15a64fa
("sound: Get rid of snd_clone and use DEVFS_CDEVPRIV(9)") we can
actually fix this, because we now expose only a single device for each
soundcard, and create the engines (channels) internally.
SNDCTL_ENGINEINFO will now report info about all channels in a given
device, and SNDCTL_AUDIOINFO[_EX] will only report information about
/dev/dspX.

To make this work, we also have to modify the SNDCTL_SYSINFO IOCTL to
report the number of audio devices and audio engines correctly.

While here, modernize the minimum and maximum channel counting in both
SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO. Currently these IOCTLs will
report only up to 2 channels, which is no longer the case.

[1] http://manuals.opensound.com/developer/SNDCTL_AUDIOINFO.html

PR:		246231, 252761
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45164

(cherry picked from commit e07f9178502b7cbc0769fc10e99ad0d013f437fd)
2024-05-25 21:30:26 +02:00
Lutz Bichler
1fb0a65ab2 snd_hda: Add patch for Asus UX331UAL
PR:		242802
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D45238

(cherry picked from commit 93ad59a251897431627345c287390ae134925a95)
2024-05-23 02:24:15 +02:00
Lexi Winter
07f3a9eb1c alc(4): disable MSI-X by default on Killer cards
Several users with alc(4)-based "Killer" Ethernet cards have reported
issues with this driver not passing traffic, which are solved by
disabling MSI-X using the provided tunable.

To work around this issue, disable MSI-X by default on this card.

This is done by having msix_disable default to 2, which means
"auto-detect".  The user can still override this to either 0 or 1 as
desired.

Since these are slow (1Gbps) Ethernet ICs used in low-end systems, it's
unlikely this will cause any practical performance issues; on the other
hand, the card not working by default likely causes issues for many new
FreeBSD users who find their network port doesn't work and have no idea
why.

PR:		230807
MFC after:	1 week

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1185

(cherry picked from commit 05a95d19cb248203acdd4e069d3eedfe597c3b49)
2024-05-21 13:43:34 -06:00
Christos Margiolis
45feaa73c6 sound: Correctly check nvlist_unpack() error
The current check is never false and if nvlist_unpack() fails, we might
panic later down the road.

PR:		266144
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch, emaste
Differential Revision:	https://reviews.freebsd.org/D45237

(cherry picked from commit 64f4e2db6d19d8ab520903a197fcaa8cc7ab9f9a)
2024-05-21 19:45:55 +02:00
Christos Margiolis
5830a00c2c sound: Check user-supplied size passed to SNDSTIOC_ADD_USER_DEVS*
SNDSTIOC_ADD_USER_DEVS* expects a user-supplied sndstioc_nv_arg->nbytes,
however we currently do not check whether this size is actually valid,
which results in a panic when SNDSTIOC_ADD_USER_DEVS* is called with an
invalid size. sndstat_add_user_devs() calls
sndstat_unpack_user_nvlbuf(), which then calls malloc() with that size.

PR:		266142
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D45236

(cherry picked from commit 074d337ad618f9cc2a1d5ab18b484928e57bd72b)
2024-05-21 19:45:49 +02:00
Christos Margiolis
bca6f391ae sound: Prevent uninitialized variable destruction in chn_init()
If dsp_unit2name() fails, we'll get to out2 with b, bs and devinfo
uninitialized, which will result in a panic.

Reported by:	Pierre Pronchery <pierre@freebsdfoundation.org>
Reported by:	Coverity Scan
CID:		1545029, 1545025
Pull-request:	https://github.com/freebsd/freebsd-src/pull/1240
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45272

(cherry picked from commit 5d1a5d6f1f599a4fbea9634cbe5c77f7370e1a5d)
2024-05-21 19:45:41 +02:00
Christos Margiolis
8a15d5e722 sound: Get rid of redundant assignments in chn_init()
c is allocated with M_ZERO.

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

(cherry picked from commit 2db2292dac7331be5414f86c3ef7863c7b6a4ac6)
2024-05-21 19:45:30 +02:00
Lexi Winter
7aba922879 sys/dev/irdma/irdma_cm: fix compile without INET
irdma_get_vlan_ipv4() calls ip_ifp_find() even if INET isn't defined, in
which case this function isn't available.

Stub this out for the non-INET case to return an error (0xffff) instead.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1156

(cherry picked from commit 0478a0356272ab3907af9d97711f0bb8b14bf38b)
2024-05-20 21:10:46 -06:00
Mark Johnston
160e7a4c16 wg: Add netmap support
When in netmap (emulated) mode, wireguard interfaces prepend or strip a
dummy ethernet header when interfacing with netmap.  The netmap
application thus sees unencrypted, de-encapsulated frames with a fixed
header.

In this mode, netmap hooks the if_input and if_transmit routines of the
ifnet.  Packets from the host TX ring are handled by wg_if_input(),
which simply hands them to the netisr layer; packets which would
otherwise be tunneled are intercepted in wg_output() and placed in the
host RX ring.

The "physical" TX ring is processed by wg_transmit(), which behaves
identically to wg_output() when netmap is not enabled, and packets
appear in the "physical" RX ring by hooking wg_deliver_in().

Reviewed by:	vmaffione
MFC after:	1 month
Sponsored by:	Klara, Inc.
Sponsored by:	Zenarmor
Differential Revision:	https://reviews.freebsd.org/D43460

(cherry picked from commit bf454ca88bdf4acfa873386e876ff5e772e6a830)
2024-05-20 09:42:35 -04:00
Christos Margiolis
a19d42b08a sound: Remove ncards variable from sound_oss_card_info()
The loop counter is also the card's index, so ncards is redundant.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45144

(cherry picked from commit 305db91d4b92a5d53826dcb6df39fc8a1f3b427e)
2024-05-17 21:30:36 +02:00
Christos Margiolis
7814ed2bd3 snd_hda: Rename LENOVO_I* to LENOVO_IDEAPAD*
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45105

(cherry picked from commit 278953360e0e6187c3f7c688cb49254df1567f0b)
2024-05-17 21:30:36 +02:00
Christos Margiolis
9a620018af snd_hda: Add patch for Lenovo Ideapad 3
Reported by:	bsd-lists@bsdforge.com
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45100

(cherry picked from commit 54cc353f505dbc5f19168b6b1417b6736433d9ae)
2024-05-17 21:30:36 +02:00
Christos Margiolis
15aa8688d0 sound: Rename oss_audioinfo->real_device to oss_audioinfo->legacy_device
The OSS manual now documents this field as "legacy_device".

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45138

(cherry picked from commit 24d5cc14dd60b49553ff3ee7830305621f782ff1)
2024-05-17 21:30:36 +02:00
Christos Margiolis
8bd14f511e sound: Add missing oss_mixerinfo devnode and legacy_device fields
They are missing from soundcard.h and are in fact used by some
applications, such as OSS' ossinfo(1):
http://manuals.opensound.com/developer/ossinfo.c.html

The new size for filler is chosen according to the most recent official
version of soundcard.h, which includes those 2 fields.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45137

(cherry picked from commit e6df8c379b0cf2f6d715d4903fcb1f279e38173e)
2024-05-17 21:30:36 +02:00
Christos Margiolis
2b36982887 sound: Fix oss_sysinfo->numcards
According to the OSS manual, oss_sysinfo->numcards holds the number of
detected audio devices in the system, while the current ncards variable,
whose value is assigned to oss_sysinfo->numcards, holds the number of
currently registered devices only.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch, emaste
Differential Revision:	https://reviews.freebsd.org/D45136

(cherry picked from commit 59d98edae3e1a6fffd292e4393c49862d624f25f)
2024-05-17 21:30:36 +02:00
Christos Margiolis
8b4e2ba31d sound: Remove nmix variable from mixer_oss_mixerinfo()
nmix is used to compare against oss_mixerinfo->dev, which is a
user-supplied value to select the mixer device (if not -1, in which case
we'll select the default one) we want to fetch the information of. It is
also used to set oss_mixerinfo->dev in case it is -1.

However, nmix is at best redundant, since we have the loop counter
already (i), and confusing at worst.

For example, suppose a system with 3 mixer devices. We call
SNDCTL_MIXERINFO with oss_mixerinfo->dev=1, meaning we want to get
information for /dev/mixer1. Suppose /dev/mixer0 detaches while inside
the loop, so we'll hit the loop's "continue" case, and nmix won't get
incremented (i.e will stay 0 for now). At this point nmix counts 1
device less, so when it reaches 1, we'll be fetching /dev/mixer2's
information instead of /dev/mixer1's.

This is also true in case the mixer device disappears prior to the call
to mixer_oss_mixerinfo().

Simply remove nmix and use the loop counter to both set
oss_mixerinfo->dev and check against it in case a non -1 value is
supplied.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45135

(cherry picked from commit 2f31a5eb75f1e47b5c49f574e8ce48d2c863e9d3)
2024-05-17 21:30:36 +02:00
Christos Margiolis
00f9d84ee2 sound: Update pcm/vchan.c LICENSE header
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week

(cherry picked from commit 2b14465faa8dd9d228b764359672b38b4c8ca8c1)
2024-05-17 21:30:35 +02:00
Christos Margiolis
17a50abe0e sound: Remove unused "num" argument from chn_init() and related callers
It is always -1 (i.e unused).

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

(cherry picked from commit 3af2beb8b24ba21fb7e7fbd165a79b8eeff37712)
2024-05-17 21:30:35 +02:00
Christos Margiolis
99e372420d sound: Rename pcm_getparentchannel() to vchan_getparentchannel()
Follow the rest of the vchan.c naming convention.

No functional change intended.

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

(cherry picked from commit 77ab4263bc42a5dcc102bbea39ce4f7f46b8d4f8)
2024-05-17 21:30:35 +02:00
Christos Margiolis
ab7c01f9e8 sound: Move vchan-related code to pcm/vchan.*
pcm/sound.* contains code that should be part of pcm/vchan.*.

Changes:
- pcm_setvchans() -> vchan_setnew()
- pcm_setmaxautovchans() -> vchan_setmaxauto()
- hw.snd.maxautovchans moved to pcm/vchan.c
- snd_maxautovchans declaration moved to pcm/vchan.h and definition to
  pcm/vchan.c

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

(cherry picked from commit 7ad5f383fcb507482d5606c8eb7a324b3621a9db)
2024-05-17 21:30:35 +02:00
Christos Margiolis
00b0cbf98b sound: Use nitems() where possible
No functional change intended.

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

(cherry picked from commit c597c557923288eff527594619a692a44ade909a)
2024-05-17 21:30:35 +02:00
Christos Margiolis
6f6cc93241 sound: Remove unused dsp_cdevs[] fields and devices
These fields and devices are unused as of e8c0d15a64fa ("sound: Get rid
of snd_clone and use DEVFS_CDEVPRIV(9)").

While here, remove unused SND_DEV_* defines from pcm/sound.h and convert
the list to an enum.

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

(cherry picked from commit 72cbd381075a2eb22a070505334d1ce92ec2d7ad)
2024-05-17 21:30:35 +02:00
Christos Margiolis
e14f7d11cb sound: Move chip.h contents to pcm/sound.h
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44997

(cherry picked from commit 923e0040a59af8ac2271d3e673fef1c641d0cce7)
2024-05-17 21:30:35 +02:00
Christos Margiolis
d1eaefde3b sound: Remove hw.snd.version and SND_DRV_VERSION
hw.snd.version and SND_DRV_VERSION define the sound driver version and
are meant to be used in bug reports, but because these values are
constant, there is not much useful information we can extract from them.

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

(cherry picked from commit 7398d1ece5cfa2e6ce4997234a95115b49c9e818)
2024-05-17 21:30:35 +02:00
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