Commit Graph

5154 Commits

Author SHA1 Message Date
Conrad Meyer
2596eb8847 arm: Fix atomic long APIs to correct 'u_long' signedness
As defined in atomic(9) and implemented on other architectures, the
atomic(9) functions all act on unsigned pointers and types.  Prior to this
revision, arm implemented some atomic(9) 'long' sized routines with correct
unsigned type, but others were incorrectly signed.

Reviewed by:	tinderbox
Sponsored by:	Dell EMC Isilon
2020-03-23 23:00:13 +00:00
Brandon Bergren
3069380898 [PowerPC][Book-E] Fix missing load base in elf_cpu_parse_dynamic().
When I implemented MD DYNAMIC parsing, I was originally passing a
linker_file_t so that the MD code could relocate pointers.

However, it turns out this isn't even filled in until later, so it was
always 0.

Just pass the load base (ef->address) directly, as that's really the only
thing we were interested in in the first place.

This fixes a crash on RB800 where it was trying to write to an unmapped
address when updating the GOT.

Reviewed by:	jhibbits
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D24105
2020-03-18 02:58:18 +00:00
Emmanuel Vadot
3f9309e571 arm: zynq: An SPI driver for Zynq platforms
Submitted by:	Thomas Skibo
Differential Revision:	https://reviews.freebsd.org/D23319
2020-02-28 10:57:23 +00:00
Dimitry Andric
a9e92640d0 Fix the following -Werror warning from clang 10.0.0:
sys/arm/arm/identcpu-v6.c:227:5: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                                if (val & CPUV7_CT_CTYPE_RA)
                                ^
sys/arm/arm/identcpu-v6.c:225:4: note: previous statement is here
                        if (val & CPUV7_CT_CTYPE_WB)
                        ^

This was due to an accidentally inserted tab before the if statement.

MFC after:	3 days
2020-02-27 19:58:20 +00:00
Pawel Biernacki
7029da5c36 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE.  All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by:	kib (mentor, blanket)
Commented by:	kib, gallatin, melifaro
Differential Revision:	https://reviews.freebsd.org/D23718
2020-02-26 14:26:36 +00:00
Pawel Biernacki
8eea36ae5b Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (13 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Approved by:	kib (mentor, blanket)
Differential Revision:	https://reviews.freebsd.org/D23635
2020-02-24 10:45:22 +00:00
Dimitry Andric
2d8a0c01e5 Fix the following -Werror warning from clang 10.0.0:
sys/arm/allwinner/clkng/aw_clk_mipi.c:144:6: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                                        m++;
                                        ^
sys/arm/allwinner/clkng/aw_clk_mipi.c:142:5: note: previous statement is here
                                if (best == *fout)
                                ^

Move the increment operations into the for loop headers instead.

Discussed with:	manu
MFC after:	3 days
2020-02-18 17:55:24 +00:00
Dimitry Andric
30882a7c88 Work around new clang 10.0.0 -Werror warning:
sys/arm/allwinner/aw_cir.c:208:41: error: converting the result of '<<' to a boolean; did you mean '((1 & 255) << 23) != 0'? [-Werror,-Wint-in-bool-context]
        active_delay = (AW_IR_ACTIVE_T + 1) * (AW_IR_ACTIVE_T_C ? 128 : 1);
                                               ^
sys/arm/allwinner/aw_cir.c:130:39: note: expanded from macro 'AW_IR_ACTIVE_T_C'
#define AW_IR_ACTIVE_T_C                ((1 & 0xff) << 23)
                                                    ^

Add the != 0 part to indicate that we indeed want to compare against
zero.
2020-02-17 18:37:15 +00:00
Ian Lepore
39c614c6b7 Implement atomic_testandclear_{32,int,long} for 32-bit arm. Also, replace
the existing implementation of atomic_testandset with the same new algorithm,
which uses fewer instructions and fewer registers.
2020-02-10 00:05:04 +00:00
Mark Johnston
c3d326fd44 Define MAXCPU consistently between the kernel and KLDs.
This reverts r177661.  The change is no longer very useful since
out-of-tree KLDs will be built to target SMP kernels anyway.  Moveover
it breaks the KBI in !SMP builds since cpuset_t's layout depends on the
value of MAXCPU, and several kernel interfaces, notably
smp_rendezvous_cpus(), take a cpuset_t as a parameter.

PR:		243711
Reviewed by:	jhb, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23512
2020-02-05 19:08:21 +00:00
Ed Maste
690a8a6acd regen linuxulator sysent after r357577 2020-02-05 16:54:16 +00:00
Ed Maste
fc7510aef7 linuxulator: implement sendfile
Submitted by:	Bora Özarslan <borako.ozarslan@gmail.com>
Submitted by:	Yang Wang <2333@outlook.jp>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19917
2020-02-05 16:53:02 +00:00
Warner Losh
c312e0f43b Kill old armv4 busdma
Move to having one busdma option for arm: the armv6/v7 one.
Kill now-unused option ARM_USE_V6_BUSDMA too.
Fixup files.arm to match rename.
2020-02-02 08:27:14 +00:00
Warner Losh
6b29cf3343 Move arm back to having one LINT
Now that armv5 is gone, we no longer need multiple LINT files. Kill
the odd-ball support here. From now on, we just have LINT built from
notes like all the other platforms. Keep the removal of LINT-V5/7
to remove stale files for a while still..
2020-02-02 08:27:08 +00:00
Warner Losh
bf19e5b9ee Remove old boardid/mach-types support.
This has been long obsolete in linux and now that all armv4/5 support
is gone, it can be retired too.
2020-02-02 06:52:10 +00:00
Warner Losh
ff9efce0ba Remove armv5 marvell support.
Per plans to remove armv5 support, remove the armv5 marvell discovery,
kirkwood and orion families.
2020-02-02 06:52:04 +00:00
Warner Losh
20d4864396 Remove Ralink RT1310 support
This armv5 SoC is being removed consistent with the removal of
armv5 support, per discussions in arm@ mailing list.
2020-02-02 06:51:42 +00:00
Mark Johnston
1c29da0279 Reimplement stack capture of running threads on i386 and amd64.
After r355784 the td_oncpu field is no longer synchronized by the thread
lock, so the stack capture interrupt cannot be delievered precisely.
Fix this using a loop which drops the thread lock and restarts if the
wrong thread was sampled from the stack capture interrupt handler.

Change the implementation to use a regular interrupt instead of an NMI.
Now that we drop the thread lock, there is no advantage to the latter.

Simplify the KPIs.  Remove stack_save_td_running() and add a return
value to stack_save_td().  On platforms that do not support stack
capture of running threads, stack_save_td() returns EOPNOTSUPP.  If the
target thread is running in user mode, stack_save_td() returns EBUSY.

Reviewed by:	kib
Reported by:	mjg, pho
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23355
2020-01-31 15:43:33 +00:00
Warner Losh
8c7cd14adf Create a convenince wrapper to fill in a CAM_PATH_INQ request for MMC sims. Pass
in the parameters needed for the different sims, but it's almost all identical.
2020-01-27 22:19:55 +00:00
Emmanuel Vadot
2de9b4d347 zilinx/zy7_qspi: Add a qspi driver for Zynq platforms.
This is a qspi driver for the Xilinx Zynq-7000 chip.
It could be useful for anyone wanting to boot a system from flash memory
instead of SD cards.

Submitted by:	Thomas Skibo (thomasskibo@yahoo.com)
Differential Revision:	https://reviews.freebsd.org/D14698
2020-01-19 20:04:44 +00:00
Emmanuel Vadot
0fe5379c6a arm: allwinner: Add GPIO Interrupt support
Not all pins in Allwinner have interrupts support so we rely
on the padconf data to add the proper caps when pin_getcaps is called.
The pin is switch to the specific "eint" function during setup_intr and
switched back to its old function in teardown_intr.
Only INTR_MAP_DATA_GPIO is supported for now.

MFC after:	1 month
2020-01-19 19:51:20 +00:00
Emmanuel Vadot
d07cc22b30 arm: allwinner: Fix padconf for interrupts information
Add a eint_bank member to the allwinner_pins structure.
On Allwinner SoCs not all pins can do interrupt.
Older SoC (A10/A13 and A20) there is a maximum number of interrupts
set to 32 and all the configuration is done in the same registers.
While on "newer" SoCs (>=A31) interrupts registers are splitted per
pin bank (i.e. all interrupts available in bank B will be configured
with a sets of registers and the one in bank G in another set).
While here set the names to all interrupts function to
pX_eintY where X is the bank name and Y the interrupt number.

To whom ever in the future look at the H5 manual and notice that the bank F
have interrupts support : This isn't true, trust me.

MFC after:	1 month
2020-01-19 19:14:49 +00:00
Kyle Evans
05d7dd739c sysent targets: further cleanup and deduplication
r355473 vastly improved the readability and cleanliness of these Makefiles.
Every single one of them follows the same pattern and duplicates the exact
same logic.

Now that we have GENERATED/SRCS, split SRCS up into the two parameters we'll
use for ${MAKESYSCALLS} rather than assuming a specific ordering of SRCS and
include a common sysent.mk to handle the rest. This makes it less tedious to
make sweeping changes.

Some default values are provided for GENERATED/SYSENT_*; almost all of these
just use a 'syscalls.master' and 'syscalls.conf' in cwd, and they all use
effectively the same filenames with an arbitrary prefix. Most ABIs will be
able to get away with just setting GENERATED_PREFIX and including
^/sys/conf/sysent.mk, while others only need light additions. kern/Makefile
is the notable exception, as it doesn't take a SYSENT_CONF and the generated
files are spread out between ^/sys/kern and ^/sys/sys, but it otherwise fits
the pattern enough to use the common version.

Reviewed by:	brooks, imp
Nice!:		emaste
Differential Revision:	https://reviews.freebsd.org/D23197
2020-01-18 20:37:45 +00:00
Kyle Evans
ac64d0f1ea bcm2835_vcbus: unifdef all platform definitions
Raspberry Pi are all over the board, and the reality is that there's no harm
in including all of the definitions by default but plenty of harm in the
current situation. This change is safe because we match a definition by root
/compatible in the FDT, so there will be no false-positives because of it.

The main array of definitions grows, but it's only walked exactly once to
determine which we need to use.
2020-01-17 21:39:28 +00:00
Emmanuel Vadot
2fbeda2aef arm: allwinner: ahci: target-supply is optional
The target-supply regulator is optional so don't fail if it's not present.
While here disable the clock on detach.

MFC after:	2 weeks
X-MFC-With:	356600
2020-01-16 20:19:20 +00:00
Emmanuel Vadot
96c7e7f427 arm: allwinner: Add support for bank supply
Each GPIO bank is powered by a different pin and so can be powered at different
voltage from different regulators.
Add a new config that now hold the pinmux data and the banks available on each
SoCs.
Since the aw_gpio driver being also the pinmux one it's attached before the PMIC
so add a config_intrhook_oneshot function that will enable the needed regulators
when the system is fully functional.

MFC after:	2 weeks
2020-01-16 20:02:41 +00:00
Emmanuel Vadot
5fcd039b3f axp8xx: Add a regnode_init method
This method will set the desired voltaged based on values in the DTS.
It will not enable the regulator, this is the job of either a consumer
or regnode_set_constraint SYSINIT if the regulator is boot_on or always_on.

MFC after:	2 weeks
2020-01-16 19:59:00 +00:00
Emmanuel Vadot
194840a170 axp8xx: Add missing voltage regulators offset
This lead to writing the desired voltage value to the wrong register.

MFC after:	2 weeks
2020-01-16 19:57:38 +00:00
Mateusz Guzik
879e0604ee Add KERNEL_PANICKED macro for use in place of direct panicstr tests 2020-01-12 06:07:54 +00:00
Emmanuel Vadot
ca4387843e arm: allwinner: axp209: Add regnode_status method
This allow consumers to check if the regulator is enable or not.

MFC after:	1 week
2020-01-10 18:53:14 +00:00
Kyle Evans
1171c633fb Set .ORDER for makesyscalls generated files
When either makesyscalls.lua or syscalls.master changes, all of the
${GENERATED} targets are now out-of-date. With make jobs > 1, this means we
will run the makesyscalls script in parallel for the same ABI, generating
the same set of output files.

Prior to r356603 , there is a large window for interlacing output for some
of the generated files that we were generating in-place rather than staging
in a temp dir. After that, we still should't need to run the script more
than once per-ABI as the first invocation should update all of them. Add
.ORDER to do so cleanly.

Reviewed by:	brooks
Discussed with:	sjg
Differential Revision:	https://reviews.freebsd.org/D23099
2020-01-10 18:24:17 +00:00
Kyle Evans
3898f9bdb3 a10_ahci: grab the target-supply regulator and enable it
This regulator is marked regulator-boot-on, but it will get shutdown if it's
not actually used/enabled by a driver. This should fix sata on the
cubieboard{1,2}.

Reported by:	Ray White @ UWaterloo
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D23112
2020-01-10 14:09:59 +00:00
Kyle Evans
d2ccf385fd bcm2835_vcbus: hide 'checking root' messages under bootverbose 2020-01-09 19:13:09 +00:00
Ryan Libby
54c5ae804f uma: reorganize flags
- Garbage collect UMA_ZONE_PAGEABLE & UMA_ZONE_STATIC.
 - Move flag VTOSLAB from public to private.
 - Introduce public NOTPAGE flag and make HASH private.
 - Introduce public NOTOUCH flag and make OFFPAGE private.
 - Update man page.

The net effect of this should be to make the contract with clients more
clear.  Clients should choose constraints, UMA will figure out how to
implement them.  This also breaks the confusing double meaning of
OFFPAGE.

Reviewed by:	jeff, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D23016
2020-01-09 02:03:03 +00:00
Ian Lepore
9a1d4b0012 Add #ifdef option-test wrappers around another call to an arm/unwind.c
function which is only compiled-in with certain options.

Why is it always the most trivial part of a big commit that takes 3 tries
to get right?
2020-01-07 21:13:34 +00:00
Ian Lepore
fce985b0bd Add the xdma framework and pl330 dma drivers to arm and arm64 lint builds. 2020-01-02 22:26:54 +00:00
Emmanuel Vadot
950beb0bc2 arm: allwinner: aw_spi: Call bus_generic_attach
This is needed when the driver is compiled into the kernel.
When compiled as a module this will be called from another
code path as we also depend on ofw_spibus.

MFC after:	1 week
2020-01-02 17:39:21 +00:00
Ian Lepore
e0f07fadf6 Since arm/unwind.c s conditionally compiled, only call functions in it
when one of those conditions is true.  Fixes build failure on kernel
configs with no debugging options active.
2020-01-02 15:38:17 +00:00
Warner Losh
3fa3fbdedf Remove NOTES.armv5. It's no longer relevant. 2020-01-02 03:25:32 +00:00
Edward Tomasz Napierala
0c80ec6dfa Regen after r356233.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-12-31 16:07:12 +00:00
Edward Tomasz Napierala
79ae56a772 Sigh, add getcpu(2) chunk missed in r356229.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-12-31 16:05:07 +00:00
Ian Lepore
140da6f8fe Set a "kernbase" symbol in 32-bit arm locore.S and use it with ldscript.arm.
This brings arm into line with how every other arch does it.  For some
reason, only arm lacked a definition of a symbol named kernbase in its
locore.S file(s) for use in its ldscript.arm file.  Needlessly different
means harder to maintain.

Using a common symbol name also eases work in progress on a script to help
generate arm and arm64 kernels packaged in various ways (like with a header
blob needed for a bootloader prepended to the kernel file).
2019-12-30 23:20:46 +00:00
Kyle Evans
06b367b2b6 sc(4) md bits: stop setting sc->kbd entirely
The machdep parts no longer need to touch keyboard parts after r356043;
sc->kbd will be 0-initialized and this works as expected.
2019-12-30 02:07:55 +00:00
Luiz Otavio O Souza
18346de0cc Initialize the bounce pages list in armv[4|6] DMA maps.
Fixes the crash on the first use of STAILQ_INSERT_TAIL() in
add_bounce_page().

Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-12-24 23:43:29 +00:00
Brandon Bergren
7821a820d0 [PowerPC] Implement Secure-PLT jump table processing for ppc32.
Due to clang and LLD's tendency to use a PLT for builtins, and as they
don't have full support for EABI, we sometimes have to deal with a PLT in
.ko files in a clang-built kernel.

As such, augment the in-kernel linker to support jump table processing.

As there is no particular reason to support lazy binding in kernel modules,
only implement Secure-PLT immediate binding.

As part of these changes, add elf_cpu_parse_dynamic() to the MD API of the
in-kernel linker (except on platforms that use raw object files.)

The new function will allow MD code to act on MD tags in _DYNAMIC.

Use this new function in the PowerPC MD code to ensure BSS-PLT modules using
PLT will be rejected during insertion, and to poison the runtime resolver to
ensure we get a clear panic reason if a call is made to the resolver.

Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D22608
2019-12-24 15:56:24 +00:00
Scott Long
757d4fbaa7 Introduce the concept of busdma tag templates. A template can be allocated
off the stack, initialized to default values, and then filled in with
driver-specific values, all without having to worry about the numerous
other fields in the tag. The resulting template is then passed into
busdma and the normal opaque tag object created.  See the man page for
details on how to initialize a template.

Templates do not support tag filters.  Filters have been broken for many
years, and only existed for an ancient make/model of hardware that had a
quirky DMA engine.  Instead of breaking the ABI/API and changing the
arugment signature of bus_dma_tag_create() to remove the filter arguments,
templates allow us to ignore them, and also significantly reduce the
complexity of creating and managing tags.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D22906
2019-12-24 14:48:46 +00:00
Kyle Evans
117deb3fc4 sc: fix arm/mips/sparc64 MD bits
r356043 missed a couple of references in machdep parts... arguably, these
lines could probably be dropped as the softc is likely still zero'd at this
point.

Pointy hat:	kevans
2019-12-23 21:41:04 +00:00
Kyle Evans
db41cd0e06 Kill off dummy kbd drivers
As far as I can tell, these are an artifact of times when linker sets
couldn't be empty, otherwise the kernel build would fail due to unresolved
symbols. hselasky fixed this in r268138, and I've audited the kbd portions
to make sure nothing would blow up due to the empty linker set and
successfully compiled+ran a kernel with no keyboard support at all.

Kill them off now since they're no longer required.

MFC after:	1 week
2019-12-20 16:22:14 +00:00
Kyle Evans
2dfc696ef1 VERSATILEPB: Unbreak after r355796
r355796 provided genkbd_get_fkeystr/genkbd_diag private and the default for
get_fkeystr/diag if these members are NULL. Follow suit here.
2019-12-20 15:28:40 +00:00
Kyle Evans
32a44e1e53 bcm2835_vcbus: add legacy compat mappings
I've opted for just duplicating the two entries needed for this, rather than
writing any other mechanism for maintaining two root compat entries to map
to one config, for simplicity. We'll eventually declare these legacy DTB
unsupported, but let's not do that yet while there's no real burden.
2019-12-18 02:29:27 +00:00
Kyle Evans
850dd7e9cd arm: add SOC_BRCM_BCM2837 option, include it in GENERIC
We use armv7/GENERIC for the RPI2 images. The original RPI2 is actually a
32-bit BCM2836, but v1.2 was upgraded to the 64-bit BCM2837. The project
continues to provide the RPI2 image as armv7, as it's the lowest common
denominator of the two. Historically, we've just kind of implicitly
acknowledged this by including some bcm2837 bits on a SOC_BCM2836 kernel
config -- this worked until r354875 added code that actually cared.

Acknowledge formally that BCM2837 is valid in arm32.

This name is inconsistent with the other BCM* SOC on !arm64 for two reasons:

1. It's a pre-existing option on arm64, and
2. the naming convention on arm/ should've arguably changed to include BRCM

#1 seems to be a convincing enough argument to maintain the existing name
for it.
2019-12-17 23:01:37 +00:00
Ian Lepore
a856c60bdd Remove unnecessary MODULE_DEPEND() from imx_i2c.c, and also from rk_i2c
where it got copied to.
2019-12-17 17:03:03 +00:00
Jeff Roberson
a94ba188c3 Repeat the spinlock_enter/exit pattern from amd64 on other architectures to
fix an assert violation introduced in r355784.  Without this spinlock_exit()
may see owepreempt and switch before reducing the spinlock count.  amd64
had been optimized to do a single critical enter/exit regardless of the
number of spinlocks which avoided the problem and this optimization had
not been applied elsewhere.

Reported by:	emaste
Suggested by:	rlibby
Discussed with:	jhb, rlibby
Tested by:	manu (arm64)
2019-12-16 20:15:04 +00:00
Kyle Evans
f00bf028b6 chrome_kb: remove default get_fkeystr/diag implementations
This file was missed in r355796, but no harm would have come from this.
2019-12-16 03:05:35 +00:00
Kyle Evans
4434de9643 kbd drivers: use kbdd_* indirection for diag invocation
These invocations were directly calling enkbd_diag(), rather than
indirection back through kbdd_diag/kbdsw. While they're functionally
equivent, invoking kbdd_diag where feasible (i.e. not in a diag
implementation) makes it easier to visually identify locking needs in these
other drivers.
2019-12-16 01:37:03 +00:00
Ian Lepore
b19c9dea3e Rewrite arm kernel stack unwind code to work when unwinding through modules.
The arm kernel stack unwinder has apparently never been able to unwind when
the path of execution leads through a kernel module. There was code that
tried to handle modules by looking for the unwind data in them, but it did
so by trying to find symbols which have never existed in arm kernel
modules. That caused the unwind code to panic, and because part of panic
handling calls into the unwind code, that just created a recursion loop.

Locating the unwind data in a loaded module requires accessing the Elf
section headers to find the SHT_ARM_EXIDX section. For preloaded modules
those headers are present in a metadata blob. For dynamically loaded
modules, the headers are present only while the loading is in progress; the
memory is freed once the module is ready to use. For that reason, there is
new code in kern/link_elf.c, wrapped in #ifdef __arm__, to extract the
unwind info while the headers are loaded. The values are saved into new
fields in the linker_file structure which are also conditional on __arm__.

In arm/unwind.c there is new code to locally cache the per-module info
needed to find the unwind tables. The local cache is crafted for lockless
read access, because the unwind code often needs to run in context where
sleeping is not allowed.  A large comment block describes the local cache
list, so I won't repeat it all here.
2019-12-15 21:16:35 +00:00
Edward Tomasz Napierala
0cde2b3239 Regen after r355752.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D22371
2019-12-14 13:32:37 +00:00
Edward Tomasz Napierala
0610f417a4 Fix definitions for linuxulator's sync_file_range(2).
Reviewed by:	brooks, emaste
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D22371
2019-12-14 13:30:43 +00:00
Warner Losh
9f07ef760a Be consistent about checking return value from bus_delayed_attach_children.
Most places checked, but a couple last minute changes didn't. Make them all use
the return value.

Noticed by: rpokala@
2019-12-13 21:39:20 +00:00
Warner Losh
b832a7e505 Create new wrapper function: bus_delayed_attach_children()
Delay the attachment of children, when requested, until after interrutps are
running. This is often needed to allow children to run transactions on i2c or
spi busses. It's a common enough idiom that it will be useful to have its own
wrapper.

Reviewed by: ian
Differential Revision: https://reviews.freebsd.org/D21465
2019-12-13 19:39:33 +00:00
Ed Maste
c4853d4514 arm linuxulator: regen sysent after r355621 2019-12-11 18:24:43 +00:00
Ed Maste
ca2c3dea28 arm linuxulator: put syscall type and argument on one line 2019-12-11 18:21:35 +00:00
Ed Maste
09019cc0fc arm linuxulator: add "make sysent" generated files
Sponsored by:	The FreeBSD Foundation
2019-12-11 17:52:06 +00:00
Ed Maste
beede70e51 arm linuxulator: add syscalls.conf and Makefile for "make sysent"
Differential Revision:	https://reviews.freebsd.org/D7973
2019-12-11 17:28:49 +00:00
Mark Johnston
5cff1f4dc3 Introduce vm_page_astate.
This is a 32-bit structure embedded in each vm_page, consisting mostly
of page queue state.  The use of a structure makes it easy to store a
snapshot of a page's queue state in a stack variable and use cmpset
loops to update that state without requiring the page lock.

This change merely adds the structure and updates references to atomic
state fields.  No functional change intended.

Reviewed by:	alc, jeff, kib
Sponsored by:	Netflix, Intel
Differential Revision:	https://reviews.freebsd.org/D22650
2019-12-10 18:14:50 +00:00
Kyle Evans
5910fe02d6 RPI: Fix DMA/SDHCI on the BCM2836 (Raspberry Pi 2)
r354875 pushed VCBUS <-> ARMC translations to runtime determination, but
incorrectly mapped addresses for the BCM2836 -- SOC_BCM2835 and SOC_BCM2836
are actually mutually exclusive, so the BCM2836 config (GENERIC) would have
taken the latter path in the header and used 0x3f000000 as peripheral start.

Easily fixed -- split out the BCM2836 into its own memmap config and use
that instead if SOC_BCM2836 is included. With this, we get back to userland
again.

Reported by:	Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
2019-12-09 17:34:40 +00:00
Luiz Otavio O Souza
16f4a8ea9e Fix the ARM64 build, include the necessary <sys/mutex.h> header.
While here, call device_delete_children() to detach and dealloc all the
existent children and handle the child's detach errors properly.

Reported by:	jenkins, hselasky, ian
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-12-06 20:05:08 +00:00
Luiz Otavio O Souza
8cfe2a7ad3 Add the SPI driver for the Marvell Armada 37x0 SoC.
Interrupt based driver, implements SPI mode and clock configuration.

Tested on espressobin and SG-3200.

Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-12-06 12:55:39 +00:00
Ian Lepore
e214f286f0 Declare the global kernel symbols created by ldscript.arm in arm's machdep.h,
and remove a couple scattered local declarations.

Most of these aren't referenced in C code (there are some references in
asm code), and they also aren't documented anywhere.  This helps a bit
with the latter.
2019-12-06 03:48:35 +00:00
Luiz Otavio O Souza
2b289d0bff Fix the build, use the correct include path.
Pointy hat to:	loos
2019-12-05 02:01:47 +00:00
Luiz Otavio O Souza
8a82d5675d Add the I2C driver for the Armada 37x0.
This controller is a bit tricky as the STOP condition must be indicated in
the last tranferred byte, some devices will not like the repeated start
behavior of this controller.  A proper fix to this issue is in the works.

