CHANGING KMDF Interrupt Policy

In light of the thread where I discovered that a given interrupt is always affinitized to the same CPU… I’d like to know:

  • How can I change the Interrupt Affinity Policy
  • How can I change the interrupt Priority Policy

Clearly, this is trival for a device that has a single interrupt that is automagically connected to the WDFINTERRUPT that’s created in your EvtDriverDeviceAdd: You call WdfInterruptSetPolicy.

However, in the case of MSI/MSI-X, if there’s more than one message (as there typically is), the docs teach us:

If your driver creates interrupts in EvtDevicePrepareHardware, do not use WdfInterruptSetPolicy or WdfInterruptSetExtendedPolicy. Instead, apply policy in EvtDeviceFilterAddResourceRequirements, by directly manipulating the interrupt resource requirement that this callback function receives in its IoResourceRequirementsList parameter.

I’ve tried this several ways now, and I can’t see any change. I don’t see any difference in the behavior of interrupts on my device, the my WDFLOGDUMP looks the same:

Always showing “OneCloseProcessor” and priority “Undefined” – From looking at the WDF code on GitHub, it LOOKS like this should reflect the policy that’s actually being used. Can anybody confirm that?

But, like I said, in any case, I’m always seeing all my interrupts on CPU 0.

I’ve searched for an example of changing the Affinity Policy and Priority Policy in KMDF for a driver with multiple MSIs… but I don’t see one anywhere.

I’d like to know if anybody has managed to do this, and if they have… would they please share the magic incantation. In return, I’ll be happy to write it up and post an example for the community.

Help? Anyone???

Peter

Hi

I was not successful, below is what I did.

I used below reg keys to spread my MSI-X across logical procs

HKR, "Interrupt Management\Affinity Policy", DevicePolicy, %RegType_DW%, 5

I had 32 MSI-X, with above I saw MSI-X MSI-X[0] being assigned to some logical-proc n (n is not zero always), and then each subsequent MSI-X assigned to next logical-proc with wrapping around, when logical-procs are exhausted.

I also tried below reg-key to control what procs my MSI-X get targetted to (instead of all like in above), but was not successful.

HKR, "Interrupt Management\Affinity Policy", AssignmentSetOverride, 0x00000001, 55,55,00,00,00,00,00,00 ;little-endian

I also tried to do programatically like below but didn’t work (I modified the descriptor inplace inside FilterResourceRequirements()).
Maybe looks like I have to call WdfIoResourceListUpdateDescriptor() as well instead of just providing hint through CM_RESOURCE_INTERRUPT_POLICY_INCLUDED (which was enough for NDIS.FilterResourcesRequirments())

 //descriptor->u.Interrupt.PriorityPolicy = IrqPriorityHigh;
                d->u.Interrupt.AffinityPolicy = IrqPolicySpecifiedProcessors;
                d->u.Interrupt.TargetedProcessors = TARGETTED_PROCESSOR(MsgId);

                d->Flags |= CM_RESOURCE_INTERRUPT_POLICY_INCLUDED; // notify PnP that we modified

Thanks

Well, WdfIoResourceListUpdateDescriptor DOES copy the data back to the list and update an internal flag or list or something (see the sources)… and, according to the docs, you’re supposed to use that.

But, even using that in my code, it didn’t make a difference.

Thanks for posting… Please keep trying, and let me know if you have any luck. I’m actively working this issue (still),

Peter