[Skiboot] [PATCH 2/7] opal: Introduce opal_del_host_sync_notifier_with_data()

Vaibhav Jain vaibhav at linux.ibm.com
Sun Sep 16 00:39:21 AEST 2018


Current implementation of opal_del_host_sync_notifier() will only
delete the first entry of the 'notify' callback found from opal_syners
list irrespective of the 'data' of list-node. This is problematic when
multiple notifiers with same callback function but different 'data'
are registered. In this case when the cleanup code will call
opal_del_host_sync_notifier() it cannot be sure if correct opal_syncer
is removed.

Hence we introduce a new function named
opal_del_host_sync_notifier_with_data() that iterates over the
opal_syncers list and only removes the first node node having the
matching value for 'notify' callback and 'data'.

Signed-off-by: Vaibhav Jain <vaibhav at linux.ibm.com>
---
 core/opal.c             | 18 ++++++++++++++++++
 include/opal-internal.h |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/core/opal.c b/core/opal.c
index 63a08510..4a3b4a61 100644
--- a/core/opal.c
+++ b/core/opal.c
@@ -687,6 +687,24 @@ void opal_del_host_sync_notifier(bool (*notify)(void *data))
 	}
 }
 
+
+/*
+ * Remove a host sync notifier for given callback and data
+ */
+void opal_del_host_sync_notifier_with_data(bool (*notify)(void *data),
+					   void *data)
+{
+	struct opal_sync_entry *ent;
+
+	list_for_each(&opal_syncers, ent, link) {
+		if (ent->notify == notify && ent->data == data) {
+			list_del(&ent->link);
+			free(ent);
+			return;
+		}
+	}
+}
+
 /*
  * OPAL call to handle host kexec'ing scenario
  */
diff --git a/include/opal-internal.h b/include/opal-internal.h
index 40bad457..4ed62997 100644
--- a/include/opal-internal.h
+++ b/include/opal-internal.h
@@ -77,6 +77,8 @@ extern void opal_run_pollers(void);
  */
 extern void opal_add_host_sync_notifier(bool (*notify)(void *data), void *data);
 extern void opal_del_host_sync_notifier(bool (*notify)(void *data));
+extern void opal_del_host_sync_notifier_with_data(bool (*notify)(void *data),
+					   void *data);
 
 /*
  * Opal internal function prototype
-- 
2.17.1



More information about the Skiboot mailing list