summaryrefslogtreecommitdiff
path: root/arch/s390/pci/pci_bus.h
diff options
context:
space:
mode:
authorPierre Morel <pmorel@linux.ibm.com>2020-03-23 12:45:43 +0300
committerVasily Gorbik <gor@linux.ibm.com>2020-04-28 14:49:46 +0300
commit05bc1be6db4b2683bbf5b9394a75d0fb3acfcede (patch)
tree98544c868a816f7bd8812ff88b53eec1fbd5e338 /arch/s390/pci/pci_bus.h
parentc9a1752b84f1a8f73187c116ff0514b2ab24d878 (diff)
downloadlinux-05bc1be6db4b2683bbf5b9394a75d0fb3acfcede.tar.xz
s390/pci: create zPCI bus
The zPCI bus is in charge to handle common zPCI resources for zPCI devices. Creating the zPCI bus, the PCI bus, the zPCI devices and the PCI devices and hotplug slots done in a specific order: - PCI hotplug slot creation needs a PCI bus - PCI bus needs a PCI domain which is reported by the pci_domain_nr() when setting up the host bridge - PCI domain is set from the zPCI with devfn 0 this is necessary to have a reproducible enumeration Therefore we can not create devices or hotplug slots for any PCI device associated with a zPCI device before having discovered the function zero of the bus. The discovery and initialization of devices can be done at several points in the code: - On Events, serialized in a thread context - On initialization, in the kernel init thread context - When powering on the hotplug slot, in a user thread context The removal of devices and their parent bus may also be done on events or for devices when powering down the slot. To guarantee the existence of the bus and devices until they are no more needed we use kref in zPCI bus and introduce a reference count in the zPCI devices. In this patch the zPCI bus still only accept a device with a devfn 0. Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Diffstat (limited to 'arch/s390/pci/pci_bus.h')
-rw-r--r--arch/s390/pci/pci_bus.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/arch/s390/pci/pci_bus.h b/arch/s390/pci/pci_bus.h
new file mode 100644
index 000000000000..c6aff42cc2cf
--- /dev/null
+++ b/arch/s390/pci/pci_bus.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright IBM Corp. 2020
+ *
+ * Author(s):
+ * Pierre Morel <pmorel@linux.ibm.com>
+ *
+ */
+
+int zpci_bus_device_register(struct zpci_dev *zdev, struct pci_ops *ops);
+void zpci_bus_device_unregister(struct zpci_dev *zdev);
+int zpci_bus_init(void);
+
+void zpci_release_device(struct kref *kref);
+static inline void zpci_zdev_put(struct zpci_dev *zdev)
+{
+ kref_put(&zdev->kref, zpci_release_device);
+}
+
+int zpci_alloc_domain(int domain);
+void zpci_free_domain(int domain);
+int zpci_setup_bus_resources(struct zpci_dev *zdev,
+ struct list_head *resources);
+
+static inline struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus)
+{
+ struct zpci_bus *zbus = bus->sysdata;
+
+ return zbus->function[ZPCI_DEVFN];
+}