Commit Graph

12 Commits

Author SHA1 Message Date
Nikunj A Dadhania b6c46e72f2 rtas-nvram: optimize erase
As this was done at byte granularity, erasing complete nvram(64K
default) took a lot of time. To reduce the number of rtas call per byte
write which is expensive, the erase is done at one shot using the
nvram_buffer that is initiated during the nvram_init call for
RTAS_NVRAM.

After this patch there is ~450msec improvement during boot. Default qemu
booting does not provide file backed nvram, so every boot there would be
full erase of 64K.

Before this patch:

real	0m2.214s
user	0m0.015s
sys	  0m0.006s

real	0m2.222s
user	0m0.014s
sys	  0m0.005s

real	0m2.201s
user	0m0.010s
sys	  0m0.005s

After this patch:

real	0m1.762s
user	0m0.014s
sys	  0m0.006s

real	0m1.773s
user	0m0.011s
sys   0m0.004s

real	0m1.754s
user	0m0.013s
sys	  0m0.005s

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-05-19 13:53:32 +10:00
Thomas Huth 271fd45605 Improve stack usage with libnvram get_partition function
The Forth-to-C wrapper for get-named-nvram-partition also
uses the STRING_INIT macro. This causes heavy stack usage
in the engine() function due to the static array in that
macro. So let's rework the wrapper to do the string convertion
in a separate function instead.
Now that all users of the STRING_INIT and STRING_FROM_STACK
macros are gone, the macros can be removed, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-02 14:54:41 +11:00
Thomas Huth baa834884c Improve stack usage in libnvram environment variable code
The Forth-to-C wrapper code in libnvram.code uses a temporary
buffer of 255 bytes via the STRING_INIT macro for each Forth string
that has to be converted to a C string. However, using such big
arrays in the wrapper code is a bad idea: Each of the buffers
is put into the stack frame of the engine() function (from paflof.c)!
That means the 7 strings from libnvram.code increase the stack
usage of engine() by 7 * 255 = 1785 bytes! This can cause stack
overflows since engine() can be called recursively, e.g. via the
forth_eval() macro.

To fix this issue in the functions from envvar.c, we can simply
pass the Forth strings directly to the functions by adding the
string length as additional function parameter, since the functions
in envvar.c don't really depend on NUL-terminated strings.

And while we're at it (i.e. we touch the function prototypes here
anyway), also rename the functions to have a proper "nvram_" prefix,
so we clearly mark them as part of libnvram instead of cluttering
the global name space with rather trivial function names.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-02 14:54:30 +11:00
Thomas Huth f0d251a077 Rework wrapper for new_nvram_partition() and fix possible bug in there
The wrapper for new_nvram_partition() is using a 12 bytes buffer to
create a zero-terminated string. However, if the string has exactly
12 characters, the final NUL-terminator is missing. new_nvram_partition()
then calls create_nvram_partition() internally which depends on proper
NUL-terminated strings. So fix this by making sure that the copied
string is always NUL-terminated - and while we're at it, also move
the copy code out of libnvram.code to save some precious bytes in the
stack space of the engine() function.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-01 17:02:04 +11:00
Nikunj A Dadhania 0d3488393a nvram: remove unnecessary prints
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-07-24 14:46:21 +05:30
Nikunj A. Dadhania 0ad10f26c9 SLOF: Support PAPR NVRAM RTAS calls
BenH still need to ACK this though.

From: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com>

* Determines size of the flash using device tree.
* Provides nvram access functions for RTAS_NVRAM
* Allocates temporary buffer of nvram in SLOF code and use that in C.
  (sbrk not available)
* NVRAM_LENGTH is used at various places, make sure it is well guarded
  and also use dynamically determined size once an RTAS-NVRAM is
  found.
* Use NVRAM_LENGTH as a variable in case of RTAS_NVRAM, not very
  elegant though

Signed-off-by: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com>

--

Changelog from v1:
* #define cleanups suggested by Thomas/Benh
* Fix makefile which missed passing $FLAG for building llfw
* renamed vio-nvram.fs as rtas-nvram.fs
2012-10-17 16:30:58 +11:00
Thomas Huth 4c00ad329d Always enabled nvram-debug function
This function is also handy when we only fake a NVRAM, so let's always
enable it.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2012-03-16 11:40:41 +01:00
Thomas Huth 4f6e2c9efe Fix compiler warnings
GCC 4.6 complains about unused-but-set variables - which can safely be removed
in our cases.
Also fixed a strict-aliasing problem in rtas_flash.c of board-js2x.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-10-12 12:50:05 +02:00
Thomas Huth 2e2e4cae37 Move functions for byte-swapping into common header file.
The byte-swapping functions were scattered all over the source tree, now they
are merged into a new common header file called byteswap.h.

Signed-off-by: <thuth@linux.vnet.ibm.com>
2011-10-12 08:43:12 +02:00
Thomas Huth 1d41e8a29b Fixed some problems with libnvram
- On board-qemu, the logging partitions were too big (bigger than the total
  NVRAM size).
- Fixed a compiler warning about type-punned pointers in nvram.c
- When DISABLE_NVRAM is set, the fake buffer should not be accessed with
  cache-inhibited functions
- Makefile did not generate proper dependencies

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-08-19 14:57:32 +02:00
Benjamin Herrenschmidt 39426bad55 Initial qemu/KVM board support
Added a new board for SLOF running on KVM/qemu.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-03-22 15:22:00 +01:00
Benjamin Herrenschmidt aaad509cdc Initial import of slof-JX-1.7.0-4
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2010-12-01 09:51:44 +11:00