driver load order for multiple pcie-functions

I’ve a pcie device with 4 functions and i want to load the same driver on all 4 functions. However, i need a specific load order such that f0 driver should be loaded first, followed by f1, f2 and f3. is there a way to control the load order? Or do i get this naturally in windows 10 kernel?

Appreciate any links to the docs that explain this subject in details.
Thanks!

Why do you think you need this? There are no guarantees for load order, and if you have 4 identical devices, there shouldn’t be any need for it.

Tell us the thinking that led you to this, and we’ll tell you the proper way to handle it.

https://docs.microsoft.com/en-us/windows-hardware/drivers/ifs/load-order-groups-for-file-system-filter-drivers

It depends on the group, and priority you’re setting to the service information.
If two or more drivers have the same service information, they will then be ordered alphabetically.

Similar threads:

@ThatsBerkan … that link doesn’t apply. It’s for file system filter drivers.

We’re talking PnP drivers here, and the load order for four separate Express functions shouldn’t matter, and isn’t really controllable, as Mr. Roberts said.

Peter

and the load order for four separate Express functions shouldn’t matter, and isn’t really controllable

…and the OP’s question does not even make sense,in the first place - he seems to be willing to load exactly the same driver 4 times, which simply does not make sense…

I strongly suspect that he’s got no idea of how PnP works, so that he seems to be confusing loading a diver with calling its AddDevice() function

AntonBassov

he seems to be willing to load exactly the same driver 4 times, which simply does not make sense.

Honestly, Anton. Of course it does. Imagine a PCIe card with 4 network adapters implemented as 4 PCIe functions. I’m not saying that’s how you’d implement it, but of course it is possible.

thank you guys for the feedback! you are right, i am very likely confused and also not know about it :slight_smile:
background is that the device has a bunch of resources that are divided among a number of functions. Idea is to run the same driver code on all functions. however, someone needs to tell each driver(before the startdevice is called) the number of device resources that are allocated to the given function. this is done by the first function that detects hw resources(not visible as general resources such mem, i/o. interrupts) and decides what other functions will have(the f0 itself will not expose any other real functionality to the user except some dynamic mgmt of hw resources). this is creating this need of ensuring that the f0 add/startdevice calls are made before any other function is started. the other option is we can just start all other functions with zero resources and pnp(stop/start) them later when f0 will assign them resources.

Look at https://docs.microsoft.com/en-us/windows-hardware/drivers/multifunction/using-the-system-supplied-multifunction-bus-driver If you can use that do it. Otherwise you are going to need to write a custom bus driver in KMDF split the resources. Then one or more function drivers to handle the specific resources.

You don’t need to have f0 do the allocation. You just need to have the first device do the allocation, whatever device it is. You can use globals in the driver to manage that, as long as you do the proper locking.