Commit graph

5908 commits

Author SHA1 Message Date
Dimitry Andric
b39662fc38 vchiq: fix build with clang 21
When compiling vchiq with clang 21, the following -Werror warning is
produced:

    sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c:728:27: error: default initialization of an object of type 'VCHIQ_QUEUE_MESSAGE32_T' with const member leaves the object uninitialized [-Werror,-Wdefault-const-init-field-unsafe]
      728 |                 VCHIQ_QUEUE_MESSAGE32_T args32;
          |                                         ^
    sys/contrib/vchiq/interface/vchiq_arm/vchiq_ioctl.h:151:40: note: member 'elements' declared 'const' here
      151 |         const /*VCHIQ_ELEMENT_T * */ uint32_t elements;
          |                                               ^

While the warning is formally correct, the 'args32' object is
immediately initialized after its declaration. Therefore, suppress the
warning.

MFC after:	3 days
2026-01-16 15:02:35 +01:00
Mitchell Horne
cae9ae66ad aw_rtc: bump settime() delays
There are delay loops, checking the BUSY status bit, before writing to
the date or time registers. Each iteration contains a 1usec delay, for a
maximum of 70 iterations.

This is frequently not enough on the D1 platform, where the message is
emitted:

  rtc0: could not set date, RTC busy

Bump the loop delay to 10usecs each, and the maximum number of
iterations to 150, for a maximum delay of 1.5msecs between each write of
the register.

In my testing this seems to be adequate.

The loop variable is renamed for clarity/simplicity.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D54180
2025-12-15 11:29:21 -04:00
Brooks Davis
80203a27e9 Add sys/_align.h replacing machine/_align.h
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run
Define _ALIGNBYTES using sizeof(void *) (no functional change on any
existing architecture) which will allow it to work with CHERI were we
must align things up to capability alignment.

In _ALIGN, replace integer manipulation which does not preserve pointer
provenance with a type and provenance preserving builtin.  This requires
modest changes in code which assumes _ALIGN returns an integer, but
those are relatively rare.

Reviewed by:	kib, markj
Effort:		CHERI upstreaming
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D53947
2025-12-10 10:57:50 +00:00
John Baldwin
575639548c bus_alloc_resource: Pass rid by value to BUS_ALLOC_RESOURCE DEVMETHOD
The wrapper functions such as bus_alloc_resource_any() still support
passing the rid by value or pointer, but the underlying implementation
now passes by value.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D53402
2025-12-09 15:00:06 -05:00
John Baldwin
f6910b09a2 sys: Remove/update references to the swapper process in various comments
Reviewed by:	olce, markj
Differential Revision:	https://reviews.freebsd.org/D54051
2025-12-04 14:52:59 -05:00
Warner Losh
b033e3684f armv7: Tweak some armv6 removals
Fixes: 42421307b115 (sys: remove armv6/6.1 support from debug monitor)
Suggested by:	jhb
Sponsored by:	Netflix
2025-12-02 22:29:42 -07:00
Robert Clausecker
7998a82d2f sys/stdint.h: add C23 _WIDTH macros
The platform-dependent macros are added to the various
_stdint.h headers, those that are always the same are
added directly to _stdint.h.

We may want to move the definitions for WCHAR_* and
WINT_* out of the platform header files as those are
always the same.

Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D53830
2025-11-30 20:21:51 +01:00
Robert Clausecker
7326bc7f9c sys/limits.h: add C23 _WIDTH macros
For compliance with IOS/IEC 9899:2024 ("C23").

These macros define the width in bits of the basic integer types.
Another new macro, BITINT_MAXWIDTH, is not yet included as I do not
understand what it should be set to.  Perhaps it is compiler-specific.

Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D53825
2025-11-30 20:21:47 +01:00
Warner Losh
02b72b1540 arm: Remove unused variable in dbg_arch_supported
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run
Removed unused dbg_didr which had been used prior to f42421307b to
detect qemu unsupported debugger. I'm unsure how this slipped through my
testing.

Fixes: f42421307b
Sponsored by: Netflix
2025-11-29 02:47:49 -07:00
Minsoo Choo
3387a1bdba sys: update comment for removal of armv6
Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1903
2025-11-28 21:56:37 -07:00
Minsoo Choo
f42421307b sys: remove armv6/6.1 support from debug monitor
Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1903
2025-11-28 21:56:36 -07:00
Minsoo Choo
42d704bfc4 sys: remove comment for armv5/6
Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1903
2025-11-28 21:56:36 -07:00
ykla
8cbe0dd509 sys: RealTek -> Realtek
Realtek changed how it styled its name 25 or so years ago, but the old
style persisted in many places. These products use the new styling in
their datasheets.

