diff options
author | Roger Pau Monné <royger@FreeBSD.org> | 2015-11-18 18:09:49 +0000 |
---|---|---|
committer | Roger Pau Monné <royger@FreeBSD.org> | 2015-11-18 18:09:49 +0000 |
commit | 531cfe55e20ccf3999ab87feed1c931615ddbf27 (patch) | |
tree | 9b19d1d64b501dd98a60e4b55f6c97d41e8c8178 /sys/x86 | |
parent | 6f42d16f4353041e1a4b2851bdc14a329fef76f4 (diff) | |
download | src-531cfe55e20ccf3999ab87feed1c931615ddbf27.tar.gz src-531cfe55e20ccf3999ab87feed1c931615ddbf27.zip |
x86/intr: allow mutex recursion in intr_remove_handler
This is needed so interrupt handlers can be removed while the PIC is
resuming, it was previously not possible due to intr_resume holding the
intr_table_lock and intr_remove_handler recursing on it.
Sponsored by: Citrix Systems R&D
Reviewed by: kib (previous version)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D4114
Notes
Notes:
svn path=/head/; revision=291022
Diffstat (limited to 'sys/x86')
-rw-r--r-- | sys/x86/x86/intr_machdep.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sys/x86/x86/intr_machdep.c b/sys/x86/x86/intr_machdep.c index d81c9132dd8c..35ec99253be4 100644 --- a/sys/x86/x86/intr_machdep.c +++ b/sys/x86/x86/intr_machdep.c @@ -197,19 +197,28 @@ int intr_remove_handler(void *cookie) { struct intsrc *isrc; - int error; + int error, mtx_owned; isrc = intr_handler_source(cookie); error = intr_event_remove_handler(cookie); if (error == 0) { - mtx_lock(&intr_table_lock); + /* + * Recursion is needed here so PICs can remove interrupts + * while resuming. It was previously not possible due to + * intr_resume holding the intr_table_lock and + * intr_remove_handler recursing on it. + */ + mtx_owned = mtx_owned(&intr_table_lock); + if (mtx_owned == 0) + mtx_lock(&intr_table_lock); isrc->is_handlers--; if (isrc->is_handlers == 0) { isrc->is_pic->pic_disable_source(isrc, PIC_NO_EOI); isrc->is_pic->pic_disable_intr(isrc); } intrcnt_updatename(isrc); - mtx_unlock(&intr_table_lock); + if (mtx_owned == 0) + mtx_unlock(&intr_table_lock); } return (error); } |