Merge branch 'freebsd/current/main' into hardened/current/master

This commit is contained in:
HardenedBSD Sync Services 2024-11-17 00:01:20 -07:00
commit 8c6bf2dd36
No known key found for this signature in database
9 changed files with 1151 additions and 19 deletions

View File

@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd January 7, 2018
.Dd November 11, 2024
.Dt AW_SYSCON 4
.Os
.Sh NAME
@ -48,9 +48,17 @@ strings:
.It
allwinner,sun50i-a64-system-controller
.It
allwinner,sun50i-a64-system-control
.It
allwinner,sun8i-a83t-system-controller
.It
allwinner,sun8i-h3-system-controller
.It
allwinner,sun8i-h3-system-control
.It
allwinner,sun50i-h5-system-control
.It
allwinner,sun20i-d1-system-control
.El
.Sh AUTHORS
The

View File

@ -134,6 +134,7 @@ static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun7i-a20-rtc", (uintptr_t) &a20_conf },
{ "allwinner,sun6i-a31-rtc", (uintptr_t) &a31_conf },
{ "allwinner,sun8i-h3-rtc", (uintptr_t) &h3_conf },
{ "allwinner,sun20i-d1-rtc", (uintptr_t) &h3_conf },
{ "allwinner,sun50i-h5-rtc", (uintptr_t) &h3_conf },
{ "allwinner,sun50i-h6-rtc", (uintptr_t) &h3_conf },
{ NULL, 0 }
@ -147,11 +148,13 @@ struct aw_rtc_softc {
static struct clk_fixed_def aw_rtc_osc32k = {
.clkdef.id = 0,
.clkdef.name = "osc32k",
.freq = 32768,
};
static struct clk_fixed_def aw_rtc_iosc = {
.clkdef.id = 2,
.clkdef.name = "iosc",
};
static void aw_rtc_install_clocks(struct aw_rtc_softc *sc, device_t dev);
@ -249,24 +252,29 @@ aw_rtc_install_clocks(struct aw_rtc_softc *sc, device_t dev) {
phandle_t node;
int nclocks;
/*
* If the device tree gives us specific output names for the clocks,
* use them.
*/
node = ofw_bus_get_node(dev);
nclocks = ofw_bus_string_list_to_array(node, "clock-output-names", &clknames);
/* No clocks to export */
if (nclocks <= 0)
return;
if (nclocks > 0) {
if (nclocks != 3) {
device_printf(dev,
"Found %d clocks instead of 3, aborting\n",
nclocks);
return;
}
if (nclocks != 3) {
device_printf(dev, "Having only %d clocks instead of 3, aborting\n", nclocks);
return;
aw_rtc_osc32k.clkdef.name = clknames[0];
aw_rtc_iosc.clkdef.name = clknames[2];
}
clkdom = clkdom_create(dev);
aw_rtc_osc32k.clkdef.name = clknames[0];
if (clknode_fixed_register(clkdom, &aw_rtc_osc32k) != 0)
device_printf(dev, "Cannot register osc32k clock\n");
aw_rtc_iosc.clkdef.name = clknames[2];
aw_rtc_iosc.freq = sc->conf->iosc_freq;
if (clknode_fixed_register(clkdom, &aw_rtc_iosc) != 0)
device_printf(dev, "Cannot register iosc clock\n");

View File

@ -51,6 +51,7 @@ static struct ofw_compat_data compat_data[] = {
{"allwinner,sun8i-h3-system-controller", 1},
{"allwinner,sun8i-h3-system-control", 1},
{"allwinner,sun50i-h5-system-control", 1},
{"allwinner,sun20i-d1-system-control", 1},
{NULL, 0}
};

View File

@ -202,6 +202,9 @@ aw_wdog_attach(device_t dev)
EVENTHANDLER_REGISTER(shutdown_final, aw_wdog_shutdown_fn, sc,
SHUTDOWN_PRI_LAST - 1);
/* Disable watchdog for now. */
WRITE(sc, sc->wdog_mode, sc->wdog_mode_key);
return (0);
}

View File

@ -1,3 +1,6 @@
RISCV opt_global.h # For cpu RISCV to work
INTRNG opt_global.h
PV_STATS opt_pmap.h
# SoC Support
SOC_ALLWINNER_D1 opt_soc.h

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1,16 @@
arm/allwinner/aw_wdog.c optional aw_wdog
arm/allwinner/aw_rtc.c optional aw_rtc fdt
arm/allwinner/aw_syscon.c optional syscon
arm/allwinner/aw_wdog.c optional aw_wdog
# Allwinner clock drivers
dev/clk/allwinner/aw_ccung.c optional aw_ccu fdt
dev/clk/allwinner/aw_clk_frac.c optional aw_ccu fdt
dev/clk/allwinner/aw_clk_m.c optional aw_ccu fdt
dev/clk/allwinner/aw_clk_mipi.c optional aw_ccu fdt
dev/clk/allwinner/aw_clk_nkmp.c optional aw_ccu fdt
dev/clk/allwinner/aw_clk_nm.c optional aw_ccu fdt
dev/clk/allwinner/aw_clk_nmm.c optional aw_ccu fdt
dev/clk/allwinner/aw_clk_np.c optional aw_ccu fdt
dev/clk/allwinner/aw_clk_prediv_mux.c optional aw_ccu fdt
dev/clk/allwinner/ccu_d1.c optional soc_allwinner_d1 aw_ccu fdt

View File

@ -2,6 +2,11 @@
# Allwinner SoC support
#
# SoC support
options SOC_ALLWINNER_D1
device aw_ccu # Allwinner clock controller
device aw_rtc # Allwinner Real-time Clock
device aw_wdog # Allwinner Watchdog
files "../allwinner/files.allwinner"

View File

@ -1475,16 +1475,17 @@ vm_page_dirty_KBI(vm_page_t m)
/*
* Insert the given page into the given object at the given pindex. mpred is
* used for memq linkage. From vm_page_insert, lookup is true, mpred is
* initially NULL, and this procedure looks it up. From vm_page_insert_after,
* lookup is false and mpred is known to the caller to be valid, and may be
* NULL if this will be the page with the lowest pindex.
* initially NULL, and this procedure looks it up. From vm_page_insert_after
* and vm_page_iter_insert, lookup is false and mpred is known to the caller
* to be valid, and may be NULL if this will be the page with the lowest
* pindex.
*
* The procedure is marked __always_inline to suggest to the compiler to
* eliminate the lookup parameter and the associated alternate branch.
*/
static __always_inline int
vm_page_insert_lookup(vm_page_t m, vm_object_t object, vm_pindex_t pindex,
vm_page_t mpred, bool lookup)
struct pctrie_iter *pages, bool iter, vm_page_t mpred, bool lookup)
{
int error;
@ -1503,7 +1504,10 @@ vm_page_insert_lookup(vm_page_t m, vm_object_t object, vm_pindex_t pindex,
* Add this page to the object's radix tree, and look up mpred if
* needed.
*/
if (lookup)
if (iter) {
KASSERT(!lookup, ("%s: cannot lookup mpred", __func__));
error = vm_radix_iter_insert(pages, m);
} else if (lookup)
error = vm_radix_insert_lookup_lt(&object->rtree, m, &mpred);
else
error = vm_radix_insert(&object->rtree, m);
@ -1532,7 +1536,8 @@ vm_page_insert_lookup(vm_page_t m, vm_object_t object, vm_pindex_t pindex,
int
vm_page_insert(vm_page_t m, vm_object_t object, vm_pindex_t pindex)
{
return (vm_page_insert_lookup(m, object, pindex, NULL, true));
return (vm_page_insert_lookup(m, object, pindex, NULL, false, NULL,
true));
}
/*
@ -1549,7 +1554,28 @@ static int
vm_page_insert_after(vm_page_t m, vm_object_t object, vm_pindex_t pindex,
vm_page_t mpred)
{
return (vm_page_insert_lookup(m, object, pindex, mpred, false));
return (vm_page_insert_lookup(m, object, pindex, NULL, false, mpred,
false));
}
/*
* vm_page_iter_insert:
*
* Tries to insert the page "m" into the specified object at offset
* "pindex" using the iterator "pages". Returns 0 if the insertion was
* successful.
*
* The page "mpred" must immediately precede the offset "pindex" within
* the specified object.
*
* The object must be locked.
*/
static int
vm_page_iter_insert(struct pctrie_iter *pages, vm_page_t m, vm_object_t object,
vm_pindex_t pindex, vm_page_t mpred)
{
return (vm_page_insert_lookup(m, object, pindex, pages, true, mpred,
false));
}
/*
@ -2373,6 +2399,7 @@ vm_page_alloc_contig_domain(vm_object_t object, vm_pindex_t pindex, int domain,
int req, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment,
vm_paddr_t boundary, vm_memattr_t memattr)
{
struct pctrie_iter pages;
vm_page_t m, m_ret, mpred;
u_int busy_lock, flags, oflags;
@ -2391,7 +2418,8 @@ vm_page_alloc_contig_domain(vm_object_t object, vm_pindex_t pindex, int domain,
object));
KASSERT(npages > 0, ("vm_page_alloc_contig: npages is zero"));
mpred = vm_page_mpred(object, pindex);
vm_page_iter_init(&pages, object);
mpred = vm_radix_iter_lookup_le(&pages, pindex);
KASSERT(mpred == NULL || mpred->pindex != pindex,
("vm_page_alloc_contig: pindex already allocated"));
for (;;) {
@ -2440,7 +2468,7 @@ vm_page_alloc_contig_domain(vm_object_t object, vm_pindex_t pindex, int domain,
m->ref_count = 1;
m->a.act_count = 0;
m->oflags = oflags;
if (vm_page_insert_after(m, object, pindex, mpred)) {
if (vm_page_iter_insert(&pages, m, object, pindex, mpred)) {
if ((req & VM_ALLOC_WIRED) != 0)
vm_wire_sub(npages);
KASSERT(m->object == NULL,