Commit graph

5728 commits

Author SHA1 Message Date
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
John Baldwin 473c90ac04 uio: Use switch statements when handling UIO_READ vs UIO_WRITE
This is mostly to reduce the diff with CheriBSD which adds additional
constants to enum uio_rw, but also matches the normal style used for
uio_segflg.

Reviewed by:	kib, emaste
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D45142
2024-05-10 13:43:36 -07:00
Elliott Mitchell 98c276811a arm: add missing atomic-pointer functions
The pointer function types were missing for these functions, so add
them.  Valuable for places where type sizes vary by architecture.

Differential Revision: https://reviews.freebsd.org/D37778
Reviewed by: imp, andrew
Pull Request: https://github.com/freebsd/freebsd-src/pull/1126
2024-05-09 17:14:59 -06:00
Elliott Mitchell e64318e76e arm/pmu: remove passing trap frame as argument
While otherwise a handy potential approach, getting the trap frame via
the argument isn't documented and isn't supposed to be used.  Adjust
pmu_intr() to instead use curthread->td_intr_frame, which is the proper
way.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1126
2024-05-09 17:14:29 -06:00
Mitchell Horne a77e1f0f81 busdma: better handling of small segment bouncing
Typically, when a DMA transaction requires bouncing, we will break up
the request into segments that are, at maximum, page-sized.

However, in the atypical case of a driver whose maximum segment size is
smaller than PAGE_SIZE, we end up inefficiently assigning each segment
its own bounce page. For example, the dwmmc driver has a maximum segment
size of 2048 (PAGE_SIZE / 2); a 4-page transfer ends up requiring 8
bounce pages in the current scheme.

We should attempt to batch segments into bounce pages more efficiently.
This is achieved by pushing all considerations of the maximum segment
size into the new _bus_dmamap_addsegs() function, which wraps
_bus_dmamap_addseg(). Thus we allocate the minimal number of bounce
pages required to complete the entire transfer, while still performing
the transfer with smaller-sized transactions.

For most drivers with a segment size >= PAGE_SIZE, this will have no
impact. For drivers like dwmmc mentioned above, this improves the memory
and performance efficiency when bouncing a large transfer.

Co-authored-by:	jhb
Reviewed by:	jhb
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D45048
2024-05-07 13:02:57 -03:00
Mitchell Horne 5604069824 busdma: deduplicate _bus_dmamap_addseg() function
It is functionally identical in all implementations, so move the
function to subr_busdma_bounce.c. The KASSERT present in the x86 version
is now enabled for all architectures. It should be universally
applicable.

Reviewed by:	jhb
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D45047
2024-05-07 13:02:57 -03:00
Christos Margiolis a3513995f5 arm: Remove stray references to dev/sound/chip.h
Fixes:		923e0040a5 ("sound: Move chip.h contents to pcm/sound.h")
Reported by:	Jenkins CI
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-05-06 21:35:30 +02:00
Mark Johnston 4a5e2ddbd8 arm: Remove duplicate definitions in armreg.h
No functional change intended.

MFC after:	1 week
2024-04-30 17:33:43 -04:00
Lexi Winter 8a8daeafaf sys/*/conf: do not use "../../conf/" when including std.*
Since config(8) searches sys/conf by default, there's no need to specify
the full relative path here; replace it by the filename alone.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1124
2024-04-23 15:13:31 -06:00
Lexi Winter 4f8f9d708e sys: add conf/std.debug, generic debugging options
The new sys/conf/std.debug contains the list of debugging options
enabled by default in -CURRENT, so they don't need to be listed
individually in every kernel config.

The enabled options are the set of all debug options which were enabled
for the GENERIC kernel on any platform.  This means some architectures
now have debugging options enabled in GENERIC which weren't previously
enabled:

- amd64: [1]
- arm64: [2]
- arm: [2]. [3]
- i386: [1], [2]
- powerpc: [1], [2], [3]
- riscv: [2]

[1] ALT_BREAK_TO_DEBUGGER is now enabled.
[2] BUF_TRACKING, FULL_BUF_TRACKING, and QUEUE_MACRO_DEBUG_TRASH are now
    enabled.
[3] DEADLKRES is now enabled.

While here, move the documentation for the (commented out) K*SAN options
for amd64 from GENERIC to NOTES.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1124
2024-04-23 15:13:31 -06:00
HP van Braam 10e0c34bf8 Enable L1SS handling on RPI4 pcib
Thanks to @kevans91 for pointing me in the right direction. FreeBSD had
the same bug as Linux (see
https://bugzilla.kernel.org/show_bug.cgi?id=217276) where the ultimate
solution was to honor the brcm,enable-l1ss FDT property.

In current versions of the dtb files this property has been added by
default.

Without this on many, many pcie addin cards the pcib will Serror when
trying to assert the clreq# pin on the pcie bus. Many cards do not have
these hooked up.

PR:		260131, 277638, 277605
Reviewed-by:	emaste
Signed-off-by: HP van Braam <hp@tmm.cx>
Pull-request: https://github.com/freebsd/freebsd-src/pull/1179
2024-04-21 18:34:05 -04:00
Gordon Bergling 26f6c148bc freescale: Fix a typo in a source code comment
- s/cant/can't/

MFC after:	3 days
2024-04-21 09:52:14 +02:00
Gordon Bergling 178cf4b9db arm: Fix a typo in a KASSERT message
- s/resoure/resource/

MFC after:	5 days
2024-04-19 08:54:39 +02:00
Lexi Winter ac83063d37 bcm2838_xhci: add module
bcm2838_xhci(4) is a shim for the XHCI controller on the Raspberry Pi 4B
SoC.  It loads the controller's firmware before passing control to the
normal xhci(4) driver.

When xhci(4) is built as a module (and not in the kernel), bcm2838_xhci
is not built at all and the RPi4's XHCI controller won't attach due to
missing firmware.

To fix this, build a new module, bcm2838_xhci.ko, which depends on
xhci.ko.  For the dependency to work correctly, also modify xhci to
provide the 'xhci' module in addition to the 'xhci_pci' module it
already provided.

Since bcm2838_xhci is specific to a quirk of the RPi4 SoC, only build
the module for AArch64.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1142
2024-04-09 21:11:39 -06:00
John Baldwin 76f22e353f NOTES: Add devices for iSCSI support
Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44688
2024-04-09 15:02:58 -07:00
John Baldwin 973d3a8209 NOTES: Move OFED options to MI NOTES
Disable in armv7 NOTES to match sys/modules/Makefile

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44686
2024-04-09 15:02:58 -07:00
Jake Freeland 05296a0ff6 ktrace: Record syscall violations with KTR_CAPFAIL
Report syscalls that are not allowed in capability mode with
CAPFAIL_SYSCALL.

Reviewed by:	markj
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D40678
2024-04-07 18:52:51 -05:00
Pierre-Luc Drouin 5ca8e32633 vf_i2c: split up and add ACPI attachments in addition to FDT
Move the code from the arm specific to the iicbus controller directory.
Split up between general logic and bus attachment code.
Add support for ACPI attachment in addition to FDT.

MFC after:	7 days
Tested by:	bz (LS1088a FDT), Pierre-Luc Drouin (Honeycomb, ACPI)
Based on:	D24917 by Val Packett (initial early version)
Differential Revision:	https://reviews.freebsd.org/D44020
2024-03-29 23:04:51 +00:00
Emmanuel Vadot fb393d22c9 arm: Remove TI from NOTES
TI support was removed so remove it from NOTES too.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
2024-03-28 07:27:10 +01:00
Emmanuel Vadot 7ad2e83d5e arm/GENERIC: Remove TI DTBs
We've removed TI support in 3416e102c4 ("arm: Remove TI code from GENERIC")
so no need to build the DTBs now.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
2024-03-20 21:04:12 +01:00
John Baldwin 66658b0f27 arm busdma: Fix parameter types to exclusion_bounce_check
These are bus addresses not CPU virtual addresses.

Reviewed by:	andrew
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D44343
2024-03-15 10:10:07 -07:00
John Baldwin 9dbf5b0e68 new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCE
The public bus_release_resource() API still accepts both forms, but
the internal kobj method no longer passes the arguments.
Implementations which need the rid or type now use rman_get_rid() or
rman_get_type() to fetch the value from the allocated resource.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D44131
2024-03-13 15:05:54 -07:00
John Baldwin 2baed46e85 new-bus: Remove the 'rid' and 'type' arguments from BUS_*ACTIVATE_RESOURCE
The public bus_activate/deactivate_resource() API still accepts both
forms, but the internal kobj methods no longer pass the arguments.
Implementations which need the rid or type now use rman_get_rid() or
rman_get_type() to fetch the value from the allocated resource.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D44130
2024-03-13 15:05:54 -07:00
John Baldwin d77f2092ce new-bus: Remove the 'type' argument from BUS_MAP/UNMAP_RESOURCE
The public bus_map/unmap_resource() API still accepts both forms, but
the internal kobj methods no longer pass the argument.
Implementations which need the type now use rman_get_type() to fetch
the value from the allocated resource.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D44129
2024-03-13 15:05:54 -07:00
John Baldwin fef01f0498 new-bus: Remove the 'type' argument from BUS_ADJUST_RESOURCE
The public bus_adjust_resource() API still accepts both forms, but the
internal kobj method no longer passes the argument.  Implementations
which need the type now use rman_get_type() to fetch the value from
the allocated resource.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D44128
2024-03-13 15:05:54 -07:00
Alex Richardson 327ada0b0e imgact_elf: Add const to the header_supported callback arguments
This callback shouldn't be modifying any of the arguments.

Reviewed by:	imp, kib, emaste, jhb
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D44193
2024-03-04 11:52:21 -08:00
Mitchell Horne f84e9df6d0 conf: deduplicate dwmmc config logic
The core of this driver is supported by multiple architectures. Move the
config entries to the MI conf/files.

This hardware is found on several available/emerging RISC-V SoCs, so we
will soon need it on this architecture.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44104
2024-02-27 18:10:14 -04:00
Bjoern A. Zeeb 89c1e54a71 ath(4): always enable 11n
Enabling 11n for ath(4) so far was handled by a kernel option, which
was only enabled for certain kernel configurations.
In order to allow loading ath(4) as a module with 11n support on
all platforms, remove the kernel option and unconditionally enable
11n in ath(4).

Reported by:	pkubaj
Discussed with:	adrian in D43549.
Reviewed by:	adrian, imp
Differential Revision: https://reviews.freebsd.org/D43964
2024-02-22 22:34:17 +00:00
Jessica Clarke 121be55599 arm: Set NEW_PCIB in DEFAULTS rather than a subset of kernel configs
All other architectures set NEW_PCIB in DEFAULTS, with arm being the one
remaining straggler that only sets it for GENERIC and TEGRA124.
ARMADA38X and ARMADAXP contain device pci but don't set NEW_PCIB,
however GENERIC claims to support them and as part of that NEW_PCIB
support was added to mv_pci, so these configs are most likely just
stale. Other than NOTES that just leaves ALPINE as the one kernel with
PCI support not covered by GENERIC, but al_pci is supported by arm64
which enables NEW_PCIB, and it's just a generic_pcie_fdt_driver with
some fixup code to deal with quirks so should support PCI_RES_BUS just
fine. Therefore it is believed that all in-tree kernel configs support
NEW_PCIB in reality, and so let's take a step towards removing all the
non-NEW_PCIB code by having it always-on everywhere.

Reviewed by:	emaste, jhb, manu
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D43806
2024-02-22 18:27:45 +00:00
Andriy Gapon b98558e69b aw_gpio: temporarily switch to input function if read in eint mode
This is needed for gpiokeys driver that needs to read input state after
receiving an interrupt for either edge.

PR:		248138
MFC after:	1 month
2024-02-18 15:55:20 +02:00
Mitchell Horne b134c10d65 busdma: fix page miscount for small segment sizes
For small segments (< PAGE_SIZE) there is a mismatch between how
required bounce pages are counted in _bus_dmamap_count_pages() and
bounce_bus_dmamap_load_buffer().

This problem has been observed on the RISC-V VisionFive v2 SoC (and
earlier revisions of the hardware) which has memory physically addressed
above 4GB. This requires some bouncing for the dwmmc driver, which has
has a maximum segment size of 2048 bytes. When attempting to load a
page-aligned 4-page buffer that requires bouncing, we can end up
counting 4 bounce pages for an 8-segment transfer. These pages will be
incorrectly configured to cover only the first half of the transfer (4 x
2048 bytes).

Fix the immediate issue by adding the maxsegsz check to
_bus_dmamap_count_pages(); this is what _bus_dmamap_count_phys() does
already. The result is that we will inefficiently allocate a separate
bounce page for each segment (8 pages for the example above), but the
transfer will proceed in its entirety.

The more complete fix is to address the shortcomings in how small
segments are assigned to bounce pages, so that we opportunistically
batch multiple segments to a page whenever they fit (e.g. two 2048 bytes
segments per 4096 page). This will be addressed more holistically in the
future. For now this change will prevent the (silent) incomplete
transfers that have been observed.

PR:		273694
Reported by:	Jari Sihvola <jsihv@gmx.com>
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34118
2024-02-16 14:38:48 -04:00
Andrew Turner 69e4b35eb3 arm: Add EARLY_PRINTF and SOCDEV_PA/VA to NOTES
This ensures they are build tested.

Sponsored by:   Arm Ltd
2024-02-13 11:48:53 +00:00
Andrew Turner 639a626b40 arm: Clean up socdev_va
Support socdev_va on arm and ensure the variable is available on arm64.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D43359
2024-02-13 11:48:52 +00:00
Warner Losh 472f84817d arm: Move locore-v6.S to locore.S
As a separate commit, now move locore-v6.S to locore.S. This makes git
annotate work, at least back to 2014 when Ian created locore-v6.S. svn
didn't save enough metadata for the converter to allow it to go back
further.

Sponsored by:		Netflix
2024-02-06 15:49:08 -07:00
Warner Losh 6949ce0486 arm: Use locore-v6.S directly
Use locore-v6.S directly, rather than indirectly via including
locore.S. This loses acle-compat.h inclusion, but that's only needed for
gcc 4.8 and earlier. Since we don't support anything that old, there's
no need for it here.

Sponsored by:		Netflix
2024-02-06 15:42:03 -07:00
Warner Losh fc2b8ee6da arm: Catchup to atmel retirement
AT91 boot2 loaders have been long gone, and don't support the AT91 parts
that have armv7 cores (since we don't have specific support for
that). Mentioning its interface is OBE, so remove it.

Sponsored by:		Netflix
2024-02-06 15:26:17 -07:00
Warner Losh 9d2c93c249 ddb: Remove useless includes
systm.h was included for boothowto here, but it's not used here, so drop
this include. Also sys/cdefs.h isn't needed, drop it too.

Sponsored by:		Netflix
2024-02-06 15:22:01 -07:00
John Baldwin afb1a3e30c arm: pmap_extract() returns a PA not a boolean value
Assume a PA of 0 indicates an invalid virtual address.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D43694
2024-02-02 14:59:03 -08:00
Mina Galić 834517eff8 x86 & arm: remove CAM_DEBUG_FLAGS= from MMCCAM kernels
we leave `options CAMDEBUG` enabled, so that when needed, CAM debugging
can be enabled *as needed*, rather than setting a default of everything.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/798
2024-02-02 12:51:51 -07:00
Mina Galić e32ef17d22 arm: fix typo in GENERIC-MMCCAM
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/798
2024-02-02 12:46:04 -07:00