powerpc/pstore: Add pstore support for nvram partitions
Subsystems (2)
v4 cover powerpc/pstore: Add pstore support for nvram partitions
This patch series adds pstore support on powernv platform to read different nvram partitions and write compressed data to oops-log nvram partition. As pseries platform already has pstore support, this series moves most of the common code for pseries and powernv platforms to a common file. Tested the patches successfully on both pseries and powernv platforms. Also, tested the patches successfully, on a kernel compiled with both CONFIG_PPC_PSERIES=y & CONFIG_PPC_POWERNV=y.
Changes from v3:
1. Updated the changelog
2. Resolved compile issues with !CONFIG_PPC_PSERIES
---
Hari Bathini (3):
powerpc/nvram: move generic code for nvram and pstore
pstore: Add pstore type id for PPC64 opal nvram partition
pstore: add pstore support on powernv
arch/powerpc/include/asm/nvram.h | 50 ++ arch/powerpc/include/asm/rtas.h | 4 arch/powerpc/kernel/nvram_64.c | 677 +++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/opal-nvram.c | 10 arch/powerpc/platforms/pseries/nvram.c | 665 --------------------------- fs/pstore/inode.c | 3 include/linux/pstore.h | 1 7 files changed, 749 insertions(+), 661 deletions(-)
--
- Hari
PATCH v4 1/3 powerpc/nvram: move generic code for nvram and pstore
With minor checks, we can move most of the code for nvram under pseries to a common place to be re-used by other powerpc platforms like powernv. This patch moves such common code to arch/powerpc/kernel/nvram_64.c file.
--- arch/powerpc/include/asm/nvram.h | 50 ++ arch/powerpc/include/asm/rtas.h | 4 arch/powerpc/kernel/nvram_64.c | 656 ++++++++++++++++++++++++++++++++ arch/powerpc/platforms/pseries/nvram.c | 665 -------------------------------- 4 files changed, 714 insertions(+), 661 deletions(-)
arch/powerpc/include/asm/nvram.h +49 -1
@@ -9,12 +9,43 @@#ifndef _ASM_POWERPC_NVRAM_H#define _ASM_POWERPC_NVRAM_H - +#include <linux/types.h> #include <linux/errno.h> #include <linux/list.h> #include <uapi/asm/nvram.h> +/* +* Set oops header version to distinguish between old and new format header. +* lnx,oops-log partition max size is 4000, header version > 4000 will +* help in identifying new header. +*/ +#define OOPS_HDR_VERSION 5000 + +struct err_log_info { +__be32 error_type; +__be32 seq_num; +}; + +struct nvram_os_partition { +const char *name; +int req_size;/* desired size, in bytes */ +int min_size;/* minimum acceptable size (0 means req_size) */ +long size;/* size of data portion (excluding err_log_info) */ +long index;/* offset of data portion of partition */ +bool os_partition;/* partition initialized by OS, not FW */ +}; + +struct oops_log_info { +__be16 version; +__be16 report_length; +__be64 timestamp; +} __attribute__((packed)); + +extern struct nvram_os_partition oops_log_partition; +#ifdef CONFIG_PPC_PSERIES +extern struct nvram_os_partition rtas_log_partition; +extern int nvram_write_error_log (char * buff,int length,unsigned int err_type,unsigned int err_seq); extern int nvram_read_error_log(char * buff, int length,
@@ -50,6 +81,23 @@ extern void pmac_xpram_write(int xpaddr, u8 data);/* Synchronize NVRAM */ extern void nvram_sync (void ); +/* Initialize NVRAM OS partition */ +extern int __init nvram_init_os_partition (struct nvram_os_partition *part); + +/* Initialize NVRAM oops partition */ +extern void __init nvram_init_oops_partition (int rtas_partition_exists); + +/* Read a NVRAM partition */ +extern int nvram_read_partition (struct nvram_os_partition *part,char *buff, +int length,unsigned int *err_type, +unsigned int *error_log_cnt); + +/* Write to NVRAM OS partition */ +extern int nvram_write_os_partition (struct nvram_os_partition *part, +char *buff,int length, +unsigned int err_type, +unsigned int error_log_cnt); +/* Determine NVRAM size */ extern ssize_t nvram_get_size (void );
arch/powerpc/include/asm/rtas.h +4 -0
@@ -343,8 +343,12 @@ extern int early_init_dt_scan_rtas(unsigned long node,extern void pSeries_log_error (char *buf,unsigned int err_type,int fatal);#ifdef CONFIG_PPC_PSERIES +extern unsigned long last_rtas_event; +extern int clobbering_unread_rtas_event (void );extern int pseries_devicetree_update (s32 scope);extern void post_mobility_fixup (void ); +#else +static inline int clobbering_unread_rtas_event (void ) {return 0 ; }#endif #ifdef CONFIG_PPC_RTAS_DAEMON
arch/powerpc/kernel/nvram_64.c +656 -0
668 lines not on this page · raw message
arch/powerpc/platforms/pseries/nvram.c +5 -660
723 lines not on this page · raw message
PATCH v4 2/3 pstore: Add pstore type id for PPC64 opal nvram partition
In reply to Hari BathiniThis patch adds a new PPC64 partition type to be used for opal specific nvram partition. A new partition type is needed as none of the existing type matches this partition type.
--- fs/pstore/inode.c | 3 +++ include/linux/pstore.h | 1 + 2 files changed, 4 insertions(+)
fs/pstore/inode.c +3 -0
@@ -359,6 +359,9 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,case PSTORE_TYPE_PPC_COMMON :sprintf (name,"powerpc-common-%s-%lld" , psname, id);break ; +case PSTORE_TYPE_PPC_OPAL : +sprintf (name,"powerpc-opal-%s-%lld" , psname, id); +break ;case PSTORE_TYPE_UNKNOWN :sprintf (name,"unknown-%s-%lld" , psname, id);break ;
include/linux/pstore.h +1 -0
@@ -39,6 +39,7 @@ enum pstore_type_id {PSTORE_TYPE_PPC_RTAS =4 ,PSTORE_TYPE_PPC_OF =5 ,PSTORE_TYPE_PPC_COMMON =6 , +PSTORE_TYPE_PPC_OPAL =7 , PSTORE_TYPE_UNKNOWN = 255 };
PATCH v4 3/3 pstore: add pstore support on powernv
In reply to Hari BathiniThis patch extends pstore, a generic interface to platform dependent persistent storage, support for powernv platform to capture certain useful information, during dying moments. Such support is already in place for pseries platform. This patch re-uses most of that code.
It is a common practice to compile kernels with both CONFIG_PPC_PSERIES=y and CONFIG_PPC_POWERNV=y. The code in nvram_init_oops_partition() routine still works as intended, as the caller is platform specific code which passes the appropriate value for "rtas_partition_exists" parameter. In all other places, where CONFIG_PPC_PSERIES or CONFIG_PPC_POWERNV flag is used in this patchset, it is to reduce the kernel size in cases where this flag is not set and doesn't have any impact logic wise.
--- arch/powerpc/kernel/nvram_64.c | 25 +++++++++++++++++++++++-- arch/powerpc/platforms/powernv/opal-nvram.c | 10 ++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-)
arch/powerpc/kernel/nvram_64.c +23 -2
@@ -127,6 +127,14 @@ static size_t oops_data_sz;static struct z_stream_s stream;#ifdef CONFIG_PSTORE +#ifdef CONFIG_PPC_POWERNV +static struct nvram_os_partition skiboot_partition = { + .name ="ibm,skiboot" , + .index =-1 , + .os_partition = false +}; +#endif +#ifdef CONFIG_PPC_PSERIES static struct nvram_os_partition of_config_partition = { .name = "of-config",
@@ -477,6 +485,16 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type, time->tv_nsec =0 ;break ;#endif +#ifdef CONFIG_PPC_POWERNV +case PSTORE_TYPE_PPC_OPAL : + sig =NVRAM_SIG_FW ; + part = &skiboot_partition; + *type =PSTORE_TYPE_PPC_OPAL ; + *id =PSTORE_TYPE_PPC_OPAL ; + time->tv_sec =0 ; + time->tv_nsec =0 ; +break ; +#endif default :return 0 ; }
@@ -552,8 +570,11 @@ static int nvram_pstore_init(void) {int rc =0 ; - nvram_type_ids[2 ] =PSTORE_TYPE_PPC_RTAS ; - nvram_type_ids[3 ] =PSTORE_TYPE_PPC_OF ; +if (machine_is (pseries)) { + nvram_type_ids[2 ] =PSTORE_TYPE_PPC_RTAS ; + nvram_type_ids[3 ] =PSTORE_TYPE_PPC_OF ; + }else + nvram_type_ids[2 ] =PSTORE_TYPE_PPC_OPAL ; nvram_pstore_info.buf = oops_data; nvram_pstore_info.bufsize = oops_data_sz;
arch/powerpc/platforms/powernv/opal-nvram.c +10 -0
@@ -16,6 +16,7 @@#include <linux/of.h> #include <asm/opal.h> +#include <asm/nvram.h> #include <asm/machdep.h> static unsigned int nvram_size;
@@ -62,6 +63,15 @@ static ssize_t opal_nvram_write(char *buf, size_t count, loff_t *index)return count; } +static int __init opal_nvram_init_log_partitions (void ) +{ +/* Scan nvram for partitions */ +nvram_scan_partitions (); +nvram_init_oops_partition (0 ); +return 0 ; +} +machine_arch_initcall (powernv, opal_nvram_init_log_partitions); +void __init opal_nvram_init (void ) {struct device_node *np;
Re: [PATCH v4 1/3] powerpc/nvram: move generic code for nvram and pstore
In reply to Hari BathiniQuoted 6 lines · On Friday 30 January 2015 20:44:00 Hari Bathini wrote:
With minor checks, we can move most of the code for nvram under pseries to a common place to be re-used by other powerpc platforms like powernv. This patch moves such common code to
arch/powerpc/kernel/nvram_64.cfile.Signed-off-by Hari Bathini <[email protected]>
Can you make this y2038-safe in the process, possibly as a follow-up patch?
Quoted 1 line
+extern unsigned long
last_rtas_event;
time64_t
arch/powerpc/kernel/nvram_64.c struct nvram_partition { · line 372
Quoted 5 lines
arch/powerpc/kernel/nvram_64.c +5
-0+ } + oops_hdr->version =cpu_to_be16 (OOPS_HDR_VERSION ); + oops_hdr->report_length =cpu_to_be16 (zipped_len); + oops_hdr->timestamp =cpu_to_be64 (get_seconds ()); +return 0 ;
ktime_get_real_seconds()
arch/powerpc/kernel/nvram_64.c struct nvram_partition { · line 440
Quoted 3 lines
arch/powerpc/kernel/nvram_64.c +3
-0+static ssize_t nvram_pstore_read (u64 *id,enum pstore_type_id *type, +int *count,struct timespec *time,char **buf, +bool *compressed,struct pstore_info *psi)
This has to remain timespec for now but can later be changed to timespec64 when the API gets changed.
arch/powerpc/kernel/nvram_64.c struct nvram_partition { · line 703
Quoted 3 lines
arch/powerpc/kernel/nvram_64.c +3
-0+ oops_hdr->version =cpu_to_be16 (OOPS_HDR_VERSION ); + oops_hdr->report_length =cpu_to_be16 (text_len); + oops_hdr->timestamp =cpu_to_be64 (get_seconds ());
ktime_get_real_seconds()
Arnd
Re: [PATCH v4 1/3] powerpc/nvram: move generic code for nvram and pstore
Quoted 9 lines · Arnd Bergmann
Quoted 6 lines · On Friday 30 January 2015 20:44:00 Hari Bathini wrote:
With minor checks, we can move most of the code for nvram under pseries to a common place to be re-used by other powerpc platforms like powernv. This patch moves such common code to
arch/powerpc/kernel/nvram_64.cfile.Signed-off-by Hari Bathini <[email protected]>Can you make this y2038-safe in the process, possibly as a follow-up patch?
Arnd, sorry for the delayed response.
I will add these changes to this patch-set and re-spin..
Thanks
Hari
Quoted 26 lines
Quoted 1 line
+extern unsigned long
last_rtas_event;
time64_tarch/powerpc/kernel/nvram_64.c struct nvram_partition { · line 372
Quoted 5 lines
arch/powerpc/kernel/nvram_64.c +5
-0+ } + oops_hdr->version =cpu_to_be16 (OOPS_HDR_VERSION ); + oops_hdr->report_length =cpu_to_be16 (zipped_len); + oops_hdr->timestamp =cpu_to_be64 (get_seconds ()); +return 0 ;
ktime_get_real_seconds()arch/powerpc/kernel/nvram_64.c struct nvram_partition { · line 440
Quoted 3 lines
arch/powerpc/kernel/nvram_64.c +3
-0+static ssize_t nvram_pstore_read (u64 *id,enum pstore_type_id *type, +int *count,struct timespec *time,char **buf, +bool *compressed,struct pstore_info *psi)This has to remain timespec for now but can later be changed to timespec64 when the API gets changed.
arch/powerpc/kernel/nvram_64.c struct nvram_partition { · line 703
Quoted 3 lines
arch/powerpc/kernel/nvram_64.c +3
-0+ oops_hdr->version =cpu_to_be16 (OOPS_HDR_VERSION ); + oops_hdr->report_length =cpu_to_be16 (text_len); + oops_hdr->timestamp =cpu_to_be64 (get_seconds ());
ktime_get_real_seconds()Arnd
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev