Synchronization issues

Hi,

I have several interrupts which when processed signal user mode via a
pending IOCTL.
I want to call the following code in my IsrDpc function. I have a
WdfInterruptAcquireLock( Interrupt ); and ReleaseLock after the following
code, and it creates a deaklock when WdfIoQueueRetrieveNextRequest is
called. My Device Level Synchronization Scope is None and ExecutionLevel
Passive. I am running it on Windows XP 64 bit, with a dual core processor.

First Is this something I shouldn’t be doing in the Dpc? what is the
alternative?

NTSTATUS status = STATUS_UNSUCCESSFUL;
WDFREQUEST currentRequest = NULL;

status = WdfIoQueueRetrieveNextRequest(pDevExt->InterruptQueue,
&currentRequest);
if (NT_SUCCESS(status))
{
PVOID pBuffer;
size_t szBufLength;

status = WdfRequestRetrieveOutputBuffer(currentRequest,
sizeof(pDevExt->CurrentInterruptData), &pBuffer, &szBufLength );
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, “Could not get the Output Buffer
Required, status %X\n”, status);
WdfRequestCompleteWithInformation(currentRequest,
STATUS_INVALID_PARAMETER, 0);
return;
}

if (pDevExt->bFoundHardware)
{
*((PInterruptStruct)pBuffer) = pDevExt->CurrentInterruptData;
pDevExt->CurrentInterruptData.uiInterruptType = 0;
pDevExt->CurrentInterruptData.uiInterruptStatus = 0;
}

WdfRequestCompleteWithInformation( currentRequest, retStatus,
sizeof(InterruptStruct) );
}

Are you saying that you are making the call to
WdfIoQueueRetrieveNextRequest while holding the interrupt lock? If so,
you are running at DIRQL and WdfIoQueueRetrieveNextRequest() is callable
at IRQL <= DISPATCH_LEVEL, so you cannot do this under the interrupt
lock

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ashok Bruno
Sent: Wednesday, November 22, 2006 2:20 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Synchronization issues

Hi,

I have several interrupts which when processed signal user mode via a
pending IOCTL.
I want to call the following code in my IsrDpc function. I have a
WdfInterruptAcquireLock( Interrupt ); and ReleaseLock after the
following
code, and it creates a deaklock when WdfIoQueueRetrieveNextRequest is
called. My Device Level Synchronization Scope is None and ExecutionLevel

Passive. I am running it on Windows XP 64 bit, with a dual core
processor.

First Is this something I shouldn’t be doing in the Dpc? what is the
alternative?

NTSTATUS status = STATUS_UNSUCCESSFUL;
WDFREQUEST currentRequest = NULL;

status = WdfIoQueueRetrieveNextRequest(pDevExt->InterruptQueue,
&currentRequest);
if (NT_SUCCESS(status))
{
PVOID pBuffer;
size_t szBufLength;

status = WdfRequestRetrieveOutputBuffer(currentRequest,
sizeof(pDevExt->CurrentInterruptData), &pBuffer, &szBufLength );
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, “Could not get the Output
Buffer
Required, status %X\n”, status);
WdfRequestCompleteWithInformation(currentRequest,
STATUS_INVALID_PARAMETER, 0);
return;
}

if (pDevExt->bFoundHardware)
{
*((PInterruptStruct)pBuffer) = pDevExt->CurrentInterruptData;
pDevExt->CurrentInterruptData.uiInterruptType = 0;
pDevExt->CurrentInterruptData.uiInterruptStatus = 0;
}

WdfRequestCompleteWithInformation( currentRequest, retStatus,
sizeof(InterruptStruct) );
}


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

D,

Thanks, understood.

If I have an app which waits for an interrupt from the device, and needs to
be notified. What are preferred methods of notification?
I currently have a thread that waits for a pending IOCTL to complete. ie.
when the interrupt happens I complete the Request and the listening
overlapped structure gets notified that the Kernel has an interrupt, along
with the type of interrupt, and the status.

