Storport - Update PCI Slot Control Register

I’m working on a storport-miniport driver for a PCI-e attached storage device.

Is there a way for my driver to alter the PCI Slot control register? Specifically, I’m looking to change Attention and power indicator controls.

I was thinking that I could use StorPortInvokeAcpiMethod. But after digging through the ACPI spec, I don’t see a relevant method.

I’d appreciate any direction on how to approach this.
Thanks,
Tom Freeman

xxxxx@hgst.com wrote:

I’m working on a storport-miniport driver for a PCI-e attached storage device.

Is there a way for my driver to alter the PCI Slot control register? Specifically, I’m looking to change Attention and power indicator controls.

You’re not supposed to touch those. They are owned by the hot-plug and
power control system in the operating system. That’s part of the PCIe
specification.

I was thinking that I could use StorPortInvokeAcpiMethod. But after digging through the ACPI spec, I don’t see a relevant method.

You can read and write configuration space by querying for an interface,
or by sending ioctls to the bus driver:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff536890.aspx


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim… thank you for the prompt response and the information

You’re not supposed to touch those. They are owned by the hot-plug and power control system in the >operating system. That’s part of the PCIe specification.
This makes sense. Based on your comment I found some pretty convincing statements in the PCIe base spec and the PCI Hot-plug spec. Hopefully, I can convince others of this.

You can read and write configuration space by querying for an interface, or by sending ioctls to the >bus driver: https://msdn.microsoft.com/en-us/library/windows/hardware/ff536890.aspx
Unless I’m missing something, this requires me to add IRP construction/processing to my driver. That’s a complexity I’d rather not deal with.

Thanks again.
Tom Freeman

xxxxx@hgst.com wrote:

> You can read and write configuration space by querying for an interface, or by sending ioctls to the >bus driver: https://msdn.microsoft.com/en-us/library/windows/hardware/ff536890.aspx
Unless I’m missing something, this requires me to add IRP construction/processing to my driver. That’s a complexity I’d rather not deal with.

Well, yes, that’s the only way to deal with other drivers in Windows.
It’s not rocket science. There are excellent examples all over the web.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

The Storport supported methods for accessing PCI configuration space are StorPortGetBusData & StorPortSetBusDataByOffset.

https://msdn.microsoft.com/en-us/library/windows/hardware/ff567076(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/hardware/ff567503(v=vs.85).aspx

The GetBusData docs say it can only be used from FindAdapter and AdapterControl. The SetBusData docs don’t mention this restriction.

I don’t know how a non-virtual miniport would do what Tim suggested and obey the official StorPort rules because they’re technically not supposed to call anything that isn’t a Storport export (unless the rules have changed recently).

You took the words out of my mouth, Mr. Swann.

Unless the OP doesn’t care about passing the Windows HLK tests, there’s no way he can poof-up IRPs and such.

Peter
OSR
@OSRDrivers

Thanks for all of the feedback.

< there’s no way he can poof-up IRPs and such.
Yes, we are concerned about passing Windows HLK.

Here is my summary of the possible solutions:
1. Bus interface method: Use IRP_MN_QUERY_INTERFACE (IRQL < dispatch) to get the BUS_INTERFACE_STANDARD structure. Then use interface methods GetBusData and SetBusData methods (these can be called from IRQL <= DIRQL) to retrieve and set the config data.
2. Use IRP_MN_READ_CONFIG/IRP_MN_WRITE_CONFIG ( only valid for IRQL < dispatch)
3. Use StorPortGetBusData (only valid from HwStorFindAdapter) and StorPortSetBusDataByOffset (IRQL ??)

-Options 1 & 2 will cause us to fail HLK.
-Option 3 - I may be able to set the data after initialization, but only based on data that was read during HwStorFindAdapter - which could be very old by the time I attempt to set it.
-All 3 methods violate the PCI-e spec’s direction to have the slot control register under the control of the hot plug manager.

Tom Freeman

As you probably already know, physical machines that support hot-plug Express slots are pretty rare. “Pretty” as in “while many people have asked, they’re so rare I’ve never seen one.”

It takes a ton of stuff to make Express hot plug work… the bus itself, the BIOS, the OS and the associated drivers all have to support it.

So… while everyone is always fond of saying “I want to support Hot Plug” in terms of real machines, good luck in anyone ever using it.

Now… you MIGHT be able to find a VM that can can consume a device from a particular slot, and allow you to hot add and hot remove it. But I couldn’t even point you to one of those that’s commercially available at this point.

Peter
OSR
@OSRDrivers