]> git.baikalelectronics.ru Git - kernel.git/commitdiff
s390/cio: dont call css_wait_for_slow_path() inside a lock
authorVineeth Vijayan <vneethv@linux.ibm.com>
Wed, 9 Jun 2021 07:21:08 +0000 (09:21 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Fri, 18 Jun 2021 14:41:19 +0000 (16:41 +0200)
Currently css_wait_for_slow_path() gets called inside the chp->lock.
The path-verification-loop of slowpath inside this lock could lead to
deadlock as reported by the lockdep validator.

The ccw_device_get_chp_desc() during the instance of a device-set-online
would try to acquire the same 'chp->lock' to read the chp->desc.
The instance of this function can get called from multiple scenario,
like probing or setting-device online manually. This could, in some
corner-cases lead to the deadlock.

lockdep validator reported this as,

        CPU0                    CPU1
        ----                    ----
   lock(&chp->lock);
                                lock(kn->active#43);
                                lock(&chp->lock);
   lock((wq_completion)cio);

The chp->lock was introduced to serialize the access of struct
channel_path. This lock is not needed for the css_wait_for_slow_path()
function, so invoke the slow-path function outside this lock.

Fixes: 7f89d7de3293 ("[S390] cio: add lock to struct channel_path")
Cc: <stable@vger.kernel.org>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
drivers/s390/cio/chp.c
drivers/s390/cio/chsc.c

index e42113825415283f137745dd844dfdda768ac9b9..1097e76982a5d0fad7ffcf7ee01856d5cd478305 100644 (file)
@@ -255,6 +255,9 @@ static ssize_t chp_status_write(struct device *dev,
        if (!num_args)
                return count;
 
+       /* Wait until previous actions have settled. */
+       css_wait_for_slow_path();
+
        if (!strncasecmp(cmd, "on", 2) || !strcmp(cmd, "1")) {
                mutex_lock(&cp->lock);
                error = s390_vary_chpid(cp->chpid, 1);
index c22d9ee27ba19c72d87a91cbef2a3561fdaad6b9..297fb399363ccff00aef5904734a4c11c482a26a 100644 (file)
@@ -801,8 +801,6 @@ int chsc_chp_vary(struct chp_id chpid, int on)
 {
        struct channel_path *chp = chpid_to_chp(chpid);
 
-       /* Wait until previous actions have settled. */
-       css_wait_for_slow_path();
        /*
         * Redo PathVerification on the devices the chpid connects to
         */