Commit Graph

1380 Commits

Author SHA1 Message Date
Vladimir Kondratyev
1975878673 hid: Import functions and constants required by new subsystem
This does an import of quirk stubs, debugging macros from USB code and
numerous usage constants used by dependent drivers.

Besides, this change renames some functions to get a better matching
with userland library and NetBSD/OpenBSD HID code. Namely:

- Old hid_report_size() renamed to hid_report_size_max()
- New hid_report_size() calculates size of given report rather than
  maximum size of all reports.
- hid_get_data_unsigned() renamed to hid_get_udata()
- hid_put_data_unsigned() renamed to hid_put_udata()

Compat shim functions are provided in usbhid.h to make possible compile
of legacy code unmodified after this change.

Reviewed by:	manu, hselasky
Differential revision:	https://reviews.freebsd.org/D27887
2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
67de2db262 Factor-out hardware-independent part of USB HID support to new module
It will be used by the upcoming HID-over-i2C implementation.  Should be
no-op, except hid.ko module dependency is to be added to affected drivers.

Reviewed by:	hselasky, manu
Differential revision:	https://reviews.freebsd.org/D27867
2021-01-08 02:18:42 +03:00
Ed Maste
f45f9ef051 arm64 GENERIC: sort to match amd64, to ease comparison
No functional change - only moved lines, changed whitespace, and
updated comments.

Reviewed by:	allanjude
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28001
2021-01-07 10:01:48 -05:00
Marcin Wojtas
ca71c7e3bb arm64: QorIQ: gpio: return BUS_PROBE_DEFAULT
There is no reason this driver can't return default probe value.

Submitted by: Artur Rojek <ar@semihalf.com>
Reviewed by: emaste, mmel
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D26869
2021-01-06 22:37:38 +01:00
Marcin Wojtas
39c24889b0 arm64: QorIQ: gpio: Cleanup qoriq_gpio_* helpers
Replace various hw reg bit set/clear helpers with a universal
`qoriq_gpio_set` function.

Submitted by: Artur Rojek <ar@semihalf.com>
Reviewed by: mmel
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D26868
2021-01-06 22:37:21 +01:00
Marcin Wojtas
c76c36f95c arm64: QorIQ: gpio: Style cleanups
Make the code more conformant to style(9) and improve the general
readability.

This patch does not alter the driver logic.

Submitted by: Artur Rojek <ar@semihalf.com>
Reviewed by: mmel
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D26867
2021-01-06 22:37:13 +01:00
Emmanuel Vadot
cb00fc7c4d arm64: genet: Add bcm2711-genet-v5 compatible
Later dtb from the RPI Foundation removed the brcm,genet-v5 compatible
for some unknown reason, add brcm,bcm2711-genet-v5 to the list of compatible
device for if_genet
2021-01-05 20:50:43 +01:00
Emmanuel Vadot
e5df46055a arm64: rockchip: rk_clk_mux: Tell the clk framework if we didn't change the clock
Otherwise the clk framework will not pass the freq change request to the clock
parents.
Fix d03fd8ede2
Reported by:	br
2021-01-04 17:30:00 +01:00
Oleksandr Tymoshenko
d03fd8ede2 rockchip: add audio-related clocks to the CRU driver
- Add I2S and CODEC clocks to CRU driver
- Add support for gate selection to frac clock
- Add setfreq support to mux clock

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D27831
2021-01-03 16:50:42 -08:00
Ryan Libby
82661227ed arm64: fix mask in atomic_testand{set,clear}_64
These macros generate both the 32- and 64-bit ops, but the mask was hard
coded for 32-bit ops, causing the 64-bit ops always to affect only the
low 32 bits.

PR:		252324
Reported by:	gbe, mmel
Reviewed by:	markj, mmel
Tested by:	mmel, rwatson
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D27886
2021-01-02 12:13:25 -08:00
Michal Meloun
28482babd0 arm64: Use new arm_kernel_boothdr script for generating booti images. 2020-12-30 13:56:11 +01:00
Michal Meloun
509a006205 Tegra210: Connect to GENERIC kernel. 2020-12-30 11:01:47 +01:00
Michal Meloun
30ae416898 Tegra210: Add lost-in-merge fixes:
- misplaced '#ifdef notyet' in max77620.c
 - misnamed 'xusb_gate' clock in tegra210_clk_per.c
