Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2705224pxv; Sun, 11 Jul 2021 23:17:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJcr2k+wMZ0AvMDaT6FTwQJy8WiBAxt5Tk+ODeqJ3o0SV549onQxq6fwcHUsIR3eUeV0/W X-Received: by 2002:a5d:8888:: with SMTP id d8mr22771310ioo.170.1626070648248; Sun, 11 Jul 2021 23:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626070648; cv=none; d=google.com; s=arc-20160816; b=tUr3Pya57j1+kDIGsUHYy3PTT5aFdZn0exWFwJeKMhXae/FyO6D24+2fYMDb9PcGAN gOSP1t55g7bGwKxq0pNMUqLgg7SClvm4pKBkm+XX6P66LobdyY90Gc6GYyAIjJFnUp22 IStlqkcg/AuHRiaMJU7uh/GrCeilQe4DoT5F1/FTSUPNcjTxlkrjjoPnSe8bwgP0gyIY C4N25g+yLuOMmxkYvFRmiCt9dMHmSKq8CI40G5LDT/kzu803SzGzsCBuWIggE8Ly7mDX HE9nPagYbtqcry8NeDy5y+RTScqf6ImymcwgObZBrp3fCjOxDT2++BLd+XIjykHr1Cyc pFaA== 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=ZFLYt/HPt4RHe3QkWWtpvsFbUCbcX0d2tKoyAmjiza8=; b=f69M31ha5ijwkuWiVNTcAPGNDtuxsnNRgM9sC5NhUlJ4udFbqowKk3KGF51Ojs0tyd FFXRgHRBCDTExHi3mThpZfRw7LNirnWh6rgHKEWSBJwoD2XHGB8lu0YU17B3gxo9MoB0 ungRx8kAISiV7gwsc4aBRBNcfPaRkQR0aRtAwgsYyIqyI/weu7eSMeKG9Ba8H9Mjebhq EoslaJKKKVB0YSrm5PTwSPWz24Y4qqE2E8l+xiCmGDS2VR2WF3TWWCUfh3/pNBZbx6rq GVJIhCcHba4kaCEc40No8fLuh6pdtEf4ElbtvM6y7wW5SPtxCUlDrMQ9KV7TTQx7gNvX mVHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bHLXWtLr; 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 z6si15916361ils.150.2021.07.11.23.17.16; Sun, 11 Jul 2021 23:17:28 -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=bHLXWtLr; 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 S233213AbhGLGTD (ORCPT + 99 others); Mon, 12 Jul 2021 02:19:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:37000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233621AbhGLGSn (ORCPT ); Mon, 12 Jul 2021 02:18:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 349C961042; Mon, 12 Jul 2021 06:15:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626070555; bh=pQzWCx0DN6ZorgGc0vmMHHZUsc4LtNkMtinNUGb6xMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bHLXWtLrm1gyl+hmwtt8bveTGR4EwpnCHgAugAhTFC2iy1kpgVHkFXleOWuovzrKH RQ0ZRzdnqOv9ywkIAz6t9BfN62vmXz34ozR9W3LU5bTg60NcQg+Mms9xT1uNdMQxMc 3oWiiAjAXoCe771w8EMqOGJprZcz5u7j0k9yGKo4= 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.4 041/348] s390/cio: dont call css_wait_for_slow_path() inside a lock Date: Mon, 12 Jul 2021 08:07:05 +0200 Message-Id: <20210712060706.524731234@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@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 @@ -753,8 +753,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 */