Ashok

“Doron Holan” wrote in message
news:xxxxx@ntdev…
Are you saying that you are making the call to
WdfIoQueueRetrieveNextRequest while holding the interrupt lock? If so,
you are running at DIRQL and WdfIoQueueRetrieveNextRequest() is callable
at IRQL <= DISPATCH_LEVEL, so you cannot do this under the interrupt
lock

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ashok Bruno
Sent: Wednesday, November 22, 2006 2:20 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Synchronization issues

Hi,

I have several interrupts which when processed signal user mode via a
pending IOCTL.
I want to call the following code in my IsrDpc function. I have a
WdfInterruptAcquireLock( Interrupt ); and ReleaseLock after the
following
code, and it creates a deaklock when WdfIoQueueRetrieveNextRequest is
called. My Device Level Synchronization Scope is None and ExecutionLevel

Passive. I am running it on Windows XP 64 bit, with a dual core
processor.

First Is this something I shouldn’t be doing in the Dpc? what is the
alternative?

NTSTATUS status = STATUS_UNSUCCESSFUL;
WDFREQUEST currentRequest = NULL;

status = WdfIoQueueRetrieveNextRequest(pDevExt->InterruptQueue,
&currentRequest);
if (NT_SUCCESS(status))
{
PVOID pBuffer;
size_t szBufLength;

status = WdfRequestRetrieveOutputBuffer(currentRequest,
sizeof(pDevExt->CurrentInterruptData), &pBuffer, &szBufLength );
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, “Could not get the Output
Buffer
Required, status %X\n”, status);
WdfRequestCompleteWithInformation(currentRequest,
STATUS_INVALID_PARAMETER, 0);
return;
}

if (pDevExt->bFoundHardware)
{
*((PInterruptStruct)pBuffer) = pDevExt->CurrentInterruptData;
pDevExt->CurrentInterruptData.uiInterruptType = 0;
pDevExt->CurrentInterruptData.uiInterruptStatus = 0;
}

WdfRequestCompleteWithInformation( currentRequest, retStatus,
sizeof(InterruptStruct) );
}


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

There is no way of signalling a user-mode application at DIRQL. You have to
get down to at least DISPATCH_LEVEL to do that. To get to DISPATCH_LEVEL,
queue a DPC routine.

  • Jake Oshins

“Ashok Bruno” wrote in message news:xxxxx@ntdev…
> D,
>
> Thanks, understood.
>
> If I have an app which waits for an interrupt from the device, and needs
> to be notified. What are preferred methods of notification?
> I currently have a thread that waits for a pending IOCTL to complete. ie.
> when the interrupt happens I complete the Request and the listening
> overlapped structure gets notified that the Kernel has an interrupt, along
> with the type of interrupt, and the status.
>
> Ashok
>
>
> “Doron Holan” wrote in message
> news:xxxxx@ntdev…
> Are you saying that you are making the call to
> WdfIoQueueRetrieveNextRequest while holding the interrupt lock? If so,
> you are running at DIRQL and WdfIoQueueRetrieveNextRequest() is callable
> at IRQL <= DISPATCH_LEVEL, so you cannot do this under the interrupt
> lock
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Ashok Bruno
> Sent: Wednesday, November 22, 2006 2:20 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Synchronization issues
>
>
> Hi,
>
> I have several interrupts which when processed signal user mode via a
> pending IOCTL.
> I want to call the following code in my IsrDpc function. I have a
> WdfInterruptAcquireLock( Interrupt ); and ReleaseLock after the
> following
> code, and it creates a deaklock when WdfIoQueueRetrieveNextRequest is
> called. My Device Level Synchronization Scope is None and ExecutionLevel
>
> Passive. I am running it on Windows XP 64 bit, with a dual core
> processor.
>
> First Is this something I shouldn’t be doing in the Dpc? what is the
> alternative?
>
> NTSTATUS status = STATUS_UNSUCCESSFUL;
> WDFREQUEST currentRequest = NULL;
>
> status = WdfIoQueueRetrieveNextRequest(pDevExt->InterruptQueue,
> &currentRequest);
> if (NT_SUCCESS(status))
> {
> PVOID pBuffer;
> size_t szBufLength;
>
> status = WdfRequestRetrieveOutputBuffer(currentRequest,
> sizeof(pDevExt->CurrentInterruptData), &pBuffer, &szBufLength );
> if (!NT_SUCCESS(status))
> {
> TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, “Could not get the Output
> Buffer
> Required, status %X\n”, status);
> WdfRequestCompleteWithInformation(currentRequest,
> STATUS_INVALID_PARAMETER, 0);
> return;
> }
>
> if (pDevExt->bFoundHardware)
> {
> *((PInterruptStruct)pBuffer) = pDevExt->CurrentInterruptData;
> pDevExt->CurrentInterruptData.uiInterruptType = 0;
> pDevExt->CurrentInterruptData.uiInterruptStatus = 0;
> }
>
> WdfRequestCompleteWithInformation( currentRequest, retStatus,
> sizeof(InterruptStruct) );
> }
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>
>