This driver works in polling mode, can be used early in the boot (required
in some cases).

Tested on espressobin/SG-1100 and the SG-3200.

Obtained from:	pfSense
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-12-05 00:56:03 +00:00
Warner Losh
f86e60008b Regularize my copyright notice
o Remove All Rights Reserved from my notices
o imp@FreeBSD.org everywhere
o regularize punctiation, eliminate date ranges
o Make sure that it's clear that I don't claim All Rights reserved by listing
  All Rights Reserved on same line as other copyright holders (but not
  me). Other such holders are also listed last where it's clear.
2019-12-04 16:56:11 +00:00
John Baldwin
31174518d2 Use uintptr_t instead of register_t * for the stack base.
- Use ustringp for the location of the argv and environment strings
  and allow destp to travel further down the stack for the stackgap
  and auxv regions.
- Update the Linux copyout_strings variants to move destp down the
  stack as was done for the native ABIs in r263349.
- Stop allocating a space for a stack gap in the Linux ABIs.  This
  used to hold translated system call arguments, but hasn't been used
  since r159992.

Reviewed by:	kib
Tested on:	md64 (amd64, i386, linux64), i386 (i386, linux)
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D22501
2019-12-03 23:17:54 +00:00
Emmanuel Vadot
357145a0ce Remove "all rights reserved" from copyright for the file that Jared McNeill
own. He gave me permission to do this.
2019-12-03 21:05:33 +00:00
Emmanuel Vadot
e213223c9b Remove "all rights reserved" from copyright for the file I own.
Some of the files have both me and Jared McNeill and he gave me
permission to remove it from his files too.
2019-12-03 21:00:45 +00:00
Jeff Roberson
0f9e06e18b Fix a few places that free a page from an object without busy held. This is
tightening constraints on busy as a precursor to lockless page lookup and
should largely be a NOP for these cases.

