Commit graph

44033 commits

Author SHA1 Message Date
Takanori Watanabe
8799446796 ichiic: Add PCI id for Arrow Lake.
Add PCI id for Arrow Lake to attach iic driver

Reviewed by: wulf, mav
Differential Revision: https://reviews.freebsd.org/D51107
2025-07-08 23:21:03 +09:00
Mark Johnston
9940c97402 random: Change the entropy harvest event queuing scheme
The entropy queue stores entropy gathered from environmental sources.
Periodically (every 100ms currently), the random kthread will drain this
queue and mix it into the CSPRNG's entropy pool(s).

The old scheme uses a ring buffer with a mutex to serialize producers,
while the sole consumer, the random kthread, avoids using a mutex on the
basis that no serialization is needed since nothing else is updating the
consumer index.  On platforms without total store ordering, however,
this isn't sufficient: when a producer inserts a queue entry and updates
`ring.in`, there is no guarantee that the consumer will see the updated
queue entry upon observing the updated producer index.  That is, the
update to `ring.in` may be visible before the updated queue entry is
visible.  As a result, we could end up mixing in zero'ed queue entries,
though this race is fairly unlikely in practice given how infrequently
the kthread runs.

The easiest way to fix this is to make the kthread acquire the mutex as
well, and hold it while processing queue entries.  However, this might
result in a long hold time if there are many queue entries, and we
really want the hold times to be short, e.g., to avoid delaying
interrupt processing.

We could introduce a proper MPSC queue, but this is probably
overcomplicated for a consumer which runs at 10Hz.

Instead, define two buffers, always with one designated as the "active"
buffer.  Producers queue entries in the active buffer, and the kthread
uses the mutex to atomically flip the two buffers, so it can process
entries from the inactive buffer without holding the mutex.  This
requires more memory, but keeps mutex hold times short and lets us keep
the queue implementation very simple.

Reviewed by:	cem
MFC after:	1 month
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D51112
2025-07-07 15:41:57 +00:00
Christos Margiolis
3ba480f418 sound: Retire SND_DEV_*
Specifying unit numbers is not needed anymore, and half of those weren't
used anymore in the first place.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	adrian, markj, emaste
Differential Revision:	https://reviews.freebsd.org/D50690
2025-07-06 16:08:50 +03:00
Christos Margiolis
92336491cc sound: Remove dead printfs from midi/mpu401.c
Sponsored by:	The FreeBSD Foundation
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D50617
2025-07-06 16:08:46 +03:00
Christos Margiolis
9a138abb21 sound: Remove unused midi_cmdname()
Sponsored by:	The FreeBSD Foundation
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D50616
2025-07-06 16:08:42 +03:00
Christos Margiolis
c566edbceb sound: Remove unnecessary comments from midi/midi.c
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D50615
2025-07-06 16:08:37 +03:00
Christos Margiolis
17b38023ea sound: Remove duplicate mpu_if.h include
Sponsored by:	The FreeBSD Foundation
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D50613
2025-07-06 16:08:34 +03:00
Christos Margiolis
fa20737ed1 sound: Remove unused mpu_if methods
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D50612
2025-07-06 16:08:30 +03:00
Christos Margiolis
0ca9410eab sound: Retire unused MIDI sysctls
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D50611
2025-07-06 16:08:26 +03:00
Christos Margiolis
7f1426971e sound: Retire /dev/midistat
This doesn't register all MIDI devices, for example USB ones, and is not
widely used in the first place. In the future all MIDI devices will
register to sndstat, where we already have defined a MIDI device type,
but we haven't made use of it yet.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D50610
2025-07-06 16:08:22 +03:00
Christos Margiolis
6cdd3226c7 sound: Retire midisynth
Unused code since we retired the sequencer.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D50609
2025-07-06 16:08:18 +03:00
Christos Margiolis
79b9680639 sound: Retire the MIDI sequencer
The in-kernel MIDI sequencer is not used anymore, since this is done by
userland applications nowadays. It also contains bugs, and we are not
exactly sure how it works, or if it worked properly in the first place.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	vishwin, markj
Differential Revision:	https://reviews.freebsd.org/D50605
2025-07-06 16:08:10 +03:00
Konstantin Belousov
ca554a7dea dev/mem: use sx instead of rw lock
Some ops require sleepable context to success, like DMAP demotion.

Reviewed by:	alc, markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D50970
2025-07-05 11:35:53 +03:00
Ahmad Khalifa
9c2509f831 gpio: hide internal gpiobus symbols
Move functions and variables internal to gpiobus to their own header to
avoid namespace pollution and misuse.

Reviewed by:	wulf, imp
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D50872
2025-07-04 23:24:31 +03:00
Ahmad Khalifa
ff826f8ed4 gpiopps: don't use internal gpiobus function
gpiobus_release_pin is only meant to be used internally by gpiobus. Use
gpio_pin_release instead.

This also fixes a memory leak since gpio_pin_get_by_ofw_idx returns a
malloc'd pointer, which gpio_pin_release now frees.

Reviewed by:	wulf, imp
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D50871
2025-07-04 23:24:31 +03:00
Ahmad Khalifa
7f297cdae3 regulator: don't use internal gpiobus function
gpiobus_acquire_pin is only meant to be used internally by gpiobus. Use
gpio_pin_acquire instead.

Reviewed by:	manu, mmel
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D50870
2025-07-04 23:24:31 +03:00
Ahmad Khalifa
4a21713278 gpiobus: add gpio_pin_acquire
In some cases, drivers may need to acquire an existing gpio_pin_t. With
the functions gpiobus currently exposes, this isn't possible as they
allocate a new pin then acquire that. Add a new gpio_pin_acquire
function which accepts an existing gpiobus_pin structure.

Reviewed by:	mmel, imp
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D50869
2025-07-04 23:24:31 +03:00
Ahmad Khalifa
92b352f694 gpiobus: gpio_pin_release: convert checks to KASSERTs
Reviewed by:	mmel, imp
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D50868
2025-07-04 23:24:31 +03:00
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