Interrupt Storm on boot-up

Hi,

My device has 1 Interrupt resource.

In my driver?s AddDevice , I do the following:

WDF_INTERRUPT_CONFIG_INIT(
&interruptConfig,
OnInterruptIsr,
NULL);
interruptConfig.PassiveHandling = TRUE;

status = WdfInterruptCreate(
fxDevice,
&interruptConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&devContext->InterruptObject);

I am seeing that the framework automatically sets up the ISR, without me calling IoConnectInterrupt. I am also seeing that the framework is enabling the interrupt automatically. My KMDF driver does not have EvtInterruptEnable callback.

Is it guaranteed that framework will succeed in setting up the ISR before the interrupt is enabled ? I am sometimes seeing an interrupt storm during boot-up since my ISR is not ready and the interrupt has been enabled already.

Kindly let me know.

Thanks.

What kind of interrupt it is?

Think about it. How can kmdf enable the interrupt on your HW when it has no idea what your HW is or how it works. In short, kmdf doesn’t enable the interrupt. All it does connect the interrupt and then call you to enable it in EvtInterruptEnable. If it is storming between the two, you should explicitly disable interrupts in D0Entry to prevent the storm

d


From: xxxxx@lists.osr.com [xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com [xxxxx@gmail.com]
Sent: Thursday, June 13, 2013 5:06 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Interrupt Storm on boot-up

Hi,

My device has 1 Interrupt resource.

In my driver?s AddDevice , I do the following:

WDF_INTERRUPT_CONFIG_INIT(
&interruptConfig,
OnInterruptIsr,
NULL);
interruptConfig.PassiveHandling = TRUE;

status = WdfInterruptCreate(
fxDevice,
&interruptConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&devContext->InterruptObject);

I am seeing that the framework automatically sets up the ISR, without me calling IoConnectInterrupt. I am also seeing that the framework is enabling the interrupt automatically. My KMDF driver does not have EvtInterruptEnable callback.

Is it guaranteed that framework will succeed in setting up the ISR before the interrupt is enabled ? I am sometimes seeing an interrupt storm during boot-up since my ISR is not ready and the interrupt has been enabled already.

Kindly let me know.

Thanks.


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

Thanks Doron, clearing the interrupt in D0Entry did the trick.

I am using GpioInt() ACPI macro do define the interrupt

GpioInt(Level, ActiveLow, Shared, PullNone, 0, “_SB.GPI0”, 0 , ResourceConsumer, , ) {20}

The framework calls the GPI0 device driver automatically to enable the interrupt. Am I correct in amy assumption ?

Kindly let me know.

Thanks

I once worked with a particularly sociopathic device. If you did a
“shutdown and restart” or took a BSOD and allowed restart, te
interrupt-enable bit was not cleared, and it was generati g interrupts
during the boot process. Sadly, the only way to be sure that interrupts
woud be disabled was to power the machine down and then power it back up.
This device had other pathologies, such as having seven different modes it
could be running in, with no way to tell what mode it was in, or set it to
a specific mode, the “powered-up” mode. There was only one operation,
“advance mode”. So you couldn’t set it back to the base mode 0 unless you
knew the current mode, and how many “Advance” commands to issue. As with
the IE bit, the only way to reset the card was a full power cycle.

My SO came home one day and saw me doing something that struck her as odd.
“I thought you were working today” she said. “I am” I replied. She
looked at what I had, and said “That looks like a dungeon map”. I
grumbled that it was; what I had discovered was that if you wrote
(nominally harmless) command K to the command register, the status
register would exhibit a value based on te current internal mode. The
problem was that the same response could be seen for several different
modes. So I would write a different command, K1, and see what came back.
And keep probing until I got an unambiguous result so I knew what mode it
was in. Sometimes, the test would be to advance to next mode, and based
on what I saw in tbe next mode, I could determine if I had done an
M1-to-M2 transition, or an M5-M6 transition, and then knew how far I had
to advance to get back to M0. What she saw me working on was the
state-transition diagram.

Which boils down to the need to make sure interrupts are off. You can try
to get the shutdown event to call a routine that disables interrupts.
There are many interrupt scopes; for some devices it makes no sense to
have interrupts enabled when there is no active IRP. So you enable
interrupts when te pending IRP is removed from tbe queue and “goes
active”, and id disabledwhen the IRP is completed (hint: watch out for
multicore race conditions; and a spin lock will not save you; careful
coding will. Another scope is from the IRP_MJ__PNP:IRP_MN_START_DEVICE to
the IRP_MJ_PNP:IRP_Mn_REMOVE_DEVICE, and an intermediate span woul be from
IRP_MJ_CREATE to the IRP_MJ_CLOSE. You get to choose one of these three,
or invent one of your own, based on your analysis of tbe needs of the
device. AFAIK, only level-triggered interrupts can generate a storm. If
the device design is screwed up so the IE bit is not cleared on a reboot,
then you have to do your best to disable it in shutdown. And be prepared
to have proper directions to you tech support drones if a a customer calls
up with symptoms consistent with an iterrupt storm. Note that it is
always good to have te device accept a command querying the firmware
and/or hardware version of the device.
joe

Think about it. How can kmdf enable the interrupt on your HW when it has
no idea what your HW is or how it works. In short, kmdf doesn’t enable the
interrupt. All it does connect the interrupt and then call you to enable
it in EvtInterruptEnable. If it is storming between the two, you should
explicitly disable interrupts in D0Entry to prevent the storm

d


From: xxxxx@lists.osr.com
[xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com
[xxxxx@gmail.com]
Sent: Thursday, June 13, 2013 5:06 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Interrupt Storm on boot-up

Hi,

My device has 1 Interrupt resource.

In my driver?s AddDevice , I do the following:

WDF_INTERRUPT_CONFIG_INIT(
&interruptConfig,
OnInterruptIsr,
NULL);
interruptConfig.PassiveHandling = TRUE;

status = WdfInterruptCreate(
fxDevice,
&interruptConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&devContext->InterruptObject);

I am seeing that the framework automatically sets up the ISR, without me
calling IoConnectInterrupt. I am also seeing that the framework is
enabling the interrupt automatically. My KMDF driver does not have
EvtInterruptEnable callback.

Is it guaranteed that framework will succeed in setting up the ISR before
the interrupt is enabled ? I am sometimes seeing an interrupt storm
during boot-up since my ISR is not ready and the interrupt has been
enabled already.

Kindly let me know.

Thanks.


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

It’s exactly because of devices like these that I hammered on the PCI Express specification until they added the “Interrupt Disable” bit to the common config header.

  • Jake Oshins
    (former interrupt guy)
    Windows Kernel Team

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@flounder.com
Sent: Friday, June 14, 2013 12:29 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Interrupt Storm on boot-up

I once worked with a particularly sociopathic device. If you did a
“shutdown and restart” or took a BSOD and allowed restart, te
interrupt-enable bit was not cleared, and it was generati g interrupts
during the boot process. Sadly, the only way to be sure that interrupts
woud be disabled was to power the machine down and then power it back up.
This device had other pathologies, such as having seven different modes it
could be running in, with no way to tell what mode it was in, or set it to
a specific mode, the “powered-up” mode. There was only one operation,
“advance mode”. So you couldn’t set it back to the base mode 0 unless you
knew the current mode, and how many “Advance” commands to issue. As with
the IE bit, the only way to reset the card was a full power cycle.

My SO came home one day and saw me doing something that struck her as odd.
“I thought you were working today” she said. “I am” I replied. She
looked at what I had, and said “That looks like a dungeon map”. I
grumbled that it was; what I had discovered was that if you wrote
(nominally harmless) command K to the command register, the status
register would exhibit a value based on te current internal mode. The
problem was that the same response could be seen for several different
modes. So I would write a different command, K1, and see what came back.
And keep probing until I got an unambiguous result so I knew what mode it
was in. Sometimes, the test would be to advance to next mode, and based
on what I saw in tbe next mode, I could determine if I had done an
M1-to-M2 transition, or an M5-M6 transition, and then knew how far I had
to advance to get back to M0. What she saw me working on was the
state-transition diagram.

Which boils down to the need to make sure interrupts are off. You can try
to get the shutdown event to call a routine that disables interrupts.
There are many interrupt scopes; for some devices it makes no sense to
have interrupts enabled when there is no active IRP. So you enable
interrupts when te pending IRP is removed from tbe queue and “goes
active”, and id disabledwhen the IRP is completed (hint: watch out for
multicore race conditions; and a spin lock will not save you; careful
coding will. Another scope is from the IRP_MJ__PNP:IRP_MN_START_DEVICE to
the IRP_MJ_PNP:IRP_Mn_REMOVE_DEVICE, and an intermediate span woul be from
IRP_MJ_CREATE to the IRP_MJ_CLOSE. You get to choose one of these three,
or invent one of your own, based on your analysis of tbe needs of the
device. AFAIK, only level-triggered interrupts can generate a storm. If
the device design is screwed up so the IE bit is not cleared on a reboot,
then you have to do your best to disable it in shutdown. And be prepared
to have proper directions to you tech support drones if a a customer calls
up with symptoms consistent with an iterrupt storm. Note that it is
always good to have te device accept a command querying the firmware
and/or hardware version of the device.
joe

Think about it. How can kmdf enable the interrupt on your HW when it has
no idea what your HW is or how it works. In short, kmdf doesn’t enable the
interrupt. All it does connect the interrupt and then call you to enable
it in EvtInterruptEnable. If it is storming between the two, you should
explicitly disable interrupts in D0Entry to prevent the storm

d


From: xxxxx@lists.osr.com
[xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com
[xxxxx@gmail.com]
Sent: Thursday, June 13, 2013 5:06 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Interrupt Storm on boot-up

Hi,

My device has 1 Interrupt resource.

In my driver?s AddDevice , I do the following:

WDF_INTERRUPT_CONFIG_INIT(
&interruptConfig,
OnInterruptIsr,
NULL);
interruptConfig.PassiveHandling = TRUE;

status = WdfInterruptCreate(
fxDevice,
&interruptConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&devContext->InterruptObject);

I am seeing that the framework automatically sets up the ISR, without me
calling IoConnectInterrupt. I am also seeing that the framework is
enabling the interrupt automatically. My KMDF driver does not have
EvtInterruptEnable callback.

Is it guaranteed that framework will succeed in setting up the ISR before
the interrupt is enabled ? I am sometimes seeing an interrupt storm
during boot-up since my ISR is not ready and the interrupt has been
enabled already.

Kindly let me know.

Thanks.


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

I have no idea where my head was when I wrote the explanation below.

OF COURSE level triggered interrupts can trigger a interrupt storm; if the
IE bit is set and the line is held low, it will generate an interrupt, and
there is nothing other than your driver that knows how to clear it. My
impression is that a reboot causes a “reset” signal on the PCI bus. The
card discussed below did nothing when it saw the reset signal, leaving the
IE bit and the timer generating interrupts. So one possible explanation
of what you are seeing is the same as I had: defective card design. If
the IE bit remains set and the interrupt condition is still pending, you
are probably hosed.
Joe

I once worked with a particularly sociopathic device. If you did a
“shutdown and restart” or took a BSOD and allowed restart, te
interrupt-enable bit was not cleared, and it was generati g interrupts
during the boot process. Sadly, the only way to be sure that interrupts
woud be disabled was to power the machine down and then power it back up.
This device had other pathologies, such as having seven different modes it
could be running in, with no way to tell what mode it was in, or set it to
a specific mode, the “powered-up” mode. There was only one operation,
“advance mode”. So you couldn’t set it back to the base mode 0 unless you
knew the current mode, and how many “Advance” commands to issue. As with
the IE bit, the only way to reset the card was a full power cycle.

My SO came home one day and saw me doing something that struck her as odd.
“I thought you were working today” she said. “I am” I replied. She
looked at what I had, and said “That looks like a dungeon map”. I
grumbled that it was; what I had discovered was that if you wrote
(nominally harmless) command K to the command register, the status
register would exhibit a value based on te current internal mode. The
problem was that the same response could be seen for several different
modes. So I would write a different command, K1, and see what came back.
And keep probing until I got an unambiguous result so I knew what mode it
was in. Sometimes, the test would be to advance to next mode, and based
on what I saw in tbe next mode, I could determine if I had done an
M1-to-M2 transition, or an M5-M6 transition, and then knew how far I had
to advance to get back to M0. What she saw me working on was the
state-transition diagram.

Which boils down to the need to make sure interrupts are off. You can try
to get the shutdown event to call a routine that disables interrupts.
There are many interrupt scopes; for some devices it makes no sense to
have interrupts enabled when there is no active IRP. So you enable
interrupts when te pending IRP is removed from tbe queue and “goes
active”, and id disabledwhen the IRP is completed (hint: watch out for
multicore race conditions; and a spin lock will not save you; careful
coding will. Another scope is from the IRP_MJ__PNP:IRP_MN_START_DEVICE to
the IRP_MJ_PNP:IRP_Mn_REMOVE_DEVICE, and an intermediate span woul be from
IRP_MJ_CREATE to the IRP_MJ_CLOSE. You get to choose one of these three,
or invent one of your own, based on your analysis of tbe needs of the
device. AFAIK, only level-triggered interrupts can generate a storm. If
the device design is screwed up so the IE bit is not cleared on a reboot,
then you have to do your best to disable it in shutdown. And be prepared
to have proper directions to you tech support drones if a a customer calls
up with symptoms consistent with an iterrupt storm. Note that it is
always good to have te device accept a command querying the firmware
and/or hardware version of the device.
joe

> Think about it. How can kmdf enable the interrupt on your HW when it has
> no idea what your HW is or how it works. In short, kmdf doesn’t enable
> the
> interrupt. All it does connect the interrupt and then call you to enable
> it in EvtInterruptEnable. If it is storming between the two, you should
> explicitly disable interrupts in D0Entry to prevent the storm
>
> d
> ________________________________________
> From: xxxxx@lists.osr.com
> [xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com
> [xxxxx@gmail.com]
> Sent: Thursday, June 13, 2013 5:06 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Interrupt Storm on boot-up
>
> Hi,
>
> My device has 1 Interrupt resource.
>
> In my driver?s AddDevice , I do the following:
>
> WDF_INTERRUPT_CONFIG_INIT(
> &interruptConfig,
> OnInterruptIsr,
> NULL);
> interruptConfig.PassiveHandling = TRUE;
>
> status = WdfInterruptCreate(
> fxDevice,
> &interruptConfig,
> WDF_NO_OBJECT_ATTRIBUTES,
> &devContext->InterruptObject);
>
>
>
> I am seeing that the framework automatically sets up the ISR, without me
> calling IoConnectInterrupt. I am also seeing that the framework is
> enabling the interrupt automatically. My KMDF driver does not have
> EvtInterruptEnable callback.
>
>
> Is it guaranteed that framework will succeed in setting up the ISR
> before
> the interrupt is enabled ? I am sometimes seeing an interrupt storm
> during boot-up since my ISR is not ready and the interrupt has been
> enabled already.
>
> Kindly let me know.
>
> Thanks.
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

THANKYOUTHANKYOUTHANKYOU!!!

It’s exactly because of devices like these that I hammered on the PCI
Express specification until they added the “Interrupt Disable” bit to the
common config header.

  • Jake Oshins
    (former interrupt guy)
    Windows Kernel Team

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@flounder.com
Sent: Friday, June 14, 2013 12:29 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Interrupt Storm on boot-up

I once worked with a particularly sociopathic device. If you did a
“shutdown and restart” or took a BSOD and allowed restart, te
interrupt-enable bit was not cleared, and it was generati g interrupts
during the boot process. Sadly, the only way to be sure that interrupts
woud be disabled was to power the machine down and then power it back up.
This device had other pathologies, such as having seven different modes it
could be running in, with no way to tell what mode it was in, or set it to
a specific mode, the “powered-up” mode. There was only one operation,
“advance mode”. So you couldn’t set it back to the base mode 0 unless you
knew the current mode, and how many “Advance” commands to issue. As with
the IE bit, the only way to reset the card was a full power cycle.

My SO came home one day and saw me doing something that struck her as odd.
“I thought you were working today” she said. “I am” I replied. She
looked at what I had, and said “That looks like a dungeon map”. I
grumbled that it was; what I had discovered was that if you wrote
(nominally harmless) command K to the command register, the status
register would exhibit a value based on te current internal mode. The
problem was that the same response could be seen for several different
modes. So I would write a different command, K1, and see what came back.
And keep probing until I got an unambiguous result so I knew what mode it
was in. Sometimes, the test would be to advance to next mode, and based
on what I saw in tbe next mode, I could determine if I had done an
M1-to-M2 transition, or an M5-M6 transition, and then knew how far I had
to advance to get back to M0. What she saw me working on was the
state-transition diagram.

Which boils down to the need to make sure interrupts are off. You can try
to get the shutdown event to call a routine that disables interrupts.
There are many interrupt scopes; for some devices it makes no sense to
have interrupts enabled when there is no active IRP. So you enable
interrupts when te pending IRP is removed from tbe queue and “goes
active”, and id disabledwhen the IRP is completed (hint: watch out for
multicore race conditions; and a spin lock will not save you; careful
coding will. Another scope is from the IRP_MJ__PNP:IRP_MN_START_DEVICE to
the IRP_MJ_PNP:IRP_Mn_REMOVE_DEVICE, and an intermediate span woul be from
IRP_MJ_CREATE to the IRP_MJ_CLOSE. You get to choose one of these three,
or invent one of your own, based on your analysis of tbe needs of the
device. AFAIK, only level-triggered interrupts can generate a storm. If
the device design is screwed up so the IE bit is not cleared on a reboot,
then you have to do your best to disable it in shutdown. And be prepared
to have proper directions to you tech support drones if a a customer calls
up with symptoms consistent with an iterrupt storm. Note that it is
always good to have te device accept a command querying the firmware
and/or hardware version of the device.
joe

> Think about it. How can kmdf enable the interrupt on your HW when it has
> no idea what your HW is or how it works. In short, kmdf doesn’t enable
> the
> interrupt. All it does connect the interrupt and then call you to enable
> it in EvtInterruptEnable. If it is storming between the two, you should
> explicitly disable interrupts in D0Entry to prevent the storm
>
> d
> ________________________________________
> From: xxxxx@lists.osr.com
> [xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com
> [xxxxx@gmail.com]
> Sent: Thursday, June 13, 2013 5:06 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Interrupt Storm on boot-up
>
> Hi,
>
> My device has 1 Interrupt resource.
>
> In my driver?s AddDevice , I do the following:
>
> WDF_INTERRUPT_CONFIG_INIT(
> &interruptConfig,
> OnInterruptIsr,
> NULL);
> interruptConfig.PassiveHandling = TRUE;
>
> status = WdfInterruptCreate(
> fxDevice,
> &interruptConfig,
> WDF_NO_OBJECT_ATTRIBUTES,
> &devContext->InterruptObject);
>
>
>
> I am seeing that the framework automatically sets up the ISR, without me
> calling IoConnectInterrupt. I am also seeing that the framework is
> enabling the interrupt automatically. My KMDF driver does not have
> EvtInterruptEnable callback.
>
>
> Is it guaranteed that framework will succeed in setting up the ISR
> before
> the interrupt is enabled ? I am sometimes seeing an interrupt storm
> during boot-up since my ISR is not ready and the interrupt has been
> enabled already.
>
> Kindly let me know.
>
> Thanks.
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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