Reviewed by:	alc, kib, markj
Differential Revision:	https://reviews.freebsd.org/D22611
2019-12-02 22:42:05 +00:00
Kyle Evans
80d6dbeea0 Remove more needless <sys/tty.h> includes
As part of my journey to make it easy to determine what's relying on tty
bits, remove a couple more. Some of these just outright didn't need it,
while others did rely on <sys/tty.h> pollution for mutex headers.
2019-12-01 20:43:37 +00:00
Ian Lepore
ef4a351452 Implement the ofw_bus_get_node method in the imx_gpio driver so that
ofw_gpiobus can find its fdt metadata and instantiate child devices.
2019-11-28 21:50:34 +00:00
Ian Lepore
b39d851dcb When doing ARM stack unwinding as part of stack_save(9), do not search
loaded modules (pass 0/false for the can_lock arg).  Searching the unwind
info in modules acquires an exclusive sxlock, and the stack(9) functions can
be called in a context where unbounded sleeps are forbidden (such as from
the witness checkorder code).

Just ignoring the existence of modules in stack_save() is not ideal, so I'm
looking for a better solution, but this commit will make it possible to boot
an ARM kernel with WITNESS enabled again, until I get something better.

PR:		242200
2019-11-24 21:08:56 +00:00
Kyle Evans
8922c2ca03 bcm2835_sdhci: fix non-INVARIANTS build
sc is now only used to make sure we're not re-entering the data handling
path erroneously.

