[Skiboot] [PATCH v2] opal-prd: display explicit message on IBM Power systems
Cédric Le Goater
clg at fr.ibm.com
Wed Nov 11 07:44:51 AEDT 2015
Today, when run on an IBM Power systems, opal-prd complains in syslog
with a set of messages similar to these :
opal-prd: CTRL: Starting PRD daemon
opal-prd: I2C: Found Chip: 00000000 engine 1 port 0
opal-prd: I2C: Found Chip: 00000010 engine 1 port 0
opal-prd: CTRL: Listening on control socket /run/opal-prd-control
opal-prd: FW: Can't open PRD device /dev/opal-prd: No such file or directory
opal-prd: FW: Error initialising PRD channel
opal-prd: CTRL: stopping PRD daemon
Which are difficult to interpret for a person not initiated to Power
firmware.
The patch below detects if the platform has support for PRD by looking
at the device tree property :
/sys/firmware/devicetree/base/ibm,opal/diagnostics/compatible
and stops opal-prd early in the main routine with an explicit
message for the user.
Signed-off-by: Cédric Le Goater <clg at fr.ibm.com>
---
Changes since v2:
- use ibm,opal/diagnostics/compatible property to detect PRD support
external/opal-prd/opal-prd.c | 51 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
Index: skiboot.git/external/opal-prd/opal-prd.c
===================================================================
--- skiboot.git.orig/external/opal-prd/opal-prd.c
+++ skiboot.git/external/opal-prd/opal-prd.c
@@ -1032,6 +1032,51 @@ out_free:
return rc;
}
+bool find_string(const char *buffer, size_t len, const char *s)
+{
+ const char *c, *end;
+
+ if (!buffer)
+ return false;
+ c = buffer;
+ end = c + len;
+
+ while (c < end) {
+ if (!strcasecmp(s, c))
+ return true;
+ c += strlen(c) + 1;
+ }
+ return false;
+}
+
+static int is_prd_supported(void)
+{
+ char *path;
+ int rc;
+ int len;
+ char *buf;
+
+ rc = asprintf(&path, "%s/ibm,opal/diagnostics/compatible",
+ devicetree_base);
+ if (rc < 0) {
+ pr_log(LOG_ERR, "FW: error creating 'compatible' node path: %m");
+ return -1;
+ }
+
+ rc = open_and_read(path, (void *) &buf, &len);
+ if (rc)
+ return -1;
+
+ if (buf[len - 1] != '\0')
+ pr_log(LOG_INFO, "FW: node %s is not nul-terminated", path);
+
+ rc = find_string(buf, len, "ibm,opal-prd") ? 0 : -1;
+
+ free(buf);
+
+ return rc;
+}
+
static int prd_init(struct opal_prd_ctx *ctx)
{
int rc;
@@ -1963,6 +2008,12 @@ int main(int argc, char *argv[])
action = ACTION_RUN_DAEMON;
}
+ if (is_prd_supported() < 0) {
+ pr_log(LOG_ERR, "CTRL: PowerNV OPAL runtime diagnostic "
+ "is not supported on this system");
+ return -1;
+ }
+
switch (action) {
case ACTION_RUN_DAEMON:
rc = run_prd_daemon(ctx);
More information about the Skiboot
mailing list