]> git.baikalelectronics.ru Git - kernel.git/commitdiff
s390/qeth: fix deadlock during failing recovery
authorAlexandra Winter <wintera@linux.ibm.com>
Tue, 21 Sep 2021 14:52:17 +0000 (16:52 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 22 Sep 2021 03:02:24 +0000 (20:02 -0700)
Commit 0b42b521db58 ("s390/qeth: fix deadlock during recovery") removed
taking discipline_mutex inside qeth_do_reset(), fixing potential
deadlocks. An error path was missed though, that still takes
discipline_mutex and thus has the original deadlock potential.

Intermittent deadlocks were seen when a qeth channel path is configured
offline, causing a race between qeth_do_reset and ccwgroup_remove.
Call qeth_set_offline() directly in the qeth_do_reset() error case and
then a new variant of ccwgroup_set_offline(), without taking
discipline_mutex.

Fixes: aec9f46caab2 ("s390/qeth: fix locking for discipline setup / removal")
Signed-off-by: Alexandra Winter <wintera@linux.ibm.com>
Reviewed-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
arch/s390/include/asm/ccwgroup.h
drivers/s390/cio/ccwgroup.c
drivers/s390/net/qeth_core_main.c

index 36dbf5043fc099db13ae4bcefdb47d4bb5e45582..aa995d91cd1da451e2915ad29031f0141e171a5d 100644 (file)
@@ -55,7 +55,7 @@ int ccwgroup_create_dev(struct device *root, struct ccwgroup_driver *gdrv,
                        int num_devices, const char *buf);
 
 extern int ccwgroup_set_online(struct ccwgroup_device *gdev);
-extern int ccwgroup_set_offline(struct ccwgroup_device *gdev);
+int ccwgroup_set_offline(struct ccwgroup_device *gdev, bool call_gdrv);
 
 extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
 extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev);
index 2ec741106cb67ef9e4d140a2d16473a4f71bccdd..f0538609dfe429b6caec78c766116de6a8b97d8c 100644 (file)
@@ -77,12 +77,13 @@ EXPORT_SYMBOL(ccwgroup_set_online);
 /**
  * ccwgroup_set_offline() - disable a ccwgroup device
  * @gdev: target ccwgroup device
+ * @call_gdrv: Call the registered gdrv set_offline function
  *
  * This function attempts to put the ccwgroup device into the offline state.
  * Returns:
  *  %0 on success and a negative error value on failure.
  */
-int ccwgroup_set_offline(struct ccwgroup_device *gdev)
+int ccwgroup_set_offline(struct ccwgroup_device *gdev, bool call_gdrv)
 {
        struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver);
        int ret = -EINVAL;
@@ -91,11 +92,16 @@ int ccwgroup_set_offline(struct ccwgroup_device *gdev)
                return -EAGAIN;
        if (gdev->state == CCWGROUP_OFFLINE)
                goto out;
+       if (!call_gdrv) {
+               ret = 0;
+               goto offline;
+       }
        if (gdrv->set_offline)
                ret = gdrv->set_offline(gdev);
        if (ret)
                goto out;
 
+offline:
        gdev->state = CCWGROUP_OFFLINE;
 out:
        atomic_set(&gdev->onoff, 0);
@@ -124,7 +130,7 @@ static ssize_t ccwgroup_online_store(struct device *dev,
        if (value == 1)
                ret = ccwgroup_set_online(gdev);
        else if (value == 0)
-               ret = ccwgroup_set_offline(gdev);
+               ret = ccwgroup_set_offline(gdev, true);
        else
                ret = -EINVAL;
 out:
index 9f26706051e5c6339203a877c85b76b3514c6c99..e9807d2996a9d77053b997594e8753a53647e9bc 100644 (file)
@@ -5514,7 +5514,8 @@ static int qeth_do_reset(void *data)
                dev_info(&card->gdev->dev,
                         "Device successfully recovered!\n");
        } else {
-               ccwgroup_set_offline(card->gdev);
+               qeth_set_offline(card, disc, true);
+               ccwgroup_set_offline(card->gdev, false);
                dev_warn(&card->gdev->dev,
                         "The qeth device driver failed to recover an error on the device\n");
        }