Commit graph

5812 commits

Author SHA1 Message Date
Warner Losh
94ffbdb462 sys: Empty hints files
Create empty hints files for these platforms. They don't normally need a
hints file, but people use them for device instance wiring. It's less
confusing if they always exist.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D49052
2025-02-21 17:25:32 -07:00
Adrian Chadd
cf82a0d2b7 ASUS_AC1300: add storage device options
This adds the required bits for the installed NAND/NOR chips.

Differential Revision:	https://reviews.freebsd.org/D49028
2025-02-20 18:48:12 -08:00
Adrian Chadd
9f32893b05 qcom_ess_edma: Add the IPQ4018/IPQ4019 ethernet MAC/MDIO driver.
This adds the ESS EDMA driver introduced by the IPQ4018/IPQ4019.

It provides a number of transmit and receive rings which can be mapped
into virtual ethernet devices, which this driver supports.

It's partially integrated into the ar40xx etherswitch which supplies
the port and some filtering/VPN offload functionality. This driver
only currently supports the per-port options which allow for the
virtual ethernet driver mapping.

This was written by reverse engineering the functionality of the
ethernet switch and ethernet driver support provided by Qualcomm
Atheros via their OpenWRT contributions.  The code is all originally
authored by myself.

Differential Revision:	https://reviews.freebsd.org/D49027
2025-02-20 18:48:12 -08:00
Harry Moulton
43b3e755d0 arm64: use FEAT_WFxT for DELAY() when available
Use a wfet, rather than a busy wait, in DELAY() when the FEAT_WFxT
extension is available.

Reviewed by:	andrew
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D48580
Signed-off-by: Harry Moulton <harry.moulton@arm.com>
2025-02-17 16:07:36 +00:00
Bojan Novković
e17e33f997 sdhci: Refactor the generic FDT driver
This patch refactors the 'sdhci_fdt.c' driver by moving all vendor
specific routines into separate files and making the base 'sdhci_fdt'
driver subclassable. The goal is to make adding new FDT-based drivers
easier and more maintainable. No functional change intended.

Reviewed by:	manu, imp
Differential Revision:	https://reviews.freebsd.org/D48527
2025-02-07 10:06:07 +01:00
John Baldwin
f66a407de2 sys: Add cpu_update_pcb hook
This MD function is invoked before dumping register set notes when
writing out a core dump to ensure that the PCB for a given thread is
up to date.  This provides a centralized place to update the PCB with
values of the current thread for each arch rather than doing this work
in each register set's get method.

Discussed with:	jrtc27
Reviewed by:	kib, markj
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D44910
2025-01-31 15:40:29 -05:00
Mitchell Horne
9257fe124f riscv: aw_timer enablement for D1
The SBI timer functionality is partially broken on the Allwinner D1, so
we require this driver to provide an eventtimer/system timer interrupts.

The timecounter interface, on the other hand, is not required. The
generic RISC-V timer driver uses the native rdtime instruction, and
implements vdso, so this should be preferred.

Reviewed by:	manu, ganbold
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48672
2025-01-27 16:04:14 -04:00
Mitchell Horne
c4530dfff4 aw_timer: rename driver from a10_timer
This reflects its expanded support for platforms other than the A10.

Functions specific to A10/A13 retain the a10 prefix, but the majority of
names in the driver are changed, e.g. a10_timer_softc becomes
aw_timer_softc.

Reviewed by:	manu, ganbold
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48671
2025-01-27 16:04:09 -04:00
Mitchell Horne
449e6a9527 a10_timer: some tidying/re-organization
In preparation for enabling the driver on the D1 platform (riscv).

 - Better isolate armv7-only portions of the driver
 - Move a10 timecounter setup into a helper function
 - Small style tweaks

Reviewed by:	manu, ganbold
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48670
2025-01-27 16:03:49 -04:00
Ahmad Khalifa
4d213c595a sys: use globals for the ELF kernel and module type strings
Initialize the globals with macros so we can use the same values in the
loader.

Also remove unnecessary "elfN module" checks.

Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1394
2025-01-24 14:29:39 -07:00
Ahmad Khalifa
b72ae900d4 sys: make the kernel metadata pointer global
The way we got the kernel metadata pointer was by calling
preload_search_by_type with one of the following three: "elf kernel",
"elf32 kernel" and "elf64 kernel". Which one(s) we used wasn't
consistent though. Sometimes we would only try "elf kernel", and other
times we would try one of the latter two if the first failed. However,
the loader only ever sets "elf kernel" as the kernel type.

