Assigning resources to FDO's from BUS Diver

Hi

I have a Bus driver which creates 2 FDOs’.

My device/resources are are not yet suitable for MF.sys (not true PCIe multifunction, FDO1 uses part of BAR and FDO uses rest of same BAR etc). Also have 1 MSI only whole device.

Bus driver is the one which gets the actual resource list from Pnp etc. FDOs’ don’t get any resources in their EventPrepHW now. Was looking into BUS driver assigning resources in standard way to FDOs’. Seems below are the 2 PDO cbs’ I have to handle.
EVT_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY - *resource requirements list*
EVT_WDF_DEVICE_RESOURCES_QUERY - *resource list*, boot configuration.

Searching archives suggest (can’t use MF.sys), can’t use above standard methods for all resources, since I have single MSI for whole device. But I might soon get multiple MSI and in future maybe separate BARs for separate FDOs, so was thinking of implementing resource arbitration by myself now itself like below - be code ready for then.

In both of above child pdo callbacks, provide whatever PCI.sys provided to bus driver EvtPrepHw. Then

  1. Within the Child FDOs, use only those subsections of the BAR that are specific to this FDO
  2. Call WdfInterruptCreate() for the raw/translated INTERRUPT (MSI) resource.

Then

  • For 1) , calling MmMapIoSpace() twice for same PA is just not optimal or causes failure itself?
  • For 2), calling WdfInterruptCreate() twice with same PWDF_INTERRUPT_CONFIG (but different Wdfdevice param) - will it cause failure or will/can now the MSI(-x) be shared !!!???

Will it have any/above/what-more issues? Asking now itself before I go down this path to test out. Please let me know. More or less I have the suggested way of exchanging resources - through driver defined interfaces.

Also above should take care of rebalance case also right?, because it is my bus driver that is providing the (same) resource list (to both FDOs’) and that is always dependent/identical as what the bus-driver has. Or there are more/what issues still left?

Thanks.

The typical method is to use a device interface to have the function driver
register a callback function and a context with the bus driver. Note:
Microsoft does not expose the interfaces to offer an interrupt as a
resource. You may think you can get it to work, but I learned from sad
experiences, that even if it works there are edge conditions that cause
failures. So the best approach is to create the interrupt in the bus
driver, and have it do the callbacks.

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Thursday, August 02, 2018 6:59 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Assigning resources to FDO’s from BUS Diver

Hi

I have a Bus driver which creates 2 FDOs’.

My device/resources are are not yet suitable for MF.sys (not true PCIe
multifunction, FDO1 uses part of BAR and FDO uses rest of same BAR etc).
Also have 1 MSI only whole device.

Bus driver is the one which gets the actual resource list from Pnp etc.
FDOs’ don’t get any resources in their EventPrepHW now. Was looking into BUS
driver assigning resources in standard way to FDOs’. Seems below are the 2
PDO cbs’ I have to handle.
EVT_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY - resource requirements list
EVT_WDF_DEVICE_RESOURCES_QUERY - resource list, boot configuration.

Searching archives suggest (can’t use MF.sys), can’t use above standard
methods for all resources, since I have single MSI for whole device. But I
might soon get multiple MSI and in future maybe separate BARs for separate
FDOs, so was thinking of implementing resource arbitration by myself now
itself like below - be code ready for then.

In both of above child pdo callbacks, provide whatever PCI.sys provided to
bus driver EvtPrepHw. Then
1) Within the Child FDOs, use only those subsections of the BAR that
are specific to this FDO
2) Call WdfInterruptCreate() for the raw/translated INTERRUPT (MSI)
resource.

Then
- For 1) , calling MmMapIoSpace() twice for same PA is just not optimal or
causes failure itself?
- For 2), calling WdfInterruptCreate() twice with same PWDF_INTERRUPT_CONFIG
(but different Wdfdevice param) - will it cause failure or will/can now the
MSI(-x) be shared !!!???

Will it have any/above/what-more issues? Asking now itself before I go down
this path to test out. Please let me know. More or less I have the suggested
way of exchanging resources - through driver defined interfaces.

Also above should take care of rebalance case also right?, because it is my
bus driver that is providing the (same) resource list (to both FDOs’) and
that is always dependent/identical as what the bus-driver has. Or there are
more/what issues still left?

Thanks.


NTDEV is sponsored by OSR

Visit the list online at:
http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at
http:</http:></http:></http:>

O.k. Thanks Don. Will stick to device interface approach.