]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
s390/cio: Do not unregister the subchannel based on DNV
authorVineeth Vijayan <vneethv@linux.ibm.com>
Mon, 23 Sep 2024 20:16:43 +0000 (22:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 18:50:42 +0000 (19:50 +0100)
[ Upstream commit 8c58a229688ce3a097b3b1a2efe1b4f5508c2123 ]

Starting with commit 2297791c92d0 ("s390/cio: dont unregister
subchannel from child-drivers"), CIO does not unregister subchannels
when the attached device is invalid or unavailable. Instead, it
allows subchannels to exist without a connected device. However, if
the DNV value is 0, such as, when all the CHPIDs of a subchannel are
configured in standby state, the subchannel is unregistered, which
contradicts the current subchannel specification.

Update the logic so that subchannels are not unregistered based
on the DNV value. Also update the SCHIB information even if the
DNV bit is zero.

Suggested-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Fixes: 2297791c92d0 ("s390/cio: dont unregister subchannel from child-drivers")
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/s390/cio/cio.c
drivers/s390/cio/device.c

index 923f5ca4f5e6b6584b902c42fc5984956ab56589..54bfa9fe3031b3920c7ca215e33c1f786dad1006 100644 (file)
@@ -459,10 +459,14 @@ int cio_update_schib(struct subchannel *sch)
 {
        struct schib schib;
 
-       if (stsch(sch->schid, &schib) || !css_sch_is_valid(&schib))
+       if (stsch(sch->schid, &schib))
                return -ENODEV;
 
        memcpy(&sch->schib, &schib, sizeof(schib));
+
+       if (!css_sch_is_valid(&schib))
+               return -EACCES;
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(cio_update_schib);
index c16f18cfeed720447d60927971c1a9e994aced43..c2ed91b69f0793d388569961c02a8e99eb57df20 100644 (file)
@@ -1390,14 +1390,18 @@ enum io_sch_action {
        IO_SCH_VERIFY,
        IO_SCH_DISC,
        IO_SCH_NOP,
+       IO_SCH_ORPH_CDEV,
 };
 
 static enum io_sch_action sch_get_action(struct subchannel *sch)
 {
        struct ccw_device *cdev;
+       int rc;
 
        cdev = sch_get_cdev(sch);
-       if (cio_update_schib(sch)) {
+       rc = cio_update_schib(sch);
+
+       if (rc == -ENODEV) {
                /* Not operational. */
                if (!cdev)
                        return IO_SCH_UNREG;
@@ -1405,6 +1409,16 @@ static enum io_sch_action sch_get_action(struct subchannel *sch)
                        return IO_SCH_UNREG;
                return IO_SCH_ORPH_UNREG;
        }
+
+       /* Avoid unregistering subchannels without working device. */
+       if (rc == -EACCES) {
+               if (!cdev)
+                       return IO_SCH_NOP;
+               if (ccw_device_notify(cdev, CIO_GONE) != NOTIFY_OK)
+                       return IO_SCH_UNREG_CDEV;
+               return IO_SCH_ORPH_CDEV;
+       }
+
        /* Operational. */
        if (!cdev)
                return IO_SCH_ATTACH;
@@ -1474,6 +1488,7 @@ static int io_subchannel_sch_event(struct subchannel *sch, int process)
                rc = 0;
                goto out_unlock;
        case IO_SCH_ORPH_UNREG:
+       case IO_SCH_ORPH_CDEV:
        case IO_SCH_ORPH_ATTACH:
                ccw_device_set_disconnected(cdev);
                break;
@@ -1505,6 +1520,7 @@ static int io_subchannel_sch_event(struct subchannel *sch, int process)
        /* Handle attached ccw device. */
        switch (action) {
        case IO_SCH_ORPH_UNREG:
+       case IO_SCH_ORPH_CDEV:
        case IO_SCH_ORPH_ATTACH:
                /* Move ccw device to orphanage. */
                rc = ccw_device_move_to_orph(cdev);