Author: royger
Date: Wed Dec  2 10:23:54 2015
New Revision: 291644
URL: https://svnweb.freebsd.org/changeset/base/291644

Log:
  MFC r291022:
  
  x86/intr: allow mutex recursion in intr_remove_handler
  
  Sponsored by:         Citrix Systems R&D

Modified:
  stable/10/sys/x86/x86/intr_machdep.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/x86/x86/intr_machdep.c
==============================================================================
--- stable/10/sys/x86/x86/intr_machdep.c        Wed Dec  2 08:17:31 2015        
(r291643)
+++ stable/10/sys/x86/x86/intr_machdep.c        Wed Dec  2 10:23:54 2015        
(r291644)
@@ -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);
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to