Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6273382imu; Mon, 21 Jan 2019 06:12:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN6o/RfFwvaQ8PwSLsV3N7znGaK8EbwK7sjAsxoDl2oqc9pcmrNM7rXefD16Q4Zmcibz6T1X X-Received: by 2002:a65:41c2:: with SMTP id b2mr28064985pgq.67.1548079925358; Mon, 21 Jan 2019 06:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079925; cv=none; d=google.com; s=arc-20160816; b=CzBdlVlL7Q94n4vE8gFWcSwVAQ30ZMzZYfKM0DkFgInA9fZrrvHXYa6jwNhSIhoWWi SMfEHzcT7F/DQXvSB/51S02DenCvS747D2RbGkEr3D8QTvCJ5QqGVupC9jILktyE4YQM vWlZpiGezB6WZNwpPLj6aAG0+SODXUc+fZWTYzcLOZaoUXiKP2e0JCqHgb5tZiRjzFLU ts2xh7FSoZG0qSTfJyktyFCSu6t+GBrLSW90kKJSi2ZdqD2EyvkAHNV0oETP64iD84/D 5e1Yte5pDxamBm6Rrxhxi/i8OBJ455j1A4RphVCC9g6loLcpuyjtDSqxRuhbRzuEHUsd kDZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5YecXhdctNcaUPONCcftUMFe4KXPAaotmqeL8+NyOa0=; b=WY8bOeo1X2FfUJboQ0OpbEMgyRrLe1VUqPkoJYv9yUmF/E/VewRo0SKTwM0Trj7w8n /UW3fDreQnnKNeQWziPZRhmr4JRAopV2AoSRnzBH46GJcZJT5InpsO4pzdIrG1tsUkCc aX4wjxL7CmhIxJQbKzmR+7RAoFY8673O/ioZo8PxB/iDj4rAm4+fmYibI0yTuNK+d9QJ rdp0/tiWryysjRoNtTu4bI/7JVbSC8xPGHVMTm7MpO5wczG+wOffNqTIkAyww/31h6GA FQ3jX+lIC6QoVqwwyI9OxFt33itpjGQmT9hHAubdAWDcfgsAIHYX/1LGIvjS5XqtbMbK KgKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q1+3WxQT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v17si12728944pga.566.2019.01.21.06.11.49; Mon, 21 Jan 2019 06:12:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q1+3WxQT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731655AbfAUNzE (ORCPT + 99 others); Mon, 21 Jan 2019 08:55:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:39480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731646AbfAUNzC (ORCPT ); Mon, 21 Jan 2019 08:55:02 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DD3C92084C; Mon, 21 Jan 2019 13:55:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548078901; bh=t6oz3AMI0IkELIQGGVUVD4yLAmFRT+QNXyWTjg/c+o4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q1+3WxQTrQLlnXlg/oRi/QB1jyJZ8WjBHPPodBjpx9PLKonyODBspmkAgMkGKPcFI feAOPQnm+Xe6bxz/Pvg0LvdGrBHIejNwIVIIO3RLYLXn/IVefOWuRxOA9PXCP7GQHE fxTOxjwrhKunO/FN++vcEMAPsw3pbENhDe2QZv6I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stanley Chu , Bart Van Assche , "Martin K. Petersen" Subject: [PATCH 4.9 23/51] scsi: core: Synchronize request queue PM status only on successful resume Date: Mon, 21 Jan 2019 14:44:19 +0100 Message-Id: <20190121122455.693289438@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121122453.700446926@linuxfoundation.org> References: <20190121122453.700446926@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stanley Chu commit 3f7e62bba0003f9c68f599f5997c4647ef5b4f4e upstream. The commit 356fd2663cff ("scsi: Set request queue runtime PM status back to active on resume") fixed up the inconsistent RPM status between request queue and device. However changing request queue RPM status shall be done only on successful resume, otherwise status may be still inconsistent as below, Request queue: RPM_ACTIVE Device: RPM_SUSPENDED This ends up soft lockup because requests can be submitted to underlying devices but those devices and their required resource are not resumed. For example, After above inconsistent status happens, IO request can be submitted to UFS device driver but required resource (like clock) is not resumed yet thus lead to warning as below call stack, WARN_ON(hba->clk_gating.state != CLKS_ON); ufshcd_queuecommand scsi_dispatch_cmd scsi_request_fn __blk_run_queue cfq_insert_request __elv_add_request blk_flush_plug_list blk_finish_plug jbd2_journal_commit_transaction kjournald2 We may see all behind IO requests hang because of no response from storage host or device and then soft lockup happens in system. In the end, system may crash in many ways. Fixes: 356fd2663cff (scsi: Set request queue runtime PM status back to active on resume) Cc: stable@vger.kernel.org Signed-off-by: Stanley Chu Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/scsi_pm.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) --- a/drivers/scsi/scsi_pm.c +++ b/drivers/scsi/scsi_pm.c @@ -79,8 +79,22 @@ static int scsi_dev_type_resume(struct d if (err == 0) { pm_runtime_disable(dev); - pm_runtime_set_active(dev); + err = pm_runtime_set_active(dev); pm_runtime_enable(dev); + + /* + * Forcibly set runtime PM status of request queue to "active" + * to make sure we can again get requests from the queue + * (see also blk_pm_peek_request()). + * + * The resume hook will correct runtime PM status of the disk. + */ + if (!err && scsi_is_sdev_device(dev)) { + struct scsi_device *sdev = to_scsi_device(dev); + + if (sdev->request_queue->dev) + blk_set_runtime_active(sdev->request_queue); + } } return err; @@ -139,16 +153,6 @@ static int scsi_bus_resume_common(struct else fn = NULL; - /* - * Forcibly set runtime PM status of request queue to "active" to - * make sure we can again get requests from the queue (see also - * blk_pm_peek_request()). - * - * The resume hook will correct runtime PM status of the disk. - */ - if (scsi_is_sdev_device(dev) && pm_runtime_suspended(dev)) - blk_set_runtime_active(to_scsi_device(dev)->request_queue); - if (fn) { async_schedule_domain(fn, dev, &scsi_sd_pm_domain);