[HDAUDBUS] Add a timeout into HDA_SendVerbs
authorVictor Perevertkin <victor.perevertkin@reactos.org>
Tue, 3 Nov 2020 20:18:14 +0000 (23:18 +0300)
committerVictor Perevertkin <victor.perevertkin@reactos.org>
Tue, 3 Nov 2020 20:18:14 +0000 (23:18 +0300)
This function may stuck during device installation if there are issues
with interrupts (or with a device itself).

This fixes the boot on my testing ThinkPad x60s

drivers/wdm/audio/hdaudbus/fdo.cpp

index a600c64..2cb977e 100644 (file)
@@ -176,11 +176,20 @@ HDA_SendVerbs(
 
     while (Queued--)
     {
-        KeWaitForSingleObject(&Codec->ResponseSemaphore,
-                              Executive,
-                              KernelMode,
-                              FALSE,
-                              NULL);
+        LARGE_INTEGER Timeout;
+        Timeout.QuadPart = -1000LL * 10000; // 1 sec
+
+        NTSTATUS waitStatus = KeWaitForSingleObject(&Codec->ResponseSemaphore,
+                                                    Executive,
+                                                    KernelMode,
+                                                    FALSE,
+                                                    &Timeout);
+
+        if (waitStatus == STATUS_TIMEOUT)
+        {
+            DPRINT1("HDA_SendVerbs: timeout! Queued: %u\n", Queued);
+            break;
+        }
     }
 
     if (Responses != NULL) {