Commit graph

43704 commits

Author SHA1 Message Date
John Baldwin
ba6c35f0ca usb: Use bus_detach_children instead of bus_generic_detach
The USB bus performs additional teardown steps in between detaching
child devices and deleting child devices.

Reported by:	phk, thj
Tested by:	phk
Fixes:		e9d3857040 ("Use bus_detach_children instead of bus_generic_detach")
2025-03-12 10:54:49 -04:00
Slava Shwartsman
7008b9fab5 mlx5: Fix BlueField-4 device description
BlueField-4 will not be based on ConnectX-8. Remove the wrong description

Sponsored by:   NVidia networking
MFC after:      1 week
2025-03-12 00:47:26 +02:00
Warner Losh
048d6ca31d umass: Remove some 20-year-old dead code
A REQUEST SENSE CDB was just copied into the cmd buffer, so testing for
INQUIRY will always fail.  Remove the dead code.

This code was added, apparently by mistake in 2003.  8541fbec79
merged changes from NetBSD's umass_scsipi.c 1.8 to address some BBB
bulk-in clear problems. NetBSD had fixed a problem in the
FORCE_SHORT_INQUIRY quirk code they had ported from FreeBSD that FreeBSD
also needed. That merge also included the dead code, which was not in
NetBSD.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D49311
2025-03-10 20:33:15 -06:00
Christos Margiolis
717adecbbb sound: Make feed_mixer_apply() __always_inline
Reported by:	mav
Fixes:		4021fa32d9 ("sound: Simplify pcm/feeder_mixer.c")
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2025-03-10 22:16:08 +01:00
Christos Margiolis
c824383b26 sound: Update COPYRIGHT notices
Only to files I've currently made significant contributions to.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2025-03-10 21:47:44 +01:00
Christos Margiolis
ab95710f30 sound: Make dev.pcm.X.mode dynamic
Currently dev.pcm.X.mode is calculated only once in pcm_sysinit(), which
is called by pcm_register() during attach, but this can result in
inconsistencies.

For some context, what pcm_mode_init() does is, it checks if "playcount"
is positive, in which case we assume the device supports playback. The
same is done for "reccount" for recording, and if "mixer_dev" is not
NULL, we know the device has a mixer.

The "playcount" and "reccount" variables correspond to the number of
_primary_ playback/recording channels, so we can assume that the primary
channels have been created before reaching pcm_mode_init(). However, for
the mixer that's not always the case. If the mixer is created _after_
pcm_register(), as is the case for snd_dummy(4) for example,
pcm_mode_init() will see that "mixer_dev" is NULL, and report that the
device does not have a mixer, whereas in reality we just created it
afterwards.

While this could be fixed by simply creating the mixers always before
pcm_register(), it is better to be robust and calculate the mode
dynamically.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D49024
2025-03-10 21:47:39 +01:00
Christos Margiolis
b768f2c777 sound: Retire SD_F_AUTOVCHAN
This flag is redundant and essentially a no-op, as it is set when the
device supports at least playback or recording, which is almost always
the case. But even if the device is mixer-only (i.e., 0 channels), there
is no reason to keep this flag; it is only used to bail out of the vchan
sysctl handlers, but we already bail out anyway if we try to use the
sysctl in a vchan direction that is not supported.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D49021
2025-03-10 21:47:35 +01:00
Christos Margiolis
2fda859711 sound: Take dsp_cdevsw out of header file
Not used outside of pcm/dsp.c.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D49217
2025-03-10 21:47:28 +01:00
Christos Margiolis
4021fa32d9 sound: Simplify pcm/feeder_mixer.c
- Get rid of macro magic.
- Make feed_mixer_info handling similar to most feeders.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48394
2025-03-10 21:38:23 +01:00
Christos Margiolis
b73b5f70e9 sound: Remove feed_matrix_apply_generic()
It does what feed_matrix_apply() already does, so it is redundant.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48036
2025-03-10 21:19:46 +01:00
Christos Margiolis
ac24c9da8b sound: Remove macro magic from pcm/feeder_matrix.c
Turn the FEEDMATRIX_DECLARE macro into a single inline function
(feed_matrix_apply()). There is no reason to have this as a macro, it
only complicated the code. An advantage of this patch is that, because
we no longer call the functions created by the macro through function
pointers (apply field of feed_matrix_info), we can call
feed_matrix_apply() directly in feed_matrix_feed().

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48035
2025-03-10 21:19:41 +01:00
Christos Margiolis
e18d66d9c5 sound: Remove macro magic from pcm/feeder_eq.c
Turn the FEEDEQ_DECLARE macro into a single inline function
(feed_eq_biquad()). There is no reason to have this as a macro, and it
only complicates the code. An advantage of this patch is that, because
we no longer call the functions created by the macro through function
pointers (biquad_op), we can call feed_eq_biquad() directly in
feed_eq_feed().

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48032
2025-03-10 21:19:35 +01:00
Christos Margiolis
4918fc2e23 sound: Turn clamp macros into a function
This makes some subsequent feeder refactors easier to implement.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48421
2025-03-10 21:19:27 +01:00
Christos Margiolis
433e270f34 sound: Refactor the format conversion framework
Merge the PCM_READ|WRITE_* macros defined in pcm/pcm.h, as well as the
intpcm_read|write_* macros defined in pcm/feeder_format.c, into six
inline functions: pcm_sample_read|write[_norm|calc](). The absence of
macro magic makes the code significantly easier to read, use and modify.

