This patch adds support to read error logs from OPAL and export them
PATCH 1/1 This patch adds support to read error logs from OPAL and export them
From: Mahesh Salgaonkar <[email protected]>
to userspace through sysfs interface /sys/firmware/opa/opal-elog.
This patch buffers 128 error log records until it is consumed by userspace tool. This patch provides an sysfs interface '/sys/firmware/opa/opal-elog-ack' to user to receive an acknowledgement of successful log consumption.
This is what user space tool would do:
- Read error log from /sys/firmware/opa/opal-elog.
- Save it to the disk.
- Send an acknowledgement on successful consumption by writing error log id to /sys/firmware/opa/opal-elog-ack.
--- arch/powerpc/include/asm/opal.h | 11 + arch/powerpc/platforms/powernv/Makefile | 2 arch/powerpc/platforms/powernv/opal-elog.c | 309 ++++++++++++++++++++++++ arch/powerpc/platforms/powernv/opal-wrappers.S | 5 arch/powerpc/platforms/powernv/opal.c | 2 5 files changed, 328 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/platforms/powernv/opal-elog.c
arch/powerpc/include/asm/opal.h +11 -0
@@ -129,6 +129,11 @@ extern int opal_enter_rtas(struct rtas_args *args,#define OPAL_LPC_READ 67#define OPAL_LPC_WRITE 68#define OPAL_RETURN_CPU 69 +#define OPAL_ELOG_READ 71 +#define OPAL_ELOG_WRITE 72 +#define OPAL_ELOG_ACK 73 +#define OPAL_ELOG_RESEND 74 +#define OPAL_ELOG_SIZE 75#define OPAL_FLASH_VALIDATE 76#define OPAL_FLASH_MANAGE 77#define OPAL_FLASH_UPDATE 78
@@ -727,6 +732,11 @@ int64_t opal_lpc_write(uint32_t chip_id, enum OpalLPCAddressType addr_type, uint32_t addr, uint32_t data, uint32_t sz);int64_t opal_lpc_read (uint32_t chip_id,enum OpalLPCAddressType addr_type,uint32_t addr,uint32_t *data,uint32_t sz); +int64_t opal_read_elog (uint64_t buffer,size_t size,uint64_t log_id); +int64_t opal_get_elog_size (uint64_t *log_id,size_t *size,uint64_t *elog_type); +int64_t opal_write_elog (uint64_t buffer,uint64_t size,uint64_t offset); +int64_t opal_send_ack_elog (uint64_t log_id); +void opal_resend_pending_logs (void );int64_t opal_validate_flash (uint64_t buffer,uint32_t *size,uint32_t *result);int64_t opal_manage_flash (uint8_t op);int64_t opal_update_flash (uint64_t blk_list);
@@ -761,6 +771,7 @@ extern void opal_get_rtc_time(struct rtc_time *tm);extern unsigned long opal_get_boot_time (void );extern void opal_nvram_init (void );extern void opal_flash_init (void ); +extern int opal_elog_init (void );extern int opal_machine_check (struct pt_regs *regs);extern bool opal_mce_check_early_recovery (struct pt_regs *regs);
arch/powerpc/platforms/powernv/Makefile +1 -1
@@ -1,6 +1,6 @@ obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o obj-y += opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o -obj-y += rng.o +obj-y += rng.o opal-elog.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o
arch/powerpc/platforms/powernv/opal-elog.c new file +309 -0
309 lines not on this page · raw message
arch/powerpc/platforms/powernv/opal-wrappers.S +5 -0
@@ -123,6 +123,11 @@ OPAL_CALL(opal_xscom_write, OPAL_XSCOM_WRITE); OPAL_CALL(opal_lpc_read, OPAL_LPC_READ); OPAL_CALL(opal_lpc_write, OPAL_LPC_WRITE); OPAL_CALL(opal_return_cpu, OPAL_RETURN_CPU); +OPAL_CALL(opal_read_elog, OPAL_ELOG_READ); +OPAL_CALL(opal_send_ack_elog, OPAL_ELOG_ACK); +OPAL_CALL(opal_get_elog_size, OPAL_ELOG_SIZE); +OPAL_CALL(opal_resend_pending_logs, OPAL_ELOG_RESEND); +OPAL_CALL(opal_write_elog, OPAL_ELOG_WRITE); OPAL_CALL(opal_validate_flash, OPAL_FLASH_VALIDATE); OPAL_CALL(opal_manage_flash, OPAL_FLASH_MANAGE); OPAL_CALL(opal_update_flash, OPAL_FLASH_UPDATE);
arch/powerpc/platforms/powernv/opal.c +2 -0
@@ -475,6 +475,8 @@ static int __init opal_init(void)/* Create "opal" kobject under /sys/firmware */ rc =opal_sysfs_init ();if (rc ==0 ) { +/* Setup error log interface */ + rc =opal_elog_init ();/* Setup code update interface */ opal_flash_init (); }
Quoted 14 lines · Mahesh J Salgaonkar
From: Mahesh Salgaonkar <[email protected]>
to userspace through sysfs interface
/sys/firmware/opa/opal-elog.This patch buffers 128 error log records until it is consumed by userspace tool. This patch provides an sysfs interface '
/sys/firmware/opa/opal-elog-ack' to user to receive an acknowledgement of successful log consumption.This is what user space tool would do:
- Read error log from/sys/firmware/opa/opal-elog.
- Save it to the disk.
- Send an acknowledgement on successful consumption by writing error log id to/sys/firmware/opa/opal-elog-ack.
Quoted 3 lines
Signed-off-by Mamatha Inamdar <[email protected]>Signed-off-by Mahesh Salgaonkar <[email protected]>Signed-off-by Vasant Hegde <[email protected]>
Please ignore this patch. I messed up the subject line, I dunno how.. My bad. I will resend this patch with correct subject.
Thanks,
-Mahesh.