2020-12-30 10:53:41 +01:00
Michal Meloun
e903478919 ARM64: Port FreeBSD to Nvidia Jetson TX1 and Nano.
Add support for the Tergra210 SoC and its companion PMIC MAX77620.
2020-12-28 14:12:41 +01:00
Andrew Turner
6270ee0b67 Use the base address for early arm64 page tables
Use the kernel physical base rather than the ttbr0 base when building
the kernel identity map. The latter is correct with current assumptions
but may not always be the case.

Sponsored by:	Innovate UK
2020-12-26 19:04:57 +00:00
Andrew Turner
449ebf135b Move the literal pool to the end of asm functions
This keeps the data at the end of a function, near to where it's used.
Sponsored by:	Innovate UK
2020-12-23 13:57:25 +00:00
Andrew Turner
edb48ff6e7 Mark all arm64 locore functions with ENTRY/LENTRY
It is useful to know where these are within the code, and will be
needed by later changes.

Sponsored by:	Innovate UK
2020-12-23 13:57:25 +00:00
Andrew Turner
6f8866af34 Add LENTRY and LEND to arm64
These allow us to mark local asm functions as a function

Sponsored by:	Innovate UK
2020-12-23 13:57:25 +00:00
Andrew Turner
42f71007d5 Use the new PAGE_SIZE_4K in the GICv3 driver
Stop assuming PAGE_SIZE is 4k in the GICv3 ITS driver. We could use
a 16k or 64k page in the future.

Sponsored by:	Innovate UK
2020-12-23 13:10:26 +00:00
Andrew Turner
3413a8cd81 Rename the arm64 4k PAGE_* macros
These now have a _4K suffix to allow us to be explicit when we mean
to use a 4k page rather than assuming PAGE_SIZE is 4k.

Sponsored by:	Innovate UK
2020-12-23 13:10:26 +00:00
Andrew Turner
166ceb6fd1 More the arm64 early page tables and stack to .bss
This removes 806k from the kernel ELF file that is only needed while
the kernel is running, not in the static file.

Sponsored by:	Innovate UK
2020-12-23 13:10:23 +00:00
Andrew Turner
659f1a6aad Improve address generation in the early arm64 boot
The adr instruction allows for an address of +-1M from the instruction.
If we replace these with an adrp and an add instruction we can generate
an address +-4G. The adrp will get an address of the 4k page the label
is within, and the add uses the :lo12: prefix to add just the low bits
to this address.

This will allow us to move things around with fewer issues than if we
needed to keep them within the +-1MB range.

Sponsored by:	Innovate UK
2020-12-23 07:54:59 +00:00
John Baldwin
1dce7d9e7e Skip the vm.pmap.kernel_maps sysctl by default.
This sysctl node can generate very verbose output, so don't trigger it
for sysctl -a or sysctl vm.pmap.

Reviewed by:	markj, kib
Differential Revision:	https://reviews.freebsd.org/D27504
2020-12-18 20:41:23 +00:00
Emmanuel Vadot
fb6d445661 arm64: rk3399: Export the watchdog clock
This clock is used by the watchdog IP and can be controlled only
in the secure world.
2020-12-18 16:55:54 +00:00
Jessica Clarke
f9c504ae7f Fix whitespace in comment modified by r368697 2020-12-16 14:47:49 +00:00
Michal Meloun
c0ffd35cbb Allocate right number of pages for the bounced buffers crossing the page.
One of the disadvantages of our current busdma code is the fact that
we process the bounced buffer in a page-by-page manner. This means that
the short (subpage) buffer allocated across page boundaries is bounced
to 2 separate pages.

This suboptimal behavior is consistent across all platforms and can be
related to (probably unimplementable or incompatible with bouncing)
BUS_DMA_KEEP_PG_OFFSET flag.

Therefore, allocate one additional page to be fully comply with this
requirement.

Discused with:	markj
PR:		251018
2020-12-16 14:36:57 +00:00
Alexander V. Chernikov
d5fe384b4d Enable ROUTE_MPATH support in GENERIC kernels.
Ability to load-balance traffic over multiple path is a must-have thing for routers.
It may be used by the servers to balance outgoing traffic over multiple default gateways.

The previous implementation, RADIX_MPATH stayed in the shadow for too long.
It was not well maintained, which lead us to a vicious circle - people were using
 non-contiguous mask or firewalls to achieve similar goals. As a result, some routing
 daemons implementation still don't have multipath support enabled for FreeBSD.

Turning on ROUTE_MPATH by default would fix it. It will allow to reduce networking
 feature gap to other operating systems. Linux and OpenBSD enabled similar support
 at least 5 years ago.