Since these functions take the input/output format as a parameter, get
rid of the read() and write() function pointers defined in struct
feed_format_info, as well as the feeder_format_read|write_op()
functions, and use the new read/write functions directly.

Sponsored by:	The FreeBSD Fondation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D47932
2025-03-10 21:19:15 +01:00
John Baldwin
02d61f2758 hdaa: Don't hold a mutex while creating child devices
The lock is already not held while deleting child devices, and the
bus_topo_lock is already held when child devices are created.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D49272
2025-03-10 13:34:07 -04:00
John Baldwin
aaf0a7302d sdhci: Use bus_topo_lock and taskqueue_bus for hotplug events
Drop SDHCI_LOCK and instead acquire bus_topo_lock when adding and
removing new-bus devices.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D49271
2025-03-10 13:33:49 -04:00
John Baldwin
c0bed9bd0b mmc: Use bus_topo_lock and taskqueue_bus while adding/removing child devices
Some drivers held regular mutexes across some new-bus calls; instead
depend on bus_topo_lock to protect the relevant softc members.  This
also fixes the bus_topo_lock to be explicit in these drivers rather
than relying on the implicit Giant from taskqueue_swi_giant.  It
avoids calling sleepable routines like device_probe_and_attach from an
swi context.

Differential Revision:	https://reviews.freebsd.org/D49270
2025-03-10 13:32:53 -04:00
John Baldwin
b23314ecb9 pcib: Use taskqueue_bus for hot-plug events instead of a private taskqueue
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D49269
2025-03-10 13:32:38 -04:00
Takanori Watanabe
f9b4092743 acpi_wmi: Add type check before evaluaeting query ACPI method
Some ACPI wmi query is implemented by named object, not method,
ACPICA complains when non-method object is evaluated with one or more arguments.
Especially, almost all binary MOF object obtaining method is the case.

This commit will fix it.

PR:	284912
Reported by:	Alexander Ziaee
Differential Revision: https://reviews.freebsd.org/D49129
2025-03-10 11:22:30 +09:00
Joshua Rogers
b7269d89e5 wsp: Fix whitespaces
Signed-off-by: Joshua Rogers <Joshua@Joshua.Hu>
2025-03-07 20:53:35 +03:00
Joshua Rogers
e381dabcc5 wsp: Rename max_finger_area sysctl to max_finger_diameter
The value of this sysctl is not an area, but a maximum diameter.

