On 2/11/2023 4:25 AM, Lukas Wunner wrote: > 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. > > Overcome this limitation 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: Ira Weiny <ira.weiny@xxxxxxxxx> > Signed-off-by: Lukas Wunner <lukas@xxxxxxxxx> > Reviewed-by: Ira Weiny <ira.weiny@xxxxxxxxx> > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> Reviewed-by: Ming Li <ming4.li@xxxxxxxxx>