ROUTE_MPATH does not consume memory unless actually used. It enables around ~1k LOC.

It does not bring any behaviour changes for userland.
Additionally, feature is (temporarily) turned off by the net.route.multipath sysctl
 defaulting to 0.

Differential Revision:	https://reviews.freebsd.org/D27428
2020-12-14 22:23:08 +00:00
Michal Meloun
22f5cb76eb Verify (and fix) the context_id argument passed to the mpentry () by PSCI.
Some older PSCI implementations corrupt (or do not pass) the context_id
argument to newly started secondary cores. Although the ideal solution to this
problem is u-boot update, we can find the correct value for the argument (cpuid)
by comparing of real core mpidr register with the value stored in pcu->mpidr.

MFC after:	2 weeks
2020-12-14 11:57:43 +00:00
Mitchell Horne
95e1f42eb9 arm64: fix struct l_sigaction_t layout
The definition was copied from amd64, but the layout of the struct
differs slightly between these platforms. This fixes spurious
`unsupported sigaction flag 0xXXXXXXXX` messages when executing some
Linux binaries on arm64.

Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27460
2020-12-08 18:24:33 +00:00
John Baldwin
ae95396817 Check that the frame pointer is within the current stack.
This same check is used on other architectures.  Previously this would
permit a stack frame to unwind into any arbitrary kernel address
(including unmapped addresses).

Reviewed by:	andrew, markj
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27362
2020-12-08 18:00:58 +00:00
Andrew Turner
047110df63 Use a macro to find the offset of kern_ttbr0
Rather than hard coding the offset of kern_ttbr0 within arm64_bootparams
use a macro like the other fields.

Sponsored by:	Innovate UK
2020-12-08 15:51:05 +00:00
Andrew Turner
3e2dc667fa Free the arm64 bootparams memory after initarm
This is only needed in initarm, we can return this memory to the stack
used by mi_startup.

Sponsored by:	Innivate UK
2020-12-08 15:41:18 +00:00
Andrew Turner
d2d350369e Ensure the boot CPU is CPU 0 on arm64
We assume the boot CPU is always CPU 0 on arm64. To allow for this reserve
cpuid 0 for the boot CPU in the ACPI and FDT cases but otherwise start the
CPU as normal. We then check for the boot CPU in start_cpu and return as if
it was started.

While here extract the FDT CPU init code into a new function to simplify
cpu_mp_start and return FALSE from start_cpu when the CPU fails to start.

Reviewed by:	mmel
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D27497
2020-12-07 17:54:49 +00:00
Michal Meloun
68225a196f Simplify startup of secondary cores and store MPIDR register to pcpu.
- record MPIDR for all started cores in pcpu, they will be used as link
   between physical locality of given core, ID in external description
   (FDT or ACPI) and cupid.
 - because of above, cpuid can (and should) be freely assigned, only boot
   CPU  must have cpuid 0. Simplify startup code according this.

Please note that pure cpuid is not sufficient instrument to hold any
information about core or cluster topology, nor to determistically iterate
over subpart of cores in CPU (iterate over all cores in single cluster for
example). Situation is more complicated by fact that PSCI can reject start
of core without reporting error (because power budget for example), or by
fact that is possible that we booted on non-first core in cluster (thus with
cpuid 0 assigned to random core).

Given cores topology should be exhibited to other parts of system
(for example to scheduler for big.little or multicluster systems) by using
smp_topo interface.

Differential Revision:  https://reviews.freebsd.org/D13863
2020-12-05 14:06:01 +00:00
Michal Meloun
6844eecfed Add basic support for Freescale LX2160A SoC.
All peripherals but the network processor are supported.
2020-12-05 12:08:37 +00:00
Michal Meloun
935b2ac1f1 Connect DTB files based on LX2160A SoC to build.
Mainly LX2K Honeycomb and ClearFog-CX boards.
2020-12-05 11:17:54 +00:00
Conrad Meyer
78599c32ef Add CFI start/end proc directives to arm64, i386, and ppc
Follow-up to r353959 and r368070: do the same for other architectures.

arm32 already seems to use its own .fnstart/.fnend directives, which
appear to be ARM-specific variants of the same thing.  Likewise, MIPS
uses .frame directives.

Reviewed by:	arichardson
Differential Revision:	https://reviews.freebsd.org/D27387
2020-12-05 00:33:28 +00:00
Michal Meloun
b0352107f1 Add support for RK3288 SoC. 2020-12-04 16:24:44 +00:00
Oleksandr Tymoshenko
014812b9be [arm64] Bump MAXMEMDOM value to 8 to match amd64
On some of the server-grade ARM64 machines the number of NUMA domains is higher
than 2. When booting GENERIC kernel on such machines the SRAT parser fails
leaving the system with a single domain. To make GENERIC kernel usable on those
server, match the parameter value with the one for amd64 arch.

Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D27368
Sponsored by:	Ampere Computing
Submitted by:	Klara, Inc.
2020-12-01 20:10:55 +00:00
John Baldwin
4d16f94191 Use uintptr_t instead of uint64_t for pointers in stack frames.
Reviewed by:	andrew
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27361
2020-12-01 18:22:34 +00:00
Emmanuel Vadot
df15910266 arm64: Do not rely on SPCR table to detect acpi
Since EDK2 commit d8e36289cef7bde628b023219cd65fa8e8d4562a, the Graphical console may
completely hide SPCR, causing panics later when locating timers.
As such simply rely on the ACPI Root pointer presence.

Submitted by:	dan.kotowski@a9development.com
Reviewed by:	andrew, mw
Differential Revision:	https://reviews.freebsd.org/D27306
2020-11-26 20:22:34 +00:00
Emmanuel Vadot
219f1919ab arm64: Check if we have a map before checking the flags
This fixes amdgpu on arm64 where linuxkpi is calling id_mapped
and we call might_bounce without a map.
2020-11-24 14:05:35 +00:00
Konstantin Belousov
4815f175d0 Linuxolator: Replace use of eventhandlers by sysent hooks.
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D27309
2020-11-23 18:18:16 +00:00
Andrew Turner
02a6de7789 Fall back to use the GICR address from the generic interrupt struct
When there is no ACPI redistributor sub-table in the MADT we need to
fall back to use the GICR base address from the GIC CPU interface
structure.

Handle this fallback when adding memory to the device and when counting
the number of redistributors.

PR:		251171
Reported by:	Andrey Fesenko <f0andrey_gmail.com>
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D27247
2020-11-19 09:26:51 +00:00
Conrad Meyer
77eb984147 'make sysent' for r367773
X-MFC-With:	r367773
2020-11-17 19:53:59 +00:00
Conrad Meyer
de774e422e linux(4): Implement name_to_handle_at(), open_by_handle_at()
They are similar to our getfhat(2) and fhopen(2) syscalls.

Differential Revision:	https://reviews.freebsd.org/D27111
2020-11-17 19:51:47 +00:00
Andrew Turner
d2d754c498 Stop calling gic_v3_detach when we haven't called gic_v3_attach
The former tries to dereference memory allocated by the latter. If counting
the redistributor fails it may try to dereference memory that was never
allocated.

Sponsored by:	Innovate UK
2020-11-17 10:27:42 +00:00
Andrew Turner
a56b066600 Allow the GICv3 ACPI driver to attach to a GICv4
The same driver works on both, allow the driver to attach to a GICv4
controller with the ACPI attachment.

Reported by:	Andrey Fesenko <f0andrey_gmail.com>
Sponsored by:	Innovate UK
2020-11-17 10:17:18 +00:00
Ruslan Bukin
4cc8701067 Introduce IOMMU support for arm64 platform.
This adds an arm64 iommu interface and a driver for Arm System Memory
Management Unit version 3.2 (ARM SMMU v3.2) specified in ARM IHI 0070C
document.

Hardware overview is provided in the header of smmu.c file.

The support is disabled by default. To enable add 'options IOMMU' to your
kernel configuration file.

The support was developed on Arm Neoverse N1 System Development Platform
(ARM N1SDP), kindly provided by ARM Ltd.

Currently, PCI-based devices and ACPI platforms are supported only.
The support was tested on IOMMU-enabled Marvell SATA controller,
Realtek Ethernet controller and a TI xHCI USB controller with a low to
medium load only.

Many thanks to Konstantin Belousov for help forming the generic IOMMU
framework that is vital for this project; to Andrew Turner for adding
IOMMU support to MSI interrupt code; to Mark Johnston for help with SMMU
page management; to John Baldwin for explaining various IOMMU bits.

Reviewed by:	mmel
Relnotes:	yes
Sponsored by:	DARPA / AFRL
Sponsored by:	Innovate UK (Digital Security by Design programme)
Differential Revision:	https://reviews.freebsd.org/D24618
2020-11-16 21:55:52 +00:00
Emmanuel Vadot
b212bf30ee imx7gpc: Remove unused functions 2020-11-16 11:54:38 +00:00