FreeBSD/src 001332bsys/dev/hyperv/netvsc if_hn.c

hn: Handle unavailable VF RSS configuration

Treat unsupported RSS queries and RSS_FUNC_NONE as normal reasons to
suppress synthetic receive hash metadata.  Keep diagnostics for other
errors and invalid configurations.  Also suppress hash metadata when
reconfiguring synthetic RSS fails, since the VF and synthetic settings
cannot then be assumed to agree.  Correct the hash-query diagnostic name.

MFC after:      2 weeks
Sponsored by:   BBOX.io
Differential Revision:  https://reviews.freebsd.org/D59691
DeltaFile
+12-6sys/dev/hyperv/netvsc/if_hn.c
+12-61 files

FreeBSD/src a3880afsys/net iflib.c ifdi_if.m

iflib: Add optional RSS configuration queries

Dispatch SIOCGIFRSSKEY and SIOCGIFRSSHASH through typed get_rss_key and
get_rss_hash methods under the context lock.  Drivers can report their
programmed key and hash selections.  The default methods return EOPNOTSUPP.

The common RSS key does not describe which hash selections a particular
device actually programs.  hn(4) needs the effective VF configuration when
synchronizing RSS between its synthetic and VF receive paths.

Reviewed by:    iflib (gallatin)
MFC after:      2 weeks
Sponsored by:   BBOX.io
Differential Revision:  https://reviews.freebsd.org/D59691
DeltaFile
+26-0sys/net/ifdi_if.m
+10-0sys/net/iflib.c
+36-02 files

FreeBSD/src 597798asys/netinet tcp_subr.c

tcp: use sparse initializer for host cache metrics

Reviewed by:            tuexen
Differential Revision:  https://reviews.freebsd.org/D59453
DeltaFile
+8-11sys/netinet/tcp_subr.c
+8-111 files

FreeBSD/src 587c6c1sys/netinet tcp_subr.c

tcp: turn on TCP hostcache for socket buffer sizes

The code has been there since introduction of the TCP hostcache
in 97d8d152c28bb in 2003, but was turned off.

Reviewed by:            tuexen, cc
Differential Revision:  https://reviews.freebsd.org/D59452
DeltaFile
+2-2sys/netinet/tcp_subr.c
+2-21 files

FreeBSD/src f8f05fesys/netinet tcp_hostcache.c in_kdtrace.h, usr.bin/netstat inet.c

tcp: collect and report more statistics on the TCP host cache

Reviewed by:            tuexen
Differential Revision:  https://reviews.freebsd.org/D59451
DeltaFile
+33-16usr.bin/netstat/inet.c
+10-3sys/netinet/tcp_var.h
+8-4sys/netinet/tcp_hostcache.c
+9-3sys/netinet/in_kdtrace.h
+9-3sys/netinet/in_kdtrace.c
+69-295 files

FreeBSD/src 8a37f8cshare/man/man9 buf_ring.9, sys/dev/cxgb cxgb_sge.c cxgb_main.c

buf_ring: use counter(9) for drops

If a buffer ring experiences drops, then system is definitely starving in
CPU resources.  Having an extra cache miss on a racy shared variable
increment doesn't help.

Reviewed by:            gallatin
Differential Revision:  https://reviews.freebsd.org/D59495
DeltaFile
+18-3sys/sys/buf_ring.h
+10-1share/man/man9/buf_ring.9
+7-0sys/kern/subr_bufring.c
+1-1sys/dev/mxge/if_mxge.c
+1-1sys/dev/cxgb/cxgb_sge.c
+1-1sys/dev/cxgb/cxgb_main.c
+38-76 files

FreeBSD/src 3b498d5share/man/man9 buf_ring.9, sys/kern subr_bufring.c

buf_ring: support different lock classes

And enable locking assertions for INVARIANTS kernel.

Reviewed by:            gallatin, kib, markj
Differential Revision:  https://reviews.freebsd.org/D59457
DeltaFile
+19-19sys/sys/buf_ring.h
+8-3share/man/man9/buf_ring.9
+3-4sys/kern/subr_bufring.c
+2-1sys/netinet/ip_mroute.c
+1-1sys/net/if_ovpn.c
+33-285 files

FreeBSD/src 11d26e3share/man/man9 callout.9, sys/sys callout.h

callout: provide callout_init_lock()

This is type agnostic locked callout initializer.  The callout_init_mtx()
and etc remain for compatibility.

Reviewed by:            kib, markj
Differential Revision:  https://reviews.freebsd.org/D59456
DeltaFile
+24-27share/man/man9/callout.9
+9-6sys/sys/callout.h
+33-332 files

FreeBSD/src 0e7c7cfsys/sys lock.h

locks: provide a macro to extract lock_object from various lock types

To be used in _Generic() KPIs that accept different lock types.

Reviewed by:            kib
Differential Revision:  https://reviews.freebsd.org/D59455
DeltaFile
+10-0sys/sys/lock.h
+10-01 files

FreeBSD/src 17af098usr.sbin/virtual_oss/virtual_oss main.c

Revert "virtual_oss(8): Fix cuse.ko check"

parse_options() was moved above cuse_init(), which makes every single
regular virtual_oss invocation which uses cuse_dev_create() fail.

This reverts commit f014795ec3bd5efb88dfc249599e9665dc10a59e.
DeltaFile
+5-11usr.sbin/virtual_oss/virtual_oss/main.c
+5-111 files

FreeBSD/src 73ce582sys/netpfil/pf pf_nl.c

pf: table_addr_parser parses to struct nl_parsed_table_addrs

Not to struct pfioc_table.

MFC after:      1 week
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+5-5sys/netpfil/pf/pf_nl.c
+5-51 files

FreeBSD/src 47cf9dcsys/dev/sound/pcm mixer.c

sound: Lock around mixer_set*() in mixer_init() for consistency

Sponsored by:   The FreeBSD Foundation
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59110
DeltaFile
+5-0sys/dev/sound/pcm/mixer.c
+5-01 files

FreeBSD/src 044ef29sys/dev/sound/pcm mixer.c

sound: Remove unncessary locking in sysctl_hw_snd_hwvol_mixer()

The locking around strlcpy() was because of m->hwvol_mixer, but this is
just an int, so we don't need to lock in this case. Instead lock only
when m->hwvol_mixer is written.

While here, add parentheses around the returns.

Sponsored by:   The FreeBSD Foundation
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59109
DeltaFile
+6-12sys/dev/sound/pcm/mixer.c
+6-121 files

FreeBSD/src db62d78sys/dev/sound/pcm mixer.c

sound: Improve some mixer return values and their handling

Sponsored by:   The FreeBSD Foundation
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59078
DeltaFile
+10-10sys/dev/sound/pcm/mixer.c
+10-101 files

FreeBSD/src 6c73547sys/dev/sound/pcm mixer.c

sound: Reuse mixer_delete() in mixer_uninit()

Sponsored by:   The FreeBSD Foundation
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59077
DeltaFile
+1-7sys/dev/sound/pcm/mixer.c
+1-71 files

FreeBSD/src 03b59d2sys/dev/sound/pcm mixer.c

sound: Do not set a recording source in mixer_uninit()

We currently set the recording source to SOUND_MIXER_MIC during mixer
deletion. Apart from the fact that this control might not be present on
all devices, it is unnecessary to do that, plus we already set all the
volumes to 0 in the mixer_set() call above.

Sponsored by:   The FreeBSD Foundation
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59076
DeltaFile
+0-2sys/dev/sound/pcm/mixer.c
+0-21 files

FreeBSD/src 9548bfasys/dev/sound/pcm mixer.h mixer.c, sys/dev/sound/usb uaudio.c

sound: Retire mixer_hwvol locked variants

