Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1752408pxb; Thu, 16 Sep 2021 14:53:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB50Nx5uW3TK3QnoqiFnMpdSS8283LtLAgWxUYCj3CFy9G9lypbfV7xShGAtEdVTBccys2 X-Received: by 2002:a92:de41:: with SMTP id e1mr5621497ilr.85.1631829188071; Thu, 16 Sep 2021 14:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631829188; cv=none; d=google.com; s=arc-20160816; b=iMxgoxpULOhYGb0wlE0GAFpk+3wuBSArB3m+pKf9lBvcPek70NgwnP5DvOrYujUnqP GbzlgLuFwneRE4nm8/y689XUNAMKBlPvg2GOOZFTtkUj3l/UO/rocHWjXNsmdMDhlcnZ pauSUM2hH7Yp1///PjRahjfCpeCCEO1RfEyj/CMufCdqEnnL73swnfHUoqhIBFxcwzZG zElLLUXlAtSzQ3jzvQ9f25sfq/lnDN3z2EKIJHkgSP2+PLHlt/OQdxQTBW2x2TaMJ3mk QOgt0Amn+9o9PI0q/3V0RpHwnLVjAVjgSc/r3ELJyXWsrj4q/eYJDdG/z3Btdj8gMW1+ SJYQ== 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=ut8eMld/nPydfvAHzfqE79+VnA5cjsk/UQ9WUXvXgzA=; b=oOsd88s5u/2SYgiFKGm9l479ni4agRJbgdL1SL34C9hUq3o7uKCzHg7Adea8Lzy5ie hdQFjVuHIEyOIuLbgNNavinLAY2XF/JcKxuSLCpfvIWXsUIJHysIEJM2WW7WT70PKCZm +5HXBl0Ex2Op6QWFNzGblVGJP5zNnoDGN7cHiuhvi0g90VfivPTyoPVpOXYwB+Xd9oie lXYWZDqgqQhum2RFjWH8XpcAAjPeiG8Up6Q0PBZEkEoNt/cVhwigfV8KqMOna1BVpkZn 0EtnyZ1KNoHSh1YP0092+0qYOCX+8j2G37qhSOA+Xrz7efEN/I8vlKZWvOhmG2DINzc+ ivpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iKzE76gz; 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 d7si3594467jaf.9.2021.09.16.14.52.56; Thu, 16 Sep 2021 14:53:08 -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=iKzE76gz; 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 S242245AbhIPQiS (ORCPT + 99 others); Thu, 16 Sep 2021 12:38:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:43876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242203AbhIPQav (ORCPT ); Thu, 16 Sep 2021 12:30:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BE52D613D1; Thu, 16 Sep 2021 16:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809146; bh=mVY6VDyoC/BMHMwwisXg4lZ6mAsEcjrgdmnT83LbBDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iKzE76gzoN5iC2gW0UvUKfQ5ZiRGh8dgaqEyf9wtCwIhqHvmLt30/Rh/9Zhf0gp/m iGdwKEEiOz6hveGJ556R66Tqy1RodmtltaXSTm9NG5TKu23TpTsC6AV30g6ajyB/NM Tpb+WRFBYpg/2ecuupzx1h9KCWDjoF28LEPak2Iw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julian Wiedmann , Benjamin Block , Heiko Carstens Subject: [PATCH 5.13 048/380] s390/qdio: cancel the ESTABLISH ccw after timeout Date: Thu, 16 Sep 2021 17:56:45 +0200 Message-Id: <20210916155805.619479643@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@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: Julian Wiedmann commit 1c1dc8bda3a05c60877a6649775894db5343bdea upstream. When the ESTABLISH ccw does not complete within the specified timeout, try our best to cancel the ccw program that is still active on the device. Otherwise the IO subsystem might be accessing it even after the driver eg. called qdio_free(). Fixes: 779e6e1c724d ("[S390] qdio: new qdio driver.") Signed-off-by: Julian Wiedmann Reviewed-by: Benjamin Block Cc: # 2.6.27 Signed-off-by: Heiko Carstens Signed-off-by: Greg Kroah-Hartman --- drivers/s390/cio/qdio_main.c | 51 +++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 21 deletions(-) --- a/drivers/s390/cio/qdio_main.c +++ b/drivers/s390/cio/qdio_main.c @@ -886,6 +886,33 @@ static void qdio_shutdown_queues(struct } } +static int qdio_cancel_ccw(struct qdio_irq *irq, int how) +{ + struct ccw_device *cdev = irq->cdev; + int rc; + + spin_lock_irq(get_ccwdev_lock(cdev)); + qdio_set_state(irq, QDIO_IRQ_STATE_CLEANUP); + if (how & QDIO_FLAG_CLEANUP_USING_CLEAR) + rc = ccw_device_clear(cdev, QDIO_DOING_CLEANUP); + else + /* default behaviour is halt */ + rc = ccw_device_halt(cdev, QDIO_DOING_CLEANUP); + spin_unlock_irq(get_ccwdev_lock(cdev)); + if (rc) { + DBF_ERROR("%4x SHUTD ERR", irq->schid.sch_no); + DBF_ERROR("rc:%4d", rc); + return rc; + } + + wait_event_interruptible_timeout(cdev->private->wait_q, + irq->state == QDIO_IRQ_STATE_INACTIVE || + irq->state == QDIO_IRQ_STATE_ERR, + 10 * HZ); + + return 0; +} + /** * qdio_shutdown - shut down a qdio subchannel * @cdev: associated ccw device @@ -923,27 +950,7 @@ int qdio_shutdown(struct ccw_device *cde qdio_shutdown_queues(irq_ptr); qdio_shutdown_debug_entries(irq_ptr); - /* cleanup subchannel */ - spin_lock_irq(get_ccwdev_lock(cdev)); - qdio_set_state(irq_ptr, QDIO_IRQ_STATE_CLEANUP); - if (how & QDIO_FLAG_CLEANUP_USING_CLEAR) - rc = ccw_device_clear(cdev, QDIO_DOING_CLEANUP); - else - /* default behaviour is halt */ - rc = ccw_device_halt(cdev, QDIO_DOING_CLEANUP); - spin_unlock_irq(get_ccwdev_lock(cdev)); - if (rc) { - DBF_ERROR("%4x SHUTD ERR", irq_ptr->schid.sch_no); - DBF_ERROR("rc:%4d", rc); - goto no_cleanup; - } - - wait_event_interruptible_timeout(cdev->private->wait_q, - irq_ptr->state == QDIO_IRQ_STATE_INACTIVE || - irq_ptr->state == QDIO_IRQ_STATE_ERR, - 10 * HZ); - -no_cleanup: + rc = qdio_cancel_ccw(irq_ptr, how); qdio_shutdown_thinint(irq_ptr); qdio_shutdown_irq(irq_ptr); @@ -1153,10 +1160,12 @@ int qdio_establish(struct ccw_device *cd return 0; err_ccw_timeout: + qdio_cancel_ccw(irq_ptr, QDIO_FLAG_CLEANUP_USING_CLEAR); err_ccw_start: qdio_shutdown_thinint(irq_ptr); err_thinint: qdio_shutdown_irq(irq_ptr); + qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE); mutex_unlock(&irq_ptr->setup_mutex); return rc; }