1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-24 07:40:52 +00:00
Commit Graph

5767 Commits

Author SHA1 Message Date
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
Christos Margiolis
516a9c0212 sound: Make device registration more intuitive
The way a sound driver currently registers to sound(4) is using the
following sequence of function calls:

1. pcm_register() to initialize snddev_info.
2. pcm_addchan() calls to create the device's primary channels.
3. pcm_setstatus() to do the final setup.

While using 3 different functions in a specific order might not be very
elegant, this pattern cannot be easily avoided. However, pcm_register()
and pcm_setstatus() are especially confusing, since one would
intuitively expect:

1. pcm_register() to actually do the registration, as opposed to a basic
   initialization.
2. pcm_setstatus() to, as the name suggests, set some kind of status, as
   opposed to finalizing the registration.

This patch renames pcm_register() to pcm_init(), and pcm_setstatus() to
pcm_register(). Drivers are modified accordingly.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D47325
2024-11-03 20:02:49 +01:00
Elliott Mitchell
3514f98940 newbus: Introduce bus_get_pass() and hide bus_current_pass
There's no reason to write to bus_current_pass outside of the controlled
times subr_bus.c does it, so move to an accessor and make
bus_current_pass private to newbus.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1457
2024-11-02 12:25:34 -06:00
Kyle Evans
4b01a7fa76 Revert "intrng: change multi-interrupt root support type to enum"
This reverts commit 536c8d948e.  The
change seemed fine on the surface, but converting to an enum has raised
some concerns due to the asm <-> C interface.  Back it out and let
someone else deal with it later if they'd like to.

Further context about the concerns can be found in D47279.
2024-10-25 16:18:40 -05:00
Kyle Evans
4f12b529f4 sys/intr.h: formally depend on machine/intr.h
sys/intr.h originally started life as an extract of arm's intr.h, and
this include was dropped in its place.  Changes in flight want to add
some MD definitions that we'll use in the more MI parts of INTRNG.

Let's formally reverse the dependency now since this is way more
common in general.  All of the includes switched in this change that I
spot-checked were in-fact wanting declarations historically included in
sys/intr.h anyways.

Reviewed by:	andrew, imp, jrtc27, mhorne, mmel, olce
Differential Revision:	https://reviews.freebsd.org/D47002
2024-10-23 22:55:29 -05:00
Elliott Mitchell
536c8d948e intrng: change multi-interrupt root support type to enum
uint32_t is handy for directly interfacing with assembly-language.  For
the C portion, enum is much handier.  In particular there is no need to
count the number of roots by hand.  This also works better for being
able to build kernels with varying numbers of roots.

Switch to INTR_ROOT_COUNT as this better matches the purpose of the
value.  Switch to root_type, rather than rootnum for similar reasons.

Remove the default from the core.  Better to require the architectures
to declare the type since they will routinely deviate and a default
chosen now will likely be suboptimal.

Leave intr_irq_handler() taking a register type as that better matches
for interfacing with assembly-language.
2024-10-23 22:55:21 -05:00
Elliott Mitchell
d64442a898 arm{,64}: use genassym for INTR_ROOT_* values
Rather than keeping the entire machine interrupt header assembly-safe,
switch to use of the existing genassym.c program to generate them.  This
will be handier in the long-term, most of the header never needs to be
exposed to assembly-language.
2024-10-23 22:55:21 -05:00
John Baldwin
5201decc8b Use bus_delayed_attach_children instead of its inline implementation
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D47186
2024-10-21 10:24:39 -04:00
Andrew Turner
b9cd72b06d sys: Use the new arm_smccc_invoke macros
Simplify the calls into the SMCCC firmware with the new
arm_smccc_invoke* macros.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D46987
2024-10-15 18:24:41 +01:00
Ayrton Munoz
85918beb38 intrng: Add support for multiple interrupt roots
Different types of interrupts may require using different exception
vectors so this commit adds support multiple interrupt roots to handle
these cases. Archs may opt-in to multiple interrupt roots by defining
INTR_ROOT_NUM as the number of roots in their intr.h. Based off
https://reviews.freebsd.org/D40161.