Signed-off-by: Joshua Rogers <Joshua@Joshua.Hu>
2025-03-07 20:53:35 +03:00
Joshua Rogers
a79397d132 wsp: Handle horizontal scrolling and create tunable for swipe/scroll.
Previously, a two-finger horizontal scroll would result in a forwards/backwards
keyboard event being performed. This patch changes that functionality to be
specified via two new sysctls: horizontal_swipe_finger_count and
scroll_finger_count. The former specifies how many fingers are used to perform
the aforementioned forwards/backwards keyboard event, while the latter specifies
how many fingers are used to perform horizontal scrolling. 0 disables each of
them.

The threshold for scrolling has been coupled into a single tunable:
scr_threshold. This tunable is used for both scrolling and the horizontal swipe.

t_factor and t_invert tunables have been created in the same manner as their
z-axis counterparts.

Horizontal scrolling is disabled by default, as it requires the sysctl
hw.usb.wsp.t_factor to 3 (wsp mode). Horizontal swiping is enabled by default
with a three-finger tap.

Also rewrite much of, and improve, documentation.

Signed-off-by: Joshua Rogers <Joshua@Joshua.Hu>
2025-03-07 20:53:35 +03:00
Joshua Rogers
8b04f07eda sysmouse(4): Add wsp(4)-style T-Axis reporting.
Neither the ums(4) nor psm(4) reporting can be used by the wsp(4)
driver, as they rely on static-length movements, while wsp(4) may need
to scroll in large amounts per evdev event push.

This style uses a false button-5 press as an indicator that the z-axis
movement is a horizontal scroll, otherwise a vertical scroll.

Signed-off-by: Joshua Rogers <Joshua@Joshua.Hu>
2025-03-07 20:53:35 +03:00
Joshua Rogers
02fb6b1162 wsp: Fix typo in function name.
Signed-off-by: Joshua Rogers <Joshua@Joshua.Hu>
2025-03-07 20:53:34 +03:00
Joshua Rogers
d452a02995 wsp: Add hw.usb.wsp.max_scroll_finger_distance for two-finger scrolling
The hw.usb.wsp.max_scroll_finger_distance sysctl may be used to specify
the maximum distance between two fingers which are registered as a z-axis
(vertical scroll with mousepad) movement.

Previously, this was shared with the tunable
hw.usb.wsp.max_double_tap_distance which is used to specify the maximum
distance between two fingers which register as a right-click.

This patch also cleans up and add new information to the manpage for
wsp(4).

Signed-off-by: Joshua Rogers <Joshua@Joshua.Hu>
2025-03-07 20:53:34 +03:00
Joshua Rogers
8ceca72751 wsp: Raise the default scr_hor_threshold sysctl.
The previous value caused nearly every horizontal movement to be
classed as a left/right-keyboard button-click.

Signed-off-by: Joshua Rogers <Joshua@Joshua.Hu>
2025-03-07 20:53:34 +03:00
Olivier Certner
ef446a8065
smbios: style(9): smbios_cksum()
Reduce some variables' lifecycle.  Remove useless casts.  Remove
superfluous braces.  Add some consts.

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
2025-03-07 17:42:47 +01:00
Olivier Certner
516e24e579
smbios: Harden decoding of the BCD revision
bcd2bin() must not be called with a value greater or equal to
LIBKERN_LEN_BCD2BIN.

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
2025-03-07 17:42:46 +01:00
Olivier Certner
bb04712e37
smbios: Carefully print wrong entry point signature on identify
Using printf() with '%s' can lead to arbitrary long printing (although,
usually, a NUL byte should appear quite quickly) and trying to print
unprintable characters.

Instead, print in hexadecimal the exact bytes that are compared to the
expected signature.

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
2025-03-07 17:42:46 +01:00
Olivier Certner
fdf08ac1e9
smbios: Print an error on unexpected entry point length on identify
This helps figuring out quickly why no SMBIOS device appears in this case.

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
2025-03-07 17:42:46 +01:00
Olivier Certner
f6cbd6b6d2
smbios: Apply the v2.1's length fixup only on a 32-bit entry point
Only allow the length tolerance (0x1e instead of 0x1f) for a 32-bit
entry point, as there was no 64-bit entry point in the erroneous SMBIOS
v2.1 standard and assigning the length with 0x1f does not make sense in
this case.

