WDDM load problem

Hi all,

I’m developing a WDDM driver, currently I have skeleton user mode
and miniport drivers.

After installation and rebooting on Win7 I’m getting the following
call sequence.

DriverEntry
DxgkDdiAddDevice
DxgkDdiQueryInterface {2564aa4f-dddb-4495-b497-6ad4a84163d7} I2C
DxgkDdiQueryInterface {bf4672de-6b4e-4be4-a325-68a91ea49c9} OPM
DxgkDdiStartDevice
DxgkDdiQueryChildRelations
DxgkDdiStopDevice
DxgkDdiRemoveDevice
DxgkDdiUnload

I can’t see any debug message that clarify the reason for choosing to
use the VGA driver instead of my WDDM driver (I’m enabling VIDEOPORT,
VIDEO, IHVVIDEO, and DEFAUL debug output).

*Device status in Device Manager show error code 43

What can be the reason for such a behaviour?

Thanks,
Ron

---- Following is detailed description of current implementation ----

The user mode driver export OpenAdapter (current imp call OutputDebugString
and return E_OUTOFMEMORY). I also call OutputDebugString in DllMain.

The miniport DriverEntry assign valid functions pointers to all members of
DRIVER_INITALIZATION_DATA except DxgkDdiLinkDevice. Most of the functions
just call DbgPrintEx and return STATUS_UNSUCCESSFUL.

The following functions have different implementation than what has been
described in the above paragraph.

DriverEntry
fill DRIVER_INITIALIZATION_DATA
call DxgkInitialize and return its ret val (is STATUS_SUCCESS)

AddDevice
allocate private device context and return STATUS_SUCCESS

StartDevice

  1. save device handle and DxgkCbUnmapMemory in the private context
  2. call DxgkCbGetDeviceInformation
  3. Map pci resources using DxgkCbMapMemory
  4. set *sources = 1 and *children = 1

StopDevice
unmap resources using DxgkCbUnmapMemory and return STATUS_SUCCESS

RemoveDevice
free private device and return STATUS_SUCCESS

QueryChildRelations
set array elemnt 0
ChildDeviceType = TypeVideoOutput;
ChildCapabilities.Type.VideoOutput.InterfaceTechnology =
D3DKMDT_VOT_HD15;

ChildCapabilities.Type.VideoOutput.MonitorOrientationAwareness =
D3DKMDT_MOA_INTERRUPTIBLE;
ChildCapabilities.Type.VideoOutput.SupportsSdtvModes = TRUE;
ChildCapabilities.HpdAwareness = HpdAwarenessInterruptible;
AcpiUid = 0;
ChildUid = 1;
return STATUS_SUCCESS

QueryInterface
return STATUS_NOT_SUPPORTED

In this scenario CM_PROB_FAILED_POST_START (error 43) typically indicates one or both of the two situations below:

  1. The port driver dxgkrnl.sys checks PCI configuration space for video adapter class 03. If it finds a different class, then it will refuse to work with this hardware.

  2. The port driver dxgkrnl.sys connects to the interrupt (instead of letting the WDDM miniport driver do this). If it cannot connect (e.g. because the hardware does not have interrupts), then it will refuse to work with this hardware.

These are known design limitations of the WDDM driver model. Contact us for a solution (ready made software and/or consulting).

Marcel R?dinger
datronicsoft

Hi,

  1. Device base class 3 subclass 0 interface 0 (unless there is some corruption, I will verify
    it in real time).

  2. The hardware have interrupt and is connected successful (InterruptRoutine is called on
    hardware interrupt).

Thanks,
Ron

Hi,

Class code in real time is 0x30000.

Thanks,
Ron

The traces don’t even get to DxgkDdiQueryAdapterInfo. There must be at least one early, simple and obvious mistake (e.g. in the above code ChildUid is 1 for the first child instead of 0).

Marcel Ruedinger
datronicsoft

Hi,

According to the documentation ChildUid is “A unique identifier, created by the display miniport driver, that identifies the child device”. Nothing imply any restriction on it except been unique. But anyway I will try to assign 0 to the first child. Maybe AcpiUid is the cause of the problem, I don’t know what value to assign.

Thanks,
Ron

Very likely neither ChildUid, nor AcpiUid are problematic. Indeed only “video present sources” have to be 0 based (but seemingly not the targets) and AcpiUid=0 works in WDDM drivers we wrote for our customers.

First option is still “some simple mistake”: This can easily happen, because there is no sample source code available for WDDM drivers. Hint: With only very few lines of code and even without touching the hardware (DxgkCbGetDeviceInformation and DxgkCbMapMemory are not needed) the driver should at least get DxgkDdiQueryAdapterInfo

Second option is still “the hardware”: Sure dxgkrnl.sys is happy with the hardware? Due to the above named WDDM limitations this question can never be answered with 100% certainty unless talking to Microsoft. If in doubt, install the “to be developed” WDDM driver on a Windows Logo certified graphics adapter hardware. If it still doesn’t get DxgkDdiQueryAdapterInfo then it is definitely the driver’s fault (back to first option above).

Marcel Ruedinger
datronicsoft

Hi,

If I understand you correctly dxgkrnl.sys is less restrictive during
WLK test. Any way I’m downloading the WLK now and I’ll probably
test it next week.

Thanks,
Ron

What I was saying:

Don’t trust a port driver like dxgkrnl.sys that accesses the hardware directly bypassing its miniport!

You can only really know what makes dxgkrnl.sys happy if talking to MS (which probably you don’t do), looking at the source (which probably you don’t do) or debugging on Assembly language level (which I did and which you probably don’t want to do). Thus the only remaining solution: Give him a hardware that is known/certified to make him happy! Then if he is still unhappy you know it is NOT the hardware he is unhappy about. In that case you can fully focus to find the error in the few lines of driver code.

