Commit graph

44015 commits

Author SHA1 Message Date
Ahmad Khalifa
a2bfb7cff2 gpiobus: gpiobus_release_pin: convert errors to panic
These are programming errors.

Suggested by:	mmel
Reviewed by:	imp
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D50939
2025-07-04 23:24:31 +03:00
Ahmad Khalifa
ed50879c4a gpiobus: gpiobus_acquire_pin: panic on invalid pin
It is a programming error to call this function with an invalid pin.
Also return proper error value on failure.

Suggested by:	mmel
Reviewed by:	imp, mmel
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D50940
2025-07-04 23:24:31 +03:00
Ahmad Khalifa
4695e3aa7c gpio: attach gpiobus when the controller is ready
Only attach gpiobus when the controller is fully initialized. Children
of gpiobus expect this to be the case.

Reviewed by:	mmel, imp, andrew
Approved by:	imp (mentor)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D51088
2025-07-04 16:56:00 +03:00
Ahmad Khalifa
2c356c8b8f gpiobus: add a gpiobus_add_bus function
Some drivers need to postpone the attachment of gpiobus until hardware
init is done. Add a new gpiobus_add_bus function to accommodate this
case.

Suggested by:	mmel, andrew
Reviewed by:	mmel, imp, andrew
Approved by:	imp (mentor)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D51133
2025-07-04 16:55:55 +03:00
Bjoern A. Zeeb
2f5666c172 LinuxKPI: MODULE_DEVICE_TABLE() factor out the bus specific MODULE_PNP_INFO()
In order to be able to use MODULE_DEVICE_TABLE() with multiple bus
attachments, factor out the bus-specfic MODULE_PNP_INFO() and place
it next to the structure defining the table.

As it turns out bnxt(4) has been using the MODULE_DEVICE_TABLE() with
PCI attachments for the "auxillary" bus so far.  That makes little sense.
Define the MODULE_PNP_INFO() to nothing for that.  We may consider
pulling these LinucKPI bits in semi-native drivers into LinuxKPI
one day as that route is not really sustainabke.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	imp, dumbbell
Differential Revision: https://reviews.freebsd.org/D51049
2025-07-04 03:22:22 +00:00
Ruslan Bukin
906d7a4b52 hwt: fix !SMP build.
Sponsored by:	UKRI
2025-07-03 21:43:01 +01:00
Ruslan Bukin
070d185b2f hwt: fix build.
Include sys/lock.h header for spinlock_enter() prototype.

Sponsored by:	UKRI
2025-07-03 21:36:18 +01:00
Mark Johnston
5e213d8a74 random: Remove ARGSUSED annotations from random_harvestq.c
Such annotations are obsolete, the compiler tells us when parameters are
unused.  No functional change intended.

Reviewed by:	cem
MFC after:	1 week
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D51114
2025-07-03 17:31:42 +00:00
Mark Johnston
e2a96b8340 random: Define a macro for getting the CPU cycle count
Entropy queue entries always include the low 32 bits of a CPU cycle
count reading.  Introduce a macro for this instead of hard-coding
get_cyclecount() calls everywhere; this is handy for testing purposes
since this way, random(4)'s use of the cycle counter (e.g., the number
of bits we use) can be changed in one place.

No functional change intended.

Reviewed by:	cem, delphij
MFC after:	1 week
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D51113
2025-07-03 17:31:42 +00:00
Mark Johnston
4b8b872a9c random: Move entropy harvest queue lock macros to random_harvestq.c
They can't be used externally, so it makes no sense to have them in a
header.  No functional change intended.

Reviewed by:	cem
MFC after:	1 week
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D51111
2025-07-03 17:21:37 +00:00
Mark Johnston
6ccf1801f2 random: Replace a comment with a static assertion
No functional change intended.

Reviewed by:	cem
MFC after:	1 week
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D51110
2025-07-03 17:21:18 +00:00
Mark Johnston
027beb002b vmm: Add a missing entry to the ioctl table
Reported by:	acm
Fixes:		b9ef152bec ("vmm: Merge vmm_dev.c")
2025-07-03 17:02:43 +00:00
Mark Johnston
5ae9f8e9ac md: Restore guards in mddestroy()
mddestroy() may be invoked on a partially constructed md device.
Restore the guards that handled this prior to commit e910221681.

