Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2834137pxv; Mon, 12 Jul 2021 03:05:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiuGVT+75Q3J4PUR86CgBCF4qkxGYEQNt5KafLO2xM+f4wQP+ic5rFa5kFcfXXYn5xX8UA X-Received: by 2002:a6b:f81a:: with SMTP id o26mr40069517ioh.68.1626084358446; Mon, 12 Jul 2021 03:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084358; cv=none; d=google.com; s=arc-20160816; b=aGF1B4VRemuMkYV9xiPUk8udQo4BYSbxvH6Gm1np1PkEqV77aSISEPtXM/i129g1Cb VWq9bSn/5QANkEgY6cTEIRAqw/5WhGcrESHyc/kd9+fMh0nP2OzXRgniewvlASl27dKp +LMGk9vZWm/66DtQGESLzm/u5Z5+iDIx9H1wdHwA43fGL6UT2snKP1k42B4xcQswSBaO MW24EPxl+r7iO4vnTNejl4kahHxLBFI0BCqvKew/E4H9JE1O0lDHD1zeVXD7cFWkvBKU 5Q2eCyNXPgyUFhuAZPHjUwTmkTC11tCzoXu/IJnasCD0ifQ+JLXsLGLA9Zxys0PkgVpX iq7g== 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=XastVfjxPV8FkpCFujXaqSTU4QnOE7QyIanQeBm8HQI=; b=E3wcLdYezIPtJPsgZX+Zx+mVKYXyUyCtaJ196Zx7Wh9dQUE99VwSx0FgFR98vE59cW X4o4+ugP6DBm3Phs0RgUCPEA+UOQJqCA1mpc7ae+NrZ43TsYfOjUG4SKjUBNzOnWb0Y7 xMp5egu+Z8QWQP8T1uBvPt2m9WZBhbHvlnAGNRDOHjeROouAuCP1Hbt4T+tR/dL3VcmM RHFWNQKOSiN13lEgDH+l7ib5thFDA25OiysFH8cp52VVAPKDARUo8oa623e7sBrgAXFg Nb6F8k/EvR2vZb4sL1gix5Ow38kLFsiSOIgBFgBvJmhWXRtdNqj6fF2h63GJylXmDh3l AwAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RsCYhDBC; 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 j23si15279431iok.60.2021.07.12.03.05.46; Mon, 12 Jul 2021 03:05:58 -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=RsCYhDBC; 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 S1343614AbhGLH2i (ORCPT + 99 others); Mon, 12 Jul 2021 03:28:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:34094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241792AbhGLG73 (ORCPT ); Mon, 12 Jul 2021 02:59:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9F9906102A; Mon, 12 Jul 2021 06:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626073001; bh=Moj7XFDKb+kqWN293CWhL1akLMoTR6+9lH8NtmXU3fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RsCYhDBCn436XNDc8owufoxSWfT0aIapcuoZZQSS0MYP3znWrgK/dTvwCdLC/jGkk LpM+L0DJI8loMR4ntUItik2u2NQeDRgkzOkqJTbQSnQTBDKxULKsbc+qe4IMXU+Sag I4suKQr4oJxVE4GTBOiZRwFaEVrubkevAt59ndbo= 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 5.12 076/700] s390/cio: dont call css_wait_for_slow_path() inside a lock Date: Mon, 12 Jul 2021 08:02:39 +0200 Message-Id: <20210712060935.444760856@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@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 @@ -255,6 +255,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 @@ -801,8 +801,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 */