Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1193211ybn; Wed, 2 Oct 2019 12:13:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4Rz4plV8BcLW4heIcs9QtAgYzTcPajtrnHgdux7VUJRnMDOoqo49IpC7yK6/APBWHr1s0 X-Received: by 2002:a17:906:49c7:: with SMTP id w7mr4561154ejv.167.1570043625949; Wed, 02 Oct 2019 12:13:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570043625; cv=none; d=google.com; s=arc-20160816; b=y8lr7lpmZL3H/D7zxFxruS57A31e2x2x5WR5ok7chGeUA4qIn/MXOhJeEWESv8rfJi uUBL1h5ZstnRwQYK4hWv8v3s+mkmvIAzWc2wAWWPD2a02i+wRMzHAByH1vvZifKHOajq JXcjml/cbsrR//+8E9Po3SqGYEqgsp80RPt/UHkpzkA1BDJJFPopEktzUEUmmcr1FZ9D 46Hq6d9LkJP9h1LP5hrV2dkJE9aBq7qOHnoTY7Ab9wwDxK93aCf5RRUMySggsH4sw0FW wejZG8zCg2JLoyAQpK5QXaRSvDjnkv1a3XIEd6Bnj/YwI0VLqfQ+kpF7qcylvebEZtsD yoYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=VeaUnF6ANORHeUbm+g4JLbG0J43lpk+Os5PoJdLe7Ew=; b=tJtnpuGdiPNK9g1OZAW1hyERGr+ggK68QiEydTaaw+AaLMttQhRwckvovPuV16vEJi 5/xz+BEYe786r5H53EHP1bqKSMDwzAeN/lNEV1LGCQdyDzoSP9Vdci3pwvneyehREox2 RbWiuGWFzzPDUksdq6tyifqDVnqhUrg1u4dR/lblAxFWrEkguaKPSNnPbXdMn7hjSl4p myKR3OIqadJJUB6/LR5192c5jRfN128SSmLM8EMkvMIEEvaQkaCsR8uIysC56gSWLalM yVSAfzv6lt6lbm0ic27MY2LBh0nQaFidqwTYctO0Td11kNl9MpouUB90y5BDv+oeiCIA JAMA== ARC-Authentication-Results: i=1; mx.google.com; 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 l45si25150edc.185.2019.10.02.12.13.22; Wed, 02 Oct 2019 12:13:45 -0700 (PDT) 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; 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 S1729821AbfJBTKS (ORCPT + 99 others); Wed, 2 Oct 2019 15:10:18 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35936 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729333AbfJBTIR (ORCPT ); Wed, 2 Oct 2019 15:08:17 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iFjyx-00035v-Q5; Wed, 02 Oct 2019 20:08:15 +0100 Received: from ben by deadeye with local (Exim 4.92.1) (envelope-from ) id 1iFjyp-0003fU-MK; Wed, 02 Oct 2019 20:08:07 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Avri Altman" , "Martin K. Petersen" , "Stanley Chu" Date: Wed, 02 Oct 2019 20:06:51 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 70/87] scsi: ufs: Avoid runtime suspend possibly being blocked forever In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.75-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Stanley Chu commit 24e2e7a19f7e4b83d0d5189040d997bce3596473 upstream. UFS runtime suspend can be triggered after pm_runtime_enable() is invoked in ufshcd_pltfrm_init(). However if the first runtime suspend is triggered before binding ufs_hba structure to ufs device structure via platform_set_drvdata(), then UFS runtime suspend will be no longer triggered in the future because its dev->power.runtime_error was set in the first triggering and does not have any chance to be cleared. To be more clear, dev->power.runtime_error is set if hba is NULL in ufshcd_runtime_suspend() which returns -EINVAL to rpm_callback() where dev->power.runtime_error is set as -EINVAL. In this case, any future rpm_suspend() for UFS device fails because rpm_check_suspend_allowed() fails due to non-zero dev->power.runtime_error. To resolve this issue, make sure the first UFS runtime suspend get valid "hba" in ufshcd_runtime_suspend(): Enable UFS runtime PM only after hba is successfully bound to UFS device structure. Fixes: 62694735ca95 ([SCSI] ufs: Add runtime PM support for UFS host controller driver) Signed-off-by: Stanley Chu Reviewed-by: Avri Altman Signed-off-by: Martin K. Petersen [bwh: Backported to 3.16: - ufshcd_pltrfm_probe() doesn't allocate or free the host structure - Adjust context] Signed-off-by: Ben Hutchings --- drivers/scsi/ufs/ufshcd-pltfrm.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c @@ -150,22 +150,19 @@ static int ufshcd_pltfrm_probe(struct pl goto out; } - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - err = ufshcd_init(dev, &hba, mmio_base, irq); if (err) { dev_err(dev, "Intialization failed\n"); - goto out_disable_rpm; + goto out; } platform_set_drvdata(pdev, hba); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + return 0; -out_disable_rpm: - pm_runtime_disable(&pdev->dev); - pm_runtime_set_suspended(&pdev->dev); out: return err; }