[USBEHCI]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Mon, 23 Jan 2012 15:49:43 +0000 (15:49 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Mon, 23 Jan 2012 15:49:43 +0000 (15:49 +0000)
- Use the same lock in the IUSBQueue as in the IDMAMemoryManager
- add debug traces (default off)

svn path=/branches/usb-bringup-trunk/; revision=55110

drivers/usb/usbehci_new/hardware.cpp
drivers/usb/usbehci_new/hub_controller.cpp
drivers/usb/usbehci_new/memory_manager.cpp
drivers/usb/usbehci_new/usb_device.cpp
drivers/usb/usbehci_new/usb_queue.cpp

index c62e81b..10a599c 100644 (file)
@@ -438,7 +438,7 @@ CUSBHardwareDevice::PnpStart(
     //
     // Initialize the UsbQueue now that we have an AdapterObject.
     //
-    Status = m_UsbQueue->Initialize(PUSBHARDWAREDEVICE(this), m_Adapter, m_MemoryManager, NULL);
+    Status = m_UsbQueue->Initialize(PUSBHARDWAREDEVICE(this), m_Adapter, m_MemoryManager, &m_Lock);
     if (!NT_SUCCESS(Status))
     {
         DPRINT1("Failed to Initialize the UsbQueue\n");
@@ -934,7 +934,9 @@ CUSBHardwareDevice::AcquireDeviceLock(void)
     //
     // acquire lock
     //
+    DPRINT(__FUNCTION__ " acquire\n");
     KeAcquireSpinLock(&m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquired\n");
 
     //
     // return old irql
@@ -947,6 +949,7 @@ VOID
 CUSBHardwareDevice::ReleaseDeviceLock(
     KIRQL OldLevel)
 {
+    DPRINT(__FUNCTION__ "release\n");
     KeReleaseSpinLock(&m_Lock, OldLevel);
 }
 
index 5d8e845..4e071d1 100644 (file)
@@ -1861,7 +1861,9 @@ CHubController::AcquireDeviceAddress()
     //
     // acquire device lock
     //
+    DPRINT(__FUNCTION__ " acquire\n");
     KeAcquireSpinLock(&m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquired\n");
 
     //
     // find address
@@ -1883,6 +1885,7 @@ CHubController::AcquireDeviceAddress()
     //
     // release spin lock
     //
+    DPRINT(__FUNCTION__ "release\n");
     KeReleaseSpinLock(&m_Lock, OldLevel);
 
     //
@@ -1900,7 +1903,9 @@ CHubController::ReleaseDeviceAddress(
     //
     // acquire device lock
     //
+    DPRINT(__FUNCTION__ " acquire\n");
     KeAcquireSpinLock(&m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquired\n");
 
     //
     // sanity check
@@ -1920,6 +1925,7 @@ CHubController::ReleaseDeviceAddress(
     //
     // release lock
     //
+    DPRINT(__FUNCTION__ "release\n");
     KeReleaseSpinLock(&m_Lock, OldLevel);
 }
 //-----------------------------------------------------------------------------------------
@@ -1935,7 +1941,9 @@ CHubController::RemoveUsbDevice(
     //
     // acquire lock
     //
+    DPRINT(__FUNCTION__ " acquire\n");
     KeAcquireSpinLock(&m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquired\n");
 
     //
     // point to first entry
@@ -1983,6 +1991,7 @@ CHubController::RemoveUsbDevice(
     //
     // release lock
     //
+    DPRINT(__FUNCTION__ "release\n");
     KeReleaseSpinLock(&m_Lock, OldLevel);
 
     //
@@ -2002,7 +2011,9 @@ CHubController::ValidateUsbDevice(PUSBDEVICE UsbDevice)
     //
     // acquire lock
     //
+    DPRINT(__FUNCTION__ " acquire\n");
     KeAcquireSpinLock(&m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquired\n");
 
     //
     // point to first entry
@@ -2040,6 +2051,7 @@ CHubController::ValidateUsbDevice(PUSBDEVICE UsbDevice)
     //
     // release lock
     //
+    DPRINT(__FUNCTION__ "release\n");
     KeReleaseSpinLock(&m_Lock, OldLevel);
 
     //
@@ -2077,7 +2089,9 @@ CHubController::AddUsbDevice(
     //
     // acquire lock
     //
+    DPRINT(__FUNCTION__ " acquire\n");
     KeAcquireSpinLock(&m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquired\n");
 
     //
     // insert entry
@@ -2087,6 +2101,7 @@ CHubController::AddUsbDevice(
     //
     // release spin lock
     //
+    DPRINT(__FUNCTION__ "release\n");
     KeReleaseSpinLock(&m_Lock, OldLevel);
 
     //
@@ -2106,7 +2121,9 @@ CHubController::SetNotification(
     //
     // acquire hub controller lock
     //
+    DPRINT(__FUNCTION__ " acquire\n");
     KeAcquireSpinLock(&m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquired\n");
 
     //
     // now set the callback routine and context of the hub
@@ -2114,10 +2131,11 @@ CHubController::SetNotification(
     m_HubCallbackContext = CallbackContext;
     m_HubCallbackRoutine = CallbackRoutine;
 
-   //
-   // release hub controller lock
-   //
-   KeReleaseSpinLock(&m_Lock, OldLevel);
+    //
+    // release hub controller lock
+    //
+    DPRINT(__FUNCTION__ "release\n");
+    KeReleaseSpinLock(&m_Lock, OldLevel);
 }
 
 //=================================================================================================
index 1cfed3e..bc1651e 100644 (file)
@@ -157,7 +157,9 @@ CDMAMemoryManager::Allocate(
     //
     // acquire lock
     //
+    DPRINT(__FUNCTION__ " acquire\n");
     KeAcquireSpinLock(m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquired\n");
 
     //
     // helper variable
@@ -235,6 +237,7 @@ CDMAMemoryManager::Allocate(
     //
     // release lock
     //
+    DPRINT(__FUNCTION__ "release\n");
     KeReleaseSpinLock(m_Lock, OldLevel);
 
     //
@@ -304,7 +307,9 @@ CDMAMemoryManager::Release(
     //
     // acquire lock
     //
+    DPRINT(__FUNCTION__ " acquire\n");
     KeAcquireSpinLock(m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquired\n");
 
     //
     // release buffer
@@ -314,6 +319,7 @@ CDMAMemoryManager::Release(
     //
     // release lock
     //
+    DPRINT(__FUNCTION__ "release\n");
     KeReleaseSpinLock(m_Lock, OldLevel);
 
     //
index 7ef98b8..d9a950c 100644 (file)
@@ -519,7 +519,9 @@ CUSBDevice::SubmitIrp(
     //
     // acquire device lock
     //
+    DPRINT(__FUNCTION__ " acquire\n");
     KeAcquireSpinLock(&m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquired\n");
 
     //
     // commit urb
@@ -529,6 +531,7 @@ CUSBDevice::SubmitIrp(
     //
     // release lock
     //
+    DPRINT(__FUNCTION__ "release\n");
     KeReleaseSpinLock(&m_Lock, OldLevel);
 
     return Status;
index ed605d1..830ef29 100644 (file)
@@ -33,7 +33,7 @@ public:
         return m_Ref;
     }
 
-    virtual NTSTATUS Initialize(IN PUSBHARDWAREDEVICE Hardware, PDMA_ADAPTER AdapterObject, IN PDMAMEMORYMANAGER MemManager, IN OPTIONAL PKSPIN_LOCK Lock);
+    virtual NTSTATUS Initialize(IN PUSBHARDWAREDEVICE Hardware, PDMA_ADAPTER AdapterObject, IN PDMAMEMORYMANAGER MemManager, IN PKSPIN_LOCK Lock);
     virtual ULONG GetPendingRequestCount();
     virtual NTSTATUS AddUSBRequest(PURB Urb);
     virtual NTSTATUS AddUSBRequest(IUSBRequest * Request);
@@ -48,7 +48,7 @@ public:
 
 protected:
     LONG m_Ref;                                                                         // reference count
-    KSPIN_LOCK m_Lock;                                                                  // list lock
+    PKSPIN_LOCK m_Lock;                                                                  // list lock
     PDMA_ADAPTER m_Adapter;                                                             // dma adapter
     PUSBHARDWAREDEVICE m_Hardware;                                                      // stores hardware object
     PQUEUE_HEAD AsyncListQueueHead;                                                     // async queue head
@@ -114,7 +114,7 @@ CUSBQueue::Initialize(
     //
     // initialize device lock
     //
-    KeInitializeSpinLock(&m_Lock);
+    m_Lock = Lock;
 
     //
     // Get the AsyncQueueHead
@@ -355,9 +355,13 @@ CUSBQueue::AddUSBRequest(
         //
         // Add it to the pending list
         //
-        KeAcquireSpinLock(&m_Lock, &OldLevel);
+        DPRINT(__FUNCTION__ " acquire\n");
+        KeAcquireSpinLock(m_Lock, &OldLevel);
+        DPRINT(__FUNCTION__ " acquired\n");
+
         LinkQueueHead(AsyncListQueueHead, QueueHead);
-        KeReleaseSpinLock(&m_Lock, OldLevel);
+        DPRINT(__FUNCTION__ "release\n");
+        KeReleaseSpinLock(m_Lock, OldLevel);
     }
 
 
@@ -575,8 +579,6 @@ CUSBQueue::QueueHeadCompletion(
     PQUEUE_HEAD CurrentQH,
     NTSTATUS Status)
 {
-    KIRQL OldLevel;
-
     //
     // now unlink the queue head
     // FIXME: implement chained queue heads
@@ -608,7 +610,9 @@ CUSBQueue::ProcessAsyncList(
     //
     // lock completed async list
     //
-    KeAcquireSpinLock(&m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquire\n");
+    KeAcquireSpinLock(m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquired\n");
 
     //
     // walk async list 
@@ -664,7 +668,8 @@ CUSBQueue::ProcessAsyncList(
     //
     // release lock
     //
-    KeReleaseSpinLock(&m_Lock, OldLevel);
+    DPRINT(__FUNCTION__ "release\n");
+    KeReleaseSpinLock(m_Lock, OldLevel);
 }
 
 
@@ -767,7 +772,9 @@ CUSBQueue::QueueHeadCleanup(
             //
             // first acquire request lock
             //
-            KeAcquireSpinLock(&m_Lock, &OldLevel);
+            DPRINT(__FUNCTION__ " acquire\n");
+            KeAcquireSpinLock(m_Lock, &OldLevel);
+            DPRINT(__FUNCTION__ " acquired\n");
 
             //
             // add to pending list
@@ -777,7 +784,8 @@ CUSBQueue::QueueHeadCleanup(
             //
             // release queue head
             //
-            KeReleaseSpinLock(&m_Lock, OldLevel);
+            DPRINT(__FUNCTION__ "release\n");
+            KeReleaseSpinLock(m_Lock, OldLevel);
 
             //
             // Done for now
@@ -846,7 +854,9 @@ CUSBQueue::CompleteAsyncRequests()
     //
     // first acquire request lock
     //
-    KeAcquireSpinLock(&m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquire\n");
+    KeAcquireSpinLock(m_Lock, &OldLevel);
+    DPRINT(__FUNCTION__ " acquired\n");
 
     //
     // the list should not be empty
@@ -873,7 +883,8 @@ CUSBQueue::CompleteAsyncRequests()
         //
         // release lock
         //
-        KeReleaseSpinLock(&m_Lock, OldLevel);
+        DPRINT(__FUNCTION__ "release\n");
+        KeReleaseSpinLock(m_Lock, OldLevel);
 
         //
         // complete request now
@@ -883,7 +894,10 @@ CUSBQueue::CompleteAsyncRequests()
         //
         // first acquire request lock
         //
-        KeAcquireSpinLock(&m_Lock, &OldLevel);
+        DPRINT(__FUNCTION__ " acquire\n");
+        KeAcquireSpinLock(m_Lock, &OldLevel);
+        DPRINT(__FUNCTION__ " acquired\n");
+
     }
 
     //
@@ -910,7 +924,8 @@ CUSBQueue::CompleteAsyncRequests()
     //
     // release lock
     //
-    KeReleaseSpinLock(&m_Lock, OldLevel);
+    DPRINT(__FUNCTION__ "release\n");
+    KeReleaseSpinLock(m_Lock, OldLevel);
 }
 
 NTSTATUS