[Skiboot] [PATCH V2 2/6] opal/errorlog : Modification as per coding guidelines to make the code more legible
Mukesh Ojha
mukesh02 at linux.vnet.ibm.com
Thu Jun 9 23:54:06 AEST 2016
Some modifications related to typo errors, alignment, case letter mismatch etc.
to add more clarity to the code.
Signed-off-by: Mukesh Ojha <mukesh02 at linux.vnet.ibm.com>
---
Changes in V2:
- New Patch.
core/elog-host.c | 43 ++++++++--------
hw/fsp/fsp-elog-read.c | 128 ++++++++++++++++++++++--------------------------
hw/fsp/fsp-elog-write.c | 76 ++++++++++++++--------------
3 files changed, 118 insertions(+), 129 deletions(-)
diff --git a/core/elog-host.c b/core/elog-host.c
index 5b4ccb5..9fb855b 100644
--- a/core/elog-host.c
+++ b/core/elog-host.c
@@ -15,13 +15,13 @@
*/
/*
- * This code provides common routines, which can be used for
- * error log write into host in FSP, AMI BMC and other service processor.
+ * 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>
+#include <lock.h>
-/*Log buffer size to WRITE into Host */
+/* Log buffer size to write into Host */
#define ELOG_WRITE_TO_HOST_BUFFER_SIZE 0x00004000
static LIST_HEAD(elog_write_to_host_pending);
@@ -31,7 +31,7 @@ static struct lock elog_write_to_host_lock = LOCK_UNLOCKED;
void *elog_write_to_host_buffer;
-/*Manipulate this only with write_lock held*/
+/* 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)
@@ -41,12 +41,11 @@ bool opal_elog_info(uint64_t *opal_elog_id, uint64_t *opal_elog_size)
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);
+ head = list_top(&elog_write_to_host_pending, struct errorlog,
+ link);
if (!head) {
- prlog(PR_ERR,
- "%s: Inconsistent internal list state !\n",
- __func__);
+ 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;
@@ -61,7 +60,6 @@ bool opal_elog_info(uint64_t *opal_elog_id, uint64_t *opal_elog_size)
void opal_commit_elog_in_host(void)
{
-
struct errorlog *buf;
lock(&elog_write_to_host_lock);
@@ -70,18 +68,17 @@ void opal_commit_elog_in_host(void)
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);
+ (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);
+ 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)
+ uint64_t opal_elog_id)
{
struct errorlog *log_data;
bool rc = false;
@@ -89,12 +86,13 @@ bool opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
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);
+ 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);
@@ -102,8 +100,7 @@ bool opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
}
memcpy((void *)buffer, elog_write_to_host_buffer,
- opal_elog_size);
-
+ 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;
@@ -123,9 +120,10 @@ bool opal_elog_ack(uint64_t ack_id)
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) {
+ next_record, link) {
if (record->plid != ack_id)
continue;
+
list_del(&record->link);
opal_elog_complete(record, true);
rc = true;
@@ -134,14 +132,15 @@ bool opal_elog_ack(uint64_t ack_id)
if ((!rc) && (!list_empty(&elog_write_to_host_pending))) {
log_data = list_top(&elog_write_to_host_pending,
- struct errorlog, link);
+ 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) {
+ next_record, link) {
if (record->plid != ack_id)
continue;
+
list_del(&record->link);
opal_elog_complete(record, true);
rc = true;
diff --git a/hw/fsp/fsp-elog-read.c b/hw/fsp/fsp-elog-read.c
index 16667ae..213d9ec 100644
--- a/hw/fsp/fsp-elog-read.c
+++ b/hw/fsp/fsp-elog-read.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.
@@ -46,14 +46,14 @@
* When Linux acks an error log, we remove it from processed list.
*/
-#include <skiboot.h>
-#include <fsp.h>
#include <cpu.h>
-#include <lock.h>
#include <errno.h>
-#include <psi.h>
+#include <fsp.h>
#include <fsp-elog.h>
+#include <lock.h>
#include <opal-api.h>
+#include <psi.h>
+#include <skiboot.h>
/*
* Maximum number of entries that are pre-allocated
@@ -61,7 +61,7 @@
*/
#define ELOG_READ_MAX_RECORD 128
-/* structure to maintain log-id,log-size, pending and processed list */
+/* Structure to maintain log-id, log-size, pending and processed list */
struct fsp_log_entry {
uint32_t log_id;
size_t log_size;
@@ -73,26 +73,26 @@ static LIST_HEAD(elog_read_processed);
static LIST_HEAD(elog_read_free);
/*
- * lock is used to protect overwriting of processed and pending list
+ * Lock is used to protect overwriting of processed and pending list
* and also used while updating state of each log
*/
static struct lock elog_read_lock = LOCK_UNLOCKED;
-/* log buffer to copy FSP log for READ */
+/* Log buffer to copy FSP log for READ */
#define ELOG_READ_BUFFER_SIZE 0x00004000
static void *elog_read_buffer;
static uint32_t elog_head_id; /* FSP entry ID */
-static size_t elog_head_size; /* actual FSP log size */
-static uint32_t elog_read_retries; /* bad response status count */
+static size_t elog_head_size; /* Actual FSP log size */
+static uint32_t elog_read_retries; /* Bad response status count */
/* Initialize the state of the log */
static enum elog_head_state elog_read_from_fsp_head_state = ELOG_STATE_NONE;
-/* Need forward declaration because of Circular dependency */
+/* Need forward declaration because of circular dependency */
static void fsp_elog_queue_fetch(void);
/*
- * check the response message for mbox acknowledgment
+ * Check the response message for mbox acknowledgment
* command send to FSP.
*/
static void fsp_elog_ack_complete(struct fsp_msg *msg)
@@ -101,16 +101,17 @@ static void fsp_elog_ack_complete(struct fsp_msg *msg)
if (!msg->resp)
return;
+
val = (msg->resp->word1 >> 8) & 0xff;
if (val != 0)
prerror("ELOG: Acknowledgment error\n");
+
fsp_freemsg(msg);
}
-/* send Error Log PHYP Acknowledgment to FSP with entry ID */
+/* Send error log PHYP acknowledgment to FSP with entry ID */
static int64_t fsp_send_elog_ack(uint32_t log_id)
{
-
struct fsp_msg *ack_msg;
ack_msg = fsp_mkmsg(FSP_CMD_ERRLOG_PHYP_ACK, 1, log_id);
@@ -118,20 +119,21 @@ static int64_t fsp_send_elog_ack(uint32_t log_id)
prerror("ELOG: Failed to allocate ack message\n");
return OPAL_INTERNAL_ERROR;
}
+
if (fsp_queue_msg(ack_msg, fsp_elog_ack_complete)) {
fsp_freemsg(ack_msg);
ack_msg = NULL;
prerror("ELOG: Error queueing elog ack complete\n");
return OPAL_INTERNAL_ERROR;
}
+
return OPAL_SUCCESS;
}
-/* retrive error log from FSP with TCE for the data transfer */
+/* Retrieve error log from FSP with TCE for the data transfer */
static void fsp_elog_check_and_fetch_head(void)
{
lock(&elog_read_lock);
-
if (elog_read_from_fsp_head_state != ELOG_STATE_NONE ||
list_empty(&elog_read_pending)) {
unlock(&elog_read_lock);
@@ -139,51 +141,50 @@ static void fsp_elog_check_and_fetch_head(void)
}
elog_read_retries = 0;
-
/* Start fetching first entry from the pending list */
fsp_elog_queue_fetch();
unlock(&elog_read_lock);
}
-/* this function should be called with the lock held */
+/* This function should be called with the lock held */
static void fsp_elog_set_head_state(enum elog_head_state state)
{
enum elog_head_state old_state = elog_read_from_fsp_head_state;
elog_read_from_fsp_head_state = state;
-
if (state == ELOG_STATE_FETCHED_DATA &&
old_state != ELOG_STATE_FETCHED_DATA)
opal_update_pending_evt(OPAL_EVENT_ERROR_LOG_AVAIL,
OPAL_EVENT_ERROR_LOG_AVAIL);
+
if (state != ELOG_STATE_FETCHED_DATA &&
old_state == ELOG_STATE_FETCHED_DATA)
opal_update_pending_evt(OPAL_EVENT_ERROR_LOG_AVAIL, 0);
}
/*
- * when we try maximum time of fetching log from fsp
+ * When we try maximum time of fetching log from fsp
* we call following function to delete log from the
- * pending list and update the state to fetch next log
+ * pending list and update the state to fetch next log.
*
- * this function should be called with the lock held
+ * This function should be called with the lock held
*/
static void fsp_elog_fetch_failure(uint8_t fsp_status)
{
struct fsp_log_entry *log_data;
- /* read top list and delete the node */
+ /* Read top list and delete the node */
log_data = list_top(&elog_read_pending, struct fsp_log_entry, link);
if (!log_data) {
prlog(PR_ERR, "%s: Inconsistent internal list state !\n",
- __func__);
+ __func__);
} else {
list_del(&log_data->link);
list_add(&elog_read_free, &log_data->link);
prerror("ELOG: received invalid data: %x FSP status: 0x%x\n",
log_data->log_id, fsp_status);
-
}
+
fsp_elog_set_head_state(ELOG_STATE_NONE);
}
@@ -191,12 +192,10 @@ static void fsp_elog_fetch_failure(uint8_t fsp_status)
static void fsp_elog_read_complete(struct fsp_msg *read_msg)
{
uint8_t val;
- /*struct fsp_log_entry *log_data;*/
lock(&elog_read_lock);
val = (read_msg->resp->word1 >> 8) & 0xff;
fsp_freemsg(read_msg);
-
if (elog_read_from_fsp_head_state == ELOG_STATE_REJECTED) {
fsp_elog_set_head_state(ELOG_STATE_NONE);
goto elog_read_out;
@@ -227,12 +226,11 @@ static void fsp_elog_read_complete(struct fsp_msg *read_msg)
elog_read_out:
unlock(&elog_read_lock);
-
/* Check if a new log needs fetching */
fsp_elog_check_and_fetch_head();
}
-/* read error log from FSP through mbox commands */
+/* Read error log from FSP through mbox commands */
static void fsp_elog_queue_fetch(void)
{
int rc;
@@ -242,14 +240,14 @@ static void fsp_elog_queue_fetch(void)
entry = list_top(&elog_read_pending, struct fsp_log_entry, link);
if (!entry) {
prlog(PR_ERR, "%s: Inconsistent internal list state !\n",
- __func__);
+ __func__);
fsp_elog_set_head_state(ELOG_STATE_NONE);
return;
}
+
fsp_elog_set_head_state(ELOG_STATE_FETCHING);
elog_head_id = entry->log_id;
elog_head_size = entry->log_size;
-
rc = fsp_fetch_data_queue(flags, FSP_DATASET_ERRLOG, elog_head_id,
0, (void *)PSI_DMA_ERRLOG_READ_BUF,
&elog_head_size, fsp_elog_read_complete);
@@ -259,13 +257,13 @@ static void fsp_elog_queue_fetch(void)
}
}
-/* opal interface for powernv to read log size and log ID from sapphire */
+/* OPAL interface for PowerNV to read log size and log ID from sapphire */
static int64_t fsp_opal_elog_info(uint64_t *opal_elog_id,
uint64_t *opal_elog_size, uint64_t *elog_type)
{
struct fsp_log_entry *log_data;
- /* copy type of the error log */
+ /* Copy type of the error log */
*elog_type = ELOG_TYPE_PEL;
/* Check if any OPAL log needs to be reported to the host */
@@ -277,30 +275,32 @@ static int64_t fsp_opal_elog_info(uint64_t *opal_elog_id,
unlock(&elog_read_lock);
return OPAL_WRONG_STATE;
}
+
log_data = list_top(&elog_read_pending, struct fsp_log_entry, link);
if (!log_data) {
prlog(PR_ERR, "%s: Inconsistent internal list state !\n",
- __func__);
+ __func__);
unlock(&elog_read_lock);
return OPAL_WRONG_STATE;
}
+
*opal_elog_id = log_data->log_id;
*opal_elog_size = log_data->log_size;
unlock(&elog_read_lock);
return OPAL_SUCCESS;
}
-/* opal interface for powernv to read log from sapphire */
+/* OPAL interface for PowerNV to read log from sapphire */
static int64_t fsp_opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
uint64_t opal_elog_id)
{
int size = opal_elog_size;
struct fsp_log_entry *log_data;
-
/* Check if any OPAL log needs to be reported to the host */
if (opal_elog_read(buffer, opal_elog_size, opal_elog_id))
return OPAL_SUCCESS;
+
/*
* Read top entry from list.
* as we know always top record of the list is fetched from FSP
@@ -331,9 +331,8 @@ static int64_t fsp_opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
memset((void *)buffer, 0, opal_elog_size);
memcpy((void *)buffer, elog_read_buffer, size);
-
/*
- * once log is read from linux move record from pending
+ * Once log is read from linux move record from pending
* to processed list and delete record from pending list
* and change state of the log to fetch next record
*/
@@ -342,23 +341,22 @@ static int64_t fsp_opal_elog_read(uint64_t *buffer, uint64_t opal_elog_size,
fsp_elog_set_head_state(ELOG_STATE_NONE);
unlock(&elog_read_lock);
-
- /* read error log from FSP */
+ /* Read error log from FSP */
fsp_elog_check_and_fetch_head();
-
return OPAL_SUCCESS;
}
-/* set state of the log head before fetching the log */
+/* Set state of the log head before fetching the log */
static void elog_reject_head(void)
{
if (elog_read_from_fsp_head_state == ELOG_STATE_FETCHING)
fsp_elog_set_head_state(ELOG_STATE_REJECTED);
+
if (elog_read_from_fsp_head_state == ELOG_STATE_FETCHED_DATA)
fsp_elog_set_head_state(ELOG_STATE_NONE);
}
-/* opal Interface for powernv to send ack to fsp with log ID */
+/* OPAL interface for PowerNV to send ack to FSP with log ID */
static int64_t fsp_opal_elog_ack(uint64_t ack_id)
{
int rc = 0;
@@ -373,6 +371,7 @@ static int64_t fsp_opal_elog_ack(uint64_t ack_id)
prerror("ELOG: failed to send acknowledgement: %d\n", rc);
return rc;
}
+
lock(&elog_read_lock);
list_for_each_safe(&elog_read_pending, record, next_record, link) {
if (record->log_id != ack_id)
@@ -380,19 +379,20 @@ static int64_t fsp_opal_elog_ack(uint64_t ack_id)
list_del(&record->link);
list_add(&elog_read_free, &record->link);
}
+
list_for_each_safe(&elog_read_processed, record, next_record, link) {
if (record->log_id != ack_id)
continue;
list_del(&record->link);
list_add(&elog_read_free, &record->link);
}
- unlock(&elog_read_lock);
+ unlock(&elog_read_lock);
return rc;
}
/*
- * once linux kexec's it ask to resend all logs which
+ * Once linux kexec's it ask to resend all logs which
* are not acknowledged from linux
*/
static void fsp_opal_resend_pending_logs(void)
@@ -401,7 +401,6 @@ static void fsp_opal_resend_pending_logs(void)
/* Check if any Sapphire logs are pending */
opal_resend_pending_logs();
-
lock(&elog_read_lock);
/*
* If processed list is not empty add all record from
@@ -416,7 +415,7 @@ static void fsp_opal_resend_pending_logs(void)
/*
* If the current fetched or fetching log doesn't match our
- * new pending list head, then reject it
+ * new pending list head, then reject it.
*/
if (!list_empty(&elog_read_pending)) {
entry = list_top(&elog_read_pending,
@@ -426,12 +425,11 @@ static void fsp_opal_resend_pending_logs(void)
}
unlock(&elog_read_lock);
-
/* Read error log from FSP if needed */
fsp_elog_check_and_fetch_head();
}
-/* fsp elog notify function */
+/* FSP elog notify function */
static bool fsp_elog_msg(uint32_t cmd_sub_mod, struct fsp_msg *msg)
{
int rc = 0;
@@ -439,24 +437,20 @@ static bool fsp_elog_msg(uint32_t cmd_sub_mod, struct fsp_msg *msg)
uint32_t log_id;
uint32_t log_size;
-
if (cmd_sub_mod != FSP_CMD_ERRLOG_NOTIFICATION)
return false;
log_id = msg->data.words[0];
log_size = msg->data.words[1];
-
- printf("ELOG: Notified of log 0x%08x (size: %d)\n",
- log_id, log_size);
-
+ printf("ELOG: Notified of log 0x%08x (size: %d)\n", log_id, log_size);
/* Make sure we don't cross read buffer size */
if (log_size > ELOG_READ_BUFFER_SIZE) {
log_size = ELOG_READ_BUFFER_SIZE;
printf("ELOG: Truncated log (0x%08x) to 0x%x\n",
- log_id, log_size);
+ log_id, log_size);
}
- /* take a lock until we take out the node from elog_read_free */
+ /* Take a lock until we take out the node from elog_read_free */
lock(&elog_read_lock);
if (!list_empty(&elog_read_free)) {
/* Create a new entry in the pending list */
@@ -465,7 +459,6 @@ static bool fsp_elog_msg(uint32_t cmd_sub_mod, struct fsp_msg *msg)
record->log_size = log_size;
list_add_tail(&elog_read_pending, &record->link);
unlock(&elog_read_lock);
-
/* Send response back to FSP for a new elog notify message */
rc = fsp_queue_msg(fsp_mkmsg(FSP_RSP_ERRLOG_NOTIFICATION,
1, log_id), fsp_freemsg);
@@ -473,22 +466,20 @@ static bool fsp_elog_msg(uint32_t cmd_sub_mod, struct fsp_msg *msg)
prerror("ELOG: Failed to queue errlog notification"
" response: %d\n", rc);
- /* read error log from FSP */
+ /* Read error log from FSP */
fsp_elog_check_and_fetch_head();
} else {
printf("ELOG: Log entry 0x%08x discarded\n", log_id);
-
- /* unlock if elog_read_free is empty */
+ /* Unlock if elog_read_free is empty */
unlock(&elog_read_lock);
-
rc = fsp_queue_msg(fsp_mkmsg(FSP_RSP_ERRLOG_NOTIFICATION,
- 1, log_id), fsp_freemsg);
+ 1, log_id), fsp_freemsg);
if (rc)
prerror("ELOG: Failed to queue errlog notification"
" response: %d\n", rc);
/*
- * if list is full with max record then we
+ * If list is full with max record then we
* send discarded by phyp (condition full) ack to FSP.
*
* At some point in the future, we'll get notified again.
@@ -523,13 +514,14 @@ static int init_elog_read_free_list(uint32_t num_entries)
list_add_tail(&elog_read_free, &entry->link);
entry++;
}
+
return 0;
out_err:
return -ENOMEM;
}
-/* fsp elog read init function */
+/* FSP elog read init function */
void fsp_elog_read_init(void)
{
int val = 0;
@@ -546,16 +538,14 @@ void fsp_elog_read_init(void)
/* Map TCEs */
fsp_tce_map(PSI_DMA_ERRLOG_READ_BUF, elog_read_buffer,
PSI_DMA_ERRLOG_READ_BUF_SZ);
-
- /* pre allocate memory for 128 record */
+ /* Pre-allocate memory for 128 record */
val = init_elog_read_free_list(ELOG_READ_MAX_RECORD);
if (val != 0)
return;
- /* register Eror log Class D2 */
+ /* Register Error log Class D2 */
fsp_register_client(&fsp_get_elog_notify, FSP_MCLASS_ERR_LOG);
-
- /* register opal Interface */
+ /* Register OPAL interface */
opal_register(OPAL_ELOG_READ, fsp_opal_elog_read, 3);
opal_register(OPAL_ELOG_ACK, fsp_opal_elog_ack, 1);
opal_register(OPAL_ELOG_RESEND, fsp_opal_resend_pending_logs, 0);
diff --git a/hw/fsp/fsp-elog-write.c b/hw/fsp/fsp-elog-write.c
index ee293f1..6e307a4 100644
--- a/hw/fsp/fsp-elog-write.c
+++ b/hw/fsp/fsp-elog-write.c
@@ -24,23 +24,23 @@
* This is termed as WRITE action to FSP.
*/
-#include <skiboot.h>
-#include <fsp.h>
#include <cpu.h>
-#include <lock.h>
#include <errno.h>
+#include <fsp.h>
#include <fsp-elog.h>
-#include <timebase.h>
+#include <lock.h>
+#include <opal-api.h>
#include <pel.h>
#include <pool.h>
-#include <opal-api.h>
+#include <skiboot.h>
+#include <timebase.h>
static LIST_HEAD(elog_write_to_fsp_pending);
static struct lock elog_write_lock = LOCK_UNLOCKED;
static struct lock elog_panic_write_lock = LOCK_UNLOCKED;
-/* log buffer to WRITE into FSP */
+/* Log buffer to write into FSP */
#define ELOG_WRITE_TO_FSP_BUFFER_SIZE 0x00004000
static void *elog_write_to_fsp_buffer;
@@ -52,7 +52,7 @@ static uint32_t elog_write_retries;
/* Manipulate this only with write_lock held */
static uint32_t elog_plid_fsp_commit = -1;
-/* Need forward declaration because of Circular dependency */
+/* Need forward declaration because of circular dependency */
static int opal_send_elog_to_fsp(void);
static void remove_elog_head_entry(void)
@@ -62,15 +62,17 @@ static void remove_elog_head_entry(void)
lock(&elog_write_lock);
if (!list_empty(&elog_write_to_fsp_pending)) {
head = list_top(&elog_write_to_fsp_pending,
- struct errorlog, link);
+ struct errorlog, link);
if (head->plid == elog_plid_fsp_commit) {
entry = list_pop(&elog_write_to_fsp_pending,
struct errorlog, link);
- opal_elog_complete(entry, elog_write_retries < MAX_RETRIES);
+ opal_elog_complete(entry,
+ elog_write_retries < MAX_RETRIES);
/* Reset the counter */
elog_plid_fsp_commit = -1;
}
}
+
elog_write_retries = 0;
unlock(&elog_write_lock);
}
@@ -81,7 +83,6 @@ static void opal_fsp_write_complete(struct fsp_msg *read_msg)
val = (read_msg->resp->word1 >> 8) & 0xff;
fsp_freemsg(read_msg);
-
switch (val) {
case FSP_STATUS_SUCCESS:
remove_elog_head_entry();
@@ -105,17 +106,19 @@ static int64_t fsp_opal_elog_write(size_t opal_elog_size)
struct fsp_msg *elog_msg;
elog_msg = fsp_mkmsg(FSP_CMD_CREATE_ERRLOG, 3, opal_elog_size,
- 0, PSI_DMA_ERRLOG_WRITE_BUF);
+ 0, PSI_DMA_ERRLOG_WRITE_BUF);
if (!elog_msg) {
prerror("ELOG: Failed to create message for WRITE to FSP\n");
return OPAL_INTERNAL_ERROR;
}
+
if (fsp_queue_msg(elog_msg, opal_fsp_write_complete)) {
fsp_freemsg(elog_msg);
elog_msg = NULL;
prerror("FSP: Error queueing elog update\n");
return OPAL_INTERNAL_ERROR;
}
+
return OPAL_SUCCESS;
}
@@ -134,12 +137,13 @@ static int opal_send_elog_to_fsp(void)
struct errorlog, link);
elog_plid_fsp_commit = head->plid;
head->log_size = create_pel_log(head,
- (char *)elog_write_to_fsp_buffer,
- ELOG_WRITE_TO_FSP_BUFFER_SIZE);
+ (char *)elog_write_to_fsp_buffer,
+ ELOG_WRITE_TO_FSP_BUFFER_SIZE);
rc = fsp_opal_elog_write(head->log_size);
unlock(&elog_write_lock);
return rc;
}
+
unlock(&elog_write_lock);
return rc;
}
@@ -151,15 +155,13 @@ static int opal_push_logs_sync_to_fsp(struct errorlog *buf)
int rc = OPAL_SUCCESS;
lock(&elog_panic_write_lock);
- opal_elog_size = create_pel_log(buf,
- (char *)elog_panic_write_buffer,
- ELOG_PANIC_WRITE_BUFFER_SIZE);
-
+ opal_elog_size = create_pel_log(buf, (char *)elog_panic_write_buffer,
+ ELOG_PANIC_WRITE_BUFFER_SIZE);
elog_msg = fsp_mkmsg(FSP_CMD_CREATE_ERRLOG, 3, opal_elog_size,
- 0, PSI_DMA_ELOG_PANIC_WRITE_BUF);
+ 0, PSI_DMA_ELOG_PANIC_WRITE_BUF);
if (!elog_msg) {
prerror("ELOG: PLID: 0x%x Failed to create message for WRITE "
- "to FSP\n", buf->plid);
+ "to FSP\n", buf->plid);
unlock(&elog_panic_write_lock);
opal_elog_complete(buf, false);
return OPAL_INTERNAL_ERROR;
@@ -172,12 +174,13 @@ static int opal_push_logs_sync_to_fsp(struct errorlog *buf)
rc = (elog_msg->resp->word1 >> 8) & 0xff;
fsp_freemsg(elog_msg);
}
- unlock(&elog_panic_write_lock);
+ unlock(&elog_panic_write_lock);
if (rc != OPAL_SUCCESS)
opal_elog_complete(buf, false);
else
opal_elog_complete(buf, true);
+
return rc;
}
@@ -192,7 +195,6 @@ int elog_fsp_commit(struct errorlog *buf)
/* Error needs to be committed, update the time out value */
buf->elog_timeout = get_elog_timeout();
-
if (buf->event_severity == OPAL_ERROR_PANIC) {
rc = opal_push_logs_sync_to_fsp(buf);
return rc;
@@ -205,6 +207,7 @@ int elog_fsp_commit(struct errorlog *buf)
rc = opal_send_elog_to_fsp();
return rc;
}
+
list_add_tail(&elog_write_to_fsp_pending, &buf->link);
unlock(&elog_write_lock);
return rc;
@@ -219,36 +222,35 @@ static void elog_timeout_poll(void *data __unused)
if (list_empty(&elog_write_to_fsp_pending)) {
unlock(&elog_write_lock);
return;
- } else {
- head = list_top(&elog_write_to_fsp_pending,
- struct errorlog, link);
- now = mftb();
- if ((tb_compare(now, head->elog_timeout) == TB_AAFTERB) ||
- (tb_compare(now, head->elog_timeout) == TB_AEQUALB)) {
- entry = list_pop(&elog_write_to_fsp_pending,
- struct errorlog, link);
- unlock(&elog_write_lock);
- elog_append_write_to_host(entry);
- } else
- unlock(&elog_write_lock);
}
+
+ head = list_top(&elog_write_to_fsp_pending, struct errorlog, link);
+ now = mftb();
+ if ((tb_compare(now, head->elog_timeout) == TB_AAFTERB) ||
+ (tb_compare(now, head->elog_timeout) == TB_AEQUALB)) {
+ entry = list_pop(&elog_write_to_fsp_pending, struct errorlog,
+ link);
+ unlock(&elog_write_lock);
+ elog_append_write_to_host(entry);
+ } else
+ unlock(&elog_write_lock);
}
-/* fsp elog init function */
+/* FSP elog init function */
void fsp_elog_write_init(void)
{
if (!fsp_present())
return;
elog_panic_write_buffer = memalign(TCE_PSIZE,
- ELOG_PANIC_WRITE_BUFFER_SIZE);
+ ELOG_PANIC_WRITE_BUFFER_SIZE);
if (!elog_panic_write_buffer) {
prerror("FSP: could not allocate ELOG_PANIC_WRITE_BUFFER!\n");
return;
}
elog_write_to_fsp_buffer = memalign(TCE_PSIZE,
- ELOG_WRITE_TO_FSP_BUFFER_SIZE);
+ ELOG_WRITE_TO_FSP_BUFFER_SIZE);
if (!elog_write_to_fsp_buffer) {
prerror("FSP: could not allocate ELOG_WRITE_BUFFER!\n");
return;
@@ -257,10 +259,8 @@ void fsp_elog_write_init(void)
/* Map TCEs */
fsp_tce_map(PSI_DMA_ELOG_PANIC_WRITE_BUF, elog_panic_write_buffer,
PSI_DMA_ELOG_PANIC_WRITE_BUF_SZ);
-
fsp_tce_map(PSI_DMA_ERRLOG_WRITE_BUF, elog_write_to_fsp_buffer,
PSI_DMA_ERRLOG_WRITE_BUF_SZ);
-
/* Add a poller */
opal_add_poller(elog_timeout_poll, NULL);
}
--
2.1.4
More information about the Skiboot
mailing list