Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


WDf Interrupt Policy

msrmsr Member Posts: 368

Hi

I am using WdfInterruptSetPolicy. I can see below m_XXX members has the new policy values I set.
But IoResourceDescriptor->Flags has CM_RESOURCE_INTERRUPT_POLICY_INCLUDED bit set and thus escapes the if block.
I am creating WDFINTERRUPT object is AddDevice() and do not have any InterruptAffinity\AssignmentOverride registry keys set.
Please let me know in case you see anywhere it is when/how/being set.

FxInterrupt::FilterResourceRequirements(
  //
    // Apply policy.  Only do this if we are running on an OS which supports
    // the notion of Interrupt Policy and if the policy is not already included
    // by the bus driver based on registry settings.
    //
    if (FxLibraryGlobals.IoConnectInterruptEx != NULL &&
        m_SetPolicy &&
        (IoResourceDescriptor->Flags & CM_RESOURCE_INTERRUPT_POLICY_INCLUDED) == 0x0) {

        IoResourceDescriptor->Flags |= CM_RESOURCE_INTERRUPT_POLICY_INCLUDED;
        IoResourceDescriptor->u.Interrupt.AffinityPolicy      = (IRQ_DEVICE_POLICY)m_Policy;
        IoResourceDescriptor->u.Interrupt.PriorityPolicy      = (IRQ_PRIORITY)m_Priority;
        IoResourceDescriptor->u.Interrupt.TargetedProcessors  = m_Processors.Mask;
        IoResourceDescriptor->u.Interrupt.Group               = m_Processors.Group;
    }
}

thanks

Comments

  • Mark_RoddyMark_Roddy Member - All Emails Posts: 4,575
    via Email
    Most likely the 'policy' is already set by the bus device providing the
    interrupt resource and you cannot change it.

    Mark Roddy
  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 9,043

    As an aside, I spent some time trying to change the interrupt policy for a PCI device that was supported by a WDF driver I was developing. I was never successful in doing it. I eventually had to abandon the effort, because I ran out of play time (and changing the interrupt policy was never anything but a lame attempt to work around a platform integration issue in any case). But I just wanted to note that changing the policy was not nearly as straight forward as I expected it to be.

    Peter Viscarola
    OSR
    @OSRDrivers

  • msrmsr Member Posts: 368

    Mark
    When in windbg, I cleared that flag, everything works. All my MSI-X vectors get the policy I individually applied to each vector/interrupt.
    For me it looks like that flag should be set only when driver INF has AssignmentSetOverride reg key.

    Peter
    Trying this again to deal a case of tput/perf under hybrid cores scenario.

    https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/interrupt-affinity-and-priority

  • Mark_RoddyMark_Roddy Member - All Emails Posts: 4,575

    For me it looks like that flag should be set only when driver INF has AssignmentSetOverride reg key.

    Well that is one way, but any bus or lower filter driver associated with the PDO can also set the flag before you get at it, right?

  • MBond2MBond2 Member Posts: 494

    Are you trying to apply a policy that will route your interrupts to performance cores only?

    As is always the case with performance, there is an interesting discussion to be had here I think. It seems sure that in direct benchmarks of your device's throughput, this would be beneficial, but it seems less clear that this would help overall system performance

    The way that the chipset handles interrupts and the way that the scheduler operates - both factors beyond your control - would seem to be more important factors. But the world of asymmetric multi processing is a very interesting one

  • msrmsr Member Posts: 368

    @Mark_Roddy said:
    Well that is one way, but any bus or lower filter driver associated with the PDO can also set the flag before you get at it, right?

    In my case I do not have a lower filter. And bus (pci.sys) should not be doing that for the API contract to workw?

    @MBond2 said:
    It seems sure that in direct benchmarks of your device's throughput, this would be beneficial,

    yes just for lab purpose

    --
    I was able to make this work with the other method, filter-resource (Though not by just modifying resources in place, like WDM way IRP filter resources suggests). So I delete all resources and add them back with the policies I want. But MSDN has below.

    The framework calls the driver's EvtDeviceRemoveAddedResources callback function immediately before it passes the device's resource list to the bus driver. This callback function removes added resources so that the bus driver will not attempt to use them.

    I do not delete the ones I added, then everything works. I can policy my interrupts the way I want. Please let know what above means?

  • Mark_RoddyMark_Roddy Member - All Emails Posts: 4,575

    Just FYI, there is always a lower filter driver in a pci stack. acpi.sys is on the stack. Go take a look.

  • msrmsr Member Posts: 368

    @Mark_Roddy said:
    Just FYI, there is always a lower filter driver in a pci stack. acpi.sys is on the stack. Go take a look.

    Thanks, I missed this.

  • MBond2MBond2 Member Posts: 494

    If this is just for a test in your lab, then why worry about any warnings that MSDN might have

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 30 January 2023 Live, Online
Developing Minifilters 20 March 2023 Live, Online
Writing WDF Drivers TBD 2023 Live, Online
Internals & Software Drivers 17 April 2023 Live, Online