pstore/blk: Introduce backend for block devices
pstore/blk is similar to pstore/ram, but uses a block device as the
storage rather than persistent ram.
The pstore/blk backend solves two common use-cases that used to preclude
using pstore/ram:
- not all devices have a battery that could be used to persist
regular RAM across power failures.
- most embedded intelligent equipment have no persistent ram, which
increases costs, instead preferring cheaper solutions, like block
devices.
pstore/blk provides separate configurations for the end user and for the
block drivers. User configuration determines how pstore/blk operates, such
as record sizes, max kmsg dump reasons, etc. These can be set by Kconfig
and/or module parameters, but module parameter have priority over Kconfig.
Driver configuration covers all the details about the target block device,
such as total size of the device and how to perform read/write operations.
These are provided by block drivers, calling pstore_register_blkdev(),
including an optional panic_write callback used to bypass regular IO
APIs in an effort to avoid potentially destabilized kernel code during
a panic.
Signed-off-by: WeiXiong Liao <liaoweixiong@allwinnertech.com>
Link: https://lore.kernel.org/lkml/20200511233229.27745-3-keescook@chromium.org/
Co-developed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
2020-03-25 16:54:57 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
|
|
|
|
#ifndef __PSTORE_BLK_H_
|
|
|
|
#define __PSTORE_BLK_H_
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/pstore.h>
|
|
|
|
#include <linux/pstore_zone.h>
|
|
|
|
|
2020-03-25 16:55:05 +08:00
|
|
|
/**
|
|
|
|
* struct pstore_device_info - back-end pstore/blk driver structure.
|
|
|
|
*
|
|
|
|
* @flags: Refer to macro starting with PSTORE_FLAGS defined in
|
|
|
|
* linux/pstore.h. It means what front-ends this device support.
|
|
|
|
* Zero means all backends for compatible.
|
2021-06-16 01:19:13 +08:00
|
|
|
* @zone: The struct pstore_zone_info details.
|
|
|
|
*
|
2020-03-25 16:55:05 +08:00
|
|
|
*/
|
|
|
|
struct pstore_device_info {
|
|
|
|
unsigned int flags;
|
2021-06-16 01:19:13 +08:00
|
|
|
struct pstore_zone_info zone;
|
2020-03-25 16:55:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
int register_pstore_device(struct pstore_device_info *dev);
|
|
|
|
void unregister_pstore_device(struct pstore_device_info *dev);
|
|
|
|
|
2020-03-25 16:55:04 +08:00
|
|
|
/**
|
|
|
|
* struct pstore_blk_config - the pstore_blk backend configuration
|
|
|
|
*
|
|
|
|
* @device: Name of the desired block device
|
|
|
|
* @max_reason: Maximum kmsg dump reason to store to block device
|
|
|
|
* @kmsg_size: Total size of for kmsg dumps
|
|
|
|
* @pmsg_size: Total size of the pmsg storage area
|
|
|
|
* @console_size: Total size of the console storage area
|
|
|
|
* @ftrace_size: Total size for ftrace logging data (for all CPUs)
|
|
|
|
*/
|
|
|
|
struct pstore_blk_config {
|
|
|
|
char device[80];
|
|
|
|
enum kmsg_dump_reason max_reason;
|
|
|
|
unsigned long kmsg_size;
|
|
|
|
unsigned long pmsg_size;
|
|
|
|
unsigned long console_size;
|
|
|
|
unsigned long ftrace_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* pstore_blk_get_config - get a copy of the pstore_blk backend configuration
|
|
|
|
*
|
|
|
|
* @info: The sturct pstore_blk_config to be filled in
|
|
|
|
*
|
|
|
|
* Failure returns negative error code, and success returns 0.
|
|
|
|
*/
|
|
|
|
int pstore_blk_get_config(struct pstore_blk_config *info);
|
|
|
|
|
pstore/blk: Introduce backend for block devices
pstore/blk is similar to pstore/ram, but uses a block device as the
storage rather than persistent ram.
The pstore/blk backend solves two common use-cases that used to preclude
using pstore/ram:
- not all devices have a battery that could be used to persist
regular RAM across power failures.
- most embedded intelligent equipment have no persistent ram, which
increases costs, instead preferring cheaper solutions, like block
devices.
pstore/blk provides separate configurations for the end user and for the
block drivers. User configuration determines how pstore/blk operates, such
as record sizes, max kmsg dump reasons, etc. These can be set by Kconfig
and/or module parameters, but module parameter have priority over Kconfig.
Driver configuration covers all the details about the target block device,
such as total size of the device and how to perform read/write operations.
These are provided by block drivers, calling pstore_register_blkdev(),
including an optional panic_write callback used to bypass regular IO
APIs in an effort to avoid potentially destabilized kernel code during
a panic.
Signed-off-by: WeiXiong Liao <liaoweixiong@allwinnertech.com>
Link: https://lore.kernel.org/lkml/20200511233229.27745-3-keescook@chromium.org/
Co-developed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
2020-03-25 16:54:57 +08:00
|
|
|
#endif
|