Reported by:	syzbot+a0ff73f664de8757cfaa@syzkaller.appspotmail.com
Reported by:	syzbot+7b4a4824bf81548283ab@syzkaller.appspotmail.com
Reviewed by:	kib
Fixes:		e910221681 ("md(4): move type-specific data under union")
Differential Revision:	https://reviews.freebsd.org/D51145
2025-07-03 15:10:41 +00:00
Ruslan Bukin
df114daef4 Import the Hardware Trace (HWT) framework.
The HWT framework provides infrastructure for hardware-assisted tracing. It
collects detailed information about software execution and records it as
"events" in highly compressed format into DRAM. The events cover information
about control flow changes of a program, whether branches taken or not,
exceptions taken, timing information, cycles elapsed and more. This allows
to reconstruct entire program flow of a given application.

This comes with separate machine-dependent tracing backends for trace
collection, trace decoder libraries and an instrumentation tool.

Reviewed by:	kib (sys/kern bits)
Sponsored by:	UKRI
Differential Revision:	https://reviews.freebsd.org/D40466
2025-07-03 15:48:34 +01:00
Konstantin Belousov
e910221681 md(4): move type-specific data under union
This way it is clear which type uses which members.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D51127
2025-07-02 18:32:58 +03:00
Kristof Provost
d1ac3e245f wg: fix LINT-NOIP build
Fixes:	d15d610fac
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-06-30 11:53:02 +02:00
Andrew Gallatin
20e15e905c mlx5: Decrease FW init timeout from 120 seconds to 5 seconds
When encountering a failed NIC, the mlx5 driver will wait up to 120
secs for the firmware to respond.  This timeout is absurdly huge, and
leads to boot times of 40 minutes to over an hour on our servers when a
NIC fails.  This is because the driver will attempt to attach to the
failed NIC multiple times (once for each driver loaded after mlx5),
and wait 2 minutes on each attempt.  This happens because the mlx5
driver is still the best match for the device.  This delay then
triggers watchdog timeouts in our environment, rendering servers
with a failed NIC entirely unbootable without manual intervention.

Note that FW_INIT_WARN_MESSAGE_INTERVAL must also be decreased, as
it must be less than the init timeout.

Reviewed by: kib (initial version, before reducing warn interval)
Sponsored by: Netflix
2025-06-29 16:51:50 -04:00
Gleb Smirnoff
24ebe9fa0e psm: fix build
Fixes:	b93063c84e
2025-06-27 15:46:56 -07:00
Vladimir Kondratyev
b93063c84e psm(4): Add kqueue support
MFC after:	2 weeks
2025-06-27 00:27:10 +03:00
Kyle Evans
d15d610fac kern: wg: add support for removing Allowed-IPs
This was recently added to Linux to improve incremental update support,
as you could previously add Allowed-IPs but not remove without replacing
the whole set (and thus, potentially disrupting existing traffic).

Removal is incredibly straightforward; we'll find it in p_aips first
to ensure that it's actually valid for this peer, then we'll delete it
from the radix tree before we remove the corresponding p_aips entry.

Reviewed by:	Jason A. Donenfeld, jhb
Differential Revision:	https://reviews.freebsd.org/D50448
2025-06-25 21:58:22 -05:00
Kyle Evans
2475a3dab0 kern: wg: split address/mask construction out of wg_aip_add()
We'll re-use these in a future wg_aip_del() to perfectly reconstruct
what we expect to find in a_addr/a_mask.

Reviewed by:	ivy, markj (both earlier version), Aaron LI, jhb
Differential Revision:	https://reviews.freebsd.org/D50447
2025-06-25 21:57:02 -05:00
Kyle Evans
ba2607ae7d kern: wg: refactor out some repetitive bits in allowed-ip config
The only difference in the wg_aip_add() call after IP validation is the
address family.  Just pull that out into a variable and avoid the two
different callsites for wg_aip_add().  A future change will add a new
call for each case to remove an address from the peer, so it's nice to
avoid needing to repeat the logic for two different branches.

Reviewed by:	Aaron LI, Jason A. Donenfeld, ivy, jhb, markj
Differential Revision:	https://reviews.freebsd.org/D50446
2025-06-25 21:57:02 -05:00
Mark Johnston
5286b96c56 md: Use a larger buffer for the ident string
With the old size, the string could easily be truncated, resulting in
non-unique identifiers.