Signed-off-by: Ayrton Munoz <a.munoz3327@gmail.com>
Co-authored-by: Kyle Evans <kevans@FreeBSD.org>
Co-authored-by: Andrew Turner <andrew@FreeBSD.org>
Reviewed-by: imp,mmel,mhorne
Pull-Request: https://github.com/freebsd/freebsd-src/pull/1363
2024-09-22 07:18:34 -06:00
Oskar Holmlund
ad7c98797b Remove TI reference from arm/GENERIC
Approved by: imp, manu (mentor)
Differential revision: https://reviews.freebsd.org/D46702
2024-09-19 20:15:47 +02:00
Andrew Turner
66a6e1d613 arm: Remove support for Armv6 CPU cores
The ARM1176 is an Armv6 CPU. As Armv6 support has been removed we can
also remove ARM1176 support.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45958
2024-09-11 10:40:35 +00:00
Andrew Turner
d29771a722 arm: Assume __ARM_ARCH == 7
The only supported 32-bit Arm architecture is Armv7. Remove old checks
for earlier architecture revisions.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45957
2024-09-11 10:40:13 +00:00
Andrew Turner
bf18be5ab7 bcm2835: Remove support for SoCs with an Armv6 CPU
Armv6 has been removed, there is no need to keep this in the tree.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45956
2024-09-11 10:39:42 +00:00
Andrew Turner
31ca046e22 arm: Only define get_cntxct_a64_unstable when used
When building an ACPI only kernel get_cntxct_a64_unstable in the Arm
generic tiner driver is unused. Add an #ifdef FDT check around it.

Sponsored by:	Arm Ltd
2024-09-09 13:15:39 +00:00
Tom Jones
d8fffc3704 imx_gpio: Add gpio compat string for imx8 SOCs
Several imx8* device trees have a compatible gpio controller which
identifies as working with the soc and imx35-gpio.

Add a compat string for the commonly included 'imx35-gpio', rather than
adding each to the table.

From a grep of our dts mirror this includes the following arm64 SOCs:
- imx8dxl
- imx8mm
- imx8mn
- imx8mp
- imx8mq
- imx8qm
- imx8qxp

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D46532
2024-09-05 14:51:37 +01:00
Zhenlei Huang
fe6985ef87 arm ti: Stop checking for failures from malloc(M_WAITOK)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45852
2024-09-03 18:25:22 +08:00
Zhenlei Huang
356be1348d kernel: Make some compile time constant variables const
Those variables are not going to be changed at runtime. Make them const
to avoid potential overwriting. This will also help spotting accidental
global variables shadowing, since the variable's name such as `version`
is short and commonly used.

This change was inspired by reviewing khng's work D44760.

No functional change intended.

MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D45227
2024-08-30 18:26:30 +08:00
Doug Moore
d48524e21f dev_pager: define free_page for mgt devices
Callers of cdev_pager_free_page in the kernel always have object->type
== OBJT_MGTDEVICE. Define a function for them to call that skips the
runtime type check in cdev_pager_free.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D46389
2024-08-21 15:48:59 -05:00
Bojan Novković
ddc09a10ea pmap_growkernel: Use VM_ALLOC_NOFREE when allocating pagetable pages
This patch modifies pmap_growkernel in all pmaps to use VM_ALLOC_NOFREE
when allocating new pagetable pages. This should help reduce longterm
fragmentation as these pages are never released after
they are allocated.

Differential Revision:	https://reviews.freebsd.org/D45998
Reviewed by:	alc, markj, kib, mhorne
Tested by:	alc
2024-07-30 17:38:24 +02:00
Mark Johnston
6aa98f78cc conf: Remove kernel stack swapping support, part 12
Remove the NO_SWAPPING option.  There is still some code in
vm_swapout.c, but it relates to RACCT handling.  Remove the option and
make compilation of vm_swapout.c conditional on RACCT.

Tested by:	pho
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D46130
2024-07-29 01:43:59 +00:00
Mark Johnston
ba682f8b9b vm: Remove kernel stack swapping support, part 5
- Remove cpu_thread_swapin() and cpu_thread_swapout().

Tested by:	pho
Reviewed by:	alc, imp, kib
Differential Revision:	https://reviews.freebsd.org/D46116
2024-07-29 01:40:39 +00:00
Mark Johnston
e24a655283 thread: Remove kernel stack swapping support, part 4
- Remove the IS_SWAPPED thread inhibitor state.
- Remove all uses of TD_IS_SWAPPED() in the kernel.
- Remove the TDF_CANSWAP flag.
- Remove the P_SWAPPINGOUT and P_SWAPPINGIN flags.

Tested by:	pho
Reviewed by:	alc, imp, kib
Differential Revision:	https://reviews.freebsd.org/D46115
2024-07-29 01:40:22 +00:00
Warner Losh
5b56413d04 newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANY
Sponsored by:		Netflix
2024-07-24 22:22:58 -06:00
Alan Cox
cd836f6004 vm: Retire kmem_arena
It has simply been an alias for the kernel_arena for many years now.
Enough time has passed to retire it.  Any out-of-tree kernel modules
that directly use kmem_arena should switch to kernel_arena.

Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D46057
2024-07-24 14:31:40 -05:00
Jessica Clarke
e1d442a6db Retire unused non-PCI_RES_BUS code
All architectures define PCI_RES_BUS unconditionally now that only
NEW_PCIB is supported, so we no longer need the legacy code.