Capture the state of the interrupt in the DPC or ISR. If in an ISR,
queue a DPC (which appears to be the case already). From the DPC, copy
the state into a local struct on the stack, possibly holding the
interrupt lock. Drop the lock, pop a request off the queue and copy
over the information you kept on the stack. Complete the request.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ashok Bruno
Sent: Wednesday, November 22, 2006 5:02 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Synchronization issues

D,

Thanks, understood.

If I have an app which waits for an interrupt from the device, and needs
to
be notified. What are preferred methods of notification?
I currently have a thread that waits for a pending IOCTL to complete.
ie.
when the interrupt happens I complete the Request and the listening
overlapped structure gets notified that the Kernel has an interrupt,
along
with the type of interrupt, and the status.

Ashok

“Doron Holan” wrote in message
news:xxxxx@ntdev…
Are you saying that you are making the call to
WdfIoQueueRetrieveNextRequest while holding the interrupt lock? If so,
you are running at DIRQL and WdfIoQueueRetrieveNextRequest() is callable
at IRQL <= DISPATCH_LEVEL, so you cannot do this under the interrupt
lock

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ashok Bruno
Sent: Wednesday, November 22, 2006 2:20 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Synchronization issues

Hi,

I have several interrupts which when processed signal user mode via a
pending IOCTL.
I want to call the following code in my IsrDpc function. I have a
WdfInterruptAcquireLock( Interrupt ); and ReleaseLock after the
following
code, and it creates a deaklock when WdfIoQueueRetrieveNextRequest is
called. My Device Level Synchronization Scope is None and ExecutionLevel

Passive. I am running it on Windows XP 64 bit, with a dual core
processor.

First Is this something I shouldn’t be doing in the Dpc? what is the
alternative?

NTSTATUS status = STATUS_UNSUCCESSFUL;
WDFREQUEST currentRequest = NULL;

status = WdfIoQueueRetrieveNextRequest(pDevExt->InterruptQueue,
&currentRequest);
if (NT_SUCCESS(status))
{
PVOID pBuffer;
size_t szBufLength;

status = WdfRequestRetrieveOutputBuffer(currentRequest,
sizeof(pDevExt->CurrentInterruptData), &pBuffer, &szBufLength );
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_PNP, “Could not get the Output
Buffer
Required, status %X\n”, status);
WdfRequestCompleteWithInformation(currentRequest,
STATUS_INVALID_PARAMETER, 0);
return;
}

if (pDevExt->bFoundHardware)
{
*((PInterruptStruct)pBuffer) = pDevExt->CurrentInterruptData;
pDevExt->CurrentInterruptData.uiInterruptType = 0;
pDevExt->CurrentInterruptData.uiInterruptStatus = 0;
}

WdfRequestCompleteWithInformation( currentRequest, retStatus,
sizeof(InterruptStruct) );
}


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer