diff options
author | Cédric Le Goater <clg@fr.ibm.com> | 2015-11-10 22:00:06 +0100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-12-03 16:03:27 +1100 |
commit | d379d6d9f5ece1606d9fc89bbbdb56814d405116 (patch) | |
tree | 4779217c922f0f9a73877c82e9a113c7beedb99a | |
parent | c15cab6f07181310cbce47037f19c35b74ab8918 (diff) | |
download | skiboot-d379d6d9f5ece1606d9fc89bbbdb56814d405116.zip skiboot-d379d6d9f5ece1606d9fc89bbbdb56814d405116.tar.gz skiboot-d379d6d9f5ece1606d9fc89bbbdb56814d405116.tar.bz2 |
opal-prd: display explicit message on IBM Power systems
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@fr.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r-- | external/opal-prd/opal-prd.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c index 91db5e6..b60512f 100644 --- a/external/opal-prd/opal-prd.c +++ b/external/opal-prd/opal-prd.c @@ -1023,6 +1023,52 @@ 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) + goto out_free; + + 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); +out_free: + free(path); + return rc; +} + static int prd_init(struct opal_prd_ctx *ctx) { int rc; @@ -1945,6 +1991,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); |