Skip to content

Commit

Permalink
powerpc/powernv Platform dump interface
Browse files Browse the repository at this point in the history
This enables support for userspace to fetch and initiate FSP and
Platform dumps from the service processor (via firmware) through sysfs.

Based on original patch from Vasant Hegde <hegdevasant@linux.vnet.ibm.com>

Flow:
  - We register for OPAL notification events.
  - OPAL sends new dump available notification.
  - We make information on dump available via sysfs
  - Userspace requests dump contents
  - We retrieve the dump via OPAL interface
  - User copies the dump data
  - userspace sends ack for dump
  - We send ACK to OPAL.

sysfs files:
  - We add the /sys/firmware/opal/dump directory
  - echoing 1 (well, anything, but in future we may support
    different dump types) to /sys/firmware/opal/dump/initiate_dump
    will initiate a dump.
  - Each dump that we've been notified of gets a directory
    in /sys/firmware/opal/dump/ with a name of the dump type and ID (in hex,
    as this is what's used elsewhere to identify the dump).
  - Each dump has files: id, type, dump and acknowledge
    dump is binary and is the dump itself.
    echoing 'ack' to acknowledge (currently any string will do) will
    acknowledge the dump and it will soon after disappear from sysfs.

OPAL APIs:
  - opal_dump_init()
  - opal_dump_info()
  - opal_dump_read()
  - opal_dump_ack()
  - opal_dump_resend_notification()

Currently we are only ever notified for one dump at a time (until
the user explicitly acks the current dump, then we get a notification
of the next dump), but this kernel code should "just work" when OPAL
starts notifying us of all the dumps present.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
stewartsmith authored and ozbenh committed Mar 7, 2014
1 parent 774fea1 commit c7e64b9
Show file tree
Hide file tree
Showing 6 changed files with 589 additions and 1 deletion.
41 changes: 41 additions & 0 deletions Documentation/ABI/stable/sysfs-firmware-opal-dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
What: /sys/firmware/opal/dump
Date: Feb 2014
Contact: Stewart Smith <stewart@linux.vnet.ibm.com>
Description:
This directory exposes interfaces for interacting with
the FSP and platform dumps through OPAL firmware interface.

This is only for the powerpc/powernv platform.

initiate_dump: When '1' is written to it,
we will initiate a dump.
Read this file for supported commands.

0xXX-0xYYYY: A directory for dump of type 0xXX and
id 0xYYYY (in hex). The name of this
directory should not be relied upon to
be in this format, only that it's unique
among all dumps. For determining the type
and ID of the dump, use the id and type files.
Do not rely on any particular size of dump
type or dump id.

Each dump has the following files:
id: An ASCII representation of the dump ID
in hex (e.g. '0x01')
type: An ASCII representation of the type of
dump in the format "0x%x %s" with the ID
in hex and a description of the dump type
(or 'unknown').
Type '0xffffffff unknown' is used when
we could not get the type from firmware.
e.g. '0x02 System/Platform Dump'
dump: A binary file containing the dump.
The size of the dump is the size of this file.
acknowledge: When 'ack' is written to this, we will
acknowledge that we've retrieved the
dump to the service processor. It will
then remove it, making the dump
inaccessible.
Reading this file will get a list of
supported actions.
14 changes: 14 additions & 0 deletions arch/powerpc/include/asm/opal.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,15 @@ extern int opal_enter_rtas(struct rtas_args *args,
#define OPAL_FLASH_VALIDATE 76
#define OPAL_FLASH_MANAGE 77
#define OPAL_FLASH_UPDATE 78
#define OPAL_DUMP_INIT 81
#define OPAL_DUMP_INFO 82
#define OPAL_DUMP_READ 83
#define OPAL_DUMP_ACK 84
#define OPAL_GET_MSG 85
#define OPAL_CHECK_ASYNC_COMPLETION 86
#define OPAL_DUMP_RESEND 91
#define OPAL_SYNC_HOST_REBOOT 87
#define OPAL_DUMP_INFO2 94

#ifndef __ASSEMBLY__

Expand Down Expand Up @@ -242,6 +248,7 @@ enum OpalPendingState {
OPAL_EVENT_EPOW = 0x80,
OPAL_EVENT_LED_STATUS = 0x100,
OPAL_EVENT_PCI_ERROR = 0x200,
OPAL_EVENT_DUMP_AVAIL = 0x400,
OPAL_EVENT_MSG_PENDING = 0x800,
};

Expand Down Expand Up @@ -838,6 +845,12 @@ 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);
int64_t opal_dump_init(uint8_t dump_type);
int64_t opal_dump_info(uint32_t *dump_id, uint32_t *dump_size);
int64_t opal_dump_info2(uint32_t *dump_id, uint32_t *dump_size, uint32_t *dump_type);
int64_t opal_dump_read(uint32_t dump_id, uint64_t buffer);
int64_t opal_dump_ack(uint32_t dump_id);
int64_t opal_dump_resend_notification(void);

int64_t opal_get_msg(uint64_t buffer, size_t size);
int64_t opal_check_completion(uint64_t buffer, size_t size, uint64_t token);
Expand Down Expand Up @@ -876,6 +889,7 @@ 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 void opal_platform_dump_init(void);

extern int opal_machine_check(struct pt_regs *regs);
extern bool opal_mce_check_early_recovery(struct pt_regs *regs);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/powernv/Makefile
Original file line number Diff line number Diff line change
@@ -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 opal-elog.o
obj-y += rng.o opal-elog.o opal-dump.o

obj-$(CONFIG_SMP) += smp.o
obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o
Expand Down

0 comments on commit c7e64b9

Please sign in to comment.