While here, fix accessing the major/minor versions via 'eps' even in the
64-bit entry point case (not causing any practical problem thus far as
the entry point length is greater than any SMBIOS revisions in
existence, so the comparison guarding the fixup would not pass).

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
2025-03-07 17:42:46 +01:00
Olivier Certner
3907feff7a
smbios: Print an error on memory map failure on identify
Consistently with what the probe and attach methods are doing.

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
2025-03-07 17:42:46 +01:00
Olivier Certner
67d510f0c0
smbios: Unmap memory on error on identify
While here, de-indent most of the code by simply bailing out if 'addr'
is still 0 after the various detection methods have been tried.

Reviewed by:    emaste, imp
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D49180
2025-03-07 17:42:45 +01:00
Olivier Certner
e421a6615d
smbios: On attach, print the entry point version and revision
Additionally, on verbose boot, print the entry point revision as
a diagnostic/debugging help.

PR:             284460
Reviewed by:    markj, imp (both older version)
MFC after:      2 weeks
Event:          February src bug-busting session
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D49179
2025-03-07 17:42:45 +01:00
Olivier Certner
bc7f650836
smbios: Search for v3 (64-bit) entry point first on BIOS boot
When booted from BIOS (i.e., not EFI), also search for a 64-bit version
of the SMBIOS Entry Point.

This allows us to detect and report the proper SMBIOS version with
BIOSes that only provide the v3 table, as happens on Hetzner virtual
machines.

For machines that provide both, leverage the v3 table in priority
consistently with the EFI case.

PR:             284460
Reviewed by:    markj, imp (both older version)
MFC after:      2 weeks
Relnotes:       yes
Event:          February src bug-busting session
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D49179
2025-03-07 17:42:45 +01:00
Olivier Certner
69cf9e9a45
smbios: style(9): sizeof(): No space before the parenthesis
No functional change.

MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
2025-03-07 17:42:40 +01:00
Vladimir Kondratyev
adc2c156ac gpioaei: Add support for ACPI _EVT method
This method is often used to process GPIO "Power on" button press on
modern x86 laptops with S0ix sleep mode.

Tested with patch from https://reviews.freebsd.org/D26407

Sponsored by:	Future Crew LLC
MFC after:	2 month
2025-03-07 18:59:12 +03:00
Ahmad Khalifa
6aab381a49 acpi_gpiobus: assume GPIO_PIN_INPUT for interrupt pins
Different drivers respond differently to having neither GPIO_PIN_INPUT
or GPIO_PIN_OUTPUT set, this stops the unpredictable results.
2025-03-07 18:59:11 +03:00
Vladimir Kondratyev
daa098cc37 iichid(4): Wait for RESET command response while attaching
before starting of children initialization to ensure that parent device
is fully functional.

Sponsored by:	Future Crew LLC
MFC after:	2 month
Differential Revision:	https://reviews.freebsd.org/D48958
2025-03-07 09:26:51 +03:00
Vladimir Kondratyev
548d3aa856 iichid(4): Read wMaxInputLength bytes over I2C even if we discards data
For some devices e.g. ITE5570 it is not enough to read HID-over-I2C
input length header of RESET command response to acknowledge interrupt.
Do a full-size read to avoid interrupt storm.

Sponsored by:	Future Crew LLC
MFC after:	2 month
Differential Revision:	https://reviews.freebsd.org/D48957
2025-03-07 09:26:51 +03:00
Vladimir Kondratyev
c7225a3ede ig4_iic: Allow sleeping if called from iichid interrupt handler.
This replaces 50 ms busy loop with mtx_sleep for the same duration thus
saving CPU time when iichid is driven with interrupts.

Sponsored by:	Future Crew, LLC
MFC after:	2 month
Differential Revision:	https://reviews.freebsd.org/D48956
2025-03-07 09:26:51 +03:00
Colin Percival
d70bac252d acpi_pci: Add quirk for PSTAT_PME-before-detach
In order to signal to Graviton [123] systems that a device is ready
to be "ejected" (after a detach request is made via the EC2 API) we
need to set PCIM_PSTAT_PME to 1 and PCIM_PSTAT_PMEENABLE to 0.  We are
not aware of any rationale for this requirement beyond "another OS
kernel happens to do this", i.e. this is effectively bug-for-bug
compatibility.

