Dear All:
I will design a device driver for a PCI-E device. I would like to have a function that is hardware reset the device. I will reset the PCI-E interface so the PCI-E link will be unlinked. The device driver is unloaded automatically by the Windows now. After finishing reset process, the hardware will link to the PCI-E. How should I do that the driver will be loaded automatically without any manual rescan. I mean that I hope the application will not be aware of this reset action and the application can continue executing. Thanks!
On Tue, 8 Apr 2008 10:34:45 -0400 (EDT), xxxxx@hotmail.com wrote:
I will design a device driver for a PCI-E device. I would like to
have a function that is hardware reset the device. I will reset the
PCI-E interface so the PCI-E link will be unlinked. The device
driver is unloaded automatically by the Windows now. After
finishing reset process, the hardware will link to the PCI-E. How
should I do that the driver will be loaded automatically without
any manual rescan. I mean that I hope the application will not be
aware of this reset action and the application can continue
executing. Thanks!
I’m not sure if this is what you want but I manage a similar thing on one of my
drivers.
When I re-flash the firmware I need to re-start the device - including the PCIe
layer. Obviously this can’t be done while I’m still connected to it so I issue a
command to the hardware that tells it to re-start when it receives a power-down
instruction. Then I unload the driver which, when it is finished sends the
power-down PCIe command and the device re-boots. I wait a suitable length of
time for the device to return and reload the driver and it all works.
Hope this helps,
–
Graeme Griffiths
Image Processing Techniques Ltd.
*****************************************************************************
The contents of this Email and any files transmitted with it are confidential
and intended solely for the use of the individual or entity to whom it is
addressed.
The views stated herein do not necessarily represent the view of the company.
If you are not the intended recipient of this Email you may not copy, forward,
disclose or otherwise use it or any part of it in any form whatsoever.
If you have received this mail in error please Email the sender.
*****************************************************************************
Omnitek/Image Processing Techniques Ltd
Tel : +44(0)1256345900
Fax : +44(0)1256345901
Website : www.omnitek.tv
Registered Office : Unit 3, Intec 2, Wade Road, Basingstoke, Hampshire, RG24 8NE
Registration Number : 3564291
Place of Registration : England
VAT Registration : 709198411
xxxxx@hotmail.com wrote:
I will design a device driver for a PCI-E device. I would like to have a function that is hardware reset the device. I will reset the PCI-E interface so the PCI-E link will be unlinked. The device driver is unloaded automatically by the Windows now. After finishing reset process, the hardware will link to the PCI-E. How should I do that the driver will be loaded automatically without any manual rescan. I mean that I hope the application will not be aware of this reset action and the application can continue executing.
Hot-plugging on PCI buses can only be done on ACPI systems where the
ACPI BIOS supports hot-plug events. If your BIOS doesn’t support that,
then your device will never be unloaded, because no one will ever report
that you have gone missing. In that case, you have a bit of a problem,
because your board will not get its PCI configuration space rewritten
after it comes back from reset.
If your ACPI BIOS supports this, then your driver will get unloaded, and
then reloaded when the device reappears. However, even in this case,
your application must be involved in the process. Its open handle will
be invalidated when the board goes away. The driver cannot fully unload
until the application closes its handle. It has to open a new handle to
get the new driver. You can use the plug-and-play notifications to find
out about these events. You can hide most of this in a DLL so that
application remains relatively ignorant.
Personally, it seems to me that this level of reset is just a bad idea.
It’s always good to have a board-level reset, but that reset should
always keep the PCIe link alive.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Hi Graeme:
Thanks for your reply! I think my system is like to yours. Is your driver loaded or unloaded automatically? Or is any function call to do this? Would you tell me how to achieve this goal? Thanks!
Best Regards,
Felix
From: xxxxx@imageproc.com> To: xxxxx@lists.osr.com> Date: Tue, 8 Apr 2008 15:43:37 +0100> Subject: Re: [ntdev] How to reset PCI-E device> > On Tue, 8 Apr 2008 10:34:45 -0400 (EDT), xxxxx@hotmail.com wrote:> > I will design a device driver for a PCI-E device. I would like to> > have a function that is hardware reset the device. I will reset the> > PCI-E interface so the PCI-E link will be unlinked. The device> > driver is unloaded automatically by the Windows now. After> > finishing reset process, the hardware will link to the PCI-E. How> > should I do that the driver will be loaded automatically without> > any manual rescan. I mean that I hope the application will not be> > aware of this reset action and the application can continue> > executing. Thanks!> > I’m not sure if this is what you want but I manage a similar thing on one of my > drivers.> > When I re-flash the firmware I need to re-start the device - including the PCIe > layer. Obviously this can’t be done while I’m still connected to it so I issue a > command to the hardware that tells it to re-start when it receives a power-down > instruction. Then I unload the driver which, when it is finished sends the > power-down PCIe command and the device re-boots. I wait a suitable length of > time for the device to return and reload the driver and it all works.> > Hope this helps,> > –> Graeme Griffiths> Image Processing Techniques Ltd.> > *****************************************************************************> The contents of this Email and any files transmitted with it are confidential> and intended solely for the use of the individual or entity to whom it is> addressed.> The views stated herein do not necessarily represent the view of the company.> If you are not the intended recipient of this Email you may not copy, forward,> disclose or otherwise use it or any part of it in any form whatsoever. > If you have received this mail in error please Email the sender. > *****************************************************************************> Omnitek/Image Processing Techniques Ltd> Tel : +44(0)1256345900> Fax : +44(0)1256345901> Website : www.omnitek.tv> Registered Office : Unit 3, Intec 2, Wade Road, Basingstoke, Hampshire, RG24 8NE> Registration Number : 3564291> Place of Registration : England> VAT Registration : 709198411> > —> NTDEV is sponsored by OSR> > 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
¥Î³¡¸¨®æ¤À¨É·Ó¤ù¡B¼vµ¡B½ì¨ý¤p¤u¨ã©M³Ì·R²M³æ¡AºÉ±¡¨q¥X§A¦Û¤v ¡X Windows Live Spaces
http://spaces.live.com/
On Wed, 9 Apr 2008 01:27:10 +0000, Yang Felix wrote:
Hi Graeme:
?? Thanks for your reply! I think my system is like to yours.Is
your driver loaded or unloaded automatically? Or is any function
call to do this? Would you tell me how to achieve this goal?
Thanks!
No problem Felix, I’ve had enough help over the years from this forum it’s nice
to give something back for a change.
The way I do this is similar to the way I connect to the driver in the first
place. Here’s my restart code (returns FALSE if it failed - signals that a
reboot is needed in the passed-in BOOLEAN pointer):
BOOLEAN
CWrapperClass::Restart(BOOLEAN *pbRestart)
{
HDEVINFO devs = INVALID_HANDLE_VALUE;
SP_PROPCHANGE_PARAMS pcp;
SP_DEVINSTALL_PARAMS devParams;
SP_DEVINFO_DATA devInfo;
BOOLEAN ret = FALSE;
*pbRestart = FALSE;
devs = SetupDiGetClassDevs (
(LPGUID)&MY_DEVCIE_GUID,
NULL, // Define no enumerator (global)
NULL, // Define no
(DIGCF_PRESENT | // Only Devices present
DIGCF_DEVICEINTERFACE)); // Function class devices.
if(devs == INVALID_HANDLE_VALUE)
return FALSE;
devInfo.cbSize = sizeof(devInfo);
if(!SetupDiEnumDeviceInfo(devs, m_Instance, &devInfo)){
DWORD dw = GetLastError();
return FALSE;
}
// Set the hardware to restart on power-down
SendRestart();
// Close ALL open handles to the device - if you don’t do this a restart will
// be required
DeviceClose();
CloseHandle(m_Handle);
m_Handle = NULL;
pcp.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
pcp.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
pcp.StateChange = DICS_DISABLE;//DICS_PROPCHANGE;//DICS_DISABLE;
pcp.Scope = DICS_FLAG_GLOBAL;//DICS_FLAG_CONFIGSPECIFIC;//DICS_FLAG_GLOBAL;
pcp.HwProfile = 0;
if(SetupDiSetClassInstallParams(devs,&devInfo,&pcp.ClassInstallHeader,sizeof(pc
p)) &&
SetupDiCallClassInstaller(DIF_PROPERTYCHANGE,devs,&devInfo)) {
// see if device needs reboot
//
ret = TRUE;
devParams.cbSize = sizeof(devParams);
if(SetupDiGetDeviceInstallParams(devs,&devInfo,&devParams)){
if(devParams.Flags & (DI_NEEDRESTART|DI_NEEDREBOOT))
*pbRestart = TRUE;
}
else
ret = FALSE;
if(*pbRestart == FALSE){
// Wait 3 seconds before re-enable - if we need a restart, don’t bother with
// the wait as the hardware will never have rebooted anyway
::Sleep(3000);
}
// re-enable the driver
pcp.StateChange = DICS_ENABLE;
if(!SetupDiSetClassInstallParams(devs,
&devInfo,
&pcp.ClassInstallHeader,
sizeof(pcp)) ||
!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE,devs,&devInfo))
ret = FALSE;
}
if(ret == TRUE){
// Reconnect to the device
DeviceConnect();
}
return ret;
}
On Tue, 08 Apr 2008 10:08:25 -0700, Tim Roberts wrote:
Personally, it seems to me that this level of reset is just a bad
idea. It’s always good to have a board-level reset, but that reset
should always keep the PCIe link alive.
Tim,
Our card (and many future cards I suspect) employs a Xilinx Virtex 5 device.
These Programmable Gate Arrays include a PCIe hard-macro (i.e. you can get a
PCIe interface without using any gates*) which is really useful (you have one
chip and it does your normal stuff PLUS the PCIe interface.
When you re-program this devcie, however, you have to take the PCIe
interface down and bring it back up. I’ve not had any problems doing this in the
way I explained to Felix (tell the h/w to reset when I disable the driver, wait
a bit and re-enable the driver) - do you see any problems using this sequence ?
* O.K. You do need to put a wrapper onto it in order to use it which does cost
you some logic but not a lot in the grand scheme of this.
Graeme Griffiths
Image Processing Techniques Ltd.
*****************************************************************************
The contents of this Email and any files transmitted with it are confidential
and intended solely for the use of the individual or entity to whom it is
addressed.
The views stated herein do not necessarily represent the view of the company.
If you are not the intended recipient of this Email you may not copy, forward,
disclose or otherwise use it or any part of it in any form whatsoever.
If you have received this mail in error please Email the sender.
*****************************************************************************
Omnitek/Image Processing Techniques Ltd
Tel : +44(0)1256345900
Fax : +44(0)1256345901
Website : www.omnitek.tv
Registered Office : Unit 3, Intec 2, Wade Road, Basingstoke, Hampshire, RG24 8NE
Registration Number : 3564291
Place of Registration : England
VAT Registration : 709198411