mirror of https://github.com/thesofproject/sof.git
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:
parent
af6655e7fa
commit
e3f8464dc9
|
@ -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 {
|
||||
|
|
|
@ -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(¬ify->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, ¬ify->list[type]);
|
||||
|
||||
out:
|
||||
irq_local_enable(irq_flags);
|
||||
|
||||
spin_unlock(¬ify->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(¬ify->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(¬ify->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]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue