Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1899310pxb; Thu, 16 Sep 2021 19:32:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzA5ZnhLVwnC1HSSV5g8fdvmJnHDAtp3IZgRrPSOfxFoc3Pj1ZvT8IqzZ+iCCyGR2Cau9Dv X-Received: by 2002:a6b:fd19:: with SMTP id c25mr2073981ioi.51.1631845969092; Thu, 16 Sep 2021 19:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631845969; cv=none; d=google.com; s=arc-20160816; b=PlbElYa9mrDsRglytsk3qXbRmu7Chf5nFQEl4Iv5MWLiEYegNN8H0lgGa+sUdXukM8 wbkh8kIg83wRZ86tz2LvHrWODiEfotbHAUjUiBOIDKGNy6c0P9DXQHbuowunFNv5UCTh 7G/wBy3cIO9B6dj53jx6gVKCPB+MdBH5Ty/OyckjRhgQ5SyZvG4mTaDB7IOFVCC47FZ+ /lMuHx2Mi20KFkwyjelBa7VAXOrGKRMiSgozyB9QXJJrL9/drMqtmOe18QIO/5GiFVVV ZT4Veq7V8Tv6QrPJmFnOTy2QxSLK7/boUCYGcK34/v8A/ai3PfrFgp4DX9Xl4cvq++Sc wGOg== 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=YYnGQMq8CeNLbNLMHcbPB/MbXuHoTkGt5PLhm7ui+rQ=; b=OTtSJPziSSmGSJb3+GehThB0THX3izs4uEoMZrA/8ELkqKDbx5o7NTkaPJDcJZu7/O uavbiZdZTwRkvyDLaU7pSMVuX2RJaYf4AWCTssoNFnM1ueCusubWdLwq4kpQ/nm1WDM3 GM9roJkIAg3npWiC+mikFODaX48JnCS+LsA86cUcgTjEamT+NC2TIMxtkjTyeseHx6QC Ga5mdOuK2+m4toBk9SNVl/yCNjZl0aXAew4PWRHzkYWv1590hgQdwb72WXHNleBNGjAs usd3pJ181HsKMV80hjyDbHny0Hll82JM2ICtpoXKOAt6Gk70utyp52Y/RR9mSZtZOm1X jTzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BQ4TWsIO; 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 y10si4452155ion.41.2021.09.16.19.32.38; Thu, 16 Sep 2021 19:32:49 -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=BQ4TWsIO; 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 S1351087AbhIPROt (ORCPT + 99 others); Thu, 16 Sep 2021 13:14:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:37568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349988AbhIPRIE (ORCPT ); Thu, 16 Sep 2021 13:08:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2F3226138D; Thu, 16 Sep 2021 16:36:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810208; bh=1N9u0hH3YUIgCGrBypF7a9d4IO7AmLIUTd4bbjnuavQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BQ4TWsIOD4u8/vGYCENFfWBH8n97oBOOcThN+0qSZqGvpyzITUonJHoyya6wr3K4b bVFiVkGzHcU87Tf6WBitW0In5d3Do0cdKvYePSOQ1aAFyQNHkezyAAC9eY9tIJa6hM PTeiRkTE/DXSoXA7Nav+TFDtj3JgjlyBeah/y+9c= 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.14 055/432] s390/qdio: cancel the ESTABLISH ccw after timeout Date: Thu, 16 Sep 2021 17:56:44 +0200 Message-Id: <20210916155812.663328141@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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 @@ -890,6 +890,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 @@ -927,27 +954,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); @@ -1157,10 +1164,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; }