Ok, for the sake of trying to come up with a solution, I tried the
following:
I added a PCI_COMMON_CONFIG member to the device extension.
In EvtDeviceD0Exit, I added:
// Check if going into D3
if (TargetState == WdfPowerDeviceD3)
{
// Save the PCI configuration state
pDevExt->BusInterface.GetBusData(pDevExt->BusInterface.Context,
PCI_WHICHSPACE_CONFIG,
&pDevExt->PciConfig,
0,
sizeof(PCI_COMMON_CONFIG));
}
and in EvtDeviceD0Entry, I added:
// Check if coming out of D3
if (PreviousState == WdfPowerDeviceD3)
{
// Delay for a second
LARGE_INTEGER DelayTime;
DelayTime.QuadPart = WDF_REL_TIMEOUT_IN_SEC(1);
KeDelayExecutionThread(KernelMode, FALSE, &DelayTime);
// Restore the PCI configuration state
pDevExt->BusInterface.SetBusData(pDevExt->BusInterface.Context,
PCI_WHICHSPACE_CONFIG,
&pDevExt->PciConfig,
0,
sizeof(PCI_COMMON_CONFIG));
}
Initial testing shows that this works, but I’m still concerned that this
might be a really bad idea to be doing independently of the PCI bus driver.
Also, is there a driver verifier time limit for how much time can be spent
in EvtDeviceD0Entry that will be violated with this delay?
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jay Talbott
Sent: Thursday, March 14, 2013 10:01 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] PCI config space uninitialized after resuming from S3
Going back to my idea of having the driver save/restore PCI config space,
what about inserting a delay (1 sec?) in EvtDeviceD0Entry before restoring
the PCI config space?
Or is having the driver restore PCI config space still a very bad idea?
I’m just trying to come up with some sort of workaround to help out my
client, since the product is already shipping to customers.
Frankly, I’m surprised that the WLK/HCK testing didn’t discover this. The
device and driver pass with flying colors. Of course, it’s an unclassified
device, so the tests don’t actually exercise any of the I/O functionality of
the driver, but still you’d think this would be something that would be
checked during PM testing.
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jake Oshins
Sent: Thursday, March 14, 2013 9:47 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] PCI config space uninitialized after resuming from S3
It’s applied universally. It is possible to confuse the PCI driver if you
mis-use the WDM power IRPs. But you seem to be using KMDF, which will do
things properly, so that’s not your problem.
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jay Talbott
Sent: Thursday, March 14, 2013 9:16 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] PCI config space uninitialized after resuming from S3
HI Jake,
Is there anything that could cause the PCI driver to not restore the PCI
config space on a particular device? For example, if there is some sort of a
bug in the device’s PCI PM capability info? Or is restoration of the PCI
config space applied universally?
Thanks,
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jake Oshins
Sent: Wednesday, March 13, 2013 10:36 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] PCI config space uninitialized after resuming from S3
The first thing that you need to understand is that EvtDeviceD0Entry is
called when the PCI driver completes the device’s D0 IRP, allowing your
driver (or in this case, WDF on your behalf) to know that the device is
actually ready to be used.
The PCI driver does a full configuration space restoration just before
completing that D0 IRP. The only thing that can stop it from completing
that restoration is a hardware failure at the device. The most common type
of failure involves not responding to the D0 transition within the 100ms
timeout mandated by the PCI spec.
Your strategy is unlikely to be successful, simply because what you’re
suggested has just failed once.
(occasional PCI guy)
Windows Kernel Team
From: xxxxx@lists.osr.com on behalf of Jay Talbott
Sent: Wednesday, March 13, 2013 8:37 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] PCI config space uninitialized after resuming from S3
A client of mine has an issue with their PCIe device where after waking up
the system from an S3 sleep state, their device’s PCI config space is
uninitialized, resulting in bad things happening when the driver tries to
resume any interaction with the device. Is a PCI device supposed to maintain
its PCI config space data while in D3, or does the PCI config space get
restored by Windows during resume from sleep?
If it’s the former, then it looks like it’s a hardware problem. But if it’s
the latter, what would be causing Windows not to be restoring the PCI config
space for my client’s device, when the rest of the PCIe devices in the
system are getting properly reinitialized?
Although I know that generally a driver should only READ its device’s PCI
config data, would it be a reasonable solution to this problem to have the
driver’s EvtDeviceD0Exit save the PCI config space when going into D3, and
then have EvtDeviceD0Entry restore it when waking back up from D3? Or is
this as much of a really bad idea as I think it is?
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
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