PR:		287679
Reported by:	Phil Krylov <phil@krylov.eu>
Reviewed by:	kib
MFC after:	2 weeks
2025-06-25 21:20:45 +00:00
Justin Hibbits
0d7abc6e1f IfAPI: Finish etherswitch driver conversions
These drivers are not compiled by default, so were missed in the
conversion.

Sponsored by:	Juniper Networks, Inc.
2025-06-25 15:53:13 -04:00
Andrew Turner
5ec268d09a dev/psci: Use the correct SMCCC TRNG field
The TRNG service will return random data in x3. Use the correct field
when filling the buffer in trng_read.

This driver has not been in any release, so no security advisory is
needed.

Reviewed by:	bz
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D50979
2025-06-24 18:45:42 +01:00
Andrew Turner
288ba78edc dev/psci: Check for functions before calling
In the SMCCC TRNG and Errata ABI drivers check if the version
functions are implemented before calling them. Without this the firmware
may complain about an unimplemented function being called.

Reported by:	bz
Reviewed by:	bz
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D50978
2025-06-24 18:45:42 +01:00
Andrew Turner
4e17c5fc50 dev/psci: Use an SMCCC return value
Switch to the SMCCC not supported macro in smccc_arch_features. This
shouldn't be a functional change as the value is identical to the PSCI
value it replaces.

Reviewed by:	bz, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D50977
2025-06-24 18:45:41 +01:00
Kevin Lo
1395712cab uchcom: add support for CH9102 and CH343 uarts
The CH343 devices support any baud rate up to 6 Mbps.
PR:	272803
Reviewed by:	imp
Tested by:	joerg, Tomasz "CeDeROM" CEDRO <tomek_AT_cedro_DOT_info>
Differential Revision:	https://reviews.freebsd.org/D46290
2025-06-25 09:33:35 +08:00
Gleb Smirnoff
01addd846c gone_in: make it __printflike()
Provide flexibility to use format strings for gone_in().  As a side
effect, this removes hardcoded string "Obsolete code will be removed
soon:" from the message, so now it is obligation of the deprecated code to
provide a meaningful message.  This required a small adoption of the
existing users: midi, drm2 and le(4).  Note that gone_in() is not a public
KPI as it has no sense to use it outside of the FreeBSD tree.

Reviewed by:		imp
Differential Revision:	https://reviews.freebsd.org/D50783
2025-06-24 15:23:47 -07:00
Andrew Turner
cbc2e34613 virtio_blk: Limit use of indirect descriptors
Pass 0 as the number of indirect descriptors when they are not
supported.

This fixes an issue on the Arm FVP model where we don't negotiate
them, however pass a number of segments greater than
VIRTIO_MAX_INDIRECT. This leads to virtqueue_alloc failing and
virtio_blk failing to attach.

Reviewed by:	Harry Moulton <harry.moulton@arm.com>
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D50909
2025-06-23 13:55:24 +01:00
Ahmad Khalifa
b2e0dfc808 vt_fb: account for endianness
Account for endianness when writing to 24bpp framebuffers. Also create a
vt_fb_mem_wr3 function to avoid code duplication.

Reviewed by:	manu, imp
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D50843
2025-06-23 09:23:21 +03:00
Ahmad Khalifa
3146c8fa19 vt_fb: fix KASSERTs
Make sure there is enough room to write more than one byte.

Reviewed by:	manu, imp
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D50842
2025-06-23 09:23:21 +03:00
Ahmad Khalifa
b670c9bafc newbus: replace leftover device unit wildcards
Reviewed by:	imp, jhb
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D50913
2025-06-21 05:57:45 +03:00
Bjoern A. Zeeb
8d51f2aba9 iwx: correct rx status reporting
We are currently not reporting any per-chain S:N values so remove
IEEE80211_R_C_RSSI and IEEE80211_R_RSSI along with it as it is set
already in the line above.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	thj
Differential Revision: https://reviews.freebsd.org/D50927
2025-06-19 16:32:28 +00:00
Bjoern A. Zeeb
be57603c46 iwx: correct chain number reporting
There is no point in assigning the channel index to the number of
chains for the RX status reporting.  The value was not tagged as
being used.  Rather than simply removing it try to fix it and
set the flag if we get a value.