Prior to 9a00e0b8ca56 ("snd_uaudio: Do not use snd_mixer->lock as
mixer_lock"), there was a need for mixer_hwvol_mute_locked() and
mixer_hwvol_step_locked(), because the unlocked variants would acquire
the lock, but uaudio_hid_rx_callback() would also hold the lock, so this
was a measure to avoid recursion on snd_mixer->lock. Now that
snd_uaudio(4) has a private mixer lock, the locked variants are not only
unnecessary, but wrong, because we now lock the private lock and not the
snd_mixer one, which is what mixer_hwvol_mute_locked() and
mixer_hwvol_step_locked() expect. Retire the locked variants and call
the regular functions instead.

The unlocked variants take the mixer lock, which is now the PCM lock,
and reach uaudio_mixer_ctl_set(), which takes mixer_lock. Calling them
straight from uaudio_hid_rx_callback() would therefore take mixer_lock
and the PCM lock in the opposite order to the mixer ioctl path, so
record what the HID report asked for and perform the volume change at
the end of the callback, with mixer_lock dropped. The USB stack allows a

    [5 lines not shown]
DeltaFile
+28-3sys/dev/sound/usb/uaudio.c
+5-19sys/dev/sound/pcm/mixer.c
+0-2sys/dev/sound/pcm/mixer.h
+33-243 files

FreeBSD/src 1a31ab1sys/dev/sound/pcm mixer.h channel.c

sound: Use snddev_info->lock in place of snd_mixer->lock

snd_mixer and snddev_info have a 1:1 relationship. Now that snd_mixer is
embedded into snddev_info, it makes even more sense for both to share
the PCM lock. The only exceptions to this are MIXER_TYPE_SECONDARY
mixers, which still retain a private lock (snd_mixer->priv_lock),
because they are attached to the device driver, and not snddev_info.
Only snd_emu10kx(4) uses a secondary mixer.

A side-effect of this is that the MIXER_SET_LOCK()/MIXER_SET_UNLOCK()
mess goes away. These macros were used in the mixer_set*() functions to
drop the mixer lock if the driver is Giant-locked and the function can
sleep inside MIXER_SET*() methods, and to avoid an LOR before locking
PCM to guard channel list traversal.

Since mixers now use the PCM lock, drop the channel lock in
chn_syncstate() before calling mix_get(), to avoid an LOR. These lines
were actually already commented out for years.


    [3 lines not shown]
DeltaFile
+46-123sys/dev/sound/pcm/mixer.c
+4-4sys/dev/sound/pcm/channel.c
+2-1sys/dev/sound/pcm/mixer.h
+52-1283 files

FreeBSD/src b976154sys/dev/sound/macio tumbler.c snapper.c

sound: Defer macio codec volume writes to a task

tumbler(4), snapper(4) and onyx(4) write the volume over I2C, and
iicbus_transfer() sleeps. This is why mixer_set() drops the mixer lock
around MIXER_SET() for non-MPSAFE drivers, relying on Giant to keep them
serialized.

Store the volume in the softc and let a task do the I2C write with no
lock held, so that the mixer method does not sleep at all. The lock
dropping for non-MPSAFE drivers will be removed in a follow-up patch.

Sponsored by:   The FreeBSD Foundation
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59073
DeltaFile
+40-2sys/dev/sound/macio/onyx.c
+36-1sys/dev/sound/macio/tumbler.c
+36-1sys/dev/sound/macio/snapper.c
+112-43 files

FreeBSD/src a614c07sys/dev/sound/pci es137x.c, sys/dev/sound/pcm sound.h mixer.h

sound: Embed mixer cdev in snd_mixer

The mixer cdev belongs to the mixer, not to the PCM device, so move it
from snddev_info->mixer_dev into a new snd_mixer->cdev field. snd_mixer
itself is now included in snddev_info.

Also add a MIXER_REGISTERED() macro similar to PCM_REGISTERED().

Sponsored by:   The FreeBSD Foundation
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59071
DeltaFile
+17-20sys/dev/sound/pcm/mixer.c
+8-8sys/dev/sound/pcm/dsp.c
+3-0sys/dev/sound/pcm/mixer.h
+1-1sys/dev/sound/pci/es137x.c
+0-1sys/dev/sound/pcm/sound.h
+29-305 files

FreeBSD/src 221babdsys/dev/sound/pci es137x.c, sys/dev/sound/pcm feeder_volume.c channel.c

sound: Simplify how snd_mixer is fetched and how the cdev is created

The primary snd_mixer was reached by accessing the mixer cdev's si_drv1.
This is tedious and ugly, so store the mixer in snddev_info->mixer and
access it directly.

Additionally, create the cdev in a new mixer_make_dev() function (in
similar fashion to dsp_make_dev()) in pcm_register(), when everything is
initialized, instead of risking potential races because mixer_init()
(called before pcm_register()) used to create the cdev.

Also add some NULL checks in pcm_register(), to avoid creating a mixer
cdev when the driver (e.g., fdt/audio_soc.c) does not create a mixer in
the first place, and similarly in pcm_unregister().

Sponsored by:   The FreeBSD Foundation
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59070
DeltaFile
+53-36sys/dev/sound/pcm/mixer.c
+10-2sys/dev/sound/pcm/sound.c
+2-3sys/dev/sound/pci/es137x.c
+1-3sys/dev/sound/pcm/dsp.c
+1-2sys/dev/sound/pcm/channel.c
+1-1sys/dev/sound/pcm/feeder_volume.c
+68-472 files not shown
+70-478 files

FreeBSD/src 13fcc9csys/dev/sound/fdt audio_soc.c, sys/dev/sound/macio aoa.c i2s.c

sound: Standardize mixer_init() call order

Device drivers call mixer_init() in a non-standard order - some before
pcm_init(), and some after pcm_register(). However, both approaches are
potentially risky, and logically weak, since pcm_register() is supposed
to be the function that finalizes sound(4) attach.

Standardize the call ordering by moving all mixer_init() calls after
pcm_init(). This is also necessary for a follow-up patch, which expects
pcm_init() to have run first and initialized the PCM lock.

Sponsored by:   The FreeBSD Foundation
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D59069
DeltaFile
+11-8sys/dev/sound/macio/davbus.c
+8-7sys/dev/sound/usb/uaudio.c
+6-6sys/dev/sound/pci/hda/hdaa.c
+8-4sys/dev/sound/macio/i2s.c
+5-4sys/dev/sound/fdt/audio_soc.c
+5-1sys/dev/sound/macio/aoa.c
+43-3027 files not shown
+85-6733 files

FreeBSD/src f014795usr.sbin/virtual_oss/virtual_oss main.c

virtual_oss(8): Fix cuse.ko check

virtual_oss(8) checks if cuse(3) is loaded. However, kldload(2) ends up calling
kern_kldload that checks permissions first. It is only later on in
linker_load_module that -EEXIST is returned if the module is already loaded.
That means that users that can't load modules, always get a -EPERM error first
even if cuse.ko is already loaded and ready to use.

Change it to check if the kernel module is already loaded and try load it if it
isn't.

In addition move the program's arguments parsing early on because otherwise, a
user can't even access the program's help if cuse.ko is not loaded and the
user doesn't have permissions to do it.

Approved by:            obiwac@
Differential Revision:  https://reviews.freebsd.org/D59621
DeltaFile
+11-5usr.sbin/virtual_oss/virtual_oss/main.c
+11-51 files

FreeBSD/src 1181ac7sys/dev/vt vt_core.c

vt: Reprogram display controller on KDSETMODE KD_TEXT for active window

When a graphical application (X.Org display server, Wayland compositor)
calls KDSETMODE to set the active VT back to KD_TEXT, vt(4) does not
reset the CRTC to point to its framebuffer, leaving the last image of
the graphical application visible instead of the text console until the
next VT switch.

Add a call to vd_postswitch to reset the CRTC, set VDF_INVALID to force
a redraw and schedule the flush timer, like vt(4) does in
vt_window_switch().

Sponsored by: Defenso

Signed-off-by: Quentin Thébault <quentin.thebault at defenso.fr>

Reviewed by:    vexeduxr
Pull request: https://github.com/freebsd/freebsd-src/pull/2308
DeltaFile
+23-1sys/dev/vt/vt_core.c
+23-11 files

FreeBSD/src b774fbdlib/libc/tests/db db_hash_tamper_test.c

libc/db: Correct a typo in the the hash tampering test

Fixes the gcc build.

Fixes:  7f5f07b139a5
DeltaFile
+1-1lib/libc/tests/db/db_hash_tamper_test.c
+1-11 files

FreeBSD/src 962125asys/kern sched_ule.c sched_4bsd.c, sys/sys sched.h

sched: rename sched_schedcpu() to sched_sysinit()

sched_schedcpu() is called only during SYSINIT to start kthread that
calls schedcpu() every second in 4BSD, but its name implies it's doing
what 4BSD's schedcpu() does. Rename this function to sched_sysinit() to
mark that schedulers can use it for its own SYSINIT routine. Note that
their SYSINIT routine does not necessarily need to be similar to 4BSD's
decay in schedcpu().

The scheduler.9 man page is planned to be rewritten from scratch, so no
change to it for now.

Reviewed by:    olce
Approved by:    olce (mentor)
MFC after:      2 weeks
Sponsored by:   FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D59437
DeltaFile
+3-3sys/kern/sched_shim.c
+2-2sys/kern/sched_ule.c
+2-2sys/kern/sched_4bsd.c
+2-1sys/sys/sched.h
+9-84 files

FreeBSD/src cd33abbsys/kern sched_4bsd.c

sched_4bsd: fix vague comment

The comment "was incremented in schedcpu()" doesn't give enough
background for decrementing ts_slptime by 1 (thus ignoring decay_cpu()
for 1 ts_slptime). More accurately, ts_slptime is decremented by 1
because decay_cpu() has already executed once in schedcpu() when
ts_slptime was 1.

Reviewed by:    olce
Approved by:    olce (mentor)
MFC after:      2 weeks
Sponsored by:   FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D59406
DeltaFile
+2-1sys/kern/sched_4bsd.c
+2-11 files

FreeBSD/src 5a87939sys/kern sched_4bsd.c sched_ule.c

sched: factor out hogticks calculation into sched_update_hogticks()

Suggested by:   olce
Reviewed by:    olce
Approved by:    olce (mentor)
MFC after:      2 weeks
Sponsored by:   FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D59471
DeltaFile
+11-6sys/kern/sched_ule.c
+10-6sys/kern/sched_4bsd.c
+21-122 files

FreeBSD/src 5803063sys/kern sched_ule.c

sched_ule: fix typo in comment

Reviewed by:    olce
Approved by:    olce (mentor)
MFC after:      2 weeks
Sponsored by:   FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D59409
DeltaFile
+1-1sys/kern/sched_ule.c
+1-11 files

FreeBSD/src 872074csys/kern sched_ule.c

sched_ule: fix comment on ts_slice

In ULE ts_slice stores the number of ticks of slice passed not
remaining.

Reviewed by:    olce
Approved by:    olce (mentor)
MFC after:      2 weeks
Sponsored by:   FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D59407
DeltaFile
+1-1sys/kern/sched_ule.c
+1-11 files