aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Schnelle <schnelle@linux.ibm.com>2021-03-26 13:58:48 +0100
committerHeiko Carstens <hca@linux.ibm.com>2021-04-12 12:46:42 +0200
commit61311e32892b008886478bdba4ce2a34f4d938f8 (patch)
treeb8e88fbcf8422e6347d0c33d6a83f755dc425f1d
parents390/pci: separate zbus registration from scanning (diff)
downloadlinux-dev-61311e32892b008886478bdba4ce2a34f4d938f8.tar.xz
linux-dev-61311e32892b008886478bdba4ce2a34f4d938f8.zip
s390/pci: narrow scope of zpci_configure_device()
Currently zpci_configure_device() can be called on a zPCI function in two completely different states. Either the underlying zPCI function has already been configured by the platform and we are only doing the scanning to get it usable by Linux drivers. Or the underlying function is in Standby and we first do an SCLP to get it configured. This makes zpci_configure_device() harder to reason about. Since calling zpci_configure_device() on a function in Standby only happens in enable_slot() simply pull out the SCLP call and setting of zdev->state and thus call zpci_configure_device() under the same circumstances as in the event handling code. Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> Reviewed-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>
-rw-r--r--arch/s390/pci/pci.c15
-rw-r--r--drivers/pci/hotplug/s390_pci_hpc.c7
2 files changed, 10 insertions, 12 deletions
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index d6c6b5119a14..c01b6dbac7cf 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -742,10 +742,9 @@ error:
* @zdev: The zpci_dev to be configured
* @fh: The general function handle supplied by the platform
*
- * Configuring a device includes the configuration itself, if not done by the
- * platform, enabling, scanning and adding it to the common code PCI subsystem.
- * If any failure occurs, the zpci_dev is left disabled either in Standby if
- * the configuration failed or Configured if enabling or scanning failed.
+ * Given a device in the configuration state Configured, enables, scans and
+ * adds it to the common code PCI subsystem. If any failure occurs, the
+ * zpci_dev is left disabled.
*
* Return: 0 on success, or an error code otherwise
*/
@@ -754,14 +753,6 @@ int zpci_configure_device(struct zpci_dev *zdev, u32 fh)
int rc;
zdev->fh = fh;
- if (zdev->state != ZPCI_FN_STATE_CONFIGURED) {
- rc = sclp_pci_configure(zdev->fid);
- zpci_dbg(3, "conf fid:%x, rc:%d\n", zdev->fid, rc);
- if (rc)
- return rc;
- zdev->state = ZPCI_FN_STATE_CONFIGURED;
- }
-
/* the PCI function will be scanned once function 0 appears */
if (!zdev->zbus->bus)
return 0;
diff --git a/drivers/pci/hotplug/s390_pci_hpc.c b/drivers/pci/hotplug/s390_pci_hpc.c
index 154532663a70..f8f056be71b7 100644
--- a/drivers/pci/hotplug/s390_pci_hpc.c
+++ b/drivers/pci/hotplug/s390_pci_hpc.c
@@ -24,10 +24,17 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
{
struct zpci_dev *zdev = container_of(hotplug_slot, struct zpci_dev,
hotplug_slot);
+ int rc;
if (zdev->state != ZPCI_FN_STATE_STANDBY)
return -EIO;
+ rc = sclp_pci_configure(zdev->fid);
+ zpci_dbg(3, "conf fid:%x, rc:%d\n", zdev->fid, rc);
+ if (rc)
+ return rc;
+ zdev->state = ZPCI_FN_STATE_CONFIGURED;
+
return zpci_configure_device(zdev, zdev->fh);
}