Reviewed by:	jhb, andrew
Differential Revision:	https://reviews.freebsd.org/D32955
2024-07-18 18:55:33 +01:00
Jessica Clarke
8415a654d0 Retire non-NEW_PCIB code and remove config option
All architectures enable NEW_PCIB in DEFAULTS (arm being the most recent
to do so in 121be55599 (arm: Set NEW_PCIB in DEFAULTS rather than a
subset of kernel configs")), so it's time we removed the legacy code
that no longer sees much testing and has a significant maintenance
burden.

Reviewed by:	jhb, andrew, emaste
Differential Revision:	https://reviews.freebsd.org/D32954
2024-07-18 18:55:12 +01:00
Andrew Turner
f5c7644378 sys/arm: Remove armv6 kernel configs
Only the Raspberry Pi config was supported on armv6. Remove it in
preparation for removing armv6 support from the kernel.

Reviewed by:	manu, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45646
2024-07-12 11:31:54 +00:00
Mark Johnston
d68d124817 arm: Add evdev to the TEGRA124 config
This is required for the kernel to link after commit 13d00a43cb.

Fixes:	13d00a43cb ("conf: Add usbhid and hidbus to GENERIC* kernel configs")
2024-07-11 15:19:42 -04:00
Emmanuel Vadot
13d00a43cb conf: Add usbhid and hidbus to GENERIC* kernel configs
Include the new unified HID stack by default in generic.
This will allow us to migrate to the multi-stack hkbd and hms instead of
relying on the older ukbd and ums which only work with USB.
To test those drivers just add hw.usb.usbhid.enable=1 in loader.conf

Differential Revision:	https://reviews.freebsd.org/D45658
Reviewed by:	emaste, imp, wulf (all older version)
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2024-07-10 08:05:25 +02:00
Mitchell Horne
558c1b3733 busdma: avoid buflen underflow
The loop condition in the dmamap_load_buffer() method is 'buflen > 0',
and buflen is an unsigned type (bus_size_t).

A recent change made it possible for sgsize to exceed the remaining
buflen, when the tag has a large alignment requirement. The result is
that we would not break out of the loop at the correct time. Fix this by
avoiding underflow in the subtraction at the end of the loop.

PR:		279383
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	jhibbits
Fixes:		a77e1f0f81 ("busdma: better handling of small segment bouncing")
Differential Revision:	https://reviews.freebsd.org/D45732
2024-07-08 11:51:31 -03:00
Zhenlei Huang
aa3860851b net: Remove unneeded NULL check for the allocated ifnet
Change 4787572d05 made if_alloc_domain() never fail, then also do the
wrappers if_alloc(), if_alloc_dev(), and if_gethandle().

No functional change intended.

Reviewed by:	kp, imp, glebius, stevek
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D45740
2024-06-28 18:16:29 +08:00
Andrew Turner
5afc347944 arm: Start to remove the now unneeded acle-compat.h
All supported compilers provide the acle macros so we don't need the
backup versions.

Keep the file around for anything that included it directly, but make
it an error to not support the acle macros.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45726
2024-06-26 08:52:08 +00:00
Andrew Turner
36e0db4916 Revert "arm: Start to remove the now unneeded acle-compat.h"
This reverts commit 3d02fe6c59.

This wasn't ready to be committed
2024-06-25 09:37:14 +00:00
Andrew Turner
3d02fe6c59 arm: Start to remove the now unneeded acle-compat.h
All supported compilers provide the acle macros so we don't need the
backup versions.

Sponsored by:	Arm Ltd
2024-06-25 09:07:19 +00:00
Oskar Holmlund
332f00cdba ti/am335x: Fix the device_set_descf() call in am335x_dmtimer_probe()
Fixes: 459dc61c8b ("arm: Convert drivers to use device_set_desc(f)()")

Reviewed by:    markj, imp, manu
Approved by:    markj, imp, manu (mentor)
Differential Revision:  https://reviews.freebsd.org/D45699
2024-06-24 13:57:25 +02:00
Mark Johnston
ddf0ed09bd sdt: Implement SDT probes using hot-patching
The idea here is to avoid a memory access and conditional branch per
probe site.  Instead, the probe is represented by an "unreachable"
unconditional function call.  asm goto is used to store the address of
the probe site (represented by a no-op sled) and the address of the
function call into a tracepoint record.  Each SDT probe carries a list
of tracepoints.

When the probe is enabled, the no-op sled corresponding to each
tracepoint is overwritten with a jmp to the corresponding label.  The
implementation uses smp_rendezvous() to park all other CPUs while the
instruction is being overwritten, as this can't be done atomically in
general.  The compiler moves argument marshalling code and the
sdt_probe() function call out-of-line, i.e., to the end of the function.

Per gallatin@ in D43504, this approach has less overhead when probes are
disabled.  To make the implementation a bit simpler, I removed support
for probes with 7 arguments; nothing makes use of this except a
regression test case.  It could be re-added later if need be.

The approach taken in this patch enables some more improvements:
1. We can now automatically fill out the "function" field of SDT probe
   names.  The SDT macros let the programmer specify the function and
   module names, but this is really a bug and shouldn't have been
   allowed.  The intent was to be able to have the same probe in
   multiple functions and to let the user restrict which probes actually
   get enabled by specifying a function name or glob.
2. We can avoid branching on SDT_PROBES_ENABLED() by adding the ability
   to include blocks of code in the out-of-line path.  For example:

	if (SDT_PROBES_ENABLED()) {
		int reason = CLD_EXITED;

		if (WCOREDUMP(signo))
			reason = CLD_DUMPED;
		else if (WIFSIGNALED(signo))
			reason = CLD_KILLED;
		SDT_PROBE1(proc, , , exit, reason);
	}

could be written

	SDT_PROBE1_EXT(proc, , , exit, reason,
		int reason;

		reason = CLD_EXITED;
		if (WCOREDUMP(signo))
			reason = CLD_DUMPED;
		else if (WIFSIGNALED(signo))
			reason = CLD_KILLED;
	);

In the future I would like to use this mechanism more generally, e.g.,
to remove branches and marshalling code used by hwpmc, and generally to
make it easier to add new tracepoint consumers without having to add
more conditional branches to hot code paths.

Reviewed by:	Domagoj Stolfa, avg
MFC after:	2 months
Differential Revision:	https://reviews.freebsd.org/D44483
2024-06-19 16:57:41 -04:00
Andrew Turner
6abad5b606 Remove the arm FIQ support
It isn't used, and only masks/unmasks FIQs on the local CPU so will be
broken on SMP.

Reviewed by:	mmel
Differential Revision:	https://reviews.freebsd.org/D33804
2024-06-10 15:16:10 +00:00
Mark Johnston
3ce9b2ee94 ti/am335x: Fix the device_set_descf() call in dmtpps_probe()
Fixes:	459dc61c8b ("arm: Convert drivers to use device_set_desc(f)()")
2024-06-09 10:08:31 -04:00
Mitchell Horne
5df74441b3 devmap: eliminate unused arguments
The optional 'table' pointer is a legacy part of the interface, which
has been replaced by devmap_register_table()/devmap_add_entry(). The few
in-tree callers have already adapted to this, so it can be removed.

The 'l1pt' argument is already entirely unused within the function.

Reviewed by:	andrew, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D45319
2024-06-04 20:17:47 -03:00
Mark Johnston
459dc61c8b arm: Convert drivers to use device_set_desc(f)()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:40 -04:00
Warner Losh
b8a7548399 LINT: Don't build bnxt on 32-bit platforms
Sponsored by: Netflix
Fixes: acd884dec9 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
2024-05-29 10:50:27 -06:00
Mitchell Horne
deab57178f Adjust comments referencing vm_mem_init()
I cannot find a time where the function was not named this.

Reviewed by:	kib, markj
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D45383
2024-05-27 18:37:40 -03:00
Bojan Novković
0a44b8a56d vm: Simplify startup page dumping conditional
This commit introduces the MINIDUMP_STARTUP_PAGE_TRACKING symbol and
uses it to simplify several instances of a complex preprocessor conditional
for adding pages allocated when bootstraping the kernel to minidumps.

Reviewed by:	markj, mhorne
Approved by:	markj (mentor)
Differential Revision: https://reviews.freebsd.org/D45085
2024-05-25 19:24:55 +02:00
Andrew Turner
e72c417723 arm: Use the correct irq when in the hypervisor
When booting in the hypervisor state we need to use the hypervisor
interrupt in the generic timer. In this case the registers we access
in the kernel are remapped to the EL2 versions, however this causes
an unexpected interrupt to trigger.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D43975
2024-05-17 16:07:16 +00:00
Andrew Turner
f715e95461 arm: Add a missing interrupt to the generic timer
The ACPI generic timer attachment added 3 interrupts, but missed the
hypervisor physical interrupt. As the field is present in all versions
of the GTDT ACPI table and isn't an optional interrupts we can add it
to the interrupts provided to the driver.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D43974
2024-05-17 16:07:15 +00:00