Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3981688pxb; Mon, 4 Oct 2021 14:21:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjMlRPCQoVEYMY1r1qmredoNBbt7oyeIty0l13oHSdt8UqP2uu06kLLTp0ENABgZFPcrXY X-Received: by 2002:a17:90a:ad82:: with SMTP id s2mr10696532pjq.4.1633382479148; Mon, 04 Oct 2021 14:21:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633382479; cv=none; d=google.com; s=arc-20160816; b=Sr/xQKcakUJTe4SKBegKCIXasGW5MU0/npLEiAILnHHpbPPPsFLypcbYwYFkF708JV B50dQmvKQu5rVTPDDsx3GDXVrQbuJslEMzeTKeeJvvrpEOjY5C+IMhPkCy3ROVkWJcej KdfdFoqc8iSgyzskS54xVswVYPkmyuVSQ1PjqrMYM2b9iChOz7M0iMIppkI3rDb3XB4H oQ1zVjBws6ht9o4HyR4NT475LQ52HE1aJ0h22uS8hJwdD1oDh3xT7fymrQgPylXILaLL IfgOzYqgDF45KBgoZVMjCoAeViuYRaBUipAjboQqB0wp2j5bcWUMqBHDsrs7fAUVOM+q A4cw== 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=KEXWyvd7DYnyFDAzW71znoCXhN1zcygQPpwOVqhf7Ag=; b=QhEefJkHVWH1CM1onlyNiuVM11DGGTNdKhociT+Js9WBfyw968fjZTkByXXkW8yJmJ I/GtcJsicmsBMjhRWZlTAbK3ogk6iOjlelHbLKeBYLbEXa1TWObJH3zdX7HMmmhLDpWv ldVHst7QYzoZt8QIGXOPc1EsvcHw5nzJgKqInBvo/yfa3MkQSadbuqScNIo7Mv+b1gQ4 QV8ZpyX2HU4ez5dORmPSSjte7PEKluydTO1XTAfcH8Qp5wpS2Tk7jZ2r0DwfYzwoKlsH RXCtTraWkHxI+6JqOeZyGrtRuskw7jibSp1oH9OblhGR9ydD/TrY7GRZejzfq/yqdYei fXBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cqravieh; 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 17si4157514pgl.243.2021.10.04.14.21.02; Mon, 04 Oct 2021 14:21:19 -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=cqravieh; 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 S237200AbhJDNaB (ORCPT + 99 others); Mon, 4 Oct 2021 09:30:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:43088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237318AbhJDN2V (ORCPT ); Mon, 4 Oct 2021 09:28:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C8CF461CA7; Mon, 4 Oct 2021 13:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353154; bh=smxWTGlT0D4LCbaPd9+O/CIMOc1B7/78TGWliO6XFlA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cqraviehDevQ+T0c1w27It5q8mPU9YYzpob/YUxbqrk3m7gKUa8egFRS+W2TABT5Q YFRPdlG7EiS8JPvufDxtspdAZX+ef8okJ6PYKUiBCFuOIddrg/pAQvlc9Sdhp4K8g/ RNARLLwtZqzN+ej2YpmMftSF+5uLXAl8TkP9ub7k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandra Winter , Julian Wiedmann , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.14 017/172] s390/qeth: fix deadlock during failing recovery Date: Mon, 4 Oct 2021 14:51:07 +0200 Message-Id: <20211004125045.523769454@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@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: Alexandra Winter [ Upstream commit d2b59bd4b06d84a4eadb520b0f71c62fe8ec0a62 ] Commit 0b9902c1fcc5 ("s390/qeth: fix deadlock during recovery") removed taking discipline_mutex inside qeth_do_reset(), fixing potential deadlocks. An error path was missed though, that still takes discipline_mutex and thus has the original deadlock potential. Intermittent deadlocks were seen when a qeth channel path is configured offline, causing a race between qeth_do_reset and ccwgroup_remove. Call qeth_set_offline() directly in the qeth_do_reset() error case and then a new variant of ccwgroup_set_offline(), without taking discipline_mutex. Fixes: b41b554c1ee7 ("s390/qeth: fix locking for discipline setup / removal") Signed-off-by: Alexandra Winter Reviewed-by: Julian Wiedmann Signed-off-by: Julian Wiedmann Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- arch/s390/include/asm/ccwgroup.h | 2 +- drivers/s390/cio/ccwgroup.c | 10 ++++++++-- drivers/s390/net/qeth_core_main.c | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/s390/include/asm/ccwgroup.h b/arch/s390/include/asm/ccwgroup.h index 20f169b6db4e..d97301d9d0b8 100644 --- a/arch/s390/include/asm/ccwgroup.h +++ b/arch/s390/include/asm/ccwgroup.h @@ -57,7 +57,7 @@ struct ccwgroup_device *get_ccwgroupdev_by_busid(struct ccwgroup_driver *gdrv, char *bus_id); extern int ccwgroup_set_online(struct ccwgroup_device *gdev); -extern int ccwgroup_set_offline(struct ccwgroup_device *gdev); +int ccwgroup_set_offline(struct ccwgroup_device *gdev, bool call_gdrv); extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev); extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev); diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c index 9748165e08e9..f19f02e75115 100644 --- a/drivers/s390/cio/ccwgroup.c +++ b/drivers/s390/cio/ccwgroup.c @@ -77,12 +77,13 @@ EXPORT_SYMBOL(ccwgroup_set_online); /** * ccwgroup_set_offline() - disable a ccwgroup device * @gdev: target ccwgroup device + * @call_gdrv: Call the registered gdrv set_offline function * * This function attempts to put the ccwgroup device into the offline state. * Returns: * %0 on success and a negative error value on failure. */ -int ccwgroup_set_offline(struct ccwgroup_device *gdev) +int ccwgroup_set_offline(struct ccwgroup_device *gdev, bool call_gdrv) { struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver); int ret = -EINVAL; @@ -91,11 +92,16 @@ int ccwgroup_set_offline(struct ccwgroup_device *gdev) return -EAGAIN; if (gdev->state == CCWGROUP_OFFLINE) goto out; + if (!call_gdrv) { + ret = 0; + goto offline; + } if (gdrv->set_offline) ret = gdrv->set_offline(gdev); if (ret) goto out; +offline: gdev->state = CCWGROUP_OFFLINE; out: atomic_set(&gdev->onoff, 0); @@ -124,7 +130,7 @@ static ssize_t ccwgroup_online_store(struct device *dev, if (value == 1) ret = ccwgroup_set_online(gdev); else if (value == 0) - ret = ccwgroup_set_offline(gdev); + ret = ccwgroup_set_offline(gdev, true); else ret = -EINVAL; out: diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index dba3b345218f..f5bad10f3f44 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -5548,7 +5548,8 @@ static int qeth_do_reset(void *data) dev_info(&card->gdev->dev, "Device successfully recovered!\n"); } else { - ccwgroup_set_offline(card->gdev); + qeth_set_offline(card, disc, true); + ccwgroup_set_offline(card->gdev, false); dev_warn(&card->gdev->dev, "The qeth device driver failed to recover an error on the device\n"); } -- 2.33.0