Date: Wed, 18 Nov 2015 18:09:49 +0000 (UTC) From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= <royger@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291022 - head/sys/x86/x86 Message-ID: <201511181809.tAII9nHD009905@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: royger Date: Wed Nov 18 18:09:49 2015 New Revision: 291022 URL: https://svnweb.freebsd.org/changeset/base/291022 Log: 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 Modified: head/sys/x86/x86/intr_machdep.c Modified: head/sys/x86/x86/intr_machdep.c ============================================================================== --- head/sys/x86/x86/intr_machdep.c Wed Nov 18 17:52:38 2015 (r291021) +++ head/sys/x86/x86/intr_machdep.c Wed Nov 18 18:09:49 2015 (r291022) @@ -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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511181809.tAII9nHD009905>