s390/pci: refactor zpci function states
authorNiklas Schnelle <schnelle@linux.ibm.com>
Tue, 2 Mar 2021 13:55:21 +0000 (14:55 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 22 Mar 2021 10:36:03 +0000 (11:36 +0100)
The current zdev->state mixes the configuration states supported by CLP
with an additional Online state which is used inconsistently to include
enabled zPCI functions which are not yet visible to the common PCI
subsytem. In preparation for a clean separation between architected
configuration states and fine grained function states remove the Online
function state.

Where we previously checked for Online it is more accurate to check if
the function is enabled to avoid an edge case where a disabled device
was still treated as Online. This also simplifies checks whether
a function is configured as this is now directly reflected by its
function state.

Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/include/asm/pci.h
arch/s390/pci/pci.c
drivers/pci/hotplug/s390_pci_hpc.c

index a75d94a9bcb2f4265cbacc1d04a2580412666e94..5ed11936dc3b5c4da268e41d7038f1b9f3d591bd 100644 (file)
@@ -85,7 +85,6 @@ enum zpci_state {
        ZPCI_FN_STATE_STANDBY = 0,
        ZPCI_FN_STATE_CONFIGURED = 1,
        ZPCI_FN_STATE_RESERVED = 2,
-       ZPCI_FN_STATE_ONLINE = 3,
 };
 
 struct zpci_bar_struct {
index 91064077526df01128b78a677d2b1fdec02737e9..053113bcad607dbb2e15fbb215d5fda1541400db 100644 (file)
@@ -661,7 +661,6 @@ int zpci_enable_device(struct zpci_dev *zdev)
        if (rc)
                goto out_dma;
 
-       zdev->state = ZPCI_FN_STATE_ONLINE;
        return 0;
 
 out_dma:
@@ -770,7 +769,7 @@ int zpci_create_device(u32 fid, u32 fh, enum zpci_state state)
        return 0;
 
 error_disable:
-       if (zdev->state == ZPCI_FN_STATE_ONLINE)
+       if (zdev_enabled(zdev))
                zpci_disable_device(zdev);
 error_destroy_iommu:
        zpci_destroy_iommu(zdev);
@@ -787,11 +786,10 @@ void zpci_release_device(struct kref *kref)
        if (zdev->zbus->bus)
                zpci_remove_device(zdev, false);
 
-       switch (zdev->state) {
-       case ZPCI_FN_STATE_ONLINE:
-       case ZPCI_FN_STATE_CONFIGURED:
+       if (zdev_enabled(zdev))
                zpci_disable_device(zdev);
-               fallthrough;
+
+       switch (zdev->state) {
        case ZPCI_FN_STATE_STANDBY:
                if (zdev->has_hp_slot)
                        zpci_exit_slot(zdev);
index a047c421debe2e10606f8649f015436953daa7d1..c93c09ae4b04ee227c3272a885a83291e58a6354 100644 (file)
 
 #define SLOT_NAME_SIZE 10
 
-static int zpci_fn_configured(enum zpci_state state)
-{
-       return state == ZPCI_FN_STATE_CONFIGURED ||
-              state == ZPCI_FN_STATE_ONLINE;
-}
-
 static inline int zdev_configure(struct zpci_dev *zdev)
 {
        int ret = sclp_pci_configure(zdev->fid);
@@ -85,7 +79,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
        struct pci_dev *pdev;
        int rc;
 
-       if (!zpci_fn_configured(zdev->state))
+       if (zdev->state != ZPCI_FN_STATE_CONFIGURED)
                return -EIO;
 
        pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);