[Skiboot] [PATCH 14/15] FSP/SYSPARAM: Introduce update notify system parameter notifier

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Fri Mar 20 23:10:48 AEDT 2015


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 <hegdevasant at linux.vnet.ibm.com>
---
 hw/fsp/fsp-sysparam.c  |   53 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/fsp-sysparam.h |    4 ++++
 2 files changed, 57 insertions(+)

diff --git a/hw/fsp/fsp-sysparam.c b/hw/fsp/fsp-sysparam.c
index bd77a1f..74ad5c8 100644
--- a/hw/fsp/fsp-sysparam.c
+++ b/hw/fsp/fsp-sysparam.c
@@ -63,6 +63,14 @@ static struct sysparam_attr {
 #undef _RW
 };
 
+struct sysparam_update_entry {
+	struct	list_node	link;
+	uint32_t		param_id;
+	sysparam_compl_t	notify;
+};
+
+static LIST_HEAD(sysparam_update_notifiers);
+
 static int fsp_sysparam_process(struct sysparam_req *r)
 {
 	u32 param_id, len;
@@ -347,6 +355,48 @@ static int64_t fsp_opal_set_param(uint64_t async_token, uint32_t param_id,
 	return OPAL_ASYNC_COMPLETION;
 }
 
+/* Add client to notifier chain */
+void sysparam_add_update_notifier(sysparam_compl_t notify, uint32_t param_id)
+{
+	struct sysparam_update_entry *entry;
+
+	entry = zalloc(sizeof(struct sysparam_update_entry));
+	assert(entry);
+
+	entry->notify = notify;
+	entry->param_id = param_id;
+	list_add_tail(&sysparam_update_notifiers, &entry->link);
+}
+
+/* Remove client from notifier chain */
+void sysparam_del_update_notifier(sysparam_compl_t notify)
+{
+	struct sysparam_update_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)
+{
+	struct sysparam_update_entry *entry;
+
+	list_for_each(&sysparam_update_notifiers, entry, link) {
+		if (entry->param_id != msg->data.words[0])
+			continue;
+
+		entry->notify(msg->data.words[0],
+			      msg->data.words[1] & 0xffff,
+			      &msg->data.words[2]);
+	}
+}
+
 static bool fsp_sysparam_msg(u32 cmd_sub_mod, struct fsp_msg *msg)
 {
 	struct fsp_msg *rsp;
@@ -357,6 +407,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..899e772 100644
--- a/include/fsp-sysparam.h
+++ b/include/fsp-sysparam.h
@@ -55,4 +55,8 @@ int fsp_get_sys_param(uint32_t param_id, void *buffer, uint32_t length,
 
 void fsp_sysparam_init(void);
 
+/* Register/unregister for system parameter update notifier chain */
+void sysparam_add_update_notifier(sysparam_compl_t notify, uint32_t param_id);
+void sysparam_del_update_notifier(sysparam_compl_t notify);
+
 #endif /*  __FSP_SYSPARAM_H */



More information about the Skiboot mailing list