Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4151812pxv; Mon, 19 Jul 2021 18:34:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMM3sY11QAM/bXHpKYqYUbdMOlg1fjVa+rYZdKqadz1yz+/pV6VP/UxqRBPzWoxPC3RhlH X-Received: by 2002:a6b:6205:: with SMTP id f5mr20773584iog.60.1626744853570; Mon, 19 Jul 2021 18:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626744853; cv=none; d=google.com; s=arc-20160816; b=qiHmZihiANvciXfpiVSfjoSflxjNHwRM46al2oryExXrR51iZ1EqTG5aILz3SVnarK B8GGIucdRDNeWh81QIs4cF16ATYoXQww0huy7mmleHFBB3WFnoDK3WQYfxkGT1Osuuz2 aJaX1hFlIZ6I1o6PLOveaufcfua4KAR8oM6r2e51qM/td2UsfX2ZGFQ3VLNamNwdpuTZ 57cPITiw4XpYJyn6jwyNnqQkLBQ3q8Y7t2VsrouTe7mZ0WeBtIKgmkR1/bzkLpkHswOm 4ZzIFBupFRYUTKAWjCcyLD9JqjeFzwCPGUW6ddH7LtcRbipTgZ28elaxOcYFqPDG1ppa 0B+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XJ8m3KeUjBlrx2f41S7B4xEPJG0OJCLKc8zzh5PKDZw=; b=r6KMzxraBndVu6olnfyomPcs4wq4G6uTSG2wEqs2S9RInJ4m47Slxise7sliaDeQTB ascGI7BizqEulJA6qDBD+ZpjsPpu0i5jnL+crraELgp8KkE1FJCRCPLSxopCZziSY0y2 MEXT8yHFRjxoMB/VyYAmxlVpvSO2tfCCvB9YEK8UBuKd/h9X2fvgIu0za9ASiaPl1dsP kdn9xpZhxOh4jPYWMzx0sU02cgX4PVvYlJR1nQgg2Gub+DJZXWqKpRQ2STCZD99x0mO/ pz095V3dhMkX3azR7XlVHNLKJ7e/X2X+br6nKHX5U3D6JGm5k8PVLf1mNAmoruqhwwnW JeqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wG6i+chu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d131si28800434iog.11.2021.07.19.18.34.01; Mon, 19 Jul 2021 18:34:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wG6i+chu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244734AbhGSOxG (ORCPT + 99 others); Mon, 19 Jul 2021 10:53:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:47094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343496AbhGSOe6 (ORCPT ); Mon, 19 Jul 2021 10:34:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6A2A860551; Mon, 19 Jul 2021 15:15:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707708; bh=bvm33jyJXdQm3RZnaxOHMbicFaMy8Y6/9H7JfLGBDqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wG6i+chu2joei1Q3mXaFxMZRYDaYSFWn1GOEluceMZyY8S97/yECDt9sVCLSTzeHu IwggBlLqJJM8xfsnSZd7VEj4KADSyB5n7PtXd7VuzypbKPNk4QqBrPESfwRmxOUMrx RxRd7OMT2aKVaF65dgcow3HFT8UzI0APJ4XgNREI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Oberparleiter , Vineeth Vijayan , Vasily Gorbik Subject: [PATCH 4.14 024/315] s390/cio: dont call css_wait_for_slow_path() inside a lock Date: Mon, 19 Jul 2021 16:48:33 +0200 Message-Id: <20210719144943.678345747@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.861561397@linuxfoundation.org> References: <20210719144942.861561397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vineeth Vijayan commit c749d8c018daf5fba6dfac7b6c5c78b27efd7d65 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: b730f3a93395 ("[S390] cio: add lock to struct channel_path") Cc: Reviewed-by: Peter Oberparleiter Signed-off-by: Vineeth Vijayan Signed-off-by: Vasily Gorbik Signed-off-by: Greg Kroah-Hartman --- drivers/s390/cio/chp.c | 3 +++ drivers/s390/cio/chsc.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) --- a/drivers/s390/cio/chp.c +++ b/drivers/s390/cio/chp.c @@ -254,6 +254,9 @@ static ssize_t chp_status_write(struct d 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); --- a/drivers/s390/cio/chsc.c +++ b/drivers/s390/cio/chsc.c @@ -769,8 +769,6 @@ int chsc_chp_vary(struct chp_id chpid, i { 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 */