ramoops: Move all boards to lib_sysinfo ramoops
authorJulius Werner <jwerner@chromium.org>
Thu, 11 Aug 2016 00:33:43 +0000 (17:33 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Thu, 11 Aug 2016 05:16:47 +0000 (22:16 -0700)
Now that coreboot allocates a ramoops area in CBMEM for all boards, we
can remove the individual hardcoded ramoops allocations from individual
boards. Also remove the ramoops_common_set_buffer() function which is no
longer needed now, and fix the check for the lib_sysinfo ramoops address
(0 is a valid memory address on some of our boards, even though you
couldn't really find CBMEM there... but it's generally cleaner to only
use size != 0 to test for existence of a range).

CQ-DEPEND=CL:368010
BRANCH=None
BUG=None
TEST=Booted Kevin and Jerry, confirmed that CBMEM ramoops address
appeared correctly in /proc/device-tree and that console-ramoops was
preserved across a crash.

Change-Id: I22d9080ba7406edf47479abbffcc76acb4a8f0de
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/367905
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
13 files changed:
src/board/gale/board.c
src/board/gru/board.c
src/board/nyan/board.c
src/board/nyan_big/board.c
src/board/nyan_blaze/board.c
src/board/oak/board.c
src/board/storm/board.c
src/board/veyron/board.c
src/board/veyron_mickey/board.c
src/board/veyron_rialto/board.c
src/board/veyron_shark/board.c
src/boot/ramoops.c
src/boot/ramoops.h

index cb2b630..5a8a84c 100644 (file)
@@ -29,7 +29,6 @@
 
 #include "base/init_funcs.h"
 #include "boot/fit.h"
-#include "boot/ramoops.h"
 #include "drivers/bus/spi/ipq40xx.h"
 #include "drivers/bus/i2c/ipq40xx.h"
 #include "drivers/bus/i2c/ipq40xx_blsp.h"
@@ -289,49 +288,6 @@ void board_dac_gpio_config(void)
 }
 #endif
 
-static void set_ramoops_buffer(void)
-{
-       uint64_t base, total_size, record_size;
-
-       /*
-        * Hardcoded record and total sizes could be defined through Kconfig.
-        *
-        * The 'total_size' bytes of memory, aligned at 'record_size' boundary
-        * is found at the top of available memory as defined in the coreboot
-        * table and assigned to the ramoops cache.
-        *
-        * This is fairly brittle, as other parts of depthcharge or libpayload
-        * could be using this memory for something. But this is no worse than
-        * hardcoding this area to any particular address.
-        *
-        * A proper solution would be to have coreboot assign this memory and
-        * explicitly describe this in the coreboot memory table.
-        */
-       record_size = 0x20000;
-       total_size = 0x100000;
-       base = 0;
-
-       /* Let's allocate it as high as possible in the available memory */
-       for (int i = 0; i < lib_sysinfo.n_memranges; i++) {
-               uint64_t new_base, size;
-               struct memrange *range = lib_sysinfo.memrange + i;
-
-               size = range->size;
-               if ((range->type != CB_MEM_RAM) ||
-                   (size < (total_size + record_size)))
-                       continue;
-
-               /* Record size aligned area is guaranteed to fit. */
-               new_base = ALIGN_DOWN(range->base + size - total_size,
-                                     record_size);
-               if (new_base > base)
-                       base = new_base;
-
-       }
-       if (base)
-               ramoops_buffer(base, total_size, record_size);
-}
-
 static uint8_t kb_buffer[4];
 static int kb_in, kb_out;
 
@@ -467,8 +423,6 @@ static int board_setup(void)
 
        list_insert_after(&ipq_enet_fixup.list_node, &device_tree_fixups);
 
-       set_ramoops_buffer();
-
        return 0;
 }
 INIT_FUNC(board_setup);
index 1001de3..21d28a0 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "base/init_funcs.h"
 #include "boot/fit.h"
-#include "boot/ramoops.h"
 #include "config.h"
 #include "drivers/bus/i2c/rockchip.h"
 #include "drivers/bus/i2s/rockchip.h"
@@ -201,8 +200,6 @@ static int board_setup(void)
        list_insert_after(&uhst0_xhci->list_node, &usb_host_controllers);
        list_insert_after(&uhst1_xhci->list_node, &usb_host_controllers);
 
-       ramoops_buffer(0x31f00000, 0x100000, 0x20000);
-
        // turn on the backlight
        if (lib_sysinfo.framebuffer &&
            lib_sysinfo.framebuffer->physical_address)
index 229e4f8..def9f33 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "base/init_funcs.h"
 #include "boot/fit.h"
-#include "boot/ramoops.h"
 #include "config.h"
 #include "drivers/bus/i2c/tegra.h"
 #include "drivers/bus/i2s/tegra.h"
@@ -219,8 +218,6 @@ static int board_setup(void)
        list_insert_after(&usbd->list_node, &usb_host_controllers);
        list_insert_after(&usb3->list_node, &usb_host_controllers);
 
-       ramoops_buffer(0x87f00000, 0x100000, 0x20000);
-
        return 0;
 }
 
index 1b4d79a..305b9ad 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "base/init_funcs.h"
 #include "boot/fit.h"
-#include "boot/ramoops.h"
 #include "config.h"
 #include "drivers/bus/i2c/tegra.h"
 #include "drivers/bus/i2s/tegra.h"
@@ -185,8 +184,6 @@ static int board_setup(void)
        list_insert_after(&usbd->list_node, &usb_host_controllers);
        list_insert_after(&usb3->list_node, &usb_host_controllers);
 
-       ramoops_buffer(0x87f00000, 0x100000, 0x20000);
-
        return 0;
 }
 
index 61202b6..e7229d1 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "base/init_funcs.h"
 #include "boot/fit.h"
-#include "boot/ramoops.h"
 #include "config.h"
 #include "drivers/bus/i2c/tegra.h"
 #include "drivers/bus/i2s/tegra.h"
@@ -186,8 +185,6 @@ static int board_setup(void)
        list_insert_after(&usb2->list_node, &usb_host_controllers);
        list_insert_after(&usb3->list_node, &usb_host_controllers);
 
-       ramoops_buffer(0x87f00000, 0x100000, 0x20000);
-
        return 0;
 }
 
index 599ae32..bc6d0f7 100644 (file)
@@ -19,7 +19,6 @@
 #include <libpayload.h>
 
 #include "base/init_funcs.h"
-#include "boot/ramoops.h"
 #include "drivers/bus/i2c/cros_ec_tunnel.h"
 #include "drivers/bus/i2c/mtk_i2c.h"
 #include "drivers/bus/i2s/mt8173.h"
@@ -172,8 +171,6 @@ static int board_setup(void)
 
        sound_setup();
 
-       ramoops_buffer(0xb1f00000, 0x100000, 0x20000);
-
        /* Setup Nor flash ops */
        MtkNorFlash *nor_flash = new_mtk_nor_flash(0x1100D000);
        flash_set_ops(&nor_flash->ops);
index 68d84df..71a1f27 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "base/init_funcs.h"
 #include "boot/fit.h"
-#include "boot/ramoops.h"
 #include "drivers/bus/i2c/ipq806x.h"
 #include "drivers/bus/i2c/ipq806x_gsbi.h"
 #include "drivers/bus/spi/ipq806x.h"
@@ -380,8 +379,6 @@ static int board_setup(void)
 
        list_insert_after(&ipq_enet_fixup.list_node, &device_tree_fixups);
 
-       ramoops_common_set_buffer();
-
        return 0;
 }
 
index fc13451..8a31138 100644 (file)
@@ -16,7 +16,6 @@
 
 #include "base/init_funcs.h"
 #include "boot/fit.h"
-#include "boot/ramoops.h"
 #include "drivers/bus/i2c/rockchip.h"
 #include "drivers/bus/i2s/rockchip.h"
 #include "drivers/bus/spi/rockchip.h"
@@ -89,8 +88,6 @@ static int board_setup(void)
        UsbHostController *usb_otg = new_usb_hc(DWC2, 0xff580000);
        list_insert_after(&usb_otg->list_node, &usb_host_controllers);
 
-       ramoops_buffer(0x31f00000, 0x100000, 0x20000);
-
        if (lib_sysinfo.framebuffer != NULL) {
                GpioOps *backlight_gpio = sysinfo_lookup_gpio("backlight", 1,
                        new_rk_gpio_output_from_coreboot);
index 1d58baa..f51b9bc 100644 (file)
@@ -16,7 +16,6 @@
 
 #include "base/init_funcs.h"
 #include "boot/fit.h"
-#include "boot/ramoops.h"
 #include "drivers/bus/i2c/rockchip.h"
 #include "drivers/bus/i2s/rockchip.h"
 #include "drivers/bus/spi/rockchip.h"
@@ -78,8 +77,6 @@ static int board_setup(void)
        flag_replace(FLAG_RECSW, sysinfo_lookup_gpio("recovery",
                                1, new_rk_gpio_input_from_coreboot));
 
-       ramoops_buffer(0x31f00000, 0x100000, 0x20000);
-
        if (lib_sysinfo.framebuffer != NULL)
                display_set_ops(NULL);
 
index 442d8f9..2699ce0 100644 (file)
@@ -17,7 +17,6 @@
 #include "base/init_funcs.h"
 #include "base/container_of.h"
 #include "boot/fit.h"
-#include "boot/ramoops.h"
 #include "drivers/gpio/rockchip.h"
 #include "drivers/bus/i2c/rockchip.h"
 #include "drivers/flash/spi.h"
@@ -207,8 +206,6 @@ static int board_setup(void)
        /* Follow Storm to use recovery button as Ctrl-U. */
        install_phys_presence_flag();
 
-       ramoops_buffer(0x31f00000, 0x100000, 0x20000);
-
        return 0;
 }
 