Summary: CM_PROB_FAILED_POST_START (error 43) is most likely the port driver dxgkrnl.sys saying “I am NOT happy!”. Typically he says this because he either doesn’t like the hardware or he doesn’t like the driver.

Thanks for your help.

Ron

Hi
one question : r u loading dxgkrnl or is it already loaded by some primary driver before ur driver loads???

well hardware interrupt is not a problem here , if it is then ur driver wouldnt have gone beyong add device…(try to install wddm with fake calls without hardware…) .Upto query child relation everything seems fine, but after that stop device shouldnt come. at all. First of all Pls verify that

  1. size of buffer u r getting in querychildrelation == size of DXGK_CHILD_DESCRIPTOR *(NumberOfChildren returned in startdevice + 1).
  2. pls zeroed out last DXGK_CHILD_DESCRIPTOR structure.OS identifies it.
  3. check the return status of ur function.
  4. provide ur own childuid (in case making virtual wddm u can provide fake id no.)
    5.choose correct value for HpdAwarenessInterruptible

this function is a simple one … wont give u much pain as compared to enum functions u ll encounter after this.

Hi,

dxgkrnl.sys is not loaded while installing the driver but at this point
the specified call sequence that I described is irrelative. It is relevant
only after I reboot the machine (I’m getting “need to restart” message
after the installation is completed).

After reboot:
On DriverEntry dxgkrnl.sys is not loaded
On AddDevice dxgkrnl.sys is loaded

Following is my DxgkDdiQueryChildRelations implementation.

#define NUM_CHILDRENS 1

static NTSTATUS NdrvQueryChildRelations(IN_CONST_PVOID context,
INOUT_PDXGK_CHILD_DESCRIPTOR relations,
IN_ULONG relations_size)
{
NDRVContext* dev;
int i;

PAGED_CODE();

DEBUG_MESSAGE(“begin”);

dev = (NDRVContext*)context;

if (!dev || !relations ||
relations_size != sizeof(DXGK_CHILD_DESCRIPTOR) * (NUM_CHILDRENS + 1) ||
!ZerosTest(relations, relations_size)) {

DEBUG_MESSAGE(“invalid args”);
DbgBreakPoint();
return STATUS_INVALID_PARAMETER;

}

for (i = 0; i < NUM_CHILDRENS; i++) {
relations[i].ChildDeviceType = TypeVideoOutput;
relations[i].ChildCapabilities.Type.VideoOutput.InterfaceTechnology = D3DKMDT_VOT_HD15;
relations[i].ChildCapabilities.Type.VideoOutput.MonitorOrientationAwareness = D3DKMDT_MOA_INTERRUPTIBLE;
relations[i].ChildCapabilities.Type.VideoOutput.SupportsSdtvModes = TRUE;
relations[i].ChildCapabilities.HpdAwareness = HpdAwarenessInterruptible;
relations[i].AcpiUid = 0;
relations[i].ChildUid = i + 1;
}

DEBUG_MESSAGE(“STATUS_SUCCESS”);

return STATUS_SUCCESS;
}

INOUT_PDXGK_CHILD_DESCRIPTOR supposed to be cleared by the caller so I only test validity.

What do you mean by “choose correct value for HpdAwarenessInterruptible”. Correct value for HpdAwareness?

Thanks,
Ron

hi

>>>dxgkrnl.sys is not loaded while installing the driver but at this point
the specified call sequence that I described is irrelative. It is relevant
only after I reboot the machine (I’m getting “need to restart” message
after the installation is completed).

ok so u are acting as primary display driver…Dxgkrnl is loaded by dxgkinitialize function u call in driverentry(can check disassembly, they use zwloaddriver for loading dxgkrnl.sys)

ur query child relation function seems to be ok to me.
r u working on win 7 or vista???
seems like ur graphic card is connected thru pci bus (not on motherboard).
m travelling now and ll be back by this friday then i ll give u values for dxgk_child_descriptor structure for pci connected graphic card(dnt remember rite now)…

i got to know (didnt check though) that virtual box VM has already made virtual wddm.
its open source . u can check that one also by the time…

Hi,

  1. I’m using Win7 and the device is virtual PCI device.

  2. I did not see anything useful in VirtualBox sources. I did some code comparison
    and I also tried to replace some code (in order to verify that I’m not missing something).
    In general VirtualBox sources doesn’t look like something that works, take a look in
    “vbox/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.inf” it is mostly
    commented out and as far as I can remember the sources also seems half baked.

Thanks,
Ron

Have you tried my suggestion above? Have you tested your driver installed on top of a Logo-certified graphics adapter hardware?

Above I was deliberately talking about “the hardware”. This is not limited to interrupts only! Just one more example: At one specific occasion on at least one OS version we have seen dxgkrnl.sys reject an adapter that was a “Vga Compatible Controller” (0x00) in PCI configuration space. Obviously it was not “VGA compatible” enough for dxgkrnl.sys. Changing it to “Other Display Controller” (0x80) helped. Is your hardware really “VGA compatible” enough?

Marcel Ruedinger
datronicsoft

Hi,

No I did not. I don’t have all the required component for installing WLK (e.g. Microsoft SQL Desktop Edition). Instead I’ll just install it on one machine while there is a remote kernel debugger connected.
For that I need additional pc so it will take some time.

Thanks,
Ron

No Windows Logo Kit needed. Any standard graphics adapter hardware (available in computer stores) with Win7 Logo will do.

Marcel Ruedinger
datronicsoft

Hi,

Is the same scenario while using Redeon HD 5750.

What is the expected call following DxgkDdiQueryChildRelations?

Thanks,
Ron

In our driver which is WDDM 1.0 we see a call to QueryAdapterInfo() after the QueryChildRelations() call.