]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IOInterruptController.cpp
xnu-344.26.tar.gz
[apple/xnu.git] / iokit / Kernel / IOInterruptController.cpp
index c41df7e8cc5accd57960e7dd0a33f355f8e93ee1..bd3baa04db7b7bee1065f6d56543537177d2aa28 100644 (file)
@@ -244,7 +244,17 @@ IOReturn IOInterruptController::enableInterrupt(IOService *nub, int source)
   
   if (vector->interruptDisabledSoft) {
     vector->interruptDisabledSoft = 0;
+#if __ppc__
+    sync();
+    isync();
+#endif
     
+    if (!getPlatform()->atInterruptLevel()) {
+      while (vector->interruptActive);
+#if __ppc__
+      isync();
+#endif
+    }
     if (vector->interruptDisabledHard) {
       vector->interruptDisabledHard = 0;
       
@@ -546,24 +556,26 @@ IOReturn IOSharedInterruptController::enableInterrupt(IOService *nub,
   long              vectorNumber;
   IOInterruptVector *vector;
   OSData            *vectorData;
-  IOInterruptState  interruptState;;
+  IOInterruptState  interruptState;
   
   interruptSources = nub->_interruptSources;
   vectorData = interruptSources[source].vectorData;
   vectorNumber = *(long *)vectorData->getBytesNoCopy();
   vector = &vectors[vectorNumber];
   
-  if (vector->interruptDisabledSoft) {
-    vector->interruptDisabledSoft = 0;
-    
-    interruptState = IOSimpleLockLockDisableInterrupt(controllerLock);
-    vectorsEnabled++;
+  interruptState = IOSimpleLockLockDisableInterrupt(controllerLock);
+  if (!vector->interruptDisabledSoft) {
     IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
-    
-    if (controllerDisabled && (vectorsEnabled == vectorsRegistered)) {
-      controllerDisabled = 0;
-      provider->enableInterrupt(0);
-    }
+    return kIOReturnSuccess;
+  }
+  
+  vector->interruptDisabledSoft = 0;
+  vectorsEnabled++;
+  IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
+  
+  if (controllerDisabled && (vectorsEnabled == vectorsRegistered)) {
+    controllerDisabled = 0;
+    provider->enableInterrupt(0);
   }
   
   return kIOReturnSuccess;
@@ -576,24 +588,23 @@ IOReturn IOSharedInterruptController::disableInterrupt(IOService *nub,
   long              vectorNumber;
   IOInterruptVector *vector;
   OSData            *vectorData;
-  IOInterruptState  interruptState;;
+  IOInterruptState  interruptState;
   
   interruptSources = nub->_interruptSources;
   vectorData = interruptSources[source].vectorData;
   vectorNumber = *(long *)vectorData->getBytesNoCopy();
   vector = &vectors[vectorNumber];
   
+  interruptState = IOSimpleLockLockDisableInterrupt(controllerLock); 
   if (!vector->interruptDisabledSoft) {
     vector->interruptDisabledSoft = 1;
 #if __ppc__
     sync();
     isync();
 #endif
-    
-    interruptState = IOSimpleLockLockDisableInterrupt(controllerLock); 
     vectorsEnabled--;
-    IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
   }
+  IOSimpleLockUnlockEnableInterrupt(controllerLock, interruptState);
   
   if (!getPlatform()->atInterruptLevel()) {
     while (vector->interruptActive);