notifier: no need to disable IRQs during registration

Use a spinlock for locking the list instead.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
This commit is contained in:
Liam Girdwood 2021-06-14 14:54:13 +01:00 committed by Liam Girdwood
parent af6655e7fa
commit e3f8464dc9
2 changed files with 7 additions and 7 deletions

View File

@ -10,6 +10,7 @@
#include <sof/bit.h>
#include <sof/list.h>
#include <sof/spinlock.h>
#include <sof/sof.h>
#include <stdint.h>
@ -38,6 +39,7 @@ enum notify_id {
struct notify {
struct list_item list[NOTIFIER_ID_COUNT]; /* list of callback handles */
spinlock_t lock; /* list lock */
};
struct notify_data {

View File

@ -41,12 +41,11 @@ int notifier_register(void *receiver, void *caller, enum notify_id type,
{
struct notify *notify = *arch_notify_get();
struct callback_handle *handle;
uint32_t irq_flags;
int ret = 0;
assert(type >= NOTIFIER_ID_CPU_FREQ && type < NOTIFIER_ID_COUNT);
irq_local_disable(irq_flags);
spin_lock(&notify->lock);
/* Find already registered event of this type */
if (flags & NOTIFIER_FLAG_AGGREGATE &&
@ -75,8 +74,7 @@ int notifier_register(void *receiver, void *caller, enum notify_id type,
list_item_prepend(&handle->list, &notify->list[type]);
out:
irq_local_enable(irq_flags);
spin_unlock(&notify->lock);
return ret;
}
@ -86,11 +84,10 @@ void notifier_unregister(void *receiver, void *caller, enum notify_id type)
struct list_item *wlist;
struct list_item *tlist;
struct callback_handle *handle;
uint32_t flags;
assert(type >= NOTIFIER_ID_CPU_FREQ && type < NOTIFIER_ID_COUNT);
irq_local_disable(flags);
spin_lock(&notify->lock);
/*
* Unregister all matching callbacks
@ -113,7 +110,7 @@ void notifier_unregister(void *receiver, void *caller, enum notify_id type)
}
}
irq_local_enable(flags);
spin_unlock(&notify->lock);
}
void notifier_unregister_all(void *receiver, void *caller)
@ -195,6 +192,7 @@ void init_system_notify(struct sof *sof)
*notify = rzalloc(SOF_MEM_ZONE_SYS, 0, SOF_MEM_CAPS_RAM,
sizeof(**notify));
spinlock_init(&(*notify)->lock);
for (i = NOTIFIER_ID_CPU_FREQ; i < NOTIFIER_ID_COUNT; i++)
list_init(&(*notify)->list[i]);