Now, the kmdp is a global, preload_kmdp, and it's initialized using
preload_initkmdp in machdep.c (or machdep_boot.c on arm/64).
preload_initkmdp takes a single boolean argument that tells us whether
not finding the kmdp is fatal or not.

Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1394
2025-01-24 14:25:51 -07:00
Andrew Turner
41dfdf04e2 arm: Fix the location of a ';'
It must have fallen off the line, return it to its correct location.

Sponsored by:	Arm Ltd
2025-01-24 12:09:29 +00:00
Mitchell Horne
5884fab461 pci: cleanup __PCI_REROUTE_INTERRUPTS
This flag was used as a transition for differing pcib implementations.
Today it is defined for all supported architectures, and can be removed.

Reviewed by:	imp, jhb
Differential Revision:	https://reviews.freebsd.org/D48485
2025-01-23 16:30:31 -04:00
Mitchell Horne
6f27755482 armada38x: implement gateclk clkdev methods
Implement basic clkdev methods required by the generic clk_gate device.
This should make it functional, and prevent panics when invoking the
clock's CLKNODE_GET_GATE method (e.g. with `sysctl -a`).

Additionally, we need to fill in other key fields of the clk_gate_def
structure before registering each clk.

PR:		278188
Reported by:	solo_code@protonmail.com
Tested by:	solo_code@protonmail.com
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48419
2025-01-16 13:27:00 -04:00
Brooks Davis
660331da7a Centralize and simpify implemention of some VM macros
These macros have substantially identical implementations on each
platform.  Use roundup2/rounddown2 for round_page/trunc_page.

This version standardizes on not using explicit casts and instead
preserving the original type.  A couple of tweaks were required to
make this work.

Reviewed by:	brooks, kib, markj
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D48450
2025-01-14 10:48:07 -05:00
Mitchell Horne
9eb30ef4b7 riscv: enable Allwinner D1 USB drivers
Add the generic USB drivers and FDT glue to the build.

Make small tweaks to the aw_usbphy and aw_musb drivers for the Allwinner
D1.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D48126
2025-01-10 13:57:36 -04:00
John Baldwin
11a9117871 Use bus_generic_detach to detach and delete child devices during detach
This is simpler and more robust than individual calls to
device_delete_child.

Differential Revision:	https://reviews.freebsd.org/D47972
2025-01-02 13:25:12 -05:00
John Baldwin
3ddaf8200b Use bus_generic_detach instead of device_delete_children in detach
While here, check for errors from bus_generic_detach and move it to
the start of detach if necessary.

Differential Revision:	https://reviews.freebsd.org/D47969
2025-01-02 13:24:28 -05:00
John Baldwin
64d1a02e4e Check for errors from bus_generic_detach in various drivers
In some cases, move the call to bus_generic_detach earlier so that any
detach failures from child devices do not leave the parent device
partially detached.

Differential Revision:	https://reviews.freebsd.org/D47966
2025-01-02 13:23:41 -05:00
John Baldwin
e74465f177 cpsw: Remove duplicate call to bus_generic_detach
Differential Revision:	https://reviews.freebsd.org/D47963
2025-01-02 13:23:02 -05:00
John Baldwin
160179ea3e Remove now-redundant calls to device_delete_children
Earlier calls to bus_generic_detach now take care of deleting
children.

Differential Revision:	https://reviews.freebsd.org/D47962
2025-01-02 13:22:50 -05:00
John Baldwin
4e62c3cafa Remove now-redundant calls to device_delete_child
Deleting a child explicitly before calling bus_generic_detach is now
redundant, so remove those calls and rely on bus_generic_detach to
delete children instead.

Differential Revision:	https://reviews.freebsd.org/D47961
2025-01-02 13:22:35 -05:00
John Baldwin
b196276c20 bus_generic_detach: Delete children after detaching them
This provides better semantics as a standalone DEVMETHOD for
device_attach as bus drivers should remove child devices they created
as part of detach cleanup.  The implementation calls
bus_detach_children() first to permit child devices an opportunity to
veto the detach operation.  If that succeeds, device_delete_children()
is used to delete the child devices.

This requires fixing various drivers that were deleting devices
explicitly (via a device_t pointer cached in the softc) after calling
bus_generic_detach to stop doing that and just rely on
bus_generic_detach to remove child devices.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D47959
2025-01-02 13:21:30 -05:00
John Baldwin
28f5e880e8 Use device_delete_children instead of explicit calls to device_delete_child
This is simpler and more robust in the face of potential double-frees
(e.g. if called after bus_generic_detach which will delete devices in
a future commit).

