Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153145848
D5121.id12833.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D5121.id12833.diff
View Options
Index: sys/arm64/arm64/intr_machdep.c
===================================================================
--- sys/arm64/arm64/intr_machdep.c
+++ sys/arm64/arm64/intr_machdep.c
@@ -105,7 +105,7 @@
intr_init(void *dummy __unused)
{
- mtx_init(&intr_list_lock, "intr sources lock", NULL, MTX_DEF);
+ mtx_init(&intr_list_lock, "intr sources lock", NULL, MTX_SPIN);
}
SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL);
@@ -123,33 +123,44 @@
}
/*
+ * Find the interrupt descriptor in the list
+ * based on the hardware IRQ number.
+ */
+static __inline struct arm64_intr_entry *
+intr_lookup_locked(u_int hw_irq)
+{
+ struct arm64_intr_entry *intr;
+
+ mtx_assert(&intr_list_lock, MA_OWNED);
+ SLIST_FOREACH(intr, &irq_slist_head, entries) {
+ if (intr->i_hw_irq == hw_irq)
+ return (intr);
+ }
+ return (NULL);
+}
+/*
* Get intr structure for the given interrupt number.
* Allocate one if this is the first time.
- * (Similar to ppc's intr_lookup() but without actual
- * lookup since irq number is an index in arm64_intrs[]).
*/
static struct arm64_intr_entry *
-intr_acquire(u_int hw_irq)
+intr_allocate(u_int hw_irq)
{
struct arm64_intr_entry *intr;
- mtx_lock(&intr_list_lock);
-
- SLIST_FOREACH(intr, &irq_slist_head, entries) {
- if (intr->i_hw_irq == hw_irq) {
- break;
- }
- }
+ /* Check if already allocated */
+ mtx_lock_spin(&intr_list_lock);
+ intr = intr_lookup_locked(hw_irq);
+ mtx_unlock_spin(&intr_list_lock);
if (intr != NULL)
- goto out;
+ return (intr);
/* Do not alloc another intr when max number of IRQs has been reached */
if (intrcntidx >= NIRQS)
- goto out;
+ return (NULL);
intr = malloc(sizeof(*intr), M_INTR, M_NOWAIT);
if (intr == NULL)
- goto out;
+ return (NULL);
intr->i_event = NULL;
intr->i_handlers = 0;
@@ -158,9 +169,10 @@
intr->i_cntidx = atomic_fetchadd_int(&intrcntidx, 1);
intr->i_cntp = &intrcnt[intr->i_cntidx];
intr->i_hw_irq = hw_irq;
+ mtx_lock_spin(&intr_list_lock);
SLIST_INSERT_HEAD(&irq_slist_head, intr, entries);
-out:
- mtx_unlock(&intr_list_lock);
+ mtx_unlock_spin(&intr_list_lock);
+
return intr;
}
@@ -312,7 +324,7 @@
struct arm64_intr_entry *intr;
int error;
- intr = intr_acquire(hw_irq);
+ intr = intr_allocate(hw_irq);
if (intr == NULL)
return (ENOMEM);
@@ -336,7 +348,7 @@
intr_priority(flags), flags, cookiep);
if (!error) {
- mtx_lock(&intr_list_lock);
+ mtx_lock_spin(&intr_list_lock);
intrcnt_setname(intr->i_event->ie_fullname, intr->i_cntidx);
intr->i_handlers++;
@@ -349,7 +361,7 @@
PIC_UNMASK(root_pic, intr->i_hw_irq);
}
- mtx_unlock(&intr_list_lock);
+ mtx_unlock_spin(&intr_list_lock);
}
return (error);
@@ -364,12 +376,12 @@
intr = intr_handler_source(cookie);
error = intr_event_remove_handler(cookie);
if (!error) {
- mtx_lock(&intr_list_lock);
+ mtx_lock_spin(&intr_list_lock);
intr->i_handlers--;
if (intr->i_handlers == 0)
PIC_MASK(root_pic, intr->i_hw_irq);
intrcnt_setname(intr->i_event->ie_fullname, intr->i_cntidx);
- mtx_unlock(&intr_list_lock);
+ mtx_unlock_spin(&intr_list_lock);
}
return (error);
@@ -380,9 +392,11 @@
{
struct arm64_intr_entry *intr;
- intr = intr_acquire(hw_irq);
+ mtx_lock_spin(&intr_list_lock);
+ intr = intr_lookup_locked(hw_irq);
+ mtx_unlock_spin(&intr_list_lock);
if (intr == NULL)
- return (ENOMEM);
+ return (EINVAL);
intr->i_trig = trig;
intr->i_pol = pol;
@@ -398,12 +412,9 @@
{
struct arm64_intr_entry *intr;
- SLIST_FOREACH(intr, &irq_slist_head, entries) {
- if (intr->i_hw_irq == hw_irq) {
- break;
- }
- }
-
+ mtx_lock_spin(&intr_list_lock);
+ intr = intr_lookup_locked(hw_irq);
+ mtx_unlock_spin(&intr_list_lock);
if (intr == NULL)
goto stray;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 20, 11:29 AM (4 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31836284
Default Alt Text
D5121.id12833.diff (3 KB)
Attached To
Mode
D5121: Fix bugs in interrupts allocation on ARM64
Attached
Detach File
Event Timeline
Log In to Comment