From 11eea4785fee409aa79e08c1679ec175563f36ae Mon Sep 17 00:00:00 2001 From: Cyril Bur Date: Wed, 14 Oct 2015 10:48:46 +1100 Subject: external/pflash: Add (C) header Signed-off-by: Cyril Bur Signed-off-by: Stewart Smith --- external/pflash/pflash.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'external') diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c index eb4b4ca..057506e 100644 --- a/external/pflash/pflash.c +++ b/external/pflash/pflash.c @@ -1,3 +1,19 @@ +/* Copyright 2013-2015 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include #include #include -- cgit v1.1 From d379d6d9f5ece1606d9fc89bbbdb56814d405116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Tue, 10 Nov 2015 22:00:06 +0100 Subject: opal-prd: display explicit message on IBM Power systems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Stewart Smith --- external/opal-prd/opal-prd.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'external') 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); -- cgit v1.1