[Skiboot] [PATCH 1/3] opal/errorlog : Generalize the errorlog write path to host
Mukesh Ojha
mukesh02 at linux.vnet.ibm.com
Wed Apr 6 21:47:44 AEST 2016
Movement of opal errorlog generic functions from fsp-elog-write.c to new
file core/elog-host.c . Function declarations are kept in errorlog.h, which
was there in fsp-elog.h earlier and fsp specific header files are kept in
fsp-elog.h .
Implementation of generic init routine for errorlog writing to host will
be initialised independent of the platform on which it is going to run. it
also involves a common memory buffer which will be used to copy the logs
from opal to host buffer.
Signed-off-by: Mukesh Ojha <mukesh02 at linux.vnet.ibm.com>
---
core/Makefile.inc | 1 +
core/elog-host.c | 193 +++++++++++++++++++++++++++++++++++++++++++++
hw/fsp/fsp-elog-write.c | 173 +---------------------------------------
include/errorlog.h | 5 +-
platforms/ibm-fsp/common.c | 6 +-
5 files changed, 206 insertions(+), 172 deletions(-)
create mode 100644 core/elog-host.c
diff --git a/core/Makefile.inc b/core/Makefile.inc
index 83370c1..1380185 100644
--- a/core/Makefile.inc
+++ b/core/Makefile.inc
@@ -8,6 +8,7 @@ CORE_OBJS += device.o exceptions.o trace.o affinity.o vpd.o
CORE_OBJS += hostservices.o platform.o nvram.o nvram-format.o hmi.o
CORE_OBJS += console-log.o ipmi.o time-utils.o pel.o pool.o errorlog.o
CORE_OBJS += timer.o i2c.o rtc.o flash.o sensor.o
+CORE_OBJS += elog-host.o
ifeq ($(SKIBOOT_GCOV),1)
CORE_OBJS += gcov-profiling.o
diff --git a/core/elog-host.c b/core/elog-host.c
new file mode 100644
index 0000000..893b9e3
--- /dev/null
+++ b/core/elog-host.c
@@ -0,0 +1,193 @@
+/* Copyright 2013-2016 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.
+ */
+
+/*
+ * This code provides common routines, which can be used for
+ * error log write into host in FSP, AMI BMC and other service processor.
+ */
+#include <lock.h>
+#include <fsp-elog.h>
+
+/*Log buffer size to WRITE into Host */
+#define ELOG_WRITE_TO_HOST_BUFFER_SIZE 0x00004000
+
+static LIST_HEAD(elog_write_to_host_pending);
+static LIST_HEAD(elog_write_to_host_processed);
+
+static struct lock elog_write_to_host_lock = LOCK_UNLOCKED;
+
+void *elog_write_to_host_buffer;
+
+/*Manipulate this only with write_lock held*/
+static enum elog_head_state elog_write_to_host_head_state = ELOG_STATE_NONE;
+
+bool opal_elog_info(uint64_t *opal_elog_id, uint64_t *opal_elog_size)
+{
+ struct errorlog *head;
+ bool rc = false;
+
+ lock(&elog_write_to_host_lock);
+ if (elog_write_to_host_head_state == ELOG_STATE_FETCHED_DATA) {
+ head = list_top(&elog_write_to_host_pending,
+ struct errorlog, link);
+ if (!head) {
+ prlog(PR_ERR,
+ "%s: Inconsistent internal list state !\n",
+ __func__);
+ elog_write_to_host_head_state = ELOG_STATE_NONE;
+ } else {
+ *opal_elog_id = head->plid;
+ *opal_elog_size = head->log_size;
+ elog_write_to_host_head_state = ELOG_STATE_FETCHED_INFO;
+ rc = true;
+ }
+ }
+ unlock(&elog_write_to_host_lock);
+ return rc;
+}
+
+void opal_commit_elog_in_host(void)
+{
+
+ struct errorlog *buf;
+
+ lock(&elog_write_to_host_lock);
+ if (!list_empty(&elog_write_to_host_pending) &&
+ (elog_write_to_host_head_state == ELOG_STATE_NONE)) {
+ buf = list_top(&elog_write_to_host_pending,
+ struct errorlog, link);
+ buf->log_size = create_pel_log(buf,
+ (char *)elog_write_to_host_buffer,
+ ELOG_WRITE_TO_HOST_BUFFER_SIZE);
+ elog_write_to_host_head_state = ELOG_STATE_FETCHED_DATA;
+ opal_update_pending_evt(OPAL_EVENT_ERROR_LOG_AVAIL,
+ OPAL_EVENT_ERROR_LOG_AVAIL);
+ }
+ unlock(&elog_write_to_host_lock);
+}
+
+
+bool opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
+ uint64_t opal_elog_id)
+{
+ struct errorlog *log_data;
+ bool rc = false;
+
+ lock(&elog_write_to_host_lock);
+ if (elog_write_to_host_head_state == ELOG_STATE_FETCHED_INFO) {
+ log_data = list_top(&elog_write_to_host_pending,
+ struct errorlog, link);
+ if (!log_data) {
+ elog_write_to_host_head_state = ELOG_STATE_NONE;
+ unlock(&elog_write_to_host_lock);
+ return rc;
+ }
+ if ((opal_elog_id != log_data->plid) &&
+ (opal_elog_size != log_data->log_size)) {
+ unlock(&elog_write_to_host_lock);
+ return rc;
+ }
+
+ memcpy((void *)buffer, elog_write_to_host_buffer,
+ opal_elog_size);
+
+ list_del(&log_data->link);
+ list_add(&elog_write_to_host_processed, &log_data->link);
+ elog_write_to_host_head_state = ELOG_STATE_NONE;
+ rc = true;
+ }
+ unlock(&elog_write_to_host_lock);
+ opal_commit_elog_in_host();
+ return rc;
+}
+
+bool opal_elog_ack(uint64_t ack_id)
+{
+ bool rc = false;
+ struct errorlog *log_data;
+ struct errorlog *record, *next_record;
+
+ lock(&elog_write_to_host_lock);
+ if (!list_empty(&elog_write_to_host_processed)) {
+ list_for_each_safe(&elog_write_to_host_processed, record,
+ next_record, link) {
+ if (record->plid != ack_id)
+ continue;
+ list_del(&record->link);
+ opal_elog_complete(record, true);
+ rc = true;
+ }
+ }
+
+ if ((!rc) && (!list_empty(&elog_write_to_host_pending))) {
+ log_data = list_top(&elog_write_to_host_pending,
+ struct errorlog, link);
+ if (ack_id == log_data->plid)
+ elog_write_to_host_head_state = ELOG_STATE_NONE;
+
+ list_for_each_safe(&elog_write_to_host_pending, record,
+ next_record, link) {
+ if (record->plid != ack_id)
+ continue;
+ list_del(&record->link);
+ opal_elog_complete(record, true);
+ rc = true;
+ }
+ }
+ unlock(&elog_write_to_host_lock);
+ return rc;
+}
+
+void opal_resend_pending_logs(void)
+{
+ struct errorlog *record;
+
+ lock(&elog_write_to_host_lock);
+ if (list_empty(&elog_write_to_host_processed)) {
+ unlock(&elog_write_to_host_lock);
+ return;
+ }
+
+ while (!list_empty(&elog_write_to_host_processed)) {
+ record = list_pop(&elog_write_to_host_processed,
+ struct errorlog, link);
+ list_add_tail(&elog_write_to_host_pending, &record->link);
+ }
+ elog_write_to_host_head_state = ELOG_STATE_NONE;
+ unlock(&elog_write_to_host_lock);
+ opal_commit_elog_in_host();
+}
+
+void elog_append_write_to_host(struct errorlog *buf)
+{
+ lock(&elog_write_to_host_lock);
+ if (list_empty(&elog_write_to_host_pending)) {
+ list_add(&elog_write_to_host_pending, &buf->link);
+ unlock(&elog_write_to_host_lock);
+ opal_commit_elog_in_host();
+ } else {
+ list_add_tail(&elog_write_to_host_pending, &buf->link);
+ unlock(&elog_write_to_host_lock);
+ }
+}
+
+void opal_elog_init(void)
+{
+ elog_write_to_host_buffer = memalign(TCE_PSIZE,
+ ELOG_WRITE_TO_HOST_BUFFER_SIZE);
+ assert(elog_write_to_host_buffer);
+ elog_init();
+}
diff --git a/hw/fsp/fsp-elog-write.c b/hw/fsp/fsp-elog-write.c
index cf915a2..ee293f1 100644
--- a/hw/fsp/fsp-elog-write.c
+++ b/hw/fsp/fsp-elog-write.c
@@ -1,4 +1,4 @@
-/* Copyright 2013-2014 IBM Corp.
+/* Copyright 2013-2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,28 +36,21 @@
#include <opal-api.h>
static LIST_HEAD(elog_write_to_fsp_pending);
-static LIST_HEAD(elog_write_to_host_pending);
-static LIST_HEAD(elog_write_to_host_processed);
static struct lock elog_write_lock = LOCK_UNLOCKED;
static struct lock elog_panic_write_lock = LOCK_UNLOCKED;
-static struct lock elog_write_to_host_lock = LOCK_UNLOCKED;
-/* log buffer to copy FSP log for READ */
+/* log buffer to WRITE into FSP */
#define ELOG_WRITE_TO_FSP_BUFFER_SIZE 0x00004000
static void *elog_write_to_fsp_buffer;
-#define ELOG_PANIC_WRITE_BUFFER_SIZE 0x00004000
+#define ELOG_PANIC_WRITE_BUFFER_SIZE 0x00004000
static void *elog_panic_write_buffer;
-#define ELOG_WRITE_TO_HOST_BUFFER_SIZE 0x00004000
-static void *elog_write_to_host_buffer;
-
static uint32_t elog_write_retries;
/* Manipulate this only with write_lock held */
static uint32_t elog_plid_fsp_commit = -1;
-static enum elog_head_state elog_write_to_host_head_state = ELOG_STATE_NONE;
/* Need forward declaration because of Circular dependency */
static int opal_send_elog_to_fsp(void);
@@ -126,143 +119,6 @@ static int64_t fsp_opal_elog_write(size_t opal_elog_size)
return OPAL_SUCCESS;
}
-bool opal_elog_info(uint64_t *opal_elog_id, uint64_t *opal_elog_size)
-{
- struct errorlog *head;
- bool rc = false;
-
- lock(&elog_write_to_host_lock);
- if (elog_write_to_host_head_state == ELOG_STATE_FETCHED_DATA) {
- head = list_top(&elog_write_to_host_pending,
- struct errorlog, link);
- if (!head) {
- prlog(PR_ERR,
- "%s: Inconsistent internal list state !\n",
- __func__);
- elog_write_to_host_head_state = ELOG_STATE_NONE;
- } else {
- *opal_elog_id = head->plid;
- *opal_elog_size = head->log_size;
- elog_write_to_host_head_state = ELOG_STATE_FETCHED_INFO;
- rc = true;
- }
- }
- unlock(&elog_write_to_host_lock);
- return rc;
-}
-
-static void opal_commit_elog_in_host(void)
-{
-
- struct errorlog *buf;
-
- lock(&elog_write_to_host_lock);
- if (!list_empty(&elog_write_to_host_pending) &&
- (elog_write_to_host_head_state == ELOG_STATE_NONE)) {
- buf = list_top(&elog_write_to_host_pending,
- struct errorlog, link);
- buf->log_size = create_pel_log(buf,
- (char *)elog_write_to_host_buffer,
- ELOG_WRITE_TO_HOST_BUFFER_SIZE);
- elog_write_to_host_head_state = ELOG_STATE_FETCHED_DATA;
- opal_update_pending_evt(OPAL_EVENT_ERROR_LOG_AVAIL,
- OPAL_EVENT_ERROR_LOG_AVAIL);
- }
- unlock(&elog_write_to_host_lock);
-}
-
-
-bool opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
- uint64_t opal_elog_id)
-{
- struct errorlog *log_data;
- bool rc = false;
-
- lock(&elog_write_to_host_lock);
- if (elog_write_to_host_head_state == ELOG_STATE_FETCHED_INFO) {
- log_data = list_top(&elog_write_to_host_pending,
- struct errorlog, link);
- if (!log_data) {
- elog_write_to_host_head_state = ELOG_STATE_NONE;
- unlock(&elog_write_to_host_lock);
- return rc;
- }
- if ((opal_elog_id != log_data->plid) &&
- (opal_elog_size != log_data->log_size)) {
- unlock(&elog_write_to_host_lock);
- return rc;
- }
-
- memcpy((void *)buffer, elog_write_to_host_buffer,
- opal_elog_size);
-
- list_del(&log_data->link);
- list_add(&elog_write_to_host_processed, &log_data->link);
- elog_write_to_host_head_state = ELOG_STATE_NONE;
- rc = true;
- }
- unlock(&elog_write_to_host_lock);
- opal_commit_elog_in_host();
- return rc;
-}
-
-bool opal_elog_ack(uint64_t ack_id)
-{
- bool rc = false;
- struct errorlog *log_data;
- struct errorlog *record, *next_record;
-
- lock(&elog_write_to_host_lock);
- if (!list_empty(&elog_write_to_host_processed)) {
- list_for_each_safe(&elog_write_to_host_processed, record,
- next_record, link) {
- if (record->plid != ack_id)
- continue;
- list_del(&record->link);
- opal_elog_complete(record, true);
- rc = true;
- }
- }
-
- if ((!rc) && (!list_empty(&elog_write_to_host_pending))) {
- log_data = list_top(&elog_write_to_host_pending,
- struct errorlog, link);
- if (ack_id == log_data->plid)
- elog_write_to_host_head_state = ELOG_STATE_NONE;
-
- list_for_each_safe(&elog_write_to_host_pending, record,
- next_record, link) {
- if (record->plid != ack_id)
- continue;
- list_del(&record->link);
- opal_elog_complete(record, true);
- rc = true;
- }
- }
- unlock(&elog_write_to_host_lock);
- return rc;
-}
-
-void opal_resend_pending_logs(void)
-{
- struct errorlog *record;
-
- lock(&elog_write_to_host_lock);
- if (list_empty(&elog_write_to_host_processed)) {
- unlock(&elog_write_to_host_lock);
- return;
- }
-
- while (!list_empty(&elog_write_to_host_processed)) {
- record = list_pop(&elog_write_to_host_processed,
- struct errorlog, link);
- list_add_tail(&elog_write_to_host_pending, &record->link);
- }
- elog_write_to_host_head_state = ELOG_STATE_NONE;
- unlock(&elog_write_to_host_lock);
- opal_commit_elog_in_host();
-}
-
static int opal_send_elog_to_fsp(void)
{
struct errorlog *head;
@@ -354,20 +210,6 @@ int elog_fsp_commit(struct errorlog *buf)
return rc;
}
-static void elog_append_write_to_host(struct errorlog *buf)
-{
-
- lock(&elog_write_to_host_lock);
- if (list_empty(&elog_write_to_host_pending)) {
- list_add(&elog_write_to_host_pending, &buf->link);
- unlock(&elog_write_to_host_lock);
- opal_commit_elog_in_host();
- } else {
- list_add_tail(&elog_write_to_host_pending, &buf->link);
- unlock(&elog_write_to_host_lock);
- }
-}
-
static void elog_timeout_poll(void *data __unused)
{
uint64_t now;
@@ -412,13 +254,6 @@ void fsp_elog_write_init(void)
return;
}
- elog_write_to_host_buffer = memalign(TCE_PSIZE,
- ELOG_WRITE_TO_HOST_BUFFER_SIZE);
- if (!elog_write_to_host_buffer) {
- prerror("FSP: could not allocate ELOG_WRITE_TO_HOST_BUFFER!\n");
- return;
- }
-
/* Map TCEs */
fsp_tce_map(PSI_DMA_ELOG_PANIC_WRITE_BUF, elog_panic_write_buffer,
PSI_DMA_ELOG_PANIC_WRITE_BUF_SZ);
@@ -426,8 +261,6 @@ void fsp_elog_write_init(void)
fsp_tce_map(PSI_DMA_ERRLOG_WRITE_BUF, elog_write_to_fsp_buffer,
PSI_DMA_ERRLOG_WRITE_BUF_SZ);
- elog_init();
-
/* Add a poller */
opal_add_poller(elog_timeout_poll, NULL);
}
diff --git a/include/errorlog.h b/include/errorlog.h
index 33d2de2..ba1c6aa 100644
--- a/include/errorlog.h
+++ b/include/errorlog.h
@@ -1,4 +1,4 @@
-/* Copyright 2013-2014 IBM Corp.
+/* Copyright 2013-2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -354,6 +354,9 @@ void log_commit(struct errorlog *elog);
* set to false. */
void opal_elog_complete(struct errorlog *elog, bool success);
+void opal_elog_init(void);
+void opal_commit_elog_in_host(void);
+void elog_append_write_to_host(struct errorlog *buf);
int elog_init(void);
#endif /* __ERRORLOG_H */
diff --git a/platforms/ibm-fsp/common.c b/platforms/ibm-fsp/common.c
index dc3a002..3beed86 100644
--- a/platforms/ibm-fsp/common.c
+++ b/platforms/ibm-fsp/common.c
@@ -1,4 +1,4 @@
-/* Copyright 2013-2014 IBM Corp.
+/* Copyright 2013-2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
#include <console.h>
#include <hostservices.h>
#include <ipmi.h>
+#include <errorlog.h>
#include "ibm-fsp.h"
@@ -92,6 +93,9 @@ void ibm_fsp_init(void)
/* Get ready to receive OCC related messages */
occ_fsp_init();
+ /*Initialize the errorlog framework*/
+ opal_elog_init();
+
/* Get ready to receive Memory [Un]corretable Error messages. */
fsp_memory_err_init();
--
2.1.4
More information about the Skiboot
mailing list