index 433d3c9..9fa865f 100644 (file)
@@ -18,7 +18,6 @@
 #include "base/init_funcs.h"
 #include "board/veyron_shark/fastboot.h"
 #include "boot/fit.h"
-#include "boot/ramoops.h"
 #include "drivers/bus/i2c/rockchip.h"
 #include "drivers/bus/i2s/rockchip.h"
 #include "drivers/bus/spi/rockchip.h"
@@ -122,8 +121,6 @@ static int board_setup(void)
 
        list_insert_after(&usb_otg->list_node, &usb_host_controllers);
 
-       ramoops_buffer(0x31f00000, 0x100000, 0x20000);
-
        if (lib_sysinfo.framebuffer != NULL) {
                GpioOps *backlight_gpio = sysinfo_lookup_gpio("backlight", 1,
                        new_rk_gpio_output_from_coreboot);
index 021b403..b2f6964 100644 (file)
@@ -97,64 +97,11 @@ void ramoops_buffer(uint64_t start, uint64_t size, uint64_t record_size)
        memory_mark_used(start, start + size);
 }
 
-void ramoops_common_set_buffer(void)
-{
-       uint64_t base, total_size, record_size;
-
-       /* ARM64 libpayload makes its own memory allocations from the top of
-        * memory and doesn't reflect them in the coreboot table. Using this
-        * function there risks overlapping ramoops with the DMA heap or the
-        * frame buffer. */
-       die_if(IS_ENABLED(CONFIG_ARCH_ARM_V8), "Don't use this on ARM64!\n");
-
-       /*
-        * Hardcoded record and total sizes could be defined through Kconfig.
-        *
-        * The 'total_size' bytes of memory, aligned at 'record_size' boundary
-        * is found at the top of available memory as defined in the coreboot
-        * table and assigned to the ramoops cache.
-        *
-        * This is fairly brittle, as other parts of depthcharge or libpayload
-        * could be using this memory for something. But this is no worse than
-        * hardcoding this area to any particular address.
-        *
-        * A proper solution would be to have coreboot assign this memory and
-        * explicitly describe this in the coreboot memory table.
-        */
-       record_size = 0x20000;
-       total_size = 0x100000;
-       base = 0;
-
-       /* Let's allocate it as high as possible in the available memory */
-       for (int i = 0; i < lib_sysinfo.n_memranges; i++) {
-               uint64_t new_base, size;
-               struct memrange *range = lib_sysinfo.memrange + i;
-
-               size = range->size;
-               if ((range->type != CB_MEM_RAM) ||
-                   (size < (total_size + record_size)))
-                       continue;
-
-               /* Record size aligned area is guaranteed to fit. */
-               new_base = ALIGN_DOWN(range->base + size - total_size,
-                                     record_size);
-               if (new_base > base)
-                       base = new_base;
-
-       }
-
-       if (base)
-               ramoops_buffer(base, total_size, record_size);
-}
-
 static int ramoops_init(void)
 {
-       if ((lib_sysinfo.ramoops_buffer == 0) ||
-           (lib_sysinfo.ramoops_buffer_size == 0))
-               return 0;
-
-       ramoops_buffer(lib_sysinfo.ramoops_buffer,
-                      lib_sysinfo.ramoops_buffer_size, 0x20000);
+       if (lib_sysinfo.ramoops_buffer_size != 0)
+               ramoops_buffer(lib_sysinfo.ramoops_buffer,
+                              lib_sysinfo.ramoops_buffer_size, 0x20000);
 
        return 0;
 }
index 7ad15e5..5b03a1e 100644 (file)
@@ -21,6 +21,5 @@
 #include <stdint.h>
 
 void ramoops_buffer(uint64_t start, uint64_t size, uint64_t record_size);
-void ramoops_common_set_buffer(void);
 
 #endif /* __BOOT_RAMOOPS_H__ */