提交 8623a4fa 编写于 作者: V Vineeth Vijayan 提交者: Zheng Zengkai

s390/cio: dont call css_wait_for_slow_path() inside a lock

stable inclusion
from stable-5.10.50
commit 38a2ba82e249098fe9e21a731957a1c1e08ad0d8
bugzilla: 174522 https://gitee.com/openeuler/kernel/issues/I4DNFY

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=38a2ba82e249098fe9e21a731957a1c1e08ad0d8

--------------------------------

commit c749d8c0 upstream.

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: b730f3a9 ("[S390] cio: add lock to struct channel_path")
Cc: <stable@vger.kernel.org>
Reviewed-by: NPeter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: NVineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 733338fd
...@@ -255,6 +255,9 @@ static ssize_t chp_status_write(struct device *dev, ...@@ -255,6 +255,9 @@ static ssize_t chp_status_write(struct device *dev,
if (!num_args) if (!num_args)
return count; return count;
/* Wait until previous actions have settled. */
css_wait_for_slow_path();
if (!strncasecmp(cmd, "on", 2) || !strcmp(cmd, "1")) { if (!strncasecmp(cmd, "on", 2) || !strcmp(cmd, "1")) {
mutex_lock(&cp->lock); mutex_lock(&cp->lock);
error = s390_vary_chpid(cp->chpid, 1); error = s390_vary_chpid(cp->chpid, 1);
......
...@@ -757,8 +757,6 @@ int chsc_chp_vary(struct chp_id chpid, int on) ...@@ -757,8 +757,6 @@ int chsc_chp_vary(struct chp_id chpid, int on)
{ {
struct channel_path *chp = chpid_to_chp(chpid); 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 * Redo PathVerification on the devices the chpid connects to
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册