• Thomas Gleixner's avatar
    PCI/MSI: Split MSI-X descriptor setup · 612ad433
    Thomas Gleixner authored
    The upcoming mechanism to allocate MSI-X vectors after enabling MSI-X needs
    to share some of the MSI-X descriptor setup.
    
    The regular descriptor setup on enable has the following code flow:
    
        1) Allocate descriptor
        2) Setup descriptor with PCI specific data
        3) Insert descriptor
        4) Allocate interrupts which in turn scans the inserted
           descriptors
    
    This cannot be easily changed because the PCI/MSI code needs to handle the
    legacy architecture specific allocation model and the irq domain model
    where quite some domains have the assumption that the above flow is how it
    works.
    
    Ideally the code flow should look like this:
    
       1) Invoke allocation at the MSI core
       2) MSI core allocates descriptor
       3) MSI core calls back into the irq domain which fills in
          the domain specific parts
    
    This could be done for underlying parent MSI domains which support
    post-enable allocation/free but that would create significantly different
    code pathes for MSI/MSI-X enable.
    
    Though for dynamic allocation which wants to share the allocation code with
    the upcoming PCI/IMS support it's the right thing to do.
    
    Split the MSI-X descriptor setup into the preallocation part which just sets
    the index and fills in the horrible hack of virtual IRQs and the real PCI
    specific MSI-X setup part which solely depends on the index in the
    descriptor. This allows to provide a common dynamic allocation interface at
    the MSI core level for both PCI/MSI-X and PCI/IMS.
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
    Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    Acked-by: default avatarMarc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20221124232326.616292598@linutronix.de
    612ad433
msi.c 23.1 KB