Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3841820pxb; Tue, 10 Nov 2020 01:07:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5U4a5R4nLUO/W8d5OOd5J/B5DX0/eUDDf/QwDL1EoTL8Aj58m94a24YsLEIopj47TBJlr X-Received: by 2002:a50:ec10:: with SMTP id g16mr20502738edr.63.1604999245705; Tue, 10 Nov 2020 01:07:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604999245; cv=none; d=google.com; s=arc-20160816; b=poOP4+RYhj4vNwQuHO++jnXlCnXKig09eQng8xJpEHIP/uTvgrHfBGUyLwK8phaCBR 5k/mmMYtaZLXT66PkDb0BE9vXF3ClKsWcmsnCNVyFu4AbmbGr1Uzg2E3IbOQkr2dR173 XxURnSA4xe78EY/vWgu23HrAqk593DuyKgONpby94tUJyKbLp+AuwYyWlkdDbyUiZ/b+ 5Ii6UPC8Q5yKpMIG3LQDRkM+EWc9VIi2tZJpvexlVKrjR4dz9IfkOtqkjwxGJ2UgbCpy 6YJGTnWuwpv1OnH5GWNeemwk/aUMXLczZuS+OmiXZ9BE7C0BipxgOCDJGjy/2IB6XcNm ruEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=b0DiL7iWKfMNQZKoydaub3k3+xYUC6DNI04bI2uj1OU=; b=mTS8/ScKWAhgk1N7JUwGbiZSak6EX032188bkTUXwn4EZvfY7/MDPK81Sykn9x/AGe +zZmbosCsdZHFQCe4U2BCMNeWh/uNbDTBcj0SW7cVSMOTrHJN5Q+2GOFgMSCgkMjx/hG 1P48OdTas2ubOsDQYCOQf3n+6WafNRGlQEjWIHnPOXLTu+Wx+Y17DYN6YwxXz+tPWFq0 kNtBb/HkBvoyaT3lYSIBYjROOlcqV4LpR9b0Kgv4oV+gtrNg1vLjQnKyfsf/vJQ8xk/h zL0rcCf5/snkumntRaf5VuaL5OPOG1tIxFm6a4PKEPQOQ+qwsC7iqilRYFMRudHNeuQp /72Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=vivo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o23si3238653edw.247.2020.11.10.01.07.03; Tue, 10 Nov 2020 01:07:25 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729385AbgKJJFj (ORCPT + 99 others); Tue, 10 Nov 2020 04:05:39 -0500 Received: from mail-m1272.qiye.163.com ([115.236.127.2]:3195 "EHLO mail-m1272.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729809AbgKJJEG (ORCPT ); Tue, 10 Nov 2020 04:04:06 -0500 X-Greylist: delayed 490 seconds by postgrey-1.27 at vger.kernel.org; Tue, 10 Nov 2020 04:04:04 EST Received: from ubuntu.localdomain (unknown [157.0.31.124]) by mail-m1272.qiye.163.com (Hmail) with ESMTPA id 0ECA1B02488; Tue, 10 Nov 2020 16:55:52 +0800 (CST) From: Yang Yang To: Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Can Guo , Bean Huo , Bart Van Assche , Asutosh Das , Sujit Reddy Thumma , Dolev Raviv , Subhash Jadavani , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: onlyfever@icloud.com, yang.yang@vivo.com Subject: [PATCH] scsi: ufs: Fix a bug in ufshcd_system_resume() Date: Tue, 10 Nov 2020 00:55:35 -0800 Message-Id: <20201110085537.2889-1-yang.yang@vivo.com> X-Mailer: git-send-email 2.17.1 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZHUpISRoYSklIT09MVkpNS09CQkNOTklPT0JVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS0hKQ1VLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6ODI6OBw6Hz8fERBDHDkKQxch EBJPCUtVSlVKTUtPQkJDTk5JQ0lOVTMWGhIXVQIaFRxVAhoVHDsNEg0UVRgUFkVZV1kSC1lBWUpO TFVLVUhKVUpJT1lXWQgBWUFITk9MNwY+ X-HM-Tid: 0a75b15e5b0398b7kuuu0eca1b02488 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org During system resume, ufshcd_system_resume() won't resume UFS host if runtime suspended. After that, scsi_bus_resume() try to set SCSI host's RPM status to RPM_ACTIVE, this will fail because UFS host's RPM status is still RPM_SUSPENDED. So fix it. scsi host0: scsi_runtime_suspend() ufshcd_runtime_suspend() scsi host0: scsi_bus_suspend() ufshcd_system_suspend() ---------------------------------- ufshcd_pltfrm_resume() scsi host0: scsi_bus_resume() scsi host0: scsi_bus_resume_common() scsi host0: pm_runtime_set_active(dev) scsi host0: runtime PM trying to activate child device host0 but parent (8800000.ufshc) is not active Fixes: 57d104c153d3 ("ufs: add UFS power management support") Signed-off-by: Yang Yang --- drivers/scsi/ufs/ufshcd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index b8f573a02713..9e666e1ad58c 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8767,11 +8767,7 @@ int ufshcd_system_resume(struct ufs_hba *hba) if (!hba) return -EINVAL; - if (!hba->is_powered || pm_runtime_suspended(hba->dev)) - /* - * Let the runtime resume take care of resuming - * if runtime suspended. - */ + if (!hba->is_powered) goto out; else ret = ufshcd_resume(hba, UFS_SYSTEM_PM); @@ -8779,8 +8775,15 @@ int ufshcd_system_resume(struct ufs_hba *hba) trace_ufshcd_system_resume(dev_name(hba->dev), ret, ktime_to_us(ktime_sub(ktime_get(), start)), hba->curr_dev_pwr_mode, hba->uic_link_state); - if (!ret) + if (!ret) { hba->is_sys_suspended = false; + + if (pm_runtime_suspended(hba->dev)) { + pm_runtime_disable(hba->dev); + pm_runtime_set_active(hba->dev); + pm_runtime_enable(hba->dev); + } + } return ret; } EXPORT_SYMBOL(ufshcd_system_resume); -- 2.17.1