Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6277749imu; Mon, 21 Jan 2019 06:15:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN5H45wML/E8VatMqBpl9ep1h2m93/YnTFW0zDoo/eKKrdBO28nSol8J8czKY/dy3m87Km75 X-Received: by 2002:a62:824c:: with SMTP id w73mr19254598pfd.150.1548080159456; Mon, 21 Jan 2019 06:15:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548080159; cv=none; d=google.com; s=arc-20160816; b=bIECDD5W03jEGqpeO6RMYr0D9a5oIW/CGPyGVt+EP9aDLfPFZOFrSZvf61loTuA3bY YftoQPKjmXUG7ESzhbFYC5+fqR6gt0zAMam9cRBpqQSTKkxLObZTk8HT+nJulltjBqeK ExJUJ1ublAJD6+LujKJsIGfeWia/XDy29YmEwvhl4Y0K0y6g3koBYdvcpachJCaXP6Ao K7HwmHeuWkeWdEU/QGz1sPI52DPcEY7tSUzLqo6t89AC/YPRQH1Yt0C1BcGCpfGqWJCs umxn793qhojZ0ezH2Ow0hhSpkV9fvvwXVQbNbOd8Y7EDgLfJaXKS8YdHRxfVdYhPnLHT v7xA== 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=PcWU0PMqcnVSbmgSP8pheKLJLluvyVTSIJgCwCGpy38=; b=wb/1VSQGdlJjg8hRgtWrf18Rk6oBgyZ39J2wyC3Ani+ZaaYW8jgsEOtHT2U1hdmxAj MAkDmdoI3KB69cthd+YTkLyAjLuN6ERaPVCHJDy9NxWkA/Xj3wCJMAXO0Qr1yJU2arPG E+JD+RnM1CMURBcWOrcpzyMWqauF93Itgaj+XGv0smvyfjOYNohxQYa2iDI7gT7mSvHN BKFsbKT3qcCJVAj/Ve2NdJZjpEoaLAaswF43fyHR22XIiLzlIMAHmcyXzUictvDRpYcj ZXVSlBhg3TBxEB7JDrp1/K5K2OTLUtVdJVoTJbMVKcvJ/3rBgqtVwfU8033YX3AJ48Ew fttw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="XMs/YNOu"; 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 g124si12611647pgc.568.2019.01.21.06.15.43; Mon, 21 Jan 2019 06:15:59 -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="XMs/YNOu"; 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 S1731022AbfAUNwV (ORCPT + 99 others); Mon, 21 Jan 2019 08:52:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:35454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731012AbfAUNwS (ORCPT ); Mon, 21 Jan 2019 08:52:18 -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 68D332063F; Mon, 21 Jan 2019 13:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548078736; bh=7MgpDpnbk8mBX7RU8dM4dLw8dmb6IQ1onFm4RZeML+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XMs/YNOuEJ6fxmLxpLAHti+b8Qy/JkX/e3P7IPQ8qpoE2Jhq9rHkr55jsjFcmYR9D VJSRazPx1TO5rsxbLL2NuYNsCPxyLfFYgoK5VEuk5AZd+PGoFgLC2EWskAykInAduo ldrOrem6JojNVsvn+HJdZxf/VRFtGTyZEiQrDIFM= 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.14 25/59] scsi: core: Synchronize request queue PM status only on successful resume Date: Mon, 21 Jan 2019 14:43:50 +0100 Message-Id: <20190121122459.343827450@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121122456.529172919@linuxfoundation.org> References: <20190121122456.529172919@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.14-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);