arch/s390/pci/pci_bus.c

Source file repositories/reference/linux-study-clean/arch/s390/pci/pci_bus.c

File Facts

System
Linux kernel
Corpus path
arch/s390/pci/pci_bus.c
Extension
.c
Size
11587 bytes
Lines
484
Domain
Architecture Layer
Bucket
arch/s390
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

if (rc) {
			pr_err("Enabling PCI function %08x failed\n", zdev->fid);
			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;

	pci_lock_rescan_remove();
	pci_bus_add_device(pdev);
	pci_unlock_rescan_remove();

	return 0;
}

/* 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;

	if (!zdev->zbus->bus)
		return;

	pdev = pci_get_slot(zbus->bus, zdev->devfn);
	if (pdev) {
		if (set_error)
			pdev->error_state = pci_channel_io_perm_failure;
		if (pdev->is_virtfn) {
			zpci_iov_remove_virtfn(pdev, zdev->vfn);
			/* balance pci_get_slot */
			pci_dev_put(pdev);
			return;
		}
		pci_stop_and_remove_bus_device_locked(pdev);
		/* balance pci_get_slot */
		pci_dev_put(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;

Annotation

Implementation Notes