Reviewed by:	manu, imp
Differential Revision:	https://reviews.freebsd.org/D47958
2025-01-02 13:20:21 -05:00
John Baldwin
e9d3857040 Use bus_detach_children instead of bus_generic_detach
These drivers perform additional teardown steps in between detaching
child devices and deleting child devices.

Differential Revision:	https://reviews.freebsd.org/D47957
2025-01-02 13:19:39 -05:00
Gordon Bergling
fad3e1fbc8 arm/qualcomm: Fix a typo in a source code comment
- s/unneccessary/unnecessary/

MFC after:	3 days
2024-12-28 07:41:24 +01:00
Elliott Mitchell
487788a69f intrng: fix INTR_ROOT_* constants
Switch to INTR_ROOT_COUNT as this name better describes its purpose.

Remove the default INTR_ROOT_IRQ from the core.  Define it (redundantly)
in each architecture's header, but now placed alongside its sibling
values (if defined by the platform, e.g. arm64 INTR_ROOT_FIQ).

Reviewed by:	mhorne
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1280
2024-12-16 15:11:52 -04:00
Olivier Certner
5e9a82e898
atomics: Constify loads
In order to match reality, allow using these functions with pointers on
const objects, and bring us closer to C11.

Remove the '+' modifier in the atomic_load_acq_64_i586()'s inline asm
statement's constraint for '*p' (the value to load).  CMPXCHG8B always
writes back some value, even when the value exchange does not happen in
which case what was read is written back.  atomic_load_acq_64_i586()
further takes care of the operation atomically writing back the same
value that was read in any case.  All in all, this makes the inline
asm's write back undetectable by any other code, whether executing on
other CPUs or code on the same CPU before and after the call to
atomic_load_acq_64_i586(), except for the fact that CMPXCHG8B will
trigger a #GP(0) if the memory address is part of a read-only mapping.
This unfortunate property is however out of scope of the C abstract
machine, and in particular independent of whether the 'uint64_t' pointed
to is declared 'const' or not.

Approved by:    markj (mentor)
MFC after:      5 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D46887
2024-12-16 15:42:26 +01:00
Zhenlei Huang
d4eb2d3f30 aw_gpio: Add a missing comma
This unbreaks arm build after commit 7192454558.

Fixes:	7192454558 aw_gpio: support Allwinner D1 GPIO
2024-12-12 14:45:11 +08:00
Julien Cassette
7192454558 aw_gpio: support Allwinner D1 GPIO
The GPIO controls the multiplexing of the D1 pins to its peripherals,
so this adds the definitions needed by the aw_gpio driver to support
the D1.

Also, this modifies the aw_gpio driver to support the differences of
the D1 controller:

- pins can have up to 15 functions
- each port is mapped with an alignment of 0x30
- CFG registers have 4 bits per pin
- DRV registers have 4 bits per pin
- the offset of PULL registers is 0x24

Signed-off-by: Julien Cassette <julien.cassette@gmail.com>
Reviewed by:	mhorne
Differential Revision:	https://reviews.freebsd.org/D35593
2024-12-10 17:30:13 -04:00
Mitchell Horne
8547197130 riscv: enable Allwinner if_awg
Enable the driver and dependencies (aw_sid, nvmem). Add compat strings,
etc.

Found on the Allwinner D1.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D47923
2024-12-10 17:28:38 -04:00
Doug Moore
c1d12b925b vm_page: pass page to iter_remove
Pass the to-be-freed page to vm_page_iter_remove as a parameter,
rather than computing it from the iterator parameter, to improve
performance.

Reviewed by:	alc
Differential Revision:	https://reviews.freebsd.org/D47730
2024-12-08 14:30:22 -06:00
John Baldwin
8f7835acc6 Remove SOC FPGA drivers
The drivers have been disconnected from the build since the removal of
the SOCFPGA kernel configs.

Reviewed by:	manu, imp, andrew
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D47885
2024-12-06 17:38:52 -05:00
John Baldwin
34f5de82e8 bus_delayed_attach_children: Switch return type to void
This function never fails similar to bus_attach_children.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D47677
2024-12-06 17:27:14 -05:00
John Baldwin
18250ec6c0 Replace calls to bus_generic_attach with bus_attach_children
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D47675
2024-12-06 17:26:16 -05:00
John Baldwin
723da5d92f Replace calls to bus_generic_probe with bus_identify_children
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D47674
2024-12-06 17:26:05 -05:00
Warner Losh
d1e843b3f9 arm: Use constants from sys/intr.h, not genassym
We can now include sys/intr.h to get these constants rather than using
genassym. Opt for this simpler method.