Sposnored by:	The FreeBSD Foundation
Reviewed by:	thj
Differential Revision: https://reviews.freebsd.org/D50926
2025-06-19 16:32:28 +00:00
Kevin Lo
19d0dd8718 mtw: fix display of the MAC revision
Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D50542
2025-06-19 13:42:39 +08:00
Mark Johnston
9d0d55e398 ufshci: Remove an unneeded variable definition
Reported by:	gcc
Fixes:		1349a733cf ("ufshci: Introduce the ufshci(4) driver")
2025-06-18 13:13:08 +00:00
Olivier Certner
8ecc419180
Internal scheduling priorities: Always use symbolic ones
Replace priorities specified by a base priority and some hardcoded
offset value by symbolic constants.  Hardcoded offsets prevent changing
the difference between priorities without changing their relative
ordering, and is generally a dangerous practice since the resulting
priority may inadvertently belong to a different selection policy's
range.

Since RQ_PPQ is 4, differences of less than 4 are insignificant, so just
remove them.  These small differences have not been changed for years,
so it is likely they have no real meaning (besides having no practical
effect).  One can still consult the changes history to recover them if
ever needed.

No functional change (intended).

MFC after:      1 month
Event:          Kitchener-Waterloo Hackathon 202506
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D45390
2025-06-17 22:08:02 -04:00
Olivier Certner
c21c24adde
runq: More selective includes of <sys/runq.h> to reduce pollution
<sys/proc.h> doesn't need <sys/runq.h>.  Remove this include and add it
back for kernel files that relied on the pollution.

Reviewed by:    kib
MFC after:      1 month
Event:          Kitchener-Waterloo Hackathon 202506
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D45387
2025-06-17 22:07:57 -04:00
Krzysztof Galazka
7ffe1a1f63 pci: Save MSIX ctrl value before pci_mask_msix call
Function pci_mask_msix uses cached value of MSI-X CTRL
register to verify if vector index is valid. Update
that value in pci_alloc_msix_method before it is
used to avoid kernel panic.

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>

Reviewed by:	jhb
Approved by:	kbowling (mentor)
Sponsored by:   Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D49484
2025-06-17 21:17:21 +02:00
Jaeyoon Choi
1349a733cf ufshci: Introduce the ufshci(4) driver
This commit adds a storage driver that supports the Universal Flash
Storage Host Controller Interface (UFSHCI) on FreeBSD.

Universal Flash Storage (UFS) is a flash-based mobile storage device
that replaces eMMC, aiming for high performance with low power. The UFS
Host Controller Interface (UFSHCI) is the host side controller and
connects UFS device to a system bus, such as PCIe.

The code targets the latest standards:
- UFS 4.1: https://www.jedec.org/standards-documents/docs/jesd220g
- UFSHCI 4.1: https://www.jedec.org/standards-documents/docs/jesd223f

The ufshci(4) driver implements controller/device initialization,
interrupt, single-doorbell(SDB) queue based IO requests. Support for
multi-queue (MCQ) IO requests is planned for a later commit.

Implemented features:
- PCIe bus support
- legacy(INTx) Interrupt Handling
- UIC command support
- UTP Transfer Request (UTR) support
- UTP Task Management Request (UTMR) support
- single doorbell queue (SDB) with multiple queue depth
- SCSI command set support
- sysctl

Work in progress:
- multi-Circular Queue (per-CPU IO queues)
- MSI-X interrupt Support
- write booster
- write Protect
- Host Performance Booster (HPB)
- interrupt aggregation
- ARM based system bus support
- ufs-utils port

Tests were performed on QEMU and an Intel-based laptop.
Since QEMU has an emulated UFS device, I tested on QEMU.

How to test on QEMU:
1. Run QEMU
    $ qemu-system-x86_64 ... -device ufs -drive file=blk1g.bin,format=raw,if=none,id=luimg -device ufs-lu,drive=luimg,lun=0
2. Loading/unloading the ufshci module on QEMU
    $ kldload /usr/obj/usr/src/amd64.amd64/sys/modules/ufshci/ufshci.ko
    $ kldunload ufshci

Testing on real hardware:
- Samsung Galaxy Book S (Intel Lakefield) with UFS 3.0
- Lenovo duet 3 11ian8 (Intel N100) with UFS 2.1

