• Lukas Wunner's avatar
    PCI/DOE: Create mailboxes on device enumeration · ac048403
    Lukas Wunner authored
    Currently a DOE instance cannot be shared by multiple drivers because
    each driver creates its own pci_doe_mb struct for a given DOE instance.
    For the same reason a DOE instance cannot be shared between the PCI core
    and a driver.
    
    Moreover, finding out which protocols a DOE instance supports requires
    creating a pci_doe_mb for it.  If a device has multiple DOE instances,
    a driver looking for a specific protocol may need to create a pci_doe_mb
    for each of the device's DOE instances and then destroy those which
    do not support the desired protocol.  That's obviously an inefficient
    way to do things.
    
    Overcome these issues by creating mailboxes in the PCI core on device
    enumeration.
    
    Provide a pci_find_doe_mailbox() API call to allow drivers to get a
    pci_doe_mb for a given (pci_dev, vendor, protocol) triple.  This API is
    modeled after pci_find_capability() and can later be amended with a
    pci_find_next_doe_mailbox() call to iterate over all mailboxes of a
    given pci_dev which support a specific protocol.
    
    On removal, destroy the mailboxes in pci_destroy_dev(), after the driver
    is unbound.  This allows drivers to use DOE in their ->remove() hook.
    
    On surprise removal, cancel ongoing DOE exchanges and prevent new ones
    from being scheduled.  Thereby ensure that a hot-removed device doesn't
    needlessly wait for a running exchange to time out.
    Tested-by: default avatarIra Weiny <ira.weiny@intel.com>
    Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
    Reviewed-by: default avatarMing Li <ming4.li@intel.com>
    Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
    Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
    Link: https://lore.kernel.org/r/40a6f973f72ef283d79dd55e7e6fddc7481199af.1678543498.git.lukas@wunner.deSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
    ac048403
pci.h 26.3 KB