PR:			283041
Sponsored by:		Netflix
Reviewed by:		mmel, andrew
Differential Revision:	https://reviews.freebsd.org/D47847
2024-12-06 10:31:36 -07:00
Warner Losh
7b16a4a75d sys/intr.h: Make it safe to include from assembler
Sometimes we need defines from this file in assembler code. Today we do
the heavyweight approach of using genassym for that. However, they are
just #defines, so in the future we want to include sys/intr.h to pick up
the needed constants in exception.S.

PR:			283041
Sponsored by:		Netflix
Reviewed by:		mmel, andrew
Differential Revision:	https://reviews.freebsd.org/D47846
2024-12-06 10:31:36 -07:00
Mark Johnston
aabd759cf7 drm2: Fix the build after commit 38e3125d6d
Fixes:	38e3125d6d ("device_pager: user iterators to free device pages")
2024-11-26 21:04:36 +00:00
Mark Johnston
ef9ffb8594 kern: Make fileops and filterops tables const where possible
No functional change intended.

MFC after:	1 week
2024-11-26 21:04:21 +00:00
Michal Meloun
3abef90c32 arm: Fix VFP state corruption during signal delivery
D37419 corrupts VFP context store on signal delivery and D38696 corrupts PCB
because it performs a binary copy between structures with different layouts.
Revert the problematic parts of these commits to have signals delivery
working. Unfortunately, there are more problems with these revisions and
more fixes need to be developed.

Fixes: 6926e2699a
Fixes: 4d2427f2c4
MFC after:	4 weeks
2024-11-26 12:18:30 +01:00
Doug Moore
38e3125d6d device_pager: user iterators to free device pages
Change cdev_mgtdev_page_free_page to take an iterator, rather than an
object and page, so that removing the page from the object radix tree
can take advantage of locality with iterators. Define a
general-purpose function to free all pages, which can be used in
several places.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D47692
2024-11-21 15:49:30 -06:00
John Baldwin
a80b9ee15a atomic(9): Implement atomic_testand(clear|set)_ptr
For current architectures, these are just aliases for the existing
operation on the relevant scalar integer.

Reviewed by:	imp, kib
Obtained from:	CheriBSD
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D47631
2024-11-19 10:24:50 -05:00
John Baldwin
fa2091d757 atomic(9): Remove fcmpset-based fallback for atomic_testand(clear|set)
All architectures implement a MD version

Reviewed by:	kib
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D47629
2024-11-19 10:23:15 -05:00
John Baldwin
987c5a1944 arm: Implement atomic_testandset_acq_long as a simple wrapper
Use a memory barrier after calling the existing atomic_testandset_long
rather than using the fcmpset-based fallback version from
<sys/_atomic_subword.h>.

Reviewed by:	kib
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D47628
2024-11-19 10:22:50 -05:00
Mitchell Horne
4b4e88d942 aw_wdog: disable timer on attach
Otherwise it may cause system reset before the watchdog can be pat. This
is consistent with other watchdog drivers.

Tested on Allwinner D1.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D47517
2024-11-16 15:55:27 -04:00
Mitchell Horne
184d0b3fe3 aw_syscon: enable for Allwinner D1 (riscv)
Add the relevant compatible string and build glue. Update the man page
with relevant compat strings.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D47516
2024-11-16 15:04:04 -04:00
Mitchell Horne
9ddd516b88 riscv: enable allwinner RTC
For the Allwinner D1 (Nehza) SBC.

This RTC driver is also a clock provider, which registers two fixed
clocks. In all the devices we currently support, the names of the clocks
are present in the "clock-output-names" property of the device tree.
This is not the case for the D1 DTS, as this property does not appear in
upstream. Therefore the clock definitions are statically assigned a
name, which is overridden when specified.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D47514
2024-11-16 15:04:04 -04:00
Michal Meloun
248109448f arm: switch the BUSDMA buffers to normal uncached memory
The BUSDMA buffer is treated as normal memory during compilation and compiler
is free to inline/optimize basic functions (i.e. memset, memcpy) accessing
buffers, including when an instruction is generated that performs a word
access to unaligned data. We support this, but only if the buffer in question
is mapped as normal memory (cached or not), but not to memory mapped as
strongly ordered or device type.

MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D47485
2024-11-11 09:22:37 +01:00
John Baldwin
d412c07617 Check for errors when detaching children first, not last
These detach routines in these drivers all ended with 'return
(bus_generic_detach())' meaning that if any child device failed to
detach, the parent driver was left in a mostly destroyed state, but
still marked attached.  Instead, bus drivers should detach child
drivers first and return errors before destroying driver state in the
parent.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D47387
2024-11-04 20:30:33 -05:00