From patchwork Tue Nov 10 20:44:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 542611 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 180D614141D for ; Wed, 11 Nov 2015 07:45:07 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id EE8F41A036D for ; Wed, 11 Nov 2015 07:45:06 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id D13641A0008 for ; Wed, 11 Nov 2015 07:45:02 +1100 (AEDT) Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Nov 2015 20:44:59 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 10 Nov 2015 20:44:57 -0000 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: clg@fr.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 34A6C1B0804B for ; Tue, 10 Nov 2015 20:45:14 +0000 (GMT) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tAAKivCV6947296 for ; Tue, 10 Nov 2015 20:44:57 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tAAKivGg005632 for ; Tue, 10 Nov 2015 13:44:57 -0700 Received: from hermes.kaod.org (sig-9-84-102-134.evts.de.ibm.com [9.84.102.134]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tAAKiujc005617; Tue, 10 Nov 2015 13:44:56 -0700 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: skiboot@lists.ozlabs.org Date: Tue, 10 Nov 2015 21:44:51 +0100 Message-Id: <1447188291-21302-1-git-send-email-clg@fr.ibm.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15111020-0021-0000-0000-000007E77675 Subject: [Skiboot] [PATCH v2] opal-prd: display explicit message on IBM Power systems X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" 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 --- 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);