Sponsored by:		Samsung Electronics
Reviewed by:		imp
Differential Revision:	https://reviews.freebsd.org/D50370
2025-06-15 00:08:56 -06:00
Kevin Bowling
5e6e4f7528 bnxt: Fix BASE-T, 40G AOC, 1G-CX, autoneg and unknown media lists
This was broken in c63d67e137, the early returns prevent building the
media lists as expected.

The BASE-T parts of the patch were suggested by "cyric@mm.st", while I
am adding the additional 40G AOC, 1CX, autoneg and unknown PHY fixes
based on code inspection.  There may be additional work left here for
Broadcom but this is certainly better than the returns.

PR:		287395

Reported by:	mickael.maillot@gmail.com, cyric@mm.st
Tested by:	Einar Bjarni Halldórsson <einar@isnic.is>
MFC after:	1 week
2025-06-14 16:54:22 -07:00
Mark Johnston
3b4bc5d70e gve: Relax a static assertion
It's okay if MCLBYTES is larger than the default receive buffer size.

Fixes:	71702df612 ("gve: Add support for 4k RX Buffers when using DQO queue formats")
2025-06-14 12:17:49 +00:00
Vee Agarwal
71702df612 gve: Add support for 4k RX Buffers when using DQO queue formats
This change adds support for using 4K RX Buffers when using DQO queue
formats when a boot-time tunable flag is set to true by the user.
When this flag is enabled, the driver will use 4K RX Buffer size either
when HW LRO is enabled or mtu > 2048.

Signed-off-by: Vee Agarwal <veethebee@google.com>

Reviewed by:	markj, ziaee
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50786
2025-06-13 18:53:51 +00:00
Kristof Provost
4f7473d18a qlnx: fix panic at startup
While attaching the qlnx driver we can end up trying to call ifmedia functions
before those are set up (through ether_ifattach() -> rtnl_handle_ifattach()
-> dump_iface() -> get_operstate_ether() -> ifmedia_ioctl()). Postpone the
ether_ifattach() until after the ifmedia setup.

Reviewed by:	markj,zlei
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D50819
2025-06-13 16:48:51 +02:00
Christos Margiolis
84e7307441 snd_hda: Patch Lenovo T420s
PR:		222636
Tested by:	vermaden@interia.pl
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
2025-06-13 01:02:15 +02:00
Stefan Eßer
dab9ef5448 snd_hda: fix attaching to some AMD Radeon GPUs
HDMI audio did not work on my older Radeon GPU, the error message
during attach was:

hdac0: hdac_get_capabilities: Invalid corb size (0)

This is fixed by calling hdac_reset() before the HDA device
capabilities are retrieved. This solution was proposed by Andriy Gapon
in 2010, but apparently did not solve the problem reported at the time.

Approved by:	christos
Differential Revision:	https://reviews.freebsd.org/D50737
2025-06-12 10:15:59 +02:00
Jan Biedermann
50461a68e0 Add USB quirk for Creative Stage SE mini
Note: The commit in main was modified for the new macros in main.
stable merge will need to use the version originally in #1715

MFC After: 2 weeks
Pull Request: https://github.com/freebsd/freebsd-src/pull/1715
Closes: https://github.com/freebsd/freebsd-src/pull/1715
2025-06-11 17:16:21 -06:00
Jan Biedermann
c2794499be usb: Don't call usb_msc_auto_quirk for UQ_MSC_IGNORE devices
usb_msc_auto_quirk() potentially crashes usb devices with a hidden
storage (see bug 287333). These devices may still operate normally if
usb_msc_auto_quirk() would not be called all and the hidden storage is
ignored. This patch makes sure, that usb_msc_auto_quirk() is not called
when the UQ_MSC_IGNORE quirk is set for a device. It shouldn't be called
anyway if the hidden storage supposed to be ignored. This gives users a
chance to get their devices working by using

'usbconfig add_dev_quirk_vplh <vid> <pid> <lo_rev> <hi_rev> UQ_MSC_IGNORE'.

Reviewed by: imp
MFC After: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/1716
Closes: https://github.com/freebsd/freebsd-src/pull/1716
2025-06-11 17:16:21 -06:00
Christos Margiolis
4a7b8cd705 sound: Add AFMT_FLOAT to feed_volume_info_tab
Fixes:		e1bbaa71d6 ("sound: Implement AFMT_FLOAT support")
Reported by:	bz
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D50793
2025-06-11 13:10:54 -04:00