Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3064622pxj; Mon, 17 May 2021 16:52:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxot7aYpTnwI5iutX9I5GBor8+khNLcQWugvjPGbF0PCQHvU1pI6aVuu5tQeFBivPi+JUTo X-Received: by 2002:a05:6402:1d28:: with SMTP id dh8mr3249341edb.303.1621295542491; Mon, 17 May 2021 16:52:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621295542; cv=none; d=google.com; s=arc-20160816; b=za6JMTy0fzQnPQe7Ei3Pk6q6ppWoRyLO/+4K5uLe+gzSnPO97MNfvtQ6xpVkAD3HVu qa4bcplRFSZ70QKnBQl1b9776Fm8li5vhuZDvGbmRLxotdGoLKSeb04Ii2yqH8YmY8gA ro5WvsnhRWAoe5LEm1p/I3LPjconhVWZjbOapfKOl423ijzjinVLcURcLf6js/iI0lPo v84DfYIHei4C+ry+OOqbCD6DRWgkbPEKhHsLQ359wL7NWK/mddXWOOiI7rotnqzFMI+x 9vi0/apnwQPbscRfRlEg3OpjgLlu/SLRg/Qgdr1G1lnF3pjYO2Oi2mv8ZxRxgdgNqWJa VXxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=T1FmKavu05/T6T6v73fh5xfBwe1y6xwKy3FQVP4zG9o=; b=VeXN5l56/euyWqMcFXCmU+xRfA/hqpX6dKpNMA4rmzHNsciEO+nAw2mkUH0abth1+K tAZa7hnIMJS2VTADHwvQxpf+QdUpdYhVXkbOYSE+TCYgVGWKiSfYeEQY9wy+fIhkjtWJ I7KnuzuyqtDIDl4hy25FAi4zoyIY/EWjfkt1TaGkzePT4e/4DqsWTriYttRPmgidppIy T9wYvlpH0H0eXnibfvb+7+CkTWOPqfXRSXn8K9U3RfVQZb7NgSU+rfeoXP7VPbWrORUc 1owsOZgB32V4/FcHKfDVQvnSGiwT3WzWtyK8BAMxwQ/0I1hpuF3fwOKC4CUsye0PpBLj wWYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IKCvnigX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b26si3907840eds.88.2021.05.17.16.51.59; Mon, 17 May 2021 16:52:22 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IKCvnigX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239379AbhEQOXu (ORCPT + 99 others); Mon, 17 May 2021 10:23:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:36010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239509AbhEQOU0 (ORCPT ); Mon, 17 May 2021 10:20:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2452761455; Mon, 17 May 2021 14:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260675; bh=IMKZyleuFGmRRVNp8ON8GyL0KpAK5SyJQrMhhsCbPgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IKCvnigXpL43rpfcKyWD6hdRQqKwU1eso3pJpnXuxwxsUb9/46HZeOly3eoZUmTYs Ta7Jlf5ry+b5M0GAdslg5/cB5FTtuOCFUBTonSIKkVfPbzwqwj13nV/qv9nR6c8HZ/ +R36Zsm2rd2BKP7vMSrcwU5MR6KEXDerNkZwqiiE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daejun Park , Can Guo , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.12 190/363] scsi: ufs: core: Narrow down fast path in system suspend path Date: Mon, 17 May 2021 16:00:56 +0200 Message-Id: <20210517140309.018177965@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Can Guo [ Upstream commit ce4f62f9dd8cf43ac044045ed598a0b80ef33890 ] If spm_lvl is set to 0 or 1, when system suspend kicks start and HBA is runtime active, system suspend may just bail without doing anything (the fast path), leaving other contexts still running, e.g., clock gating and clock scaling. When system resume kicks start, concurrency can happen between ufshcd_resume() and these contexts, leading to various stability issues. Add a check against HBA's runtime state and allowing fast path only if HBA is runtime suspended, otherwise let system suspend go ahead call ufshcd_suspend(). This will guarantee that these contexts are stopped by either runtime suspend or system suspend. Link: https://lore.kernel.org/r/1619408921-30426-4-git-send-email-cang@codeaurora.org Fixes: 0b257734344a ("scsi: ufs: optimize system suspend handling") Reviewed-by: Daejun Park Signed-off-by: Can Guo Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ufs/ufshcd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 4631a609b0e3..0c71a159d08f 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8984,6 +8984,7 @@ int ufshcd_system_suspend(struct ufs_hba *hba) hba->curr_dev_pwr_mode) && (ufs_get_pm_lvl_to_link_pwr_state(hba->spm_lvl) == hba->uic_link_state) && + pm_runtime_suspended(hba->dev) && !hba->dev_info.b_rpm_dev_flush_capable) goto out; -- 2.30.2