Arguably this should be done by the ACPI _EJ0 method on these systems,
but it is not.

Create a new ACPI_Q_CLEAR_PME_ON_DETACH quirk and set it in EC2 AMIs,
and add the PCI register write to acpi_pci_device_notify_handler when
that quirk is set.

Reviewed by:	jhb
MFC after:	1 month
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D49146
2025-03-05 12:25:49 -08:00
SHENGYI HONG
8ee127efb0 vm_lowmem: Fix signature mismatches in vm_lowmem callbacks
This is required for kernel CFI.

Reviewed by:	rrs, jhb, glebius
Differential Revision:	https://reviews.freebsd.org/D49111
2025-03-04 20:18:52 -05:00
Warner Losh
ca48e43ba9 usb: Kill left-over cdefs.h includes
These includes were for __FBSD_RCSID() macro. They weren't formatted
like the rest of the tree so weren't trimmed automatically when that
script was run. Trim them now.

MFC After: 1 week
Sponsored by:		Netflix
2025-03-04 14:44:22 -07:00
Kyle Evans
2bef0d54f7 kern: wg: remove overly-restrictive address family check
IPv4 packets can be routed via an IPv6 nexthop, so the handling of the
parsed address family is more strict than it needs to be.  If we have a
valid header that matches a known peer, then we have no reason to
decline the packet.

Convert it to an assertion that it matches the destination as viewed by
the stack below it, instead.  `dst` may be the gateway instead of the
destination in the case of a nexthop, so the `af` assignment must be
switched to use the destination in all cases.

Add a test case that approximates a setup like in the PR and
demonstrates the issue.

PR:		284857
Reviewed by:	markj (earlier version), zlei
Differential Revision:	https://reviews.freebsd.org/D49172
2025-03-04 13:57:34 -06:00
Slava Shwartsman
85af37e159 mlx5en: Fix domain set usage in TLS tag import functions
Use the correct device pointer to obtain the domain set for memory
allocation. Previously, the functions were incorrectly using the arg
parameter directly instead of accessing mlx5_core_dev.

Signed-off-by: Slava Shwartsman <slavash@nvidia.com>

Sponsored by:	NVidia networking
MFC after:	1 week
2025-03-04 06:58:07 +02:00
Doug Ambrisko
1c9c4a25e6 enic: fix potential panic due to not understanding what iflib had allocated
For safety I was trying to clear out the descriptor but the full descriptor
was not allocated.  Remove any code trying to do that so the same mistake
won't be made.  This was found when looking to MFC the prior change
and having the loader, load the module.

Remove cq->ntxqsets since the completion queue is part of the RX and TX sets
2025-03-03 12:49:01 -08:00
Mitchell Horne
e2a08ac9ce riscv: enable EFI framebuffer
Pass framebuffer information from loader(8) to the kernel via the
MODINFOMD_EFI_FB metadata field.

Enable the vt_efifb driver. A small tweak is required to work around the
lack of VM_MEMATTR_WRITE_COMBINING on this platform; we use
VM_MEMATTR_UNCACHEABLE instead.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48884
2025-03-03 12:12:15 -04:00
Adrian Chadd
10c633ab12 ath_rate_sample: fix setting HT rates
ieee80211_node_set_txrate_ht_mcsrate() takes an MCS rate from 0..76,
the high bit (IEEE80211_RATE_MCS) must not be set.

This is definitely my fault - I likely didn't get to testing this
diff when I changed it from ieee80211_node_set_txrate_dot11rate()
just before landing.

Differential Revision:	https://reviews.freebsd.org/D49197
Reviewed by:	bz
2025-03-01 15:32:56 -08:00
Adrian Chadd
50ec1e7af0 ath: fix 20MHz HT short-gi logic.
This was broken in an earlier commit

(ca389486a9).

PR:		kern/285096
Differential Revision:	https://reviews.freebsd.org/D49196
Fixes:	ca389486a9
Reviewed by:	bz
2025-03-01 15:32:04 -08:00