Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6267147imu; Mon, 21 Jan 2019 06:06:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN67oexAvmsP8qCjt3ibkeJg+FPVdsQGe3BfvYJm56TMkPE8QgoblDczyI8nIHMgnuXPO957 X-Received: by 2002:a65:4904:: with SMTP id p4mr28517415pgs.384.1548079609037; Mon, 21 Jan 2019 06:06:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079609; cv=none; d=google.com; s=arc-20160816; b=DmsiyNALilnao50LH1qdcBZ7e8JQLgkWsomY4h1Kimud2ZSXXUHUu/HE2XhnBzLcwD v60rbHxa1Trb2FkEEUBrC/LsNkvLcMTAMvDhHjsQfOHAFqAT1vmsrS7bq0VjNVvUus/W CGnX3Nm497IsA75dcNaVlCpj5zx+Z2EBRzyefrQLKeZm7WlBCMwBzeypHv828KCj+A2k S7OZpYU1rcHyrFR1FXf0IKOGd33oRlCnAyzpPOXQq1Kpv/cZVGm2RmqjRBXv3TDifv6u CBO/QVk//ocoHL2fHyYMjoypgowG7UFJ/qRwbSS2L6R70Rz3HYhwOdbDmSen3LURRxnb a7WQ== 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=qo9p+IdCWtNUyMdNAhBlvmwMIbCR8/SJALPjwJsd5i0=; b=hGfIq5Z+Eg9hfwc1+YwdO3M8DyK6Y8SUcbgRxvqgkJNtblLyZPpPiaOqDXYzhvOP7g 4/mPlWwRJmBKMrsQ2AY9z6S4xJtHkrFR1KzoWGUoq7uNhw/nsuMhfLUpbqHNIH9ZpLDC Dfss3Iqy+sPx6FJLTB08r+mcvq72eIQcx/tkHPtBJtcHOCND9uU5TgJyHuqpyhlSLOA7 xDASRiYtGUvBK+fS20zGWasY14TkasUalFR/91XK9vTxqXk42hPaD4qyki4PnqmpQpnN jRHJVss3izBuildd9cCZt/+XossE4Py9oD41/gfqj0VvAquTaHUkTndPguQq3w03WhY3 0bbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nVfxCB98; 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 d3si12792076pla.122.2019.01.21.06.06.33; Mon, 21 Jan 2019 06:06:49 -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=nVfxCB98; 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 S1732715AbfAUOB4 (ORCPT + 99 others); Mon, 21 Jan 2019 09:01:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:49050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729683AbfAUOBv (ORCPT ); Mon, 21 Jan 2019 09:01:51 -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 3662E214D8; Mon, 21 Jan 2019 14:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079310; bh=0TbYX5BhHKCLVFbvN6eIL+hLDBc0hCJF3VKBGMjvMdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nVfxCB98ZfeBhBdLTier1CUQEvIzaEKrAUvLOhFYmR0uyjxw8i3vL+gNdvAmwkXSf dmRFbs/7e6oBEdqor3cPiVEpD9d6O+iww8YRlfaoLEzfBNMME3mjm5kBx1EaS4k4pY jyL4kfTUgXTSRlv0rLKl0xZGBx/LKSX33bNC0TtE= 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.19 43/99] scsi: core: Synchronize request queue PM status only on successful resume Date: Mon, 21 Jan 2019 14:48:35 +0100 Message-Id: <20190121134915.612212061@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121134913.924726465@linuxfoundation.org> References: <20190121134913.924726465@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.19-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);