Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1527024pxb; Thu, 16 Sep 2021 09:15:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNvipbmuxccxRQiVU3g6SalIb0Y2Jsg3IOP9iG5Ya7PGRQzIZckFgLrdEo+btbkNKh18ts X-Received: by 2002:a92:cd46:: with SMTP id v6mr4634461ilq.66.1631808940445; Thu, 16 Sep 2021 09:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631808940; cv=none; d=google.com; s=arc-20160816; b=jiqaMTltt+ZNFKNbIj37UbUqvg1Lx9GL76w6MlUt7umBX5hrBpoigh8YwJS5gZnHqI 15GT7+kMUJmAXz08eibiwhW9u6DCc96TWi9I5oaRoXSPd3Fb3myz/j/cJsGHvlIp9Wzo 6xfIU62Fj8UhoseeopqvNcNNGuWN8LgM4Weh6l41HPI1uRWXbMQq1R1mnGWP/Vby+yvo LOLsCQxdtJDrT5O7P3qQ0zHHXMT16dXQRgLG/vHsMesvXnmEdPT2sou7AP4jmiimdXDn tYFvXNHgoGfeMAz1IBFC1h00Jxbiz4nMy9TY0CKNVR80ErpNyNsT+vqursdXyrkr5gUS 6Fcw== 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=1IS4klsgJUJSxr68blV4My81MRrW88IL9RRzfQ9/FJM=; b=lKldk0LgaAKQuBV71c4Qvw5YSdaaoay2ExtPp2p7ZIzCWWpod0/y7lsSelGjUgbqhq 0UQw/YT3i2lnrPJOSbH1nY6t73d70W0VYHkuuNFcxz3FHX4lOR3fZRN3JVjcvUqMQF/P CocEf4Tdh+Of+mlPKfURzHsZmw7GqfFMKtwL0HRDKPTECvSaHHYOT6cVFH+mKNb5O39+ 0wusMcDoGAvJQV6FUaHPv7IgoVpOZV9hsywO1jgK3aL6E/jzk7OmSF/YJHeUWUnalqsR 3DzBXS93HI7Ajw/pqkOgwFn5v8ZG9EFacfNpE3xAJvGy/JB8e7IcPCb+SI5HZf3uysHC mhIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OAaz8Gt1; 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 w18si2966380ilc.63.2021.09.16.09.15.25; Thu, 16 Sep 2021 09:15:40 -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=OAaz8Gt1; 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 S232907AbhIPQNG (ORCPT + 99 others); Thu, 16 Sep 2021 12:13:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:46774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbhIPQHt (ORCPT ); Thu, 16 Sep 2021 12:07:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1AE1A61241; Thu, 16 Sep 2021 16:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808388; bh=Xw7WHIR8zlTaRNmVgAWcJpG6pB2TX1GUY6Q4q5Z2sBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OAaz8Gt1hleUT4tyROnT/kC1x/Os6mALHnAhcldX0ZD9TM2YUb4JgpUoE2KIgOLo1 2xzJefuleJTGMfge43iTiMyrYwFT6Xpdnw4I+R/L6XxOcb4yRQi39m588rh5LkfVsM ZHB5NlTK04kAtX/9h1LMDhxkgUHko+cqFalPe2dM= 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.10 040/306] s390/qdio: cancel the ESTABLISH ccw after timeout Date: Thu, 16 Sep 2021 17:56:25 +0200 Message-Id: <20210916155755.314251643@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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 @@ -1025,6 +1025,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 @@ -1063,27 +1090,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); @@ -1316,10 +1323,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; }