/* zpci_bus_prepare_device - Prepare a zPCI function for scanning * @zdev: the zPCI function to be prepared * * The PCI resources for the function are set up and added to its zbus and the * function is enabled. The function must be added to a zbus which must have * a PCI bus created. If an error occurs the zPCI function is not enabled. * * Return: 0 on success, an error code otherwise
*/ staticint zpci_bus_prepare_device(struct zpci_dev *zdev)
{ int rc, i;
if (!zdev_enabled(zdev)) {
rc = zpci_enable_device(zdev); if (rc) return rc;
}
if (!zdev->has_resources) {
zpci_setup_bus_resources(zdev); for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (zdev->bars[i].res)
pci_bus_add_resource(zdev->zbus->bus, zdev->bars[i].res);
}
}
return 0;
}
/* zpci_bus_scan_device - Scan a single device adding it to the PCI core * @zdev: the zdev to be scanned * * Scans the PCI function making it available to the common PCI code. * * Return: 0 on success, an error value otherwise
*/ int zpci_bus_scan_device(struct zpci_dev *zdev)
{ struct pci_dev *pdev; int rc;
rc = zpci_bus_prepare_device(zdev); if (rc) return rc;
pdev = pci_scan_single_device(zdev->zbus->bus, zdev->devfn); if (!pdev) return -ENODEV;
/* zpci_bus_remove_device - Removes the given zdev from the PCI core * @zdev: the zdev to be removed from the PCI core * @set_error: if true the device's error state is set to permanent failure * * Sets a zPCI device to a configured but offline state; the zPCI * device is still accessible through its hotplug slot and the zPCI * API but is removed from the common code PCI bus, making it * no longer available to drivers.
*/ void zpci_bus_remove_device(struct zpci_dev *zdev, bool set_error)
{ struct zpci_bus *zbus = zdev->zbus; struct pci_dev *pdev;
/* zpci_bus_scan_bus - Scan all configured zPCI functions on the bus * @zbus: the zbus to be scanned * * Enables and scans all PCI functions on the bus making them available to the * common PCI code. If a PCI function fails to be initialized an error will be * returned but attempts will still be made for all other functions on the bus. * * Return: 0 on success, an error value otherwise
*/ int zpci_bus_scan_bus(struct zpci_bus *zbus)
{ struct zpci_dev *zdev; int devfn, rc, ret = 0;
for (devfn = 0; devfn < ZPCI_FUNCTIONS_PER_BUS; devfn++) {
zdev = zbus->function[devfn]; if (zdev && zdev->state == ZPCI_FN_STATE_CONFIGURED) {
rc = zpci_bus_prepare_device(zdev); if (rc)
ret = -EIO;
}
}
/* zpci_bus_create_pci_bus - Create the PCI bus associated with this zbus * @zbus: the zbus holding the zdevices * @fr: PCI root function that will determine the bus's domain, and bus speed * @ops: the pci operations * * The PCI function @fr determines the domain (its UID), multifunction property * and maximum bus speed of the entire bus. * * Return: 0 on success, an error code otherwise
*/ staticint zpci_bus_create_pci_bus(struct zpci_bus *zbus, struct zpci_dev *fr, struct pci_ops *ops)
{ struct pci_bus *bus; int domain;
domain = zpci_alloc_domain((u16)fr->uid); if (domain < 0) return domain;
/* * Note that the zbus->resources are taken over and zbus->resources * is empty after a successful call
*/
bus = pci_create_root_bus(NULL, ZPCI_BUS_NR, ops, zbus, &zbus->resources); if (!bus) {
zpci_free_domain(zbus->domain_nr); return -EFAULT;
}
/* * With pdev->no_vf_scan the common PCI probing code does not * perform PF/VF linking.
*/ if (zdev->vfn) {
zpci_iov_setup_virtfn(zdev->zbus, pdev, zdev->vfn);
pdev->no_command_memory = 1;
}
}
if (zbus->multifunction) { if (!zdev->rid_available) {
WARN_ONCE(1, "rid_available not set for multifunction\n"); return rc;
}
zdev->devfn = zdev->rid & ZPCI_RID_MASK_DEVFN;
}
if (zbus->function[zdev->devfn]) {
pr_err("devfn %04x is already assigned\n", zdev->devfn); return rc;
}
zdev->zbus = zbus;
zbus->function[zdev->devfn] = zdev;
zpci_nb_devices++;
rc = zpci_init_slot(zdev); if (rc) goto error;
zdev->has_hp_slot = 1;
if (zpci_nb_devices == ZPCI_NR_DEVICES) {
pr_warn("Adding PCI function %08x failed because the configured limit of %d is reached\n",
zdev->fid, ZPCI_NR_DEVICES); return -ENOSPC;
}
topo = topo_is_tid ? zdev->tid : zdev->pchid;
zbus = zpci_bus_get(topo, topo_is_tid); /* * An isolated VF gets its own domain/bus even if there exists * a matching domain/bus already
*/ if (zbus && zpci_bus_is_isolated_vf(zbus, zdev)) {
zpci_bus_put(zbus);
zbus = NULL;
}
if (!zbus) {
zbus = zpci_bus_alloc(topo, topo_is_tid); if (!zbus) return -ENOMEM;
}
if (!zbus->bus) { /* The UID of the first PCI function registered with a zpci_bus * is used as the domain number for that bus. Currently there * is exactly one zpci_bus per domain.
*/
rc = zpci_bus_create_pci_bus(zbus, zdev, ops); if (rc) goto error;
}
rc = zpci_bus_add_device(zbus, zdev); if (rc) goto error;
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.