Re: Interesting KMDF Gotcha
- From: "Doron Holan [MS]" <doronh@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 29 Nov 2006 23:08:24 -0800
this is great feedback, I will fwd it to the team.
d
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tim Roberts" <timr@xxxxxxxxx> wrote in message
news:gsusm2h2vh97p02ge319eb9ngbe3kdmi0q@xxxxxxxxxx
I encountered an interesting problem today. It was entirely of my own
doing, but I wanted to present the story as a "bad example".
I did a KMDF driver for a client, who has a DMA-based PCI device that also
accepts a bunch of commands. I started from plx9x5x sample, radically
altered.
As I was going through the sample, I came to the routine that creates the
interrupt. When I saw the code was setting AutomaticSerialization to
TRUE,
I read the description, and said "gosh, that sounds like a good idea".
Last week, the client complained that, during testing, on some
motherboards, certain commands caused the machine to lock up tight --
power
cycle required.
As it turns out, some of the commands I have to execute take a couple of
milliseconds to complete. I block (using KeDelayExecutionThread) waiting
for the "command complete" bit to set. What happened in this particular
case is that I got an interrupt while I was waiting. Because
AutomaticSerialization was set, the framework's interrupt handler tried to
acquire the framework device spinlock, which, of course, I was already
holding in my blocked dispatch callback. This caused a nice, tight,
efficient infinite loop, with interrupts disabled, at DIRQL.
I've now gone through the driver from top to bottom with a new
appreciation
for the synchronization settings. The fact that I have the framework
acquiring spinlocks on my behalf makes it way too easy to violate the
"never block with a spinlock held" rule.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
.
- References:
- Interesting KMDF Gotcha
- From: Tim Roberts
- Interesting KMDF Gotcha
- Prev by Date: Interesting KMDF Gotcha
- Next by Date: USB string descriptors and Vista
- Previous by thread: Interesting KMDF Gotcha
- Next by thread: Re: Interesting KMDF Gotcha
- Index(es):
Relevant Pages
|