Reported by:	Mark Millard
2019-11-23 13:39:47 +00:00
Kyle Evans
d5f1d33c67 bcm2835_dma: rip out the "use_dma" flag, make it non-optional
Now that it works for the Raspberry Pi 4, we can discontinue our workarounds
that were put in place to at least get a bootable kernel for other testing.
2019-11-23 01:47:17 +00:00
Kyle Evans
d7399dfdba bcm2835_sdhci: "fix" DMA on the RPi 4
According to the documentation I have, DREQ pacing should be required here.
The DREQ# hasn't changed since the BCM2835. As soon as we attempt to setup
DREQ, DMA stalls and there's no clear reason why as of yet. Setting this
back to NONE seems to work just as well, though it's yet to be determined if
this is a sustainable model in high-throughput scenarios.
2019-11-23 01:46:02 +00:00
Kyle Evans
ba78f78f44 bcm2835_vcbus: add the *other* rpi4 compat string
The DTS I used initially had brcm,bcm2838; the new one uses brcm,bcm2711.
Add that one as well.
2019-11-22 19:56:52 +00:00
Warner Losh
5bebf8b402 Remove two obsolete comments that reference splhigh/splx. 2019-11-21 18:49:54 +00:00
Kyle Evans
28b1b80e0e bcm2835_sdhci: only inspect interrupts we handle
We'll write the value we read back to ack pending interrupts, but we should
at least make it clear to ourselves that we only want to ack pending
transfer interrupts.
2019-11-21 14:01:44 +00:00
Ed Maste
21ad8c5eb0 mark arm.arm (v4/v5) kernels as NO_UNIVERSE for now
r354290 removed arm.arm from universe, but arm.arm kernels were still
found and built during the kernel stage.  I'm not aware of a better way
to address this at the moment, but since there aren't many arm.arm
kernels anyhow just add an explicit NO_UNIVERSE to them.

Reported by:	rpokala
2019-11-21 03:10:02 +00:00
Kyle Evans
a8761a2a55 bcm2835_sdhci: clean up DMA segments in error handling path
Later parts assume that this would've been done if interrupts are enabled,
but this is the only case in which that wouldn't have been true. This commit
also reorders operations such that we're done touching slot/slot->intmask
before we call back into the SDHCI framework and exit.
2019-11-21 02:49:41 +00:00
Kyle Evans
b61ac06706 bcm2835_sdhci: roll back r354823
r354823 kicked DATA_END handling out of the DMA interrupt path "to make
things easy", but this was likely a mistake -- if we know we're done after
we've finished pending DMA operations, we should go ahead and acknowledge
it rather than waiting for the controller to finalize it. If it's not ready,
we'll simply re-enable interrupts and wait for it anyways, to be re-entered
in sdhci_data_intr.
2019-11-21 02:47:55 +00:00
Kyle Evans
e68976d877 Revert r354930: wrong diff, right message. 2019-11-21 02:44:05 +00:00
Kyle Evans
7af945c666 bcm2835_sdhci: clean up DMA segments in error handling path
Later parts assume that this would've been done if interrupts are enabled,
but this is the only case in which that wouldn't have been true. This commit
also reorders operations such that we're done touching slot/slot->intmask
before we call back into the SDHCI framework and exit.
2019-11-21 02:41:22 +00:00
Kyle Evans
588b15d703 bcm2835_vcbus: add compatibility name for ^/sys/contrib/vchiq
It's unclear how this didn't get caught in my last iteration, but the fix is
easy- the interface is still compatible, it was just gratuituously renamed
to match my arbitrary definition of consistency... VCBUS, the BCM2835 name,
represents an address on the VideoCore CPU Bus.

In a similar fashion, while it is a physical address, the ARMC portion
represents that these are addresses as seen by the ARM CPU.

To make things even more fun, the BCM2711 peripheral documentation describes
not virtual address space vs. physical address space, but instead the 32-bit
address map vs. the address map in "Low Peripheral" mode. The latter of
these is what the *ARMC* macros translate to/from.
2019-11-20 05:04:44 +00:00
Kyle Evans
40084ac37f bcm2835: push address mapping conversion for DMA/mailbox to runtime
We could maintain the static conversions for the !AArch64 Raspberry Pis, but
I'm not sure it's worth it -- we'll traverse the platform list exactly once
(of which there are only two for armv7), then every conversion there-after
traverses the memory map listing of which there are at-most two entries for
these boards: sdram and peripheral space.

Detecting this at runtime is necessary for the AArch64 SOC, though, because
of the distinct IO windows being otherwise not discernible just from support
compiled into the kernel. We currently select the correct window based on
/compatible in the FDT.

We also use a similar mechanism to describe the DMA restrictions- the RPi 4
can have up to 4GB of RAM while the DMA controller and mailbox mechanism can
technically, kind of, only access the lowest 1GB. See the comment in
bcm2835_vcbus.h for a fun description/clarification of this.

Differential Revision:	https://reviews.freebsd.org/D22301
2019-11-20 03:57:46 +00:00
Kyle Evans
44cc3f9c31 bcm2835_sdhci: various refactoring of DMA path
This round of refactoring is mostly about streamlining the interrupt handler
to make it easier to verify and reason about operations taking place while
trying to bring FreeBSD up on the RPi4.
2019-11-19 23:12:43 +00:00
Kyle Evans
55fa224bd1 bcm2835_sdhci: formalize DMA tag/segment scaling requirements
This allows easy and care-free scaling of NUM_DMA_SEGS with proper-ish
calculations to make sure we can actually handle the number of segments we'd
like to handle on average so that performance comparisons can be easily made
at different values if/once we can actually handle it. It also makes it
helps the untrained reader understand more quickly the reasoning behind the
choice of maxsize/maxsegs/maxsegsize.
2019-11-19 04:23:57 +00:00
Kyle Evans
ddf5b0fb84 bcm2835_sdhci: some style cleanup, no functional change 2019-11-19 03:45:41 +00:00
Kyle Evans
0f53b527c4 bcm2835_sdhci: drop an assert in start_dma_seg
Trivial change to clarify locking expectations... no functional change.
2019-11-19 03:40:17 +00:00
Mark Johnston
85e06c728c Set MALLOC_DEBUG_MAXZONES=1 in GENERIC-NODEBUG configurations.
The purpose of this option is to make it easier to track down memory
corruption bugs by reducing the number of malloc(9) types that might
have recently been associated with a given chunk of memory.  However, it
increases fragmentation and is disabled in release kernels.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-18 20:03:28 +00:00
Kyle Evans
6cd7d8a648 bcm2835_sdhci: use a macro for interrupts we handle
This is just further simplification, very little functional change. In the
DMA interrupt handler, we *do* now acknowledge both DATA_AVAIL | SPACE_AVAIL
every time -- these operations are mutually exclusive, so while this is a
functional change, it's effectively a nop. Removing the 'mask' local allows
us to further simplify in a future change.
2019-11-18 19:28:09 +00:00
Kyle Evans
c22f8ca6cc bcm2835_sdhci: push DATA_END handling out of DMA interrupt path
This simplifies the DMA interrupt handler quite a bit. The sdhci framework
will call platform_finish_transfer() if it's received SDHCI_INT_DATA_END, so
we can take care of any final cleanup there and simply not worry about the
possibility of it ending in the DMA interrupt path.
2019-11-18 18:40:35 +00:00
John Baldwin
e353233118 Add a sv_copyout_auxargs() hook in sysentvec.
Change the FreeBSD ELF ABIs to use this new hook to copyout ELF auxv
instead of doing it in the sv_fixup hook.  In particular, this new
hook allows the stack space to be allocated at the same time the auxv
values are copied out to userland.  This allows us to avoid wasting
space for unused auxv entries as well as not having to recalculate
where the auxv vector is by walking back up over the argv and
environment vectors.

Reviewed by:	brooks, emaste
Tested on:	amd64 (amd64 and i386 binaries), i386, mips, mips64
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D22355
2019-11-15 18:42:13 +00:00
Ian Lepore
c3916f9145 Rewrite arm/stack_machdep.c for EABI; add stack(9) support to arm kernels.
The old stack_machdep.c code was written for the APCS ABI (aka "oldabi").
When we switched to ARM EABI (back in freebsd 10) this file never got
updated, and apparently nobody noticed that until now.

The new implementation uses the same stack unwinder code used by the
arm implemenation of the db_trace stuff.
2019-11-14 16:46:27 +00:00
Kyle Evans
da30baba4a bcm2835_sdhci: don't panic in DMA interrupt if curcmd went away
This is an exceptional case; generally found during controller errors.
A panic when we attempt to acess slot->curcmd->data is less ideal than
warning, and other verbiage will be emitted to indicate the exact error.
2019-11-10 03:06:03 +00:00
Kyle Evans
ff3b277b34 bcm2835: commit missing constant from r354560
Surgically pulling the patch from my debugging work lead to this slopiness-
my apologies.
2019-11-08 20:53:56 +00:00
Kyle Evans
9786eaf3d0 bcm2835_sdhci: remove unused power_id field
This was once set, but I removed it by the time I committed it because both
configurations use the same POWER_ID. This can be separated back out if the
situation changes.
2019-11-08 20:14:36 +00:00
Kyle Evans
939f1d8f5f bcm2835_sdhci: add some very basic support for rpi4
DMA is currently disabled while I work out why it's broken, but this is
enough for upstream U-Boot + rpi-firmware + our rpi3-psci-monitor to boot
with the right config.

The RPi 4 is still not in a good "supported" state, as we have no
USB/PCI-E/Ethernet drivers, but if air-gapped pies only able to operate over
cereal is your thing, here's your guy.

Submitted by:	Robert Crowston (with modifications)
2019-11-08 20:12:57 +00:00
Ed Maste
60247c8ffd arm linuxulator: reformat syscalls.master per current style
Equivalent to r339958 for sys/kern/syscalls.master.

Also add a dummy name for an UNUSED.

Sponsored by:	The FreeBSD Foundation
2019-11-08 14:18:16 +00:00
Ed Maste
b6bb45f24b arm linuxulator: add syscalls definition
From Linux arch/arm/kernel/call.S

Reviewed by:	imp (earlier)
Submitted by:	Grégory Soutadé <soutade_gmail.com>
Differential Revision:	https://reviews.freebsd.org/D7972
2019-11-08 14:17:25 +00:00
Kyle Evans
c23f22a973 bcm2835_dma: Mark IRQs shareable
On the RPi4, some of these IRQs are shared. Start moving toward a mode where
we accept that shared IRQs happen and simply ignore interrupts that are
seemingly for no reason.

I would like to be more verbose here, but my 30-minute assessment of the
current world order is that mapping a resource/rid to an actual IRQ number
(as found in FDT) data is not a simple matter. Determining if more than one
handler is attached to an IRQ is closer to feasible, but it's unclear which
way is the cleaner path. Beyond that, we're only really using it to be
slightly more verbose when something's going wrong, so for now just suppress
and drop a complaint-comment.

This was originally submitted (via freebsd-arm@) by Robert Crowston; the
additional verbosity was dropped by kevans@.

Submitted by:	Robert Crowston <crowston@protonmail.com>
2019-11-08 03:27:56 +00:00
Kyle Evans
63f34d0109 bcm_lintc: don't attach if "interrupt-controller" is missing
This is a standard required property for interrupt controllers, and present
on the bcm_lintc nodes for currently supported RPi models. For the RPi4, we
have both bcm_lintc as well as GIC-400, but only one may be active at a
time.

Don't probe bcm_lintc if it's missing the "interrupt-controller" property --
in RPi 4 DTS, the bcm_lintc node is actually missing this along with other
required interrupt properties. Presumably, if the earlier boot stages will
support switching to the legacy interrupt controller (as is suggested
possible by the documentation), the DTS will need to be updated to indicate
the proper interrupt-parent and hopefully also mark this node as an
interrupt-controller instead.
2019-11-07 21:31:15 +00:00
Emmanuel Vadot
5bf4529b14 arm64: allwinner: a64: Do not init the video related clocks
This should be handled by the video drivers and this break EFIFB
as this changes clock setup by the bootloader.

MFC after:	1 month
2019-11-06 18:39:32 +00:00
Emmanuel Vadot
94d3675ea0 arm: allwinner: aw_mmc: Check if the regulator support the voltage
Don't blindy say that we support both 3.3V and 1.8V.
If we have a regulator for the data lines, check that the voltage is
supported before adding the signaling caps.
If we don't have a regulator, just assume that the data lines are 3.3V
This unbreak eMMC on some allwinner boards.

