Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/sunxi avoid allocations in the reboot (maybe cr...



details:   https://anonhg.NetBSD.org/src/rev/5f5570969e11
branches:  trunk
changeset: 457222:5f5570969e11
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon Jun 17 05:27:01 2019 +0000

description:
avoid allocations in the reboot (maybe crash) path and map the
reset registers in new *platform_bootstrap() functions that
merely move the bus_space_map() here, and then call the
original sunxi_platform_bootstrap().

tested on cubietruck and cubietruck plus.

diffstat:

 sys/arch/arm/sunxi/sunxi_platform.c |  88 +++++++++++++++++++++++-------------
 1 files changed, 57 insertions(+), 31 deletions(-)

diffs (208 lines):

diff -r 3af9aaf7edc5 -r 5f5570969e11 sys/arch/arm/sunxi/sunxi_platform.c
--- a/sys/arch/arm/sunxi/sunxi_platform.c       Mon Jun 17 03:34:01 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_platform.c       Mon Jun 17 05:27:01 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_platform.c,v 1.36 2019/04/30 10:10:45 mrg Exp $ */
+/* $NetBSD: sunxi_platform.c,v 1.37 2019/06/17 05:27:01 mrg Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
 #include "opt_console.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.36 2019/04/30 10:10:45 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.37 2019/06/17 05:27:01 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -114,6 +114,8 @@
 #define        sunxi_bs_tag            arm_generic_bs_tag
 #define        sunxi_a4x_bs_tag        arm_generic_a4x_bs_tag
 
+static bus_space_handle_t reset_bsh;
+
 static const struct pmap_devmap *
 sunxi_platform_devmap(void)
 {
@@ -268,6 +270,42 @@
        }
 }
 
+static void
+sun4i_platform_bootstrap(void)
+{
+       bus_space_tag_t bst = &sunxi_bs_tag;
+
+       sunxi_platform_bootstrap();
+       bus_space_map(bst, SUN4I_WDT_BASE, SUN4I_WDT_SIZE, 0, &reset_bsh);
+}
+
+static void
+sun6i_platform_bootstrap(void)
+{
+       bus_space_tag_t bst = &sunxi_bs_tag;
+
+       sunxi_platform_bootstrap();
+       bus_space_map(bst, SUN6I_WDT_BASE, SUN6I_WDT_SIZE, 0, &reset_bsh);
+}
+
+static void
+sun9i_platform_bootstrap(void)
+{
+       bus_space_tag_t bst = &sunxi_bs_tag;
+
+       sunxi_platform_bootstrap();
+       bus_space_map(bst, SUN9I_WDT_BASE, SUN9I_WDT_SIZE, 0, &reset_bsh);
+}
+
+static void
+sun50i_h6_platform_bootstrap(void)
+{
+       bus_space_tag_t bst = &sunxi_bs_tag;
+
+       sunxi_platform_bootstrap();
+       bus_space_map(bst, SUN50I_H6_WDT_BASE, SUN50I_H6_WDT_SIZE, 0, &reset_bsh);
+}
+
 #if defined(SOC_SUNXI_MC)
 static int
 cpu_enable_sun8i_a83t(int phandle)
@@ -296,14 +334,11 @@
 sun4i_platform_reset(void)
 {
        bus_space_tag_t bst = &sunxi_bs_tag;
-       bus_space_handle_t bsh;
 
-       bus_space_map(bst, SUN4I_WDT_BASE, SUN4I_WDT_SIZE, 0, &bsh);
-
-       bus_space_write_4(bst, bsh, SUN4I_WDT_CTRL,
+       bus_space_write_4(bst, reset_bsh, SUN4I_WDT_CTRL,
            SUN4I_WDT_CTRL_KEY | SUN4I_WDT_CTRL_RESTART);
        for (;;) {
-               bus_space_write_4(bst, bsh, SUN4I_WDT_MODE,
+               bus_space_write_4(bst, reset_bsh, SUN4I_WDT_MODE,
                    SUN4I_WDT_MODE_EN | SUN4I_WDT_MODE_RST_EN);
        }
 }
@@ -344,41 +379,32 @@
 sun6i_platform_reset(void)
 {
        bus_space_tag_t bst = &sunxi_bs_tag;
-       bus_space_handle_t bsh;
 
-       bus_space_map(bst, SUN6I_WDT_BASE, SUN6I_WDT_SIZE, 0, &bsh);
-
-       bus_space_write_4(bst, bsh, SUN6I_WDT_CFG, SUN6I_WDT_CFG_SYS);
-       bus_space_write_4(bst, bsh, SUN6I_WDT_MODE, SUN6I_WDT_MODE_EN);
+       bus_space_write_4(bst, reset_bsh, SUN6I_WDT_CFG, SUN6I_WDT_CFG_SYS);
+       bus_space_write_4(bst, reset_bsh, SUN6I_WDT_MODE, SUN6I_WDT_MODE_EN);
 }
 
 static void
 sun9i_platform_reset(void)
 {
        bus_space_tag_t bst = &sunxi_bs_tag;
-       bus_space_handle_t bsh;
 
-       bus_space_map(bst, SUN9I_WDT_BASE, SUN9I_WDT_SIZE, 0, &bsh);
-
-       bus_space_write_4(bst, bsh, SUN9I_WDT_CFG, SUN9I_WDT_CFG_SYS);
-       bus_space_write_4(bst, bsh, SUN9I_WDT_MODE, SUN9I_WDT_MODE_EN);
+       bus_space_write_4(bst, reset_bsh, SUN9I_WDT_CFG, SUN9I_WDT_CFG_SYS);
+       bus_space_write_4(bst, reset_bsh, SUN9I_WDT_MODE, SUN9I_WDT_MODE_EN);
 }
 
 static void
 sun50i_h6_platform_reset(void)
 {
        bus_space_tag_t bst = &sunxi_bs_tag;
-       bus_space_handle_t bsh;
 
-       bus_space_map(bst, SUN50I_H6_WDT_BASE, SUN50I_H6_WDT_SIZE, 0, &bsh);
-
-       bus_space_write_4(bst, bsh, SUN50I_H6_WDT_CFG, SUN50I_H6_WDT_CFG_SYS);
-       bus_space_write_4(bst, bsh, SUN50I_H6_WDT_MODE, SUN50I_H6_WDT_MODE_EN);
+       bus_space_write_4(bst, reset_bsh, SUN50I_H6_WDT_CFG, SUN50I_H6_WDT_CFG_SYS);
+       bus_space_write_4(bst, reset_bsh, SUN50I_H6_WDT_MODE, SUN50I_H6_WDT_MODE_EN);
 }
 
 static const struct arm_platform sun4i_platform = {
        .ap_devmap = sunxi_platform_devmap,
-       .ap_bootstrap = sunxi_platform_bootstrap,
+       .ap_bootstrap = sun4i_platform_bootstrap,
        .ap_init_attach_args = sunxi_platform_init_attach_args,
        .ap_device_register = sunxi_platform_device_register,
        .ap_reset = sun4i_platform_reset,
@@ -390,7 +416,7 @@
 
 static const struct arm_platform sun5i_platform = {
        .ap_devmap = sunxi_platform_devmap,
-       .ap_bootstrap = sunxi_platform_bootstrap,
+       .ap_bootstrap = sun4i_platform_bootstrap,
        .ap_init_attach_args = sunxi_platform_init_attach_args,
        .ap_device_register = sunxi_platform_device_register,
        .ap_reset = sun4i_platform_reset,
@@ -403,7 +429,7 @@
 
 static const struct arm_platform sun6i_platform = {
        .ap_devmap = sunxi_platform_devmap,
-       .ap_bootstrap = sunxi_platform_bootstrap,
+       .ap_bootstrap = sun6i_platform_bootstrap,
        .ap_init_attach_args = sunxi_platform_init_attach_args,
        .ap_device_register = sunxi_platform_device_register,
        .ap_reset = sun6i_platform_reset,
@@ -416,7 +442,7 @@
 
 static const struct arm_platform sun7i_platform = {
        .ap_devmap = sunxi_platform_devmap,
-       .ap_bootstrap = sunxi_platform_bootstrap,
+       .ap_bootstrap = sun4i_platform_bootstrap,
        .ap_init_attach_args = sunxi_platform_init_attach_args,
        .ap_device_register = sunxi_platform_device_register,
        .ap_reset = sun4i_platform_reset,
@@ -429,7 +455,7 @@
 
 static const struct arm_platform sun8i_platform = {
        .ap_devmap = sunxi_platform_devmap,
-       .ap_bootstrap = sunxi_platform_bootstrap,
+       .ap_bootstrap = sun6i_platform_bootstrap,
        .ap_init_attach_args = sunxi_platform_init_attach_args,
        .ap_device_register = sunxi_platform_device_register,
        .ap_reset = sun6i_platform_reset,
@@ -443,7 +469,7 @@
 
 static const struct arm_platform sun8i_a83t_platform = {
        .ap_devmap = sun8i_a83t_platform_devmap,
-       .ap_bootstrap = sunxi_platform_bootstrap,
+       .ap_bootstrap = sun6i_platform_bootstrap,
        .ap_init_attach_args = sunxi_platform_init_attach_args,
        .ap_device_register = sunxi_platform_device_register,
        .ap_reset = sun6i_platform_reset,
@@ -456,7 +482,7 @@
 
 static const struct arm_platform sun9i_platform = {
        .ap_devmap = sun9i_a80_platform_devmap,
-       .ap_bootstrap = sunxi_platform_bootstrap,
+       .ap_bootstrap = sun9i_platform_bootstrap,
        .ap_init_attach_args = sunxi_platform_init_attach_args,
        .ap_device_register = sunxi_platform_device_register,
        .ap_reset = sun9i_platform_reset,
@@ -469,7 +495,7 @@
 
 static const struct arm_platform sun50i_platform = {
        .ap_devmap = sunxi_platform_devmap,
-       .ap_bootstrap = sunxi_platform_bootstrap,
+       .ap_bootstrap = sun6i_platform_bootstrap,
        .ap_init_attach_args = sunxi_platform_init_attach_args,
        .ap_device_register = sunxi_platform_device_register,
        .ap_reset = sun6i_platform_reset,
@@ -483,7 +509,7 @@
 
 static const struct arm_platform sun50i_h6_platform = {
        .ap_devmap = sunxi_platform_devmap,
-       .ap_bootstrap = sunxi_platform_bootstrap,
+       .ap_bootstrap = sun50i_h6_platform_bootstrap,
        .ap_init_attach_args = sunxi_platform_init_attach_args,
        .ap_device_register = sunxi_platform_device_register,
        .ap_reset = sun50i_h6_platform_reset,



Home | Main Index | Thread Index | Old Index