From patchwork Thu Feb 5 08:40:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 436685 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 A5AC2140276 for ; Thu, 5 Feb 2015 19:40:45 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 94B221A0EE4 for ; Thu, 5 Feb 2015 19:40:45 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e28smtp04.in.ibm.com (e28smtp04.in.ibm.com [122.248.162.4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4A5761A0E36 for ; Thu, 5 Feb 2015 19:40:41 +1100 (AEDT) Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Feb 2015 14:10:39 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp04.in.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Feb 2015 14:10:36 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 02468E0045 for ; Thu, 5 Feb 2015 14:12:05 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay01.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t158eath21364744 for ; Thu, 5 Feb 2015 14:10:36 +0530 Received: from d28av01.in.ibm.com (localhost [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t158eZvg030574 for ; Thu, 5 Feb 2015 14:10:35 +0530 Received: from localhost.localdomain ([9.124.35.64]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t158eZOc030568 for ; Thu, 5 Feb 2015 14:10:35 +0530 From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 05 Feb 2015 14:10:35 +0530 Message-ID: <20150205084035.12859.8726.stgit@localhost.localdomain> In-Reply-To: <20150205083611.12859.41225.stgit@localhost.localdomain> References: <20150205083611.12859.41225.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15020508-0013-0000-0000-000003A5D436 Subject: [Skiboot] [PATCH 13/22] FSP/LEDS: Track LED list read status 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" We are going to expose LED list to host via device tree. We want to make sure 'query LED list' MBOX command is completed before populating the device tree. fsp_led_init initiates async MBOX command to retrieve list of LEDs. And towards the end of OPAL init path we will come back to LED driver and populate device tree. We can reuse existing led_support variable to check the status before populating device tree. But this doesn't guarantee that LED list read request is completed. Hence modify led_support to have multiple state. Signed-off-by: Vasant Hegde --- hw/fsp/fsp-leds.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c index 127b58a..2ac9723 100644 --- a/hw/fsp/fsp-leds.c +++ b/hw/fsp/fsp-leds.c @@ -38,8 +38,14 @@ /* SPCN replay threshold */ #define SPCN_REPLAY_THRESHOLD 2 -/* Sapphire LED support */ -static bool led_support; +/* LED support status */ +enum led_support_state { + LED_STATE_ABSENT, + LED_STATE_READING, + LED_STATE_PRESENT, +}; + +enum led_support_state led_support = LED_STATE_ABSENT; /* * PSI mapped buffer for LED data @@ -850,7 +856,7 @@ static bool fsp_indicator_message(u32 cmd_sub_mod, struct fsp_msg *msg) struct fsp_msg *resp; /* LED support not available yet */ - if (!led_support) { + if (led_support != LED_STATE_PRESENT) { log_simple_error(&e_info(OPAL_RC_LED_SUPPORT), PREFIX "Indicator message while LED support not" " available yet\n"); @@ -1041,11 +1047,12 @@ static void fsp_process_leds_data(u16 len) static void replay_spcn_cmd(u32 last_spcn_cmd) { u32 cmd_hdr = 0; - int rc = 0; + int rc = -1; /* Reached threshold */ if (replay == SPCN_REPLAY_THRESHOLD) { replay = 0; + led_support = LED_STATE_ABSENT; return; } @@ -1075,6 +1082,10 @@ static void replay_spcn_cmd(u32 last_spcn_cmd) "Replay SPCN_MOD_PRS_LED_DATA_SUB" " command could not be queued\n"); } + + /* Failed to queue MBOX message */ + if (rc) + led_support = LED_STATE_ABSENT; } /* @@ -1105,7 +1116,7 @@ static void fsp_read_leds_data_complete(struct fsp_msg *msg) PREFIX "FSP returned error %x LED not supported\n", msg_status); /* LED support not available */ - led_support = false; + led_support = LED_STATE_ABSENT; fsp_freemsg(msg); return; @@ -1119,9 +1130,10 @@ static void fsp_read_leds_data_complete(struct fsp_msg *msg) "SPCN_RSP_STATUS_SUCCESS: %d bytes received\n", data_len); + led_support = LED_STATE_PRESENT; + /* Copy data to the local list */ fsp_process_leds_data(data_len); - led_support = true; /* LEDs captured on the system */ prlog(PR_DEBUG, PREFIX @@ -1173,9 +1185,12 @@ static void fsp_read_leds_data_complete(struct fsp_msg *msg) SPCN_ADDR_MODE_CEC_NODE, cmd_hdr, 0, PSI_DMA_LED_BUF), fsp_read_leds_data_complete); - if (rc) + if (rc) { prlog(PR_ERR, PREFIX "SPCN_MOD_PRS_LED_DATA_SUB command" " could not be queued\n"); + + led_support = LED_STATE_ABSENT; + } break; /* Other expected error codes*/ @@ -1184,6 +1199,7 @@ static void fsp_read_leds_data_complete(struct fsp_msg *msg) case SPCN_RSP_STATUS_INVALID_MOD: case SPCN_RSP_STATUS_STATE_PROHIBIT: case SPCN_RSP_STATUS_UNKNOWN: + default: /* Replay the previous SPCN command */ replay_spcn_cmd(last_spcn_cmd); } @@ -1211,7 +1227,6 @@ static void fsp_leds_query_spcn(void) u32 cmd_hdr = SPCN_MOD_PRS_LED_DATA_FIRST << 24 | SPCN_CMD_PRS << 16; /* Till the last batch of LED data */ - led_support = false; last_spcn_cmd = 0; /* Empty the lists */ @@ -1244,6 +1259,8 @@ static void fsp_leds_query_spcn(void) prlog(PR_ERR, PREFIX "SPCN_MOD_PRS_LED_DATA_FIRST command could" " not be queued\n"); + else /* Initiated LED list fetch MBOX command */ + led_support = LED_STATE_READING; } /* Init the LED subsystem at boot time */