2019-02-07 |
common: state: fix typo
...
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Ulrich Ölmann
authored
on 6 Feb 2019
Sascha Hauer
committed
on 7 Feb 2019
|
2017-09-26 |
remove checks for xzalloc() returning NULL
...
xzalloc() either returns memory or panics, so checking for NULL is useless.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Uwe Kleine-König
authored
on 25 Sep 2017
Sascha Hauer
committed
on 26 Sep 2017
|
2017-07-10 |
state: fix compile warnings for dev_err expansion
...
Fix the following warnings:
CC common/state/backend_format_dtb.o
In file included from include/common.h:33:0,
from common/state/backend_format_dtb.c:18:
common/state/backend_format_dtb.c: In function ‘state_backend_format_dtb_verify’:
include/printk.h:52:52: warning: format ‘%d’ expects argument of type ‘int’, but
argument 4 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
(level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
^
include/printk.h:63:2: note: in expansion of macro ‘__dev_printf’
__dev_printf(3, (dev) , format , ## arg)
^~~~~~~~~~~~
common/state/backend_format_dtb.c:52:3: note: in expansion of macro ‘dev_err’
dev_err(fdtb->dev, "Error, stored DTB length (%d) longer than read buffer (%d)\n",
^~~~~~~
include/printk.h:52:52: warning: format ‘%d’ expects argument of type ‘int’, but
argument 5 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
(level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
^
include/printk.h:63:2: note: in expansion of macro ‘__dev_printf’
__dev_printf(3, (dev) , format , ## arg)
^~~~~~~~~~~~
common/state/backend_format_dtb.c:52:3: note: in expansion of macro ‘dev_err’
dev_err(fdtb->dev, "Error, stored DTB length (%d) longer than read buffer (%d)\n",
^~~~~~~
CC common/state/backend_format_raw.o
In file included from include/common.h:33:0,
from common/state/backend_format_raw.c:18:
common/state/backend_format_raw.c: In function ‘backend_format_raw_verify’:
include/printk.h:52:52: warning: format ‘%d’ expects argument of type ‘int’, but
argument 4 has type ‘ssize_t {aka long int}’ [-Wformat=]
(level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
^
include/printk.h:63:2: note: in expansion of macro ‘__dev_printf’
__dev_printf(3, (dev) , format , ## arg)
^~~~~~~~~~~~
common/state/backend_format_raw.c:111:3: note: in expansion of macro ‘dev_err’
dev_err(backend_raw->dev, "Error, buffer length (%d) is shorter than the minimum required header length\n",
^~~~~~~
CC common/state/backend_storage.o
In file included from common/state/backend_storage.c:24:0:
common/state/backend_storage.c: In function ‘state_storage_mtd_buckets_init’:
include/printk.h:52:52: warning: format ‘%zu’ expects argument of type ‘size_t’,
but argument 5 has type ‘uint32_t {aka unsigned int}’ [-Wformat=]
(level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
^
include/printk.h:63:2: note: in expansion of macro ‘__dev_printf’
__dev_printf(3, (dev) , format , ## arg)
^~~~~~~~~~~~
common/state/backend_storage.c:250:3: note: in expansion of macro ‘dev_err’
dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %ld, erasesize %zu\n",
^~~~~~~
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Steffen Trumtrar
authored
on 10 Jul 2017
Lucas Stach
committed
on 10 Jul 2017
|
2017-04-24 |
state: backend_raw: init digest earlier
...
In backend_format_raw_pack() digest_length is used before it's
initialized in backend_raw_digest_init() which results in a too small
memory allocation for the raw backend. Fix this and prevent a memory
corruption.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 24 Apr 2017
|
2017-03-31 |
state: Allow to load without authentification
...
Sometimes it's useful to be able to load a state even when it
can't be authentificated. Add an option for this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
state: backend_raw: alloc digest only when needed
...
Instead of deferring probe just allocate the digest when
it's needed. This way the credentials can be added later,
possibly on the commandline.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
state: Convert all bufs to void *
...
A void * is a much better type for a buffer than a u8 * as it
can be casted to any other type implicitly. Convert all buffers
used by the state framework to void *.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
state: replace len_hint logic
...
The len_hint mechanism is rather hard to understand as it's not clear
from where to where the hint is passed and also it's not clear what
happens if the hint is empty or wrong.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Sascha Hauer
committed
on 31 Mar 2017
|
2016-11-03 |
state: use packed attribute for on storage structs
...
These structs are used for on-storage data layouts. They should be not
affected by different integer precisions and alignment optimizations of
32bit or 64bit machines. Using the architecture independent integer data
types, like uint32_t, achieves the former, using the packed attribute
the later.
Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Stefan Lengfeld
authored
on 2 Nov 2016
Sascha Hauer
committed
on 3 Nov 2016
|
2016-07-08 |
state: Refactor state framework
...
The state framework grew organically over the time. Unfortunately the
architecture and abstractions disappeared during this period.
This patch refactors the framework to recreate the abstractions. The
main focus was the backend with its storage. The main use-case was to
offer better NAND support with less erase cycles and interchangeable
data formats (dtb,raw).
The general architecture now has a backend which consists of a data
format and storage. The storage consists of multiple storage buckets
each holding exactly one copy of the state data. A data format describes
a data serialization for the state framework. This can be either dtb or
raw. A storage bucket is a storage location which is used to store any
data. There is a (new) circular type which writes changes behind the
last written data and therefore reduces the number of erases. The other
type is a direct bucket which writes directly to a storage offset for
all non-erase storage.
Furthermore this patch splits up all classes into different files in a
subdirectory.
This is currently all in one patch as I can't see a good way to split
the changes up without having a non-working state framework in between.
The following diagram shows the new architecture roughly:
.----------.
| state |
'----------'
|
|
v
.----------------------------.
| state_backend |
|----------------------------|
| + state_load(*state); |
| + state_save(*state); |
| + state_backend_init(...); |
| |
| |
'----------------------------'
| | The format describes
| | how the state data
| '-------------> is serialized
| .--------------------------------------------.
| | state_backend_format <INTERFACE> |
| |--------------------------------------------|
| | + verify(*format, magic, *buf, len); |
| | + pack(*format, *state, **buf, len); |
| | + unpack(*format, *state, *buf, len); |
| | + get_packed_len(*format, *state); |
| | + free(*format); |
| '--------------------------------------------'
| ^ ^
| * *
| * *
| .--------------------. .--------------------.
| | backend_format_dtb | | backend_format_raw |
| '--------------------' '--------------------'
|
|
|
v
.----------------------------------------------------------.
| state_backend_storage |
|----------------------------------------------------------|
| + init(...); |
| + free(*storage); |
| + read(*storage, *format, magic, **buf, *len, len_hint); |
| + write(*storage, *buf, len); |
| + restore_consistency(*storage, *buf, len); |
'----------------------------------------------------------'
|
The backend storage is responsible to manage multiple
data copies and distribute them onto several buckets.
Read data is verified against the given format to
ensure that the read data is correct.
|
|
|
|
|
v
.------------------------------------------.
| state_backend_storage_bucket <INTERFACE> |
|------------------------------------------|
| + init(*bucket); |
| + write(*bucket, *buf, len); |
| + read(*bucket, **buf, len_hint); |
| + free(*bucket); |
'------------------------------------------'
^ ^ ^
* * *
* * *
A storage bucket represents*exactly one data copy at one
data location. A circular b*cket writes any new data to
the end of the bucket (for *educed erases on NAND). A
direct bucket directly writ*s at one location.
* * *
* * *
* * *
.-----------------------. * .-------------------------.
| backend_bucket_direct | * | backend_bucket_circular |
'-----------------------' * '-------------------------'
^ * ^
| * |
| * |
| * |
| .-----------------------. |
'--| backend_bucket_cached |---'
'-----------------------'
A backend_bucket_cached is a transparent
bucket that directly uses another bucket
as backend device and caches all accesses.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Markus Pargmann
authored
on 6 Jul 2016
Sascha Hauer
committed
on 8 Jul 2016
|