summaryrefslogtreecommitdiffstats
path: root/arch/s390/pci/pci_bus.c
diff options
context:
space:
mode:
authorNiklas Schnelle <schnelle@linux.ibm.com>2021-02-12 12:17:53 +0100
committerHeiko Carstens <hca@linux.ibm.com>2021-04-12 12:46:41 +0200
commit7dc697d6b2b5299ab7e09c592d727671a3859be2 (patch)
tree506cc8d7405afeb30189c6b24638ff811185e7d0 /arch/s390/pci/pci_bus.c
parents390/pci: introduce zpci_bus_scan_device() (diff)
downloadlinux-7dc697d6b2b5299ab7e09c592d727671a3859be2.tar.xz
linux-7dc697d6b2b5299ab7e09c592d727671a3859be2.zip
s390/pci: do more bus setup in zpci_bus_scan()
Pull setting the maximum bus speed and multifunction attribute into zpci_bus_scan() in preparation for handling bus creation separately from scanning the bus. Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> Acked-by: Pierre Morel <pmorel@linux.ibm.com> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Diffstat (limited to 'arch/s390/pci/pci_bus.c')
-rw-r--r--arch/s390/pci/pci_bus.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/arch/s390/pci/pci_bus.c b/arch/s390/pci/pci_bus.c
index 7b37c4316e35..f2577fb35be2 100644
--- a/arch/s390/pci/pci_bus.c
+++ b/arch/s390/pci/pci_bus.c
@@ -86,24 +86,33 @@ void zpci_bus_remove_device(struct zpci_dev *zdev, bool set_error)
}
}
-/* zpci_bus_scan
+/* zpci_bus_scan - Scan the PCI bus associated with this zbus
* @zbus: the zbus holding the zdevices
+ * @f0: function 0 of the bus
* @ops: the pci operations
*
- * The domain number must be set before pci_scan_root_bus is called.
- * This function can be called once the domain is known, hence
- * when the function_0 is dicovered.
+ * Function zero is taken as a parameter as this is used to determine the
+ * domain, multifunction property and maximum bus speed of the entire bus.
+ *
+ * Return: 0 on success, an error code otherwise
*/
-static int zpci_bus_scan(struct zpci_bus *zbus, int domain, struct pci_ops *ops)
+static int zpci_bus_scan(struct zpci_bus *zbus, struct zpci_dev *f0, struct pci_ops *ops)
{
struct pci_bus *bus;
- int rc;
+ int domain;
- rc = zpci_alloc_domain(domain);
- if (rc < 0)
- return rc;
- zbus->domain_nr = rc;
+ domain = zpci_alloc_domain((u16)f0->uid);
+ if (domain < 0)
+ return domain;
+ zbus->domain_nr = domain;
+ zbus->multifunction = f0->rid_available;
+ zbus->max_bus_speed = f0->max_bus_speed;
+
+ /*
+ * Note that the zbus->resources are taken over and zbus->resources
+ * is empty after a successful call
+ */
bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, ops, zbus, &zbus->resources);
if (!bus) {
zpci_free_domain(zbus->domain_nr);
@@ -288,7 +297,7 @@ int zpci_bus_device_register(struct zpci_dev *zdev, struct pci_ops *ops)
WARN_ONCE(1, "rid_available not set on function 0 for multifunction\n");
goto error_bus;
}
- rc = zpci_bus_scan(zbus, (u16)zdev->uid, ops);
+ rc = zpci_bus_scan(zbus, zdev, ops);
if (rc)
goto error_bus;
zpci_bus_add_devices(zbus);
@@ -296,8 +305,6 @@ int zpci_bus_device_register(struct zpci_dev *zdev, struct pci_ops *ops)
if (rc)
goto error_bus;
zdev->has_hp_slot = 1;
- zbus->multifunction = zdev->rid_available;
- zbus->max_bus_speed = zdev->max_bus_speed;
} else {
zbus->multifunction = 1;
}