diff options
author | Cyril Bur <cyril.bur@au1.ibm.com> | 2017-12-01 14:53:07 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-11-30 23:45:45 -0600 |
commit | 92813a8bf9f3658dac5315c0c02025b74a8b0533 (patch) | |
tree | 3f06738611476b2cc7108ab5106a07027c3381d0 /core/nvram.c | |
parent | ac685bccd8899b6021f6441551e845151a9a1b94 (diff) | |
download | blackbird-skiboot-92813a8bf9f3658dac5315c0c02025b74a8b0533.tar.gz blackbird-skiboot-92813a8bf9f3658dac5315c0c02025b74a8b0533.zip |
nvram: Fix 'missing' nvram on FSP systems.
commit ba4d46fdd9eb ("console: Set log level from nvram") wants to read
from NVRAM rather early. This works fine on BMC based systems as
nvram_init() is actually synchronous. This is not true for FSP systems
and it turns out that the query for the console log level simply
queries blank nvram.
The simple fix is to wait for the NVRAM read to complete before
performing any query. Unfortunately it turns out that the fsp-nvram
code does not inform the generic NVRAM layer when the read is complete,
rather, it must be prompted to do so.
This patch addresses both these problems. This patch adds a check before
the first read of the NVRAM (for the console log level) that the read
has completed. The fsp-nvram code has been updated to inform the generic
layer as soon as the read completes.
The old prompt to the fsp-nvram code has been removed but a check to
ensure that the NVRAM has been loaded remains. It is conservative but
if the NVRAM is not done loading before the host is booted it will not
have an nvram device-tree node which means it won't be able to access
the NVRAM at all, ever, even after the NVRAM has loaded.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/nvram.c')
-rw-r--r-- | core/nvram.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/core/nvram.c b/core/nvram.c index 2140706a..de6cbddf 100644 --- a/core/nvram.c +++ b/core/nvram.c @@ -122,6 +122,41 @@ void nvram_read_complete(bool success) nvram_ready = true; } +bool nvram_wait_for_load(void) +{ + /* Short cut */ + if (nvram_ready) + return true; + + /* Tell the caller it will never happen */ + if (!platform.nvram_info) + return false; + + /* + * One of two things has happened here. + * 1. nvram_wait_for_load() was called before nvram_init() + * 2. The read of NVRAM failed. + * Either way, this is quite a bad event. + */ + if (!nvram_image && !nvram_size) { + prlog(PR_CRIT, "NVRAM: Possible wait before nvram_init()!\n"); + return false; + } + + while (!nvram_ready) { + opal_run_pollers(); + /* If the read fails, tell the caller */ + if (!nvram_image && !nvram_size) + return false; + } + return true; +} + +bool nvram_has_loaded(void) +{ + return nvram_ready; +} + void nvram_init(void) { int rc; |