// SPDX-License-Identifier: GPL-2.0 /* * PCI Backend - Provides a Virtual PCI bus (with real devices) * to the frontend * * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
*/
/* * Keep multi-function devices together on the virtual PCI bus, except * that we want to keep virtual functions at func 0 on their own. They * aren't multi-function devices and hence their presence at func 0 * may cause guests to not scan the other functions.
*/ if (!dev->is_virtfn || func) { for (slot = 0; slot < PCI_SLOT_MAX; slot++) { if (list_empty(&vpci_dev->dev_list[slot])) continue;
t = list_entry(list_first(&vpci_dev->dev_list[slot]), struct pci_dev_entry, list); if (t->dev->is_virtfn && !PCI_FUNC(t->dev->devfn)) continue;
/* Assign to a new slot on the virtual PCI bus */ for (slot = 0; slot < PCI_SLOT_MAX; slot++) { if (list_empty(&vpci_dev->dev_list[slot])) {
dev_info(&dev->dev, "vpci: assign to virtual slot %d\n",
slot);
list_add_tail(&dev_entry->list,
&vpci_dev->dev_list[slot]); goto unlock;
}
}
err = -ENOMEM;
xenbus_dev_fatal(pdev->xdev, err, "No more space on root virtual PCI bus");
unlock:
mutex_unlock(&vpci_dev->lock);
/* Publish this device. */ if (!err)
err = publish_cb(pdev, 0, 0, PCI_DEVFN(slot, func), devid); else
kfree(dev_entry);
if (found_dev) { if (lock)
device_lock(&found_dev->dev);
pcistub_put_pci_dev(found_dev); if (lock)
device_unlock(&found_dev->dev);
}
}
staticint __xen_pcibk_init_devices(struct xen_pcibk_device *pdev)
{ int slot; struct vpci_dev_data *vpci_dev;
vpci_dev = kmalloc(sizeof(*vpci_dev), GFP_KERNEL); if (!vpci_dev) return -ENOMEM;
mutex_init(&vpci_dev->lock);
for (slot = 0; slot < PCI_SLOT_MAX; slot++)
INIT_LIST_HEAD(&vpci_dev->dev_list[slot]);
pdev->pci_dev_data = vpci_dev;
return 0;
}
staticint __xen_pcibk_publish_pci_roots(struct xen_pcibk_device *pdev,
publish_pci_root_cb publish_cb)
{ /* The Virtual PCI bus has only one root */ return publish_cb(pdev, 0, 0);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.