Signed-off-by: ykla yklaxds@gmail.com
Sponsored by: Chinese FreeBSD Community
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1901
2025-11-26 23:19:26 -07:00
Christos Margiolis
120f8a4c2a arm: Add missing argument in mtx_init() calls
Fixes:		9d18115ca0 ("sound: Retire snd_mtx* wrappers")
Reported by:	CI
Sponsored by:	The FreeBSD Foundation
MFC after:	4 days
2025-11-24 13:19:25 +01:00
Christos Margiolis
9d18115ca0 sound: Retire snd_mtx* wrappers
Do not create mutexes with snd_mtxcreate(). It doesn't provide any
value, plus it first allocates the mutex with malloc(9). Allocate
mutexes in the stack and use mtx_* functions directly instead of the
snd_mtx* wrappers.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D53855
2025-11-21 17:14:47 +01:00
Andrew Turner
8178a4e3c1 arm/gic: Make GICV3_IVAR_SUPPORT_LPIS generic
GICv5 will need this too, so move to the GIC_IVAR namespace.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D53663
2025-11-18 18:00:31 +00:00
Andrew Turner
262fadda37 arm: Handle GIC_IVAR_VGIC in the gic driver
We don't have a GICv2 vgic so can just return 0.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D53662
2025-11-18 18:00:31 +00:00
Marco Devesas Campos
aa6b871ea7 arm64: Add support to vchiq and bcm2835_audio (plus some fixes)
Add 64 bit support to vchiq:

 * update fields to the appropriate fixed bit-size variants (everywhere [cf. e.g., ref:sizes and ref:sizes2])
 * refer to event semaphores (that go into the very 32 bit VC) by offset instead of pointers [ref:sems]
 * dsb() is dsb(sy) in arm64 (vchiq_{core.c,core.h,kmod.c}) [ref:dsb]
 * comment out some unneeded code in parse_rx_slots around VCHIQ_MSG_BULK_RX (cf. [ref:deadcode])
 * adapt remote_event_signal to arm64 caching behaviours (vchiq_kmod.c)
 * refactor synchronization around remote_event_signal, forcing a wmb to be on the safe side; thereby make it look more like what linux does [ref:sync] (vchiq_{core,kmod}.c); and make a comment in vchiq_core.c true (wasn't before)
 * add a few more syncs to be on the safe side (vchiq_2835_arm.c)
 * use arm64 dcache invalidation mechanisms (vchiq_2835_arm.c)
 * explicitly invalidate pages on arm64 post bulk-read (vchiq_2835_arm.c)
 * support bulk transfers on rpi-4 (aka "long address space" transfers), by hard-coding their vc offset (0) and different bit-shift [ref:longbulk] (vchiq_2835_arm.c)
 * refactor a loop-of-constant-test (vchiq_2835_arm.c)
 * use the correct (hard-coded) cache-line size on arm64
 * rework the handling of chipset "features" to account for the extra behaviours with 64 bit chipsets. (vchiq_kmod.c)
 * add sysctl-s (log, arm_log) to control debug (vchiq_kmod.c)
 * add example kernel config (GENERIC-VCHIQ)

Fixes:

 * Rework error handling in create_pagelist, avoiding a potential panic when
   freeing memory that had been dmamem_alloc, a potential null dereference,
   and a leak when having problems pinning pages (vchiq_2835_arm.c)
 * fix a confusion about the behaviour cv_wait_sig that lead to
   uninterruptible looping (vchiq_bsd.c)
 * implement detection of fatal signals (vchiq_bsd.c)
 * fix a confusion with the name of a variable introduced by #a0b8746
   that could lead to a panic when closing the cdev file (vchiq_arm.c)
 * release user connection when destructing cdevpriv and avoid user processes
   sharing connection data, which lead to stalls and data corruption. (vchiq_arm.c)

Update bcm2835_audio to work on 64bit systems:

 * update VC audio fields (vc_vchi_audioserv_defs.h, bcm2835_audio.c)
 * repurpose the hitherto unused callback field to help push a 64 bit pointer in (bcm2835_audio.c)
 * increase (hopefully) the robustness of the code that shifts data to VC (bcm2835_audio.c)
 * add a sysctl to control the amount of debugging info output by bcm2835_audio.c

Tested on zero, zero2 and 4+ with ping, functional, bulk and control vchiq_test-s, and omxplayer

  [ref:dsb]: 35b7ebda57
  [ref:sems]: 24a4262afb
  [ref:sizes]: e64568b8ea
  [ref:sizes2]: f9bee6dd24
  [ref:deadcode]: 14f4d72fb7
  [ref:sync]: 51c0712650
  [ref:longbulk]: 37f6f19a83

Differential Revision:	https://reviews.freebsd.org/D37878
Submitted by: Marco Devesas Campos <devesas.campos@gmail.com>
2025-11-14 19:27:46 -08:00
Christos Margiolis
78c5026ae1 sound: Get rid of useless sndbuf getters and setters
No functional change intended.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D53528
2025-11-11 13:05:34 +01:00
David E. O'Brien
d6f10a5d01 random: allow disabling of entropy harvesting from keyboard & mice
Reviewed by:	jmg
Sponsored by:	Juniper Networks
Differential Revision:	https://reviews.freebsd.org/D53390
2025-11-10 18:47:41 -08:00
David E. O'Brien
3deb21f1af random: TPM_HARVEST should have been named RANDOM_ENABLE_TPM
* Enable RANDOM_ENABLE_TPM by default

* The commit of TPM_HARVEST failed to add it to NOTES
  so that the LINT kernel would build the code.

Fixes: 4ee7d3b011
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D53460
2025-11-10 12:54:48 -08:00
Marco Devesas Campos
8b43286fc3 vchiq: fix another logging format string for 32/64 bit
This is from work from https://reviews.freebsd.org/D37878.

Submitted by: Marco Devesas Campos <devesas.campos@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D53372
2025-10-29 17:48:12 -07:00
Marco Devesas Campos
df764dd133 vchiq: logging/tracing refactoring
* Create macros for error, info, warn, trace / debug
* Migrate existing printf() logging to use the above macros
* Add a sysctl knob to control it at runtime

This is based on work done in https://reviews.freebsd.org/D37878 .

Submitted by: Marco Devesas Campos <devesas.campos@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D53371
2025-10-29 17:48:05 -07:00
Gordon Bergling
862024c00f arm/ti: Fix typo in a KASSERT message
- s/patcket/packet/

MFC after:	5 days
2025-10-29 16:45:15 +01:00
Gordon Bergling
b074d14696 arm/mv: Fix typo in a kernel error message
- s/Unkown/Unknown/

MFC after:	5 days
2025-10-29 16:45:07 +01:00
Gordon Bergling
b87836e824 arm/nvidia/tegra: Fix a couple of typos in kernel messages
- s/intialization/initialization/
- s/Cannott/Cannot/
- s/ivalid/invalid/
- s/wating/waiting/

MFC after:	1 week
2025-10-28 09:04:33 +01:00
Justin Hibbits
3b9578059c kexec: Add dummy headers for arm, i386, powerpc, and riscv
kexec hasn't been ported to these architectures, yet, so appease the
build with dummy headers.

Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D51625
2025-10-27 10:33:51 -04:00
Robert Clausecker
a8079d40ae sys/arm: add fp[gs]et* prototypes to <ieeefp.h>
We have provided implementations for hard float of these for
a while now.  Add them to the header to make things official.
This is required for a bunch of legacy programs in ports.

Approved by:	markj (mentor)
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D53156
2025-10-22 15:41:54 +02:00
Mitchell Horne
f34e152e02 ti_clkctrl.c: fix paths in comment
Now under sys/contrib/device-tree.
2025-10-20 20:43:28 -03:00
Mitchell Horne
5aefe9f16f arm: tweak imx module build logic
Add the subdirectory in the Makefile, not the config.

No functional change intended.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2025-10-20 20:37:13 -03:00
Mitchell Horne
5522519731 modules: enable allwinner kmods on riscv
While here, standardize the place they are enabled in the Makefile. For
armv7 the module subdirectory was added explicitly in the config file,
but this is not idiomatic.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2025-10-20 20:37:13 -03:00
Zhenlei Huang
301e6c4712 imgact: Mark brandinfo and note structures as const
No functional change intended.

Reviewed by:	kib
MFC after:	10 days
MFC with:	80336636b6
Differential Revision:	https://reviews.freebsd.org/D53173
2025-10-19 00:11:30 +08:00
Konstantin Belousov
3613896984 knotes: kqueue: handle copy for trivial filters
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D52045
2025-10-18 08:12:37 +03:00
David E. O'Brien
0050289464 style(9): white space after ; and around binary operators
in for() loops.  Also, use 'while', where only the
conditional test of 'for' was used.

Reviewed by: sjg
2025-10-16 15:02:50 -07:00
Zhenlei Huang
0b9c12fa97 arm: Use proper prototype for SYSINIT functions
The only possible return value of function module_info_init() is 0. Make
it return void to match the prototype of SYSINIT.

MFC after:	1 week
2025-10-13 18:12:35 +08:00
Ahmad Khalifa
f1a372ed88 gpio: implement bus_setup_intr and bus_teardown_intr
Implement bus_setup_intr and bus_teardown_intr as bus_generic_setup_intr
and bus_generic_teardown_intr respectively for GPIO drivers that support
interrupts. This allows children to setup interrupts.

Reported by:	Evgenii Ivanov <devivanov@proton.me>
Reviewed by:	imp
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D52197
2025-09-30 07:20:05 +03:00
Vladimir Kondratyev
e43fbf2797 u2f(4): Invert U2F_MAKE_UHID_ALIAS kernel build option
This makes non-GENERIC kernel configs easier to maintain.

Requested by:	glebius
MFC after:	2 days
2025-09-25 10:54:19 +03:00
Andrew Turner
0efa0fe26b arm: Use the Self-Synchronized counter registers
When FEAT_ECV is implemented on arm64 a Self-Synchronized view of the
counter registers are available. These don't need an isb before reading
the count as they are not able to be speculatively executed.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D51820
2025-09-23 18:08:37 +01:00
Konstantin Belousov
1c0465a3d3 arm/atomic.h: remove misleading comment
Noted and reviewed by:	jrtc27
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D52626
2025-09-20 22:24:02 +03:00
Konstantin Belousov
b31abc95eb arm, powerpc, riscv: implement atomic_set/clear_16
Reviewed by:	jrtc27, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D52626
2025-09-20 22:23:54 +03:00
Andrew Turner
055229eda6 arm64: Add cpu_feat_disabled for disabled features
When a feature is disabled we may need to run a cleanup handler, e.g.
to remove a feature from the sanitized ID registers. Add support for
this with a new feat_disabled handler.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D52577
2025-09-19 11:05:46 +01:00
Andrew Turner
226375a1f6 arm64: Fix the FEAT_WFxT check
The check was always true so would incorrectly enable the feature when
it wasn't supported.

Due to another bug this was harmless.

Sponsored by:	Arm Ltd
2025-09-15 14:32:18 +01:00
Olivier Certner
c1eff1d745
sys: NOTES: Fix comment for wlan_* devices; GENERIC*: Re-order 'wlan_tkip'
Fix the comment introducing the 'wlan_*' devices (AES-CCMP is missing)
after introducing AES-GCMP.

While here, re-order the devices in order of appearance of the related
technologies.

No functional change (intended).

Reviewed by:    adrian, emaste
Fixes:          7bf82ea4fd ("sys: add wlan_gcmp to GENERIC kernels as appropriate")
MFC after:      3 days
MFC to:         stable/15
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52444
2025-09-09 17:19:04 +02:00
Andrew Turner
4bc68fa98f arm64: Support managing features from loader
Allow the user to enable/disable supported cpu features/errata from a
known tunable. This will allow the user to disable features, e.g. to
work around broken firmware. It can also be used to enable workarounds
for rare errata.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D52358
2025-09-04 15:45:09 +01:00
Andrew Turner
9204a315a7 arm64: Add a sysctl to see if features are enabled
This will also be used as a tunable to control features in a later
change.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D52357
2025-09-04 15:44:39 +01:00
Andrew Turner
b3605a7bb6 arm64: Add a macro to create cpu_feat
This will be used later to extend cpu feature detection

Reviewed by:	imp (earlier version)
Sponsored by:   Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D52356
2025-09-04 15:25:41 +01:00
Vladimir Kondratyev
4a04e0a6c7 u2f(4): a HID driver for FIDO/U2F security keys
While FIDO/U2F keys were already supported by the generic uhid(4) and
hidraw(4) drivers, this driver adds some additional features an does
steps to tighten the security of FIDO/U2F access.

- It automatically loads through devd.
- Automatically enables HQ_NO_READAHEAD for FIDO/U2F devices.
- Implements only miminum set of features.
- Do not requires external devfs configuration to set character device
  permissions.
- Names character device as u2f/# to make possible capsicum or any
  other pledge()-style sandboxing.

PR:		265528
Differential Revision:	https://reviews.freebsd.org/D51612
2025-08-18 00:00:45 +03:00
Gordon Bergling
9c7a9b3ff1 arm: Fix two typos in kernel messages of pmu_fdt.c
- s/interupt/interrupt/

MFC after:	5 days
2025-08-17 09:01:13 +02:00
Ahmad Khalifa
c063fb7acc gpio: remove gpiobus_attach_bus
Since gpiobus_attach_bus can attach the gpiobus child along with its
children in the same bus pass, the parent controller's reference to
gpiobus might not be set by the time the children need it. Instead,
drivers should use gpiobus_add_bus and explicitly call
bus_attach_children.

Reviewed by:	mmel, imp (older version)
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D51578
2025-08-13 14:14:00 +03:00
Julien Cassette
4113280f75 aw_mmc: changes for Allwinner D1
Necessary driver changes to run on the platform:
 - DMA descriptors need shifting
 - Add quirk for max-sized transfers
 - Add compatible string

Co-authored-by:	br
Co-authored-by:	mhorne
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D51197
2025-07-22 12:03:48 -03:00