From patchwork Wed Feb 4 05:07:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 436137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 55BA91400B7 for ; Wed, 4 Feb 2015 16:09:06 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 3E23F1A09F1 for ; Wed, 4 Feb 2015 16:09:06 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 664511A08A9 for ; Wed, 4 Feb 2015 16:08:57 +1100 (AEDT) Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Feb 2015 15:08:56 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 4 Feb 2015 15:08:54 +1000 Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id A10322BB0040 for ; Wed, 4 Feb 2015 16:08:52 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t1458inP33095792 for ; Wed, 4 Feb 2015 16:08:52 +1100 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t1458JMo027335 for ; Wed, 4 Feb 2015 16:08:19 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t1458JO7026873; Wed, 4 Feb 2015 16:08:19 +1100 Received: from localhost (haven.au.ibm.com [9.192.253.15]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 18C06A03B5; Wed, 4 Feb 2015 16:07:56 +1100 (AEDT) From: Alistair Popple To: skiboot@lists.ozlabs.org Date: Wed, 4 Feb 2015 16:07:45 +1100 Message-Id: <1423026466-31386-4-git-send-email-alistair@popple.id.au> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1423026466-31386-1-git-send-email-alistair@popple.id.au> References: <1423026466-31386-1-git-send-email-alistair@popple.id.au> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15020405-1618-0000-0000-0000018E2455 Subject: [Skiboot] [PATCH v2 3/4] ipmi: Add support for synchronous message sending X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This patch adds support for sending ipmi messages synchronously. This is necessary to allow messages to be sent during skiboot initialisation as interrupt servicing/polling is controlled by the host operating system which is not yet running. Signed-off-by: Alistair Popple Reviewed-by: Joel Stanley --- core/ipmi.c | 23 +++++++++++++++++++++++ include/ipmi.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/core/ipmi.c b/core/ipmi.c index da06c5f..99c2fd9 100644 --- a/core/ipmi.c +++ b/core/ipmi.c @@ -19,8 +19,13 @@ #include #include #include +#include +#include +#include struct ipmi_backend *ipmi_backend = NULL; +static struct lock sync_lock = LOCK_UNLOCKED; +static struct ipmi_msg *sync_msg = NULL; void ipmi_free_msg(struct ipmi_msg *msg) { @@ -109,6 +114,24 @@ void ipmi_cmd_done(uint8_t cmd, uint8_t netfn, uint8_t cc, struct ipmi_msg *msg) /* At this point the message has should have been freed by the completion functions. */ + + /* If this is a synchronous message flag that we are done */ + if (msg == sync_msg) + sync_msg = NULL; +} + +void ipmi_queue_msg_sync(struct ipmi_msg *msg) +{ + lock(&sync_lock); + + assert(!sync_msg); + sync_msg = msg; + ipmi_queue_msg(msg); + + while (sync_msg) + time_wait_ms(100); + + unlock(&sync_lock); } static void ipmi_read_event_complete(struct ipmi_msg *msg) diff --git a/include/ipmi.h b/include/ipmi.h index 9c3f295..5cee692 100644 --- a/include/ipmi.h +++ b/include/ipmi.h @@ -193,6 +193,10 @@ int ipmi_queue_msg(struct ipmi_msg *msg); /* Add an ipmi message to the start of the queue */ int ipmi_queue_msg_head(struct ipmi_msg *msg); +/* Synchronously send an ipmi message. This won't return until the + * messages callback has been called. */ +void ipmi_queue_msg_sync(struct ipmi_msg *msg); + /* Process a completed message */ void ipmi_cmd_done(uint8_t cmd, uint8_t netfn, uint8_t cc, struct ipmi_msg *msg);