Reported by:	ganbold
MFC after:	1 month
X-MFC-With:	r354396
2019-11-06 14:58:25 +00:00
Emmanuel Vadot
9c3a56d076 regulator: Add regulator_check_voltage function
This function will call the regnode_check_voltage method for a given regulator
and check if the desired voltage in reachable by it.
Also adds a default method that check the std_param and which should be enough
for most regulators and add it as the method for axp* rk805 and fixed regulators.

Reviewed by:	mmel
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D22260
2019-11-06 14:55:24 +00:00
Ilya Bakulin
ef546520da Use the new cam_sim_alloc_dev function to properly initialize SIM
Using cam_sim_alloc_dev() allows to properly set sim_dev field so that
sdiob(4) can attach to the CAM device that represents SDIO card.
The same change for SDHCI driver happened in r348800.

Approved by:		imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D22192
2019-10-30 20:43:27 +00:00
Emmanuel Vadot
f66cb502db axp81x: Use the default regnode_init method
MFC after:	1 week
2019-10-23 09:54:50 +00:00
Kyle Evans
c89d4b3ce1 arm: correct kernelstack allocation size
This appears to be a copy-pasto from previous lines that propagated to v6
over the years. Indeed, nothing references kernelstack beyond
USPACE_SVC_STACK_TOP and it would be odd if anything did.

Noticed by:	markj
2019-10-22 21:46:03 +00:00
Mark Johnston
24b3b8e29d Initialize thread0.td_kstack_pages on arm.
Fix style on the line below.

Reported by:	Jenkins (hardware CI lab)
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-10-22 17:21:23 +00:00
Gleb Smirnoff
9321bbc558 Convert to if_foreach_llmaddr() KPI. 2019-10-21 18:13:28 +00:00
Gleb Smirnoff
c65484668d Convert to if_foreach_llmaddr() KPI. 2019-10-21 18:13:24 +00:00
Gleb Smirnoff
915a6a5179 Convert to if_foreach_llmaddr() KPI. 2019-10-21 18:13:19 +00:00
Gleb Smirnoff
45193b43a1 Convert to if_foreach_llmaddr() KPI. 2019-10-21 18:13:14 +00:00
Michal Meloun
4b84206b7f Update Armada 8k drivers to cover newly imported DT and latest changes
in simple multifunction driver.
- follow interrupt changes in DT. Split old ICU driver to function oriented
  parts and add drivers for newly defined parts (system error interrupts).
- Many drivers are children of simple multifunction driver. But after r349596
  simple MF driver doesn't longer exports memory resources, and all children
  must use syscon interface to access their registers. Adapt affected
  drivers to this fact.

MFC after:	3 weeks
2019-10-20 10:48:27 +00:00
Mark Johnston
01cef4caa7 Remove page locking from pmap_mincore().
After r352110 the page lock no longer protects a page's identity, so
there is no purpose in locking the page in pmap_mincore().  Instead,
if vm.mincore_mapped is set to the non-default value of 0, re-lookup
the page after acquiring its object lock, which holds the page's
identity stable.

The change removes the last callers of vm_page_pa_tryrelock(), so
remove it.

Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21823
2019-10-16 22:03:27 +00:00
Konstantin Belousov
96448820a3 Port r353622 to sparc64 and arm v4.
Noted by:	alc
Reviewed by:	alc, jeff, markj
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D22056
2019-10-16 21:07:18 +00:00
Ian Lepore
caf894f793 Update some comments; no functional changes. Some historical old comments
in this driver indicate that the SD_CAPA register is write-once and after
being set one time the values in it cannot be changed.  That turns out not
to be the case -- the values written to it survive a reset, but they can
be rewritten/changed at any time.
2019-10-16 16:26:35 +00:00
Ian Lepore
d436d6e96f Revert r351218 (by manu). While the changes in r351218 appear to be (and
should be) correct, they lead to the eMMC on a Beaglebone failing to work
in some situations.

The TI sdhci hardware is kind of strange.  The first device inherently
supports 1.8v and 3.3v and the abililty to switch between them, and the
other two devices must be set to 1.8v in the sdhci power control register to
operate correctly, but doing so actually makes them run at 3.3v (unless an
external level-shifter is present in the signal path).  Even the 1.8v on the
first device may actually be 3.3v (or any other value), depending on what
voltage is fed to the VDDS1-VDDS7 power supply pins on the am335x chip.

Another strange quirk is that the convention for am335x sdhci drivers in
linux and uboot and the am335x boot ROM seems to be to set the voltage in
the sdhci capabilities register to 3.0v even though the actual voltage is
3.3v.  Why this is done is a complete mystery to me, but it seems to be
required for correct operation.

If we had complete modern support for the am335x chip we could get the
actual voltages from the FDT data and the regulator framework.  But our
am335x code currently doesn't have any regulator framework support.
Reverting to the prior code will get the popular Beaglebone boards working
again.

This is part of the fix for PR 241301, but also requires r353651 for a
complete fix.

PR:		241301
Discussed with: manu
2019-10-16 16:19:21 +00:00
Jeff Roberson
638f867814 (6/6) Convert pmap to expect busy in write related operations now that all
callers hold it.

This simplifies pmap code and removes a dependency on the object lock.

Reviewed by:    kib, markj
Tested by:      pho
Sponsored by:   Netflix, Intel
Differential Revision:	https://reviews.freebsd.org/D21596
2019-10-15 03:51:46 +00:00
Jeff Roberson
205be21d99 (3/6) Add a shared object busy synchronization mechanism that blocks new page
busy acquires while held.

This allows code that would need to acquire and release a very large number
of page busy locks to use the old mechanism where busy is only checked and
not held.  This comes at the cost of false positives but never false
negatives which the single consumer, vm_fault_soft_fast(), handles.

Reviewed by:    kib
Tested by:      pho
Sponsored by:   Netflix, Intel
Differential Revision:	https://reviews.freebsd.org/D21592
2019-10-15 03:41:36 +00:00
Emmanuel Vadot
f44e743679 arm: allwinner: Add np and nmm clock file to the build
MFC after:	1 month
2019-10-14 22:29:20 +00:00
Emmanuel Vadot
26b0cd3a95 arm64: allwinner: Add aw_dwc3 driver
This is a simplebus like driver that just deal with clocks and resets
and attach the dwc3 child node.

MFC after:	1 month
2019-10-14 22:22:19 +00:00
Emmanuel Vadot
fe924cbd5a arm64: allwinner: Add support for the usb3 phy
The usb 3 controller in the H6 SoC have a dedicated phy.
Add support for it.
Mostly imported from NetBSD

MFC after:	1 month
2019-10-14 21:58:46 +00:00
Emmanuel Vadot
126700faec arm64: allwinner: aw_usbphy: Add support for H6 PHY
MFC after:	1 month
2019-10-14 21:56:41 +00:00
Emmanuel Vadot
61d432cd73 arm64: allwinner: Add H6 GPIO/Pinctrl driver
This adds support for Allwinner H6 GPIO and pinctrl driver for
both the main pinctrl unit and the 'r_' one.

MFC after:	1 month
2019-10-14 21:55:45 +00:00
Emmanuel Vadot
6c4464cb74 arm64: allwinner: Add Allwinner H6 Support
This adds support for H6 SoC.
Add a CCU driver for H6 that support all PLLs and most of the clocks
that we are intersted in for now (i2c, mmc, usb, etc ...)

MFC after:	1 month
2019-10-14 21:53:53 +00:00
Emmanuel Vadot
101260f3a2 arm: allwinner: Disable the clock before changing it's freq
You aren't supposed to changing the freq of a clock when it is
enable so disable the clock before changing the freq and then
re-enable it.

MFC after:	1 month
2019-10-14 21:50:44 +00:00
Emmanuel Vadot
153e7b98e9 arm64: allwinner: Add aw_clk_nmm clock
This is a clock type present on Allwinner H6 where the formula is :
f = fparent * n / m0 / m1

MFC after:	1 month
2019-10-14 21:49:07 +00:00
Emmanuel Vadot
fcc82a8310 arm64: allwinner: Add new clock aw_clk_np
This is a clock type present in Allwinner H6 where the formula is :
f = fparent * N / P

MFC after:	1 month
2019-10-14 21:47:20 +00:00
Emmanuel Vadot
59c7842efe aw_ccung: Add more debug printfs
No functional changes

MFC after:	1 month
2019-10-14 21:45:15 +00:00
Andriy Gapon
80475f9523 align use of cp15_pmccntr_get with its availability
According to ian, the only armv6 cpu we support is the 1176, so this
change is effectively a no-op.
The change is just to make the code more self-consistent.
The issue was noticed by a standalone module build for armv6.

Reviewed by:	ian
MFC after:	3 weeks
2019-10-07 07:37:42 +00:00
Emmanuel Vadot
29ee738052 allwinner: Remove a10_ehci driver
We have generic-ehci since r353062 so use it.

MFC after:	1 month
X-MFC-With:	r353062
2019-10-03 18:58:15 +00:00
Emmanuel Vadot
fbf39b9767 arm: allwinner: a10_ehci: Enable all phys
Even if there should be only one phy enable all the ones declared in
the dts just to be sure.
2019-10-01 22:19:12 +00:00
Emmanuel Vadot
ecd012f975 arm: allwinner: a10_ehci: Look for the phy based on the id
phy-names was never in the bindings schema even if it was present
in some DTS. Get the optional phy based on its ID.

PR:		240978
2019-10-01 20:22:54 +00:00
Ian Lepore
044477e294 Add 8 and 16 bit versions of atomic_cmpset and atomic_fcmpset for arm.
This adds 8 and 16 bit versions of the cmpset and fcmpset functions. Macros
are used to generate all the flavors from the same set of instructions; the
macro expansion handles the couple minor differences between each size
variation (generating ldrexb/ldrexh/ldrex for 8/16/32, etc).

In addition to handling new sizes, the instruction sequences used for cmpset
and fcmpset are rewritten to be a bit shorter/faster, and the new sequence
will not return false when *dst==*old but the store-exclusive fails because
of concurrent writers. Instead, it just loops like ldrex/strex sequences
normally do until it gets a non-conflicted store. The manpage allows LL/SC
architectures to bogusly return false, but there's no reason to actually do
so, at least on arm.

Reviewed by:	cognet
2019-10-01 19:39:00 +00:00
Emmanuel Vadot
ce70577d7f arm: allwinner: Add pll_mipi to the files 2019-09-28 23:01:23 +00:00
Emmanuel Vadot
f99055394d arm64: allwinner: a64: Add PLL_MIPI
PLL_MIPI is the last important PLL that we missed.
Add support for it.
Since it's one of the possible parent for TCON0 also add this clock
now that we can.
While here add some info about what video related clocks should be
enabled at boot and with what frequency.
2019-09-28 22:14:33 +00:00
Konstantin Belousov
df08823d07 Improve MD page fault handlers.
Centralize calculation of signal and ucode delivered on unhandled page
fault in new function vm_fault_trap().  MD trap_pfault() now almost
always uses the signal numbers and error codes calculated in
consistent MI way.

This introduces the protection fault compatibility sysctls to all
non-x86 architectures which did not have that bug, but apparently they
were already much more wrong in selecting delivered signals on
protection violations.

Change the delivered signal for accesses to mapped area after the
backing object was truncated.  According to POSIX description for
mmap(2):
   The system shall always zero-fill any partial page at the end of an
   object. Further, the system shall never write out any modified
   portions of the last page of an object which are beyond its
   end. References within the address range starting at pa and
   continuing for len bytes to whole pages following the end of an
   object shall result in delivery of a SIGBUS signal.

   An implementation may generate SIGBUS signals when a reference
   would cause an error in the mapped object, such as out-of-space
   condition.
Adjust according to the description, keeping the existing
compatibility code for SIGSEGV/SIGBUS on protection failures.

For situations where kernel cannot handle page fault due to resource
limit enforcement, SIGBUS with a new error code BUS_OBJERR is
delivered.  Also, provide a new error code SEGV_PKUERR for SIGSEGV on
amd64 due to protection key access violation.

vm_fault_hold() is renamed to vm_fault().  Fixed some nits in
trap_pfault()s like mis-interpreting Mach errors as errnos.  Removed
unneeded truncations of the fault addresses reported by hardware.

PR:	211924
Reviewed by:	alc
Discussed with:	jilles, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D21566
2019-09-27 18:43:36 +00:00
Mark Johnston
b119329d81 Complete the removal of the "wire_count" field from struct vm_page.
Convert all remaining references to that field to "ref_count" and update
comments accordingly.  No functional change intended.

Reviewed by:	alc, kib
Sponsored by:	Intel, Netflix
Differential Revision:	https://reviews.freebsd.org/D21768
2019-09-25 16:11:35 +00:00
Mark Johnston
e8bcf6966b Revert r352406, which contained changes I didn't intend to commit. 2019-09-16 15:04:45 +00:00
Mark Johnston
41fd4b9422 Fix a couple of nits in r352110.
- Remove a dead variable from the amd64 pmap_extract_and_hold().
- Fix grammar in the vm_page_wire man page.

Reported by:	alc
Reviewed by:	alc, kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21639
2019-09-16 15:03:12 +00:00
Ian Lepore
7887a5a140 Apply a runtime patch to the FDT data for imx6 to fix iomuxc problems.
The latest imported FDT data defines a node for an iomuxc-gpr device,
which we don't support (or need, right now) in addition to the usual
iomuxc device.  Unfortunately, the dts improperly assigns overlapping
ranges of mmio space to both devices.  The -gpr device is also a syscon
and simple_mfd device.

At runtime the simple_mfd driver attaches for the iomuxc-gpr node, then
when the real iomuxc driver comes along later, it fails to attach because
it tries to allocate its register space, and it's already partially in
use by the bogus instance of simple_mfd.

This change works around the problem by simply disabling the node for
the iomuxc-gpr device, since we don't need it for anything.
2019-09-15 19:38:15 +00:00
Ian Lepore
3dffab60f3 Make the ti_sysc device quiet. It's an internal utility pseudo-device
that makes the upstream FDT data work right, so we don't need to see a
couple dozen instances of it spam the dmesg at boot time unless it's a
verbose boot.
2019-09-15 01:02:01 +00:00