From patchwork Mon Apr 6 07:06:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 458334 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 73C94140142 for ; Mon, 6 Apr 2015 17:07:58 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 5A1341A084B for ; Mon, 6 Apr 2015 17:07:58 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 7835F1A030F for ; Mon, 6 Apr 2015 17:07:55 +1000 (AEST) Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 6 Apr 2015 17:07:55 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 6 Apr 2015 17:07:53 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 5D6B62BB0052 for ; Mon, 6 Apr 2015 17:07:53 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t3677jmD33816664 for ; Mon, 6 Apr 2015 17:07:53 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t3677Ksl002738 for ; Mon, 6 Apr 2015 17:07:20 +1000 Received: from localhost.localdomain ([9.124.35.90]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t3677Jen002545 for ; Mon, 6 Apr 2015 17:07:19 +1000 From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Mon, 06 Apr 2015 12:36:59 +0530 Message-ID: <20150406070650.10986.44325.stgit@localhost.localdomain> In-Reply-To: <20150406065920.10986.50507.stgit@localhost.localdomain> References: <20150406065920.10986.50507.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: 15040607-0021-0000-0000-000001083C55 Subject: [Skiboot] [PATCH 11/12] FSP/SYSPARAM: Introduce update notify system parameter notifier 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" FSP sends update system parameter notification asynchronously. Presently no one is using this notification. We just ACK this notification. This patch adds notifier chain so that if someone (like LED) is interested in this notification, they can register and get notification. Signed-off-by: Vasant Hegde Changes in v2: - Updated notifier function so that we can pass fsp_msg structure to clients. --- hw/fsp/fsp-sysparam.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ include/fsp-sysparam.h | 12 ++++++++++++ 2 files changed, 61 insertions(+) diff --git a/hw/fsp/fsp-sysparam.c b/hw/fsp/fsp-sysparam.c index a59c329..2dbf05c 100644 --- a/hw/fsp/fsp-sysparam.c +++ b/hw/fsp/fsp-sysparam.c @@ -346,6 +346,52 @@ static int64_t fsp_opal_set_param(uint64_t async_token, uint32_t param_id, return OPAL_ASYNC_COMPLETION; } +struct sysparam_notify_entry { + struct list_node link; + sysparam_update_notify notify; +}; + +static LIST_HEAD(sysparam_update_notifiers); + +/* Add client to notifier chain */ +void sysparam_add_update_notifier(sysparam_update_notify notify) +{ + struct sysparam_notify_entry *entry; + + entry = zalloc(sizeof(struct sysparam_notify_entry)); + assert(entry); + + entry->notify = notify; + list_add_tail(&sysparam_update_notifiers, &entry->link); +} + +/* Remove client from notifier chain */ +void sysparam_del_update_notifier(sysparam_update_notify notify) +{ + struct sysparam_notify_entry *entry; + + list_for_each(&sysparam_update_notifiers, entry, link) { + if (entry->notify == notify) { + list_del(&entry->link); + free(entry); + return; + } + } +} + +/* Update notification chain */ +static void sysparam_run_update_notifier(struct fsp_msg *msg) +{ + bool ret; + struct sysparam_notify_entry *entry; + + list_for_each(&sysparam_update_notifiers, entry, link) { + ret = entry->notify(msg); + if (ret == true) + break; + } +} + static bool fsp_sysparam_msg(u32 cmd_sub_mod, struct fsp_msg *msg) { struct fsp_msg *rsp; @@ -356,6 +402,9 @@ static bool fsp_sysparam_msg(u32 cmd_sub_mod, struct fsp_msg *msg) case FSP_CMD_SP_SPARM_UPD_1: printf("FSP: Got sysparam update, param ID 0x%x\n", msg->data.words[0]); + + sysparam_run_update_notifier(msg); + rsp = fsp_mkmsg((cmd_sub_mod & 0xffff00) | 0x008000, 0); if (rsp) rc = fsp_queue_msg(rsp, fsp_freemsg); diff --git a/include/fsp-sysparam.h b/include/fsp-sysparam.h index ca95936..731a372 100644 --- a/include/fsp-sysparam.h +++ b/include/fsp-sysparam.h @@ -55,4 +55,16 @@ int fsp_get_sys_param(uint32_t param_id, void *buffer, uint32_t length, void fsp_sysparam_init(void); +/* + * System parameter update notification. + * param_id : parameter id + * len : length of data + * data : pointer to data + */ +typedef bool (*sysparam_update_notify)(struct fsp_msg *msg); + +/* Register/unregister for system parameter update notifier chain */ +void sysparam_add_update_notifier(sysparam_update_notify notify); +void sysparam_del_update_notifier(sysparam_update_notify notify); + #endif /* __FSP_SYSPARAM_H */