How to get SCSI miniport driver's PDO?

Hi, All:
My driver is a SCSI miniport driver for storage device on PCI bus. I need to access device PCI configuration space registers to fix HW bugs. According Microsoft comments, driver can’t access PCI config registers by 0xCF8/0xCFC ports. So I need to use PNP IRP to access PCI config registers. But my driver is a miniport driver, I can’t get the device object and the phyiscal device object too.
How can I do?
Thank you very much!

Abei

>

Hi, All:
My driver is a SCSI miniport driver for storage device on PCI bus. I
need to
access device PCI configuration space registers to fix HW bugs.
According
Microsoft comments, driver can’t access PCI config registers by
0xCF8/0xCFC
ports. So I need to use PNP IRP to access PCI config registers. But my
driver
is a miniport driver, I can’t get the device object and the phyiscal
device
object too.
How can I do?
Thank you very much!

You aren’t ‘allowed’ to get the PDO, but there are probably a few ways
to do it.

Could you use ScsiPortSetBusDataByOffset instead to access the PCI
config registers in a supported way?

James

I am not try this way, but WDK doc has said that this function can only be called from FindAdapter and AdapterControl with control type ScsiSetRunningConfig.
But I want to access PCI config registers anywhere in my driver.

>

I am not try this way, but WDK doc has said that this function can
only be
called from FindAdapter and AdapterControl with control type
ScsiSetRunningConfig.
But I want to access PCI config registers anywhere in my driver.

All of your driver except those two routines run at DIRQL, and you can’t
send IRP at DIRQL, only PASSIVE and DISPATCH_LEVEL.

If you got BUS_INTERFACE_STANDARD, then you can call BusSetDeviceData,
but I don’t know what IRQL’s you are allowed to call that at… could be
any in which case you might have success.

Could you solve your problem with a filter driver?

James

If you’re not expecting this to be WHQL’d, you can acquire the Device Object but you will have to have what I call a left-handed WDM side, or a source file that uses WDM headers but provides function calls for your miniport… Once you have called ScsiPortInitialize, make a call into this left handed side and acquire the Device Object that you need. In DriverEntry you will need to save the DRIVER_OBJECT so you can access it after ScsiPortInitialize, possibly in FindAdapter.

Gary G. Little

----- Original Message -----
From: xxxxx@hotmail.com
To: “Windows System Software Devs Interest List”
Sent: Tuesday, January 18, 2011 6:51:30 AM
Subject: [ntdev] How to get SCSI miniport driver’s PDO?

Hi, All:
My driver is a SCSI miniport driver for storage device on PCI bus. I need to access device PCI configuration space registers to fix HW bugs. According Microsoft comments, driver can’t access PCI config registers by 0xCF8/0xCFC ports. So I need to use PNP IRP to access PCI config registers. But my driver is a miniport driver, I can’t get the device object and the phyiscal device object too.
How can I do?
Thank you very much!

Abei


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

Hi, Gary:
Our driver need to be WHQL’d. So I can’t use WDM headers.
So there is no way to access PCI config regsiters in SCSI miniport driver since device object can’t be acquired by normal method?
Thanks

Abei

Hi, James:
Sorry, I can’t solve it by filter driver because I need to maintain this filter driver. This is cost consideration. Thanks

Abei

The PCI config registers belong to the PCI bus driver and do NOT belong to your miniport, hence you cannot just read and write to them without going through the owning element, and to do that requires that you build and link with NON-SCSIPORT elements. You MIGHT be able to solve the issue by changing to a STORPORT mini-port.

Gary G. Little

----- Original Message -----
From: xxxxx@hotmail.com
To: “Windows System Software Devs Interest List”
Sent: Tuesday, January 18, 2011 9:08:09 PM
Subject: RE:[ntdev] How to get SCSI miniport driver’s PDO?

Hi, Gary:
Our driver need to be WHQL’d. So I can’t use WDM headers.
So there is no way to access PCI config regsiters in SCSI miniport driver since device object can’t be acquired by normal method?
Thanks

Abei


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

>configuration space registers to fix HW bugs. According Microsoft comments, driver can’t access PCI

config registers by 0xCF8/0xCFC ports.

So, the MS-recommended way is to fix your hardware.

If you cannot do this - why not go the MS-unrecommended way of direct usage of 0xcf8/0xcfc? the product is crap anyway :slight_smile:

SCSIPORT’s model just plain does not support the storage controller’s driver accessing the PCI config space of its device. This is how Windows works, and it is better that the hardware will be compatible with Windows.

Probably you can - by small hardware remake - remap some of the features provided by the config space for now to the usual PCI BARs.

STORPORT can probably solve this, but it is Srv2003+, and IIRC even Srv2003 SP1+ (not all markets require you to support obsolete service pack versions of the OS, but sometimes yes, this is required).


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Perhaps you might want to explain why on earth you need to access
config space for your device ‘anywhere in your driver’? In general
your pci config space rarely needs to be accessed and then only at
device initialization.

Mark Roddy

On Tue, Jan 18, 2011 at 7:59 AM, wrote:
> I am not try this way, but WDK doc has said that this function can only be called from FindAdapter and AdapterControl with control type ScsiSetRunningConfig.
> But I want to access PCI config registers anywhere in my driver.
>
> —
> 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
>

> your pci config space rarely needs to be accessed and then only at

device initialization.

Correct.

One of the requirements in “Windows PCI Hardware Design Guidelines” (the PowerPoint document dating back to 1999 if not earlier) is: no control/status registers in config space.

So, there must not be a scenario when config space must be accessed for usual IO request processing.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

>Our driver need to be WHQL’d. So I can’t use WDM headers.
WHQL would allow to do this for now but it could not guarantee that you could use WDM headers in next releases of Windows.

Igor Sharovar

Thanks to you all for your reply!
The key point is software need to fix some hardware bugs by adjusting the PCI configuration registers.
Boss don’t want to remake hardware because he don’t want to pay money for it. So boss push me to solve hardware bugs by software.

i think a KMDF lower filter is probably going to be your best bet. I realize that you earlier said you don’t want to write a filter and incur the cost of it, but in this case it looks like scsiport does not afford you the ability to do what you want. by using KMDF the filter will be quite small, i would guess that you might have to just implement EvtDeviceD0Entry and D0Exit to fix your device.

d

You can solve the problem using software. We’ve outlined them to you. To not find a safe, sane, and well behaved way to rectify your bad hardware is irresponsible and could quite easily get his ass canned and your company bankrupt.

Gary G. Little

----- Original Message -----
From: xxxxx@hotmail.com
To: “Windows System Software Devs Interest List”
Sent: Thursday, January 20, 2011 1:10:02 AM
Subject: RE:[ntdev] How to get SCSI miniport driver’s PDO?

Thanks to you all for your reply!
The key point is software need to fix some hardware bugs by adjusting the PCI configuration registers.
Boss don’t want to remake hardware because he don’t want to pay money for it. So boss push me to solve hardware bugs by software.


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