summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorSol Boucher <solb@chromium.org>2015-03-12 18:22:31 -0700
committerPatrick Georgi <pgeorgi@google.com>2015-04-22 08:42:22 +0200
commitb41914952d1f7e2e9f896edd05924deb5b610dff (patch)
tree05cc1d8f31ccd6fa3251b1362ffd93584f81bdbc /src/drivers
parent15b4580cc6261a94279f4623d7d212443e4feac9 (diff)
downloadcoreboot-b41914952d1f7e2e9f896edd05924deb5b610dff.tar.xz
elog: Eliminate CONFIG_ELOG_FULL_THRESHOLD and CONFIG_ELOG_SHRINK_SIZE
These Kconfig options provided a level of configurability that is almost never necessary, so they are being moved into ordinary preprocessor defines in elog_internal.h. The new threshold to trigger shrinking is relative to the number of additional (maximum-size) events that can fit, and the new target post-shrink size is a percentage of the total ELOG area size. BUG=chromium:467820 TEST=Add loop at the end of elog_init() that fills the ELOG area to just below full_threshold with dummy events. Observe successful shrinkage when the next event is logged. BRANCH=None Change-Id: I414c4955a2d819d112ae4f0c7d3571576f732336 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: ce439361e3954a2bf5186292f96936329171cf56 Original-Change-Id: I926097f86262888dcdd47d73fba474bb2e19856a Original-Signed-off-by: Sol Boucher <solb@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/260501 Original-Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org> Reviewed-on: http://review.coreboot.org/9869 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/elog/Kconfig21
-rw-r--r--src/drivers/elog/elog.c42
-rw-r--r--src/drivers/elog/elog_internal.h2
3 files changed, 22 insertions, 43 deletions
diff --git a/src/drivers/elog/Kconfig b/src/drivers/elog/Kconfig
index 162cc5f361..7affd0694a 100644
--- a/src/drivers/elog/Kconfig
+++ b/src/drivers/elog/Kconfig
@@ -45,27 +45,6 @@ config ELOG_AREA_SIZE
Default is 4K.
-config ELOG_FULL_THRESHOLD
- hex "Threshold at which flash is considered full"
- default 0xC00
- help
- When the Event Log size is larger than this it will be shrunk
- to ELOG_SHRINK_SIZE. Must be greater than ELOG_AREA_SIZE, and
- ELOG_AREA_SIZE - ELOG_FULL_THRESHOLD must be greater than the
- maximum event size of 128.
-
- Default is 75% of the log, or 3K.
-
-config ELOG_SHRINK_SIZE
- hex "Resulting size when the event log is shrunk"
- default 0x400
- help
- When the Event Log is shrunk it will go to this size.
- ELOG_AREA_SIZE - ELOG_SHRINK_SIZE must be less than
- CONFIG_ELOG_FULL_THRESHOLD.
-
- Default is 1K.
-
config ELOG_CBMEM
bool "Store a copy of ELOG in CBMEM"
default n
diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c
index f5135d99a3..de18d5d82f 100644
--- a/src/drivers/elog/elog.c
+++ b/src/drivers/elog/elog.c
@@ -40,19 +40,6 @@
#if !IS_ENABLED(CONFIG_CHROMEOS) && CONFIG_ELOG_FLASH_BASE == 0
#error "CONFIG_ELOG_FLASH_BASE is invalid"
#endif
-#if CONFIG_ELOG_FULL_THRESHOLD >= CONFIG_ELOG_AREA_SIZE
-#error "CONFIG_ELOG_FULL_THRESHOLD is larger than CONFIG_ELOG_AREA_SIZE"
-#endif
-#if (CONFIG_ELOG_AREA_SIZE - CONFIG_ELOG_FULL_THRESHOLD) < (MAX_EVENT_SIZE + 1)
-#error "CONFIG_ELOG_FULL_THRESHOLD is too small"
-#endif
-#if CONFIG_ELOG_SHRINK_SIZE >= CONFIG_ELOG_AREA_SIZE
-#error "CONFIG_ELOG_SHRINK_SIZE is larger than CONFIG_ELOG_AREA_SIZE"
-#endif
-#if (CONFIG_ELOG_AREA_SIZE - CONFIG_ELOG_SHRINK_SIZE) > \
- CONFIG_ELOG_FULL_THRESHOLD
-#error "CONFIG_ELOG_SHRINK_SIZE is too large"
-#endif
#if CONFIG_ELOG_DEBUG
#define elog_debug(STR...) printk(BIOS_DEBUG, STR)
@@ -65,14 +52,16 @@
*/
static struct elog_area *elog_area;
static u16 total_size;
-static u16 log_size;
+static u16 log_size; /* excluding header */
static u32 flash_base;
+static u16 full_threshold; /* from end of header */
+static u16 shrink_size; /* from end of header */
static elog_area_state area_state;
static elog_header_state header_state;
static elog_event_buffer_state event_buffer_state;
-static u16 next_event_offset;
+static u16 next_event_offset; /* from end of header */
static u16 event_count;
static struct spi_flash *elog_spi;
@@ -402,12 +391,12 @@ static int elog_shrink(void)
elog_debug("elog_shrink()\n");
- if (next_event_offset < CONFIG_ELOG_SHRINK_SIZE)
+ if (next_event_offset < shrink_size)
return 0;
while (1) {
/* Next event has exceeded constraints */
- if (offset > CONFIG_ELOG_SHRINK_SIZE)
+ if (offset > shrink_size)
break;
event = elog_get_event_base(offset);
@@ -429,7 +418,7 @@ static int elog_shrink(void)
elog_scan_flash();
/* Ensure the area was successfully erased */
- if (next_event_offset >= CONFIG_ELOG_FULL_THRESHOLD) {
+ if (next_event_offset >= full_threshold) {
printk(BIOS_ERR, "ELOG: Flash area was not erased!\n");
return -1;
}
@@ -544,6 +533,9 @@ static void elog_find_flash(void)
total_size = CONFIG_ELOG_AREA_SIZE;
#endif
log_size = total_size - sizeof(struct elog_header);
+ full_threshold = log_size - ELOG_MIN_AVAILABLE_ENTRIES * MAX_EVENT_SIZE;
+ shrink_size = MIN(total_size * ELOG_SHRINK_PERCENTAGE / 100,
+ full_threshold);
}
/*
@@ -575,6 +567,13 @@ int elog_init(void)
if (flash_base == 0) {
printk(BIOS_ERR, "ELOG: Invalid flash base\n");
return -1;
+ } else if (total_size < sizeof(struct elog_header) + MAX_EVENT_SIZE) {
+ printk(BIOS_ERR, "ELOG: Region too small to hold any events\n");
+ return -1;
+ } else if (log_size - shrink_size >= full_threshold) {
+ printk(BIOS_ERR,
+ "ELOG: SHRINK_PERCENTAGE set too small for MIN_AVAILABLE_ENTRIES\n");
+ return -1;
}
elog_area = malloc(total_size);
@@ -608,13 +607,12 @@ int elog_init(void)
elog_area, flash_base);
printk(BIOS_INFO, "ELOG: area is %d bytes, full threshold %d,"
- " shrink size %d\n", total_size,
- CONFIG_ELOG_FULL_THRESHOLD, CONFIG_ELOG_SHRINK_SIZE);
+ " shrink size %d\n", total_size, full_threshold, shrink_size);
elog_initialized = ELOG_INITIALIZED;
/* Shrink the log if we are getting too full */
- if (next_event_offset >= CONFIG_ELOG_FULL_THRESHOLD)
+ if (next_event_offset >= full_threshold)
if (elog_shrink() < 0)
return -1;
@@ -726,7 +724,7 @@ void elog_add_event_raw(u8 event_type, void *data, u8 data_size)
event_type, event_size);
/* Shrink the log if we are getting too full */
- if (next_event_offset >= CONFIG_ELOG_FULL_THRESHOLD)
+ if (next_event_offset >= full_threshold)
elog_shrink();
}
diff --git a/src/drivers/elog/elog_internal.h b/src/drivers/elog/elog_internal.h
index dd282311a6..6194ef6c3e 100644
--- a/src/drivers/elog/elog_internal.h
+++ b/src/drivers/elog/elog_internal.h
@@ -31,6 +31,8 @@ struct elog_header {
/* ELOG related constants */
#define ELOG_SIGNATURE 0x474f4c45 /* 'ELOG' */
#define ELOG_VERSION 1
+#define ELOG_MIN_AVAILABLE_ENTRIES 2 /* Shrink when this many can't fit */
+#define ELOG_SHRINK_PERCENTAGE 25 /* Percent of total area to remove */
/* SMBIOS event log header */
struct event_header {