From: Harison213 on
Doran, thanks for your comment.

The driver is using power-managed queues, and I have the option of either
disabling interrupts in EvtIoStop or not - I'd rather not to!

The actual question is, if I don't disable the interrupts in EvtIoStop and I
receive an interrupt after calling WdfRequestStopAcknowledge in EvtIoStop
(but before EvtInterruptDisable is called) documentation says you shouldn't
access the hardware. However, by receiving the interrupt, not only I'm going
to access the hardware - few register accesses though - but also I will queue
a DPC object in order to complete the pending request.

Considering above situation:
1. Is it alright to access the hardware after WdfRequestStopAcknowledge is
called (e.g. in the ISR)? Documentation says you shouldn't.
2. If you postpone the processing of a request by calling
WdfRequestStopAcknowledge in EvtIoStop, can you complete that same request
_before_ EvtIoResume for that request is called? E.g. you postpone the
request, then receive an interrupt just before EvtInterruptDisable (before
leaving D0), and you try to complete the request. Is this allowed?

Thanks,
Harison

--
There are 10 kinds of people in the world: those who understand binary, and
those who don't!

From: Eliyas Yakub [MSFT] on
After EvtIoStop if you are only accessing the hardware in the Isr - not in
the DPC - then you are fine. The fact that ISR is running after EvtIoStop
means that the device hasn't been powered down yet (because framework asks
you to disable the interrupt at DIRQL before calling D0Exit). The reason you
cannot access the hardware in the DPC is because your DPC could be racing
with the thread that's powering-down the device on another processor. So to
be safe you should call WdfDpcCancel(dpc, TRUE) in D0Exit to make sure that
DpcForIsr has run to completion before powering down the device. It's
possible that framework might be doing this but I'm not sure. I will let you
know.

As to question of completing the acknowledged request in the DPC, yes you
can do that. We allow completing an acknowledged request before EvtIoResume.

-Eliyas


From: Eliyas Yakub [MSFT] on
Scratch my previous response. I did get that right.

The simple answer is that you can access the hardware in Isr and DpcForIsr
after EvtIoStop. After stopping all the power managed queues, the framework
asks the driver to disable the interrupt at DIRQL and then it flushes the
dpcs to make sure the DpcForIsr has run to completion before calling
D0Exit.

So if you have to complete an already stop-acknowledged request in the Dpc,
you can do that.

-Eliyas

From: Harison213 on
Eliyas, thanks for your comment. It couldn't be more clarifying than this :)

--
There are 10 kinds of people in the